babylon.module.d.ts 5.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320
  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. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8552. /**
  8553. * Creates a depth stencil texture.
  8554. * This is only available in WebGL 2 or with the depth texture extension available.
  8555. * @param size The size of face edge in the texture.
  8556. * @param options The options defining the texture.
  8557. * @returns The texture
  8558. */
  8559. createDepthStencilTexture(size: number | {
  8560. width: number;
  8561. height: number;
  8562. }, options: DepthTextureCreationOptions): InternalTexture;
  8563. /** @hidden */
  8564. _createDepthStencilTexture(size: number | {
  8565. width: number;
  8566. height: number;
  8567. }, options: DepthTextureCreationOptions): InternalTexture;
  8568. }
  8569. }
  8570. }
  8571. declare module "babylonjs/Maths/math.axis" {
  8572. import { Vector3 } from "babylonjs/Maths/math.vector";
  8573. /** Defines supported spaces */
  8574. export enum Space {
  8575. /** Local (object) space */
  8576. LOCAL = 0,
  8577. /** World space */
  8578. WORLD = 1,
  8579. /** Bone space */
  8580. BONE = 2
  8581. }
  8582. /** Defines the 3 main axes */
  8583. export class Axis {
  8584. /** X axis */
  8585. static X: Vector3;
  8586. /** Y axis */
  8587. static Y: Vector3;
  8588. /** Z axis */
  8589. static Z: Vector3;
  8590. }
  8591. }
  8592. declare module "babylonjs/Cameras/targetCamera" {
  8593. import { Nullable } from "babylonjs/types";
  8594. import { Camera } from "babylonjs/Cameras/camera";
  8595. import { Scene } from "babylonjs/scene";
  8596. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8597. /**
  8598. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8599. * This is the base of the follow, arc rotate cameras and Free camera
  8600. * @see http://doc.babylonjs.com/features/cameras
  8601. */
  8602. export class TargetCamera extends Camera {
  8603. private static _RigCamTransformMatrix;
  8604. private static _TargetTransformMatrix;
  8605. private static _TargetFocalPoint;
  8606. /**
  8607. * Define the current direction the camera is moving to
  8608. */
  8609. cameraDirection: Vector3;
  8610. /**
  8611. * Define the current rotation the camera is rotating to
  8612. */
  8613. cameraRotation: Vector2;
  8614. /**
  8615. * When set, the up vector of the camera will be updated by the rotation of the camera
  8616. */
  8617. updateUpVectorFromRotation: boolean;
  8618. private _tmpQuaternion;
  8619. /**
  8620. * Define the current rotation of the camera
  8621. */
  8622. rotation: Vector3;
  8623. /**
  8624. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8625. */
  8626. rotationQuaternion: Quaternion;
  8627. /**
  8628. * Define the current speed of the camera
  8629. */
  8630. speed: number;
  8631. /**
  8632. * Add constraint to the camera to prevent it to move freely in all directions and
  8633. * around all axis.
  8634. */
  8635. noRotationConstraint: boolean;
  8636. /**
  8637. * Define the current target of the camera as an object or a position.
  8638. */
  8639. lockedTarget: any;
  8640. /** @hidden */
  8641. _currentTarget: Vector3;
  8642. /** @hidden */
  8643. _initialFocalDistance: number;
  8644. /** @hidden */
  8645. _viewMatrix: Matrix;
  8646. /** @hidden */
  8647. _camMatrix: Matrix;
  8648. /** @hidden */
  8649. _cameraTransformMatrix: Matrix;
  8650. /** @hidden */
  8651. _cameraRotationMatrix: Matrix;
  8652. /** @hidden */
  8653. _referencePoint: Vector3;
  8654. /** @hidden */
  8655. _transformedReferencePoint: Vector3;
  8656. protected _globalCurrentTarget: Vector3;
  8657. protected _globalCurrentUpVector: Vector3;
  8658. /** @hidden */
  8659. _reset: () => void;
  8660. private _defaultUp;
  8661. /**
  8662. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8663. * This is the base of the follow, arc rotate cameras and Free camera
  8664. * @see http://doc.babylonjs.com/features/cameras
  8665. * @param name Defines the name of the camera in the scene
  8666. * @param position Defines the start position of the camera in the scene
  8667. * @param scene Defines the scene the camera belongs to
  8668. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8669. */
  8670. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8671. /**
  8672. * Gets the position in front of the camera at a given distance.
  8673. * @param distance The distance from the camera we want the position to be
  8674. * @returns the position
  8675. */
  8676. getFrontPosition(distance: number): Vector3;
  8677. /** @hidden */
  8678. _getLockedTargetPosition(): Nullable<Vector3>;
  8679. private _storedPosition;
  8680. private _storedRotation;
  8681. private _storedRotationQuaternion;
  8682. /**
  8683. * Store current camera state of the camera (fov, position, rotation, etc..)
  8684. * @returns the camera
  8685. */
  8686. storeState(): Camera;
  8687. /**
  8688. * Restored camera state. You must call storeState() first
  8689. * @returns whether it was successful or not
  8690. * @hidden
  8691. */
  8692. _restoreStateValues(): boolean;
  8693. /** @hidden */
  8694. _initCache(): void;
  8695. /** @hidden */
  8696. _updateCache(ignoreParentClass?: boolean): void;
  8697. /** @hidden */
  8698. _isSynchronizedViewMatrix(): boolean;
  8699. /** @hidden */
  8700. _computeLocalCameraSpeed(): number;
  8701. /**
  8702. * Defines the target the camera should look at.
  8703. * @param target Defines the new target as a Vector or a mesh
  8704. */
  8705. setTarget(target: Vector3): void;
  8706. /**
  8707. * Return the current target position of the camera. This value is expressed in local space.
  8708. * @returns the target position
  8709. */
  8710. getTarget(): Vector3;
  8711. /** @hidden */
  8712. _decideIfNeedsToMove(): boolean;
  8713. /** @hidden */
  8714. _updatePosition(): void;
  8715. /** @hidden */
  8716. _checkInputs(): void;
  8717. protected _updateCameraRotationMatrix(): void;
  8718. /**
  8719. * 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)
  8720. * @returns the current camera
  8721. */
  8722. private _rotateUpVectorWithCameraRotationMatrix;
  8723. private _cachedRotationZ;
  8724. private _cachedQuaternionRotationZ;
  8725. /** @hidden */
  8726. _getViewMatrix(): Matrix;
  8727. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8728. /**
  8729. * @hidden
  8730. */
  8731. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8732. /**
  8733. * @hidden
  8734. */
  8735. _updateRigCameras(): void;
  8736. private _getRigCamPositionAndTarget;
  8737. /**
  8738. * Gets the current object class name.
  8739. * @return the class name
  8740. */
  8741. getClassName(): string;
  8742. }
  8743. }
  8744. declare module "babylonjs/Events/keyboardEvents" {
  8745. /**
  8746. * Gather the list of keyboard event types as constants.
  8747. */
  8748. export class KeyboardEventTypes {
  8749. /**
  8750. * The keydown event is fired when a key becomes active (pressed).
  8751. */
  8752. static readonly KEYDOWN: number;
  8753. /**
  8754. * The keyup event is fired when a key has been released.
  8755. */
  8756. static readonly KEYUP: number;
  8757. }
  8758. /**
  8759. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8760. */
  8761. export class KeyboardInfo {
  8762. /**
  8763. * Defines the type of event (KeyboardEventTypes)
  8764. */
  8765. type: number;
  8766. /**
  8767. * Defines the related dom event
  8768. */
  8769. event: KeyboardEvent;
  8770. /**
  8771. * Instantiates a new keyboard info.
  8772. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8773. * @param type Defines the type of event (KeyboardEventTypes)
  8774. * @param event Defines the related dom event
  8775. */
  8776. constructor(
  8777. /**
  8778. * Defines the type of event (KeyboardEventTypes)
  8779. */
  8780. type: number,
  8781. /**
  8782. * Defines the related dom event
  8783. */
  8784. event: KeyboardEvent);
  8785. }
  8786. /**
  8787. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8788. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8789. */
  8790. export class KeyboardInfoPre extends KeyboardInfo {
  8791. /**
  8792. * Defines the type of event (KeyboardEventTypes)
  8793. */
  8794. type: number;
  8795. /**
  8796. * Defines the related dom event
  8797. */
  8798. event: KeyboardEvent;
  8799. /**
  8800. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8801. */
  8802. skipOnPointerObservable: boolean;
  8803. /**
  8804. * Instantiates a new keyboard pre info.
  8805. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8806. * @param type Defines the type of event (KeyboardEventTypes)
  8807. * @param event Defines the related dom event
  8808. */
  8809. constructor(
  8810. /**
  8811. * Defines the type of event (KeyboardEventTypes)
  8812. */
  8813. type: number,
  8814. /**
  8815. * Defines the related dom event
  8816. */
  8817. event: KeyboardEvent);
  8818. }
  8819. }
  8820. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8821. import { Nullable } from "babylonjs/types";
  8822. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8823. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8824. /**
  8825. * Manage the keyboard inputs to control the movement of a free camera.
  8826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8827. */
  8828. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8829. /**
  8830. * Defines the camera the input is attached to.
  8831. */
  8832. camera: FreeCamera;
  8833. /**
  8834. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8835. */
  8836. keysUp: number[];
  8837. /**
  8838. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8839. */
  8840. keysDown: number[];
  8841. /**
  8842. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8843. */
  8844. keysLeft: number[];
  8845. /**
  8846. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8847. */
  8848. keysRight: number[];
  8849. private _keys;
  8850. private _onCanvasBlurObserver;
  8851. private _onKeyboardObserver;
  8852. private _engine;
  8853. private _scene;
  8854. /**
  8855. * Attach the input controls to a specific dom element to get the input from.
  8856. * @param element Defines the element the controls should be listened from
  8857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8858. */
  8859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8860. /**
  8861. * Detach the current controls from the specified dom element.
  8862. * @param element Defines the element to stop listening the inputs from
  8863. */
  8864. detachControl(element: Nullable<HTMLElement>): void;
  8865. /**
  8866. * Update the current camera state depending on the inputs that have been used this frame.
  8867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8868. */
  8869. checkInputs(): void;
  8870. /**
  8871. * Gets the class name of the current intput.
  8872. * @returns the class name
  8873. */
  8874. getClassName(): string;
  8875. /** @hidden */
  8876. _onLostFocus(): void;
  8877. /**
  8878. * Get the friendly name associated with the input class.
  8879. * @returns the input friendly name
  8880. */
  8881. getSimpleName(): string;
  8882. }
  8883. }
  8884. declare module "babylonjs/Lights/shadowLight" {
  8885. import { Camera } from "babylonjs/Cameras/camera";
  8886. import { Scene } from "babylonjs/scene";
  8887. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8889. import { Light } from "babylonjs/Lights/light";
  8890. /**
  8891. * Interface describing all the common properties and methods a shadow light needs to implement.
  8892. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8893. * as well as binding the different shadow properties to the effects.
  8894. */
  8895. export interface IShadowLight extends Light {
  8896. /**
  8897. * The light id in the scene (used in scene.findLighById for instance)
  8898. */
  8899. id: string;
  8900. /**
  8901. * The position the shdow will be casted from.
  8902. */
  8903. position: Vector3;
  8904. /**
  8905. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8906. */
  8907. direction: Vector3;
  8908. /**
  8909. * The transformed position. Position of the light in world space taking parenting in account.
  8910. */
  8911. transformedPosition: Vector3;
  8912. /**
  8913. * The transformed direction. Direction of the light in world space taking parenting in account.
  8914. */
  8915. transformedDirection: Vector3;
  8916. /**
  8917. * The friendly name of the light in the scene.
  8918. */
  8919. name: string;
  8920. /**
  8921. * Defines the shadow projection clipping minimum z value.
  8922. */
  8923. shadowMinZ: number;
  8924. /**
  8925. * Defines the shadow projection clipping maximum z value.
  8926. */
  8927. shadowMaxZ: number;
  8928. /**
  8929. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8930. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8931. */
  8932. computeTransformedInformation(): boolean;
  8933. /**
  8934. * Gets the scene the light belongs to.
  8935. * @returns The scene
  8936. */
  8937. getScene(): Scene;
  8938. /**
  8939. * Callback defining a custom Projection Matrix Builder.
  8940. * This can be used to override the default projection matrix computation.
  8941. */
  8942. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8943. /**
  8944. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8945. * @param matrix The materix to updated with the projection information
  8946. * @param viewMatrix The transform matrix of the light
  8947. * @param renderList The list of mesh to render in the map
  8948. * @returns The current light
  8949. */
  8950. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8951. /**
  8952. * Gets the current depth scale used in ESM.
  8953. * @returns The scale
  8954. */
  8955. getDepthScale(): number;
  8956. /**
  8957. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8958. * @returns true if a cube texture needs to be use
  8959. */
  8960. needCube(): boolean;
  8961. /**
  8962. * Detects if the projection matrix requires to be recomputed this frame.
  8963. * @returns true if it requires to be recomputed otherwise, false.
  8964. */
  8965. needProjectionMatrixCompute(): boolean;
  8966. /**
  8967. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8968. */
  8969. forceProjectionMatrixCompute(): void;
  8970. /**
  8971. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8972. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8973. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8974. */
  8975. getShadowDirection(faceIndex?: number): Vector3;
  8976. /**
  8977. * Gets the minZ used for shadow according to both the scene and the light.
  8978. * @param activeCamera The camera we are returning the min for
  8979. * @returns the depth min z
  8980. */
  8981. getDepthMinZ(activeCamera: Camera): number;
  8982. /**
  8983. * Gets the maxZ used for shadow according to both the scene and the light.
  8984. * @param activeCamera The camera we are returning the max for
  8985. * @returns the depth max z
  8986. */
  8987. getDepthMaxZ(activeCamera: Camera): number;
  8988. }
  8989. /**
  8990. * Base implementation IShadowLight
  8991. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8992. */
  8993. export abstract class ShadowLight extends Light implements IShadowLight {
  8994. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8995. protected _position: Vector3;
  8996. protected _setPosition(value: Vector3): void;
  8997. /**
  8998. * Sets the position the shadow will be casted from. Also use as the light position for both
  8999. * point and spot lights.
  9000. */
  9001. get position(): Vector3;
  9002. /**
  9003. * Sets the position the shadow will be casted from. Also use as the light position for both
  9004. * point and spot lights.
  9005. */
  9006. set position(value: Vector3);
  9007. protected _direction: Vector3;
  9008. protected _setDirection(value: Vector3): void;
  9009. /**
  9010. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9011. * Also use as the light direction on spot and directional lights.
  9012. */
  9013. get direction(): Vector3;
  9014. /**
  9015. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9016. * Also use as the light direction on spot and directional lights.
  9017. */
  9018. set direction(value: Vector3);
  9019. protected _shadowMinZ: number;
  9020. /**
  9021. * Gets the shadow projection clipping minimum z value.
  9022. */
  9023. get shadowMinZ(): number;
  9024. /**
  9025. * Sets the shadow projection clipping minimum z value.
  9026. */
  9027. set shadowMinZ(value: number);
  9028. protected _shadowMaxZ: number;
  9029. /**
  9030. * Sets the shadow projection clipping maximum z value.
  9031. */
  9032. get shadowMaxZ(): number;
  9033. /**
  9034. * Gets the shadow projection clipping maximum z value.
  9035. */
  9036. set shadowMaxZ(value: number);
  9037. /**
  9038. * Callback defining a custom Projection Matrix Builder.
  9039. * This can be used to override the default projection matrix computation.
  9040. */
  9041. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9042. /**
  9043. * The transformed position. Position of the light in world space taking parenting in account.
  9044. */
  9045. transformedPosition: Vector3;
  9046. /**
  9047. * The transformed direction. Direction of the light in world space taking parenting in account.
  9048. */
  9049. transformedDirection: Vector3;
  9050. private _needProjectionMatrixCompute;
  9051. /**
  9052. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9053. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9054. */
  9055. computeTransformedInformation(): boolean;
  9056. /**
  9057. * Return the depth scale used for the shadow map.
  9058. * @returns the depth scale.
  9059. */
  9060. getDepthScale(): number;
  9061. /**
  9062. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9063. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9064. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9065. */
  9066. getShadowDirection(faceIndex?: number): Vector3;
  9067. /**
  9068. * Returns the ShadowLight absolute position in the World.
  9069. * @returns the position vector in world space
  9070. */
  9071. getAbsolutePosition(): Vector3;
  9072. /**
  9073. * Sets the ShadowLight direction toward the passed target.
  9074. * @param target The point to target in local space
  9075. * @returns the updated ShadowLight direction
  9076. */
  9077. setDirectionToTarget(target: Vector3): Vector3;
  9078. /**
  9079. * Returns the light rotation in euler definition.
  9080. * @returns the x y z rotation in local space.
  9081. */
  9082. getRotation(): Vector3;
  9083. /**
  9084. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9085. * @returns true if a cube texture needs to be use
  9086. */
  9087. needCube(): boolean;
  9088. /**
  9089. * Detects if the projection matrix requires to be recomputed this frame.
  9090. * @returns true if it requires to be recomputed otherwise, false.
  9091. */
  9092. needProjectionMatrixCompute(): boolean;
  9093. /**
  9094. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9095. */
  9096. forceProjectionMatrixCompute(): void;
  9097. /** @hidden */
  9098. _initCache(): void;
  9099. /** @hidden */
  9100. _isSynchronized(): boolean;
  9101. /**
  9102. * Computes the world matrix of the node
  9103. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9104. * @returns the world matrix
  9105. */
  9106. computeWorldMatrix(force?: boolean): Matrix;
  9107. /**
  9108. * Gets the minZ used for shadow according to both the scene and the light.
  9109. * @param activeCamera The camera we are returning the min for
  9110. * @returns the depth min z
  9111. */
  9112. getDepthMinZ(activeCamera: Camera): number;
  9113. /**
  9114. * Gets the maxZ used for shadow according to both the scene and the light.
  9115. * @param activeCamera The camera we are returning the max for
  9116. * @returns the depth max z
  9117. */
  9118. getDepthMaxZ(activeCamera: Camera): number;
  9119. /**
  9120. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9121. * @param matrix The materix to updated with the projection information
  9122. * @param viewMatrix The transform matrix of the light
  9123. * @param renderList The list of mesh to render in the map
  9124. * @returns The current light
  9125. */
  9126. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9127. }
  9128. }
  9129. declare module "babylonjs/Materials/effectFallbacks" {
  9130. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9131. import { Effect } from "babylonjs/Materials/effect";
  9132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9133. /**
  9134. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9135. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9136. */
  9137. export class EffectFallbacks implements IEffectFallbacks {
  9138. private _defines;
  9139. private _currentRank;
  9140. private _maxRank;
  9141. private _mesh;
  9142. /**
  9143. * Removes the fallback from the bound mesh.
  9144. */
  9145. unBindMesh(): void;
  9146. /**
  9147. * Adds a fallback on the specified property.
  9148. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9149. * @param define The name of the define in the shader
  9150. */
  9151. addFallback(rank: number, define: string): void;
  9152. /**
  9153. * Sets the mesh to use CPU skinning when needing to fallback.
  9154. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9155. * @param mesh The mesh to use the fallbacks.
  9156. */
  9157. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9158. /**
  9159. * Checks to see if more fallbacks are still availible.
  9160. */
  9161. get hasMoreFallbacks(): boolean;
  9162. /**
  9163. * Removes the defines that should be removed when falling back.
  9164. * @param currentDefines defines the current define statements for the shader.
  9165. * @param effect defines the current effect we try to compile
  9166. * @returns The resulting defines with defines of the current rank removed.
  9167. */
  9168. reduce(currentDefines: string, effect: Effect): string;
  9169. }
  9170. }
  9171. declare module "babylonjs/Materials/materialHelper" {
  9172. import { Nullable } from "babylonjs/types";
  9173. import { Scene } from "babylonjs/scene";
  9174. import { Engine } from "babylonjs/Engines/engine";
  9175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9176. import { Light } from "babylonjs/Lights/light";
  9177. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9178. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9180. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9181. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9182. /**
  9183. * "Static Class" containing the most commonly used helper while dealing with material for
  9184. * rendering purpose.
  9185. *
  9186. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9187. *
  9188. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9189. */
  9190. export class MaterialHelper {
  9191. /**
  9192. * Bind the current view position to an effect.
  9193. * @param effect The effect to be bound
  9194. * @param scene The scene the eyes position is used from
  9195. */
  9196. static BindEyePosition(effect: Effect, scene: Scene): void;
  9197. /**
  9198. * Helps preparing the defines values about the UVs in used in the effect.
  9199. * UVs are shared as much as we can accross channels in the shaders.
  9200. * @param texture The texture we are preparing the UVs for
  9201. * @param defines The defines to update
  9202. * @param key The channel key "diffuse", "specular"... used in the shader
  9203. */
  9204. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9205. /**
  9206. * Binds a texture matrix value to its corrsponding uniform
  9207. * @param texture The texture to bind the matrix for
  9208. * @param uniformBuffer The uniform buffer receivin the data
  9209. * @param key The channel key "diffuse", "specular"... used in the shader
  9210. */
  9211. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9212. /**
  9213. * Gets the current status of the fog (should it be enabled?)
  9214. * @param mesh defines the mesh to evaluate for fog support
  9215. * @param scene defines the hosting scene
  9216. * @returns true if fog must be enabled
  9217. */
  9218. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9219. /**
  9220. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9221. * @param mesh defines the current mesh
  9222. * @param scene defines the current scene
  9223. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9224. * @param pointsCloud defines if point cloud rendering has to be turned on
  9225. * @param fogEnabled defines if fog has to be turned on
  9226. * @param alphaTest defines if alpha testing has to be turned on
  9227. * @param defines defines the current list of defines
  9228. */
  9229. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9230. /**
  9231. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9232. * @param scene defines the current scene
  9233. * @param engine defines the current engine
  9234. * @param defines specifies the list of active defines
  9235. * @param useInstances defines if instances have to be turned on
  9236. * @param useClipPlane defines if clip plane have to be turned on
  9237. */
  9238. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9239. /**
  9240. * Prepares the defines for bones
  9241. * @param mesh The mesh containing the geometry data we will draw
  9242. * @param defines The defines to update
  9243. */
  9244. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9245. /**
  9246. * Prepares the defines for morph targets
  9247. * @param mesh The mesh containing the geometry data we will draw
  9248. * @param defines The defines to update
  9249. */
  9250. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9251. /**
  9252. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9253. * @param mesh The mesh containing the geometry data we will draw
  9254. * @param defines The defines to update
  9255. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9256. * @param useBones Precise whether bones should be used or not (override mesh info)
  9257. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9258. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9259. * @returns false if defines are considered not dirty and have not been checked
  9260. */
  9261. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9262. /**
  9263. * Prepares the defines related to multiview
  9264. * @param scene The scene we are intending to draw
  9265. * @param defines The defines to update
  9266. */
  9267. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9268. /**
  9269. * Prepares the defines related to the light information passed in parameter
  9270. * @param scene The scene we are intending to draw
  9271. * @param mesh The mesh the effect is compiling for
  9272. * @param light The light the effect is compiling for
  9273. * @param lightIndex The index of the light
  9274. * @param defines The defines to update
  9275. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9276. * @param state Defines the current state regarding what is needed (normals, etc...)
  9277. */
  9278. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9279. needNormals: boolean;
  9280. needRebuild: boolean;
  9281. shadowEnabled: boolean;
  9282. specularEnabled: boolean;
  9283. lightmapMode: boolean;
  9284. }): void;
  9285. /**
  9286. * Prepares the defines related to the light information passed in parameter
  9287. * @param scene The scene we are intending to draw
  9288. * @param mesh The mesh the effect is compiling for
  9289. * @param defines The defines to update
  9290. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9291. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9292. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9293. * @returns true if normals will be required for the rest of the effect
  9294. */
  9295. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9296. /**
  9297. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9298. * @param lightIndex defines the light index
  9299. * @param uniformsList The uniform list
  9300. * @param samplersList The sampler list
  9301. * @param projectedLightTexture defines if projected texture must be used
  9302. * @param uniformBuffersList defines an optional list of uniform buffers
  9303. */
  9304. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9305. /**
  9306. * Prepares the uniforms and samplers list to be used in the effect
  9307. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9308. * @param samplersList The sampler list
  9309. * @param defines The defines helping in the list generation
  9310. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9311. */
  9312. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9313. /**
  9314. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9315. * @param defines The defines to update while falling back
  9316. * @param fallbacks The authorized effect fallbacks
  9317. * @param maxSimultaneousLights The maximum number of lights allowed
  9318. * @param rank the current rank of the Effect
  9319. * @returns The newly affected rank
  9320. */
  9321. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9322. private static _TmpMorphInfluencers;
  9323. /**
  9324. * Prepares the list of attributes required for morph targets according to the effect defines.
  9325. * @param attribs The current list of supported attribs
  9326. * @param mesh The mesh to prepare the morph targets attributes for
  9327. * @param influencers The number of influencers
  9328. */
  9329. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9330. /**
  9331. * Prepares the list of attributes required for morph targets according to the effect defines.
  9332. * @param attribs The current list of supported attribs
  9333. * @param mesh The mesh to prepare the morph targets attributes for
  9334. * @param defines The current Defines of the effect
  9335. */
  9336. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9337. /**
  9338. * Prepares the list of attributes required for bones according to the effect defines.
  9339. * @param attribs The current list of supported attribs
  9340. * @param mesh The mesh to prepare the bones attributes for
  9341. * @param defines The current Defines of the effect
  9342. * @param fallbacks The current efffect fallback strategy
  9343. */
  9344. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9345. /**
  9346. * Check and prepare the list of attributes required for instances according to the effect defines.
  9347. * @param attribs The current list of supported attribs
  9348. * @param defines The current MaterialDefines of the effect
  9349. */
  9350. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9351. /**
  9352. * Add the list of attributes required for instances to the attribs array.
  9353. * @param attribs The current list of supported attribs
  9354. */
  9355. static PushAttributesForInstances(attribs: string[]): void;
  9356. /**
  9357. * Binds the light information to the effect.
  9358. * @param light The light containing the generator
  9359. * @param effect The effect we are binding the data to
  9360. * @param lightIndex The light index in the effect used to render
  9361. */
  9362. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9363. /**
  9364. * Binds the lights information from the scene to the effect for the given mesh.
  9365. * @param light Light to bind
  9366. * @param lightIndex Light index
  9367. * @param scene The scene where the light belongs to
  9368. * @param effect The effect we are binding the data to
  9369. * @param useSpecular Defines if specular is supported
  9370. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9371. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9372. */
  9373. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9374. /**
  9375. * Binds the lights information from the scene to the effect for the given mesh.
  9376. * @param scene The scene the lights belongs to
  9377. * @param mesh The mesh we are binding the information to render
  9378. * @param effect The effect we are binding the data to
  9379. * @param defines The generated defines for the effect
  9380. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9381. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9382. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9383. */
  9384. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9385. private static _tempFogColor;
  9386. /**
  9387. * Binds the fog information from the scene to the effect for the given mesh.
  9388. * @param scene The scene the lights belongs to
  9389. * @param mesh The mesh we are binding the information to render
  9390. * @param effect The effect we are binding the data to
  9391. * @param linearSpace Defines if the fog effect is applied in linear space
  9392. */
  9393. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9394. /**
  9395. * Binds the bones information from the mesh to the effect.
  9396. * @param mesh The mesh we are binding the information to render
  9397. * @param effect The effect we are binding the data to
  9398. */
  9399. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9400. /**
  9401. * Binds the morph targets information from the mesh to the effect.
  9402. * @param abstractMesh The mesh we are binding the information to render
  9403. * @param effect The effect we are binding the data to
  9404. */
  9405. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9406. /**
  9407. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9408. * @param defines The generated defines used in the effect
  9409. * @param effect The effect we are binding the data to
  9410. * @param scene The scene we are willing to render with logarithmic scale for
  9411. */
  9412. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9413. /**
  9414. * Binds the clip plane information from the scene to the effect.
  9415. * @param scene The scene the clip plane information are extracted from
  9416. * @param effect The effect we are binding the data to
  9417. */
  9418. static BindClipPlane(effect: Effect, scene: Scene): void;
  9419. }
  9420. }
  9421. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9422. /** @hidden */
  9423. export var packingFunctions: {
  9424. name: string;
  9425. shader: string;
  9426. };
  9427. }
  9428. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9429. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9430. /** @hidden */
  9431. export var shadowMapPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9437. /** @hidden */
  9438. export var bonesDeclaration: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9444. /** @hidden */
  9445. export var morphTargetsVertexGlobalDeclaration: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9451. /** @hidden */
  9452. export var morphTargetsVertexDeclaration: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9458. /** @hidden */
  9459. export var instancesDeclaration: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9465. /** @hidden */
  9466. export var helperFunctions: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9472. /** @hidden */
  9473. export var morphTargetsVertex: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9479. /** @hidden */
  9480. export var instancesVertex: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9486. /** @hidden */
  9487. export var bonesVertex: {
  9488. name: string;
  9489. shader: string;
  9490. };
  9491. }
  9492. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9493. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9494. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9495. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9496. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9497. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9498. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9499. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9500. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9501. /** @hidden */
  9502. export var shadowMapVertexShader: {
  9503. name: string;
  9504. shader: string;
  9505. };
  9506. }
  9507. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9508. /** @hidden */
  9509. export var depthBoxBlurPixelShader: {
  9510. name: string;
  9511. shader: string;
  9512. };
  9513. }
  9514. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9515. import { Nullable } from "babylonjs/types";
  9516. import { Scene } from "babylonjs/scene";
  9517. import { Matrix } from "babylonjs/Maths/math.vector";
  9518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9520. import { Mesh } from "babylonjs/Meshes/mesh";
  9521. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9522. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9523. import { Effect } from "babylonjs/Materials/effect";
  9524. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9525. import "babylonjs/Shaders/shadowMap.fragment";
  9526. import "babylonjs/Shaders/shadowMap.vertex";
  9527. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9528. import { Observable } from "babylonjs/Misc/observable";
  9529. /**
  9530. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9531. */
  9532. export interface ICustomShaderOptions {
  9533. /**
  9534. * Gets or sets the custom shader name to use
  9535. */
  9536. shaderName: string;
  9537. /**
  9538. * The list of attribute names used in the shader
  9539. */
  9540. attributes?: string[];
  9541. /**
  9542. * The list of unifrom names used in the shader
  9543. */
  9544. uniforms?: string[];
  9545. /**
  9546. * The list of sampler names used in the shader
  9547. */
  9548. samplers?: string[];
  9549. /**
  9550. * The list of defines used in the shader
  9551. */
  9552. defines?: string[];
  9553. }
  9554. /**
  9555. * Interface to implement to create a shadow generator compatible with BJS.
  9556. */
  9557. export interface IShadowGenerator {
  9558. /**
  9559. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9560. * @returns The render target texture if present otherwise, null
  9561. */
  9562. getShadowMap(): Nullable<RenderTargetTexture>;
  9563. /**
  9564. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9565. * @returns The render target texture if the shadow map is present otherwise, null
  9566. */
  9567. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9568. /**
  9569. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9570. * @param subMesh The submesh we want to render in the shadow map
  9571. * @param useInstances Defines wether will draw in the map using instances
  9572. * @returns true if ready otherwise, false
  9573. */
  9574. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9575. /**
  9576. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9577. * @param defines Defines of the material we want to update
  9578. * @param lightIndex Index of the light in the enabled light list of the material
  9579. */
  9580. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9581. /**
  9582. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9583. * defined in the generator but impacting the effect).
  9584. * It implies the unifroms available on the materials are the standard BJS ones.
  9585. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9586. * @param effect The effect we are binfing the information for
  9587. */
  9588. bindShadowLight(lightIndex: string, effect: Effect): void;
  9589. /**
  9590. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9591. * (eq to shadow prjection matrix * light transform matrix)
  9592. * @returns The transform matrix used to create the shadow map
  9593. */
  9594. getTransformMatrix(): Matrix;
  9595. /**
  9596. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9597. * Cube and 2D textures for instance.
  9598. */
  9599. recreateShadowMap(): void;
  9600. /**
  9601. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9602. * @param onCompiled Callback triggered at the and of the effects compilation
  9603. * @param options Sets of optional options forcing the compilation with different modes
  9604. */
  9605. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9606. useInstances: boolean;
  9607. }>): void;
  9608. /**
  9609. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9610. * @param options Sets of optional options forcing the compilation with different modes
  9611. * @returns A promise that resolves when the compilation completes
  9612. */
  9613. forceCompilationAsync(options?: Partial<{
  9614. useInstances: boolean;
  9615. }>): Promise<void>;
  9616. /**
  9617. * Serializes the shadow generator setup to a json object.
  9618. * @returns The serialized JSON object
  9619. */
  9620. serialize(): any;
  9621. /**
  9622. * Disposes the Shadow map and related Textures and effects.
  9623. */
  9624. dispose(): void;
  9625. }
  9626. /**
  9627. * Default implementation IShadowGenerator.
  9628. * This is the main object responsible of generating shadows in the framework.
  9629. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9630. */
  9631. export class ShadowGenerator implements IShadowGenerator {
  9632. /**
  9633. * Shadow generator mode None: no filtering applied.
  9634. */
  9635. static readonly FILTER_NONE: number;
  9636. /**
  9637. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9638. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9639. */
  9640. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9641. /**
  9642. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9643. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9644. */
  9645. static readonly FILTER_POISSONSAMPLING: number;
  9646. /**
  9647. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9648. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9649. */
  9650. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9651. /**
  9652. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9653. * edge artifacts on steep falloff.
  9654. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9655. */
  9656. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9657. /**
  9658. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9659. * edge artifacts on steep falloff.
  9660. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9661. */
  9662. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9663. /**
  9664. * Shadow generator mode PCF: Percentage Closer Filtering
  9665. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9666. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9667. */
  9668. static readonly FILTER_PCF: number;
  9669. /**
  9670. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9671. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9672. * Contact Hardening
  9673. */
  9674. static readonly FILTER_PCSS: number;
  9675. /**
  9676. * Reserved for PCF and PCSS
  9677. * Highest Quality.
  9678. *
  9679. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9680. *
  9681. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9682. */
  9683. static readonly QUALITY_HIGH: number;
  9684. /**
  9685. * Reserved for PCF and PCSS
  9686. * Good tradeoff for quality/perf cross devices
  9687. *
  9688. * Execute PCF on a 3*3 kernel.
  9689. *
  9690. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9691. */
  9692. static readonly QUALITY_MEDIUM: number;
  9693. /**
  9694. * Reserved for PCF and PCSS
  9695. * The lowest quality but the fastest.
  9696. *
  9697. * Execute PCF on a 1*1 kernel.
  9698. *
  9699. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9700. */
  9701. static readonly QUALITY_LOW: number;
  9702. /** Gets or sets the custom shader name to use */
  9703. customShaderOptions: ICustomShaderOptions;
  9704. /**
  9705. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9706. */
  9707. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9708. /**
  9709. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9710. */
  9711. onAfterShadowMapRenderObservable: Observable<Effect>;
  9712. /**
  9713. * Observable triggered before a mesh is rendered in the shadow map.
  9714. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9715. */
  9716. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9717. /**
  9718. * Observable triggered after a mesh is rendered in the shadow map.
  9719. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9720. */
  9721. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9722. private _bias;
  9723. /**
  9724. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9725. */
  9726. get bias(): number;
  9727. /**
  9728. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9729. */
  9730. set bias(bias: number);
  9731. private _normalBias;
  9732. /**
  9733. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9734. */
  9735. get normalBias(): number;
  9736. /**
  9737. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9738. */
  9739. set normalBias(normalBias: number);
  9740. private _blurBoxOffset;
  9741. /**
  9742. * Gets the blur box offset: offset applied during the blur pass.
  9743. * Only useful if useKernelBlur = false
  9744. */
  9745. get blurBoxOffset(): number;
  9746. /**
  9747. * Sets the blur box offset: offset applied during the blur pass.
  9748. * Only useful if useKernelBlur = false
  9749. */
  9750. set blurBoxOffset(value: number);
  9751. private _blurScale;
  9752. /**
  9753. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9754. * 2 means half of the size.
  9755. */
  9756. get blurScale(): number;
  9757. /**
  9758. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9759. * 2 means half of the size.
  9760. */
  9761. set blurScale(value: number);
  9762. private _blurKernel;
  9763. /**
  9764. * Gets the blur kernel: kernel size of the blur pass.
  9765. * Only useful if useKernelBlur = true
  9766. */
  9767. get blurKernel(): number;
  9768. /**
  9769. * Sets the blur kernel: kernel size of the blur pass.
  9770. * Only useful if useKernelBlur = true
  9771. */
  9772. set blurKernel(value: number);
  9773. private _useKernelBlur;
  9774. /**
  9775. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9776. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9777. */
  9778. get useKernelBlur(): boolean;
  9779. /**
  9780. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9781. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9782. */
  9783. set useKernelBlur(value: boolean);
  9784. private _depthScale;
  9785. /**
  9786. * Gets the depth scale used in ESM mode.
  9787. */
  9788. get depthScale(): number;
  9789. /**
  9790. * Sets the depth scale used in ESM mode.
  9791. * This can override the scale stored on the light.
  9792. */
  9793. set depthScale(value: number);
  9794. private _filter;
  9795. /**
  9796. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9797. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9798. */
  9799. get filter(): number;
  9800. /**
  9801. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9802. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9803. */
  9804. set filter(value: number);
  9805. /**
  9806. * Gets if the current filter is set to Poisson Sampling.
  9807. */
  9808. get usePoissonSampling(): boolean;
  9809. /**
  9810. * Sets the current filter to Poisson Sampling.
  9811. */
  9812. set usePoissonSampling(value: boolean);
  9813. /**
  9814. * Gets if the current filter is set to ESM.
  9815. */
  9816. get useExponentialShadowMap(): boolean;
  9817. /**
  9818. * Sets the current filter is to ESM.
  9819. */
  9820. set useExponentialShadowMap(value: boolean);
  9821. /**
  9822. * Gets if the current filter is set to filtered ESM.
  9823. */
  9824. get useBlurExponentialShadowMap(): boolean;
  9825. /**
  9826. * Gets if the current filter is set to filtered ESM.
  9827. */
  9828. set useBlurExponentialShadowMap(value: boolean);
  9829. /**
  9830. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9831. * exponential to prevent steep falloff artifacts).
  9832. */
  9833. get useCloseExponentialShadowMap(): boolean;
  9834. /**
  9835. * Sets the current filter to "close ESM" (using the inverse of the
  9836. * exponential to prevent steep falloff artifacts).
  9837. */
  9838. set useCloseExponentialShadowMap(value: boolean);
  9839. /**
  9840. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9841. * exponential to prevent steep falloff artifacts).
  9842. */
  9843. get useBlurCloseExponentialShadowMap(): boolean;
  9844. /**
  9845. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9846. * exponential to prevent steep falloff artifacts).
  9847. */
  9848. set useBlurCloseExponentialShadowMap(value: boolean);
  9849. /**
  9850. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9851. */
  9852. get usePercentageCloserFiltering(): boolean;
  9853. /**
  9854. * Sets the current filter to "PCF" (percentage closer filtering).
  9855. */
  9856. set usePercentageCloserFiltering(value: boolean);
  9857. private _filteringQuality;
  9858. /**
  9859. * Gets the PCF or PCSS Quality.
  9860. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9861. */
  9862. get filteringQuality(): number;
  9863. /**
  9864. * Sets the PCF or PCSS Quality.
  9865. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9866. */
  9867. set filteringQuality(filteringQuality: number);
  9868. /**
  9869. * Gets if the current filter is set to "PCSS" (contact hardening).
  9870. */
  9871. get useContactHardeningShadow(): boolean;
  9872. /**
  9873. * Sets the current filter to "PCSS" (contact hardening).
  9874. */
  9875. set useContactHardeningShadow(value: boolean);
  9876. private _contactHardeningLightSizeUVRatio;
  9877. /**
  9878. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9879. * Using a ratio helps keeping shape stability independently of the map size.
  9880. *
  9881. * It does not account for the light projection as it was having too much
  9882. * instability during the light setup or during light position changes.
  9883. *
  9884. * Only valid if useContactHardeningShadow is true.
  9885. */
  9886. get contactHardeningLightSizeUVRatio(): number;
  9887. /**
  9888. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9889. * Using a ratio helps keeping shape stability independently of the map size.
  9890. *
  9891. * It does not account for the light projection as it was having too much
  9892. * instability during the light setup or during light position changes.
  9893. *
  9894. * Only valid if useContactHardeningShadow is true.
  9895. */
  9896. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9897. private _darkness;
  9898. /** Gets or sets the actual darkness of a shadow */
  9899. get darkness(): number;
  9900. set darkness(value: number);
  9901. /**
  9902. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9903. * 0 means strongest and 1 would means no shadow.
  9904. * @returns the darkness.
  9905. */
  9906. getDarkness(): number;
  9907. /**
  9908. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9909. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9910. * @returns the shadow generator allowing fluent coding.
  9911. */
  9912. setDarkness(darkness: number): ShadowGenerator;
  9913. private _transparencyShadow;
  9914. /** Gets or sets the ability to have transparent shadow */
  9915. get transparencyShadow(): boolean;
  9916. set transparencyShadow(value: boolean);
  9917. /**
  9918. * Sets the ability to have transparent shadow (boolean).
  9919. * @param transparent True if transparent else False
  9920. * @returns the shadow generator allowing fluent coding
  9921. */
  9922. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9923. private _shadowMap;
  9924. private _shadowMap2;
  9925. /**
  9926. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9927. * @returns The render target texture if present otherwise, null
  9928. */
  9929. getShadowMap(): Nullable<RenderTargetTexture>;
  9930. /**
  9931. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9932. * @returns The render target texture if the shadow map is present otherwise, null
  9933. */
  9934. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9935. /**
  9936. * Gets the class name of that object
  9937. * @returns "ShadowGenerator"
  9938. */
  9939. getClassName(): string;
  9940. /**
  9941. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9942. * @param mesh Mesh to add
  9943. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9944. * @returns the Shadow Generator itself
  9945. */
  9946. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9947. /**
  9948. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9949. * @param mesh Mesh to remove
  9950. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9951. * @returns the Shadow Generator itself
  9952. */
  9953. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9954. /**
  9955. * Controls the extent to which the shadows fade out at the edge of the frustum
  9956. * Used only by directionals and spots
  9957. */
  9958. frustumEdgeFalloff: number;
  9959. private _light;
  9960. /**
  9961. * Returns the associated light object.
  9962. * @returns the light generating the shadow
  9963. */
  9964. getLight(): IShadowLight;
  9965. /**
  9966. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9967. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9968. * It might on the other hand introduce peter panning.
  9969. */
  9970. forceBackFacesOnly: boolean;
  9971. private _scene;
  9972. private _lightDirection;
  9973. private _effect;
  9974. private _viewMatrix;
  9975. private _projectionMatrix;
  9976. private _transformMatrix;
  9977. private _cachedPosition;
  9978. private _cachedDirection;
  9979. private _cachedDefines;
  9980. private _currentRenderID;
  9981. private _boxBlurPostprocess;
  9982. private _kernelBlurXPostprocess;
  9983. private _kernelBlurYPostprocess;
  9984. private _blurPostProcesses;
  9985. private _mapSize;
  9986. private _currentFaceIndex;
  9987. private _currentFaceIndexCache;
  9988. private _textureType;
  9989. private _defaultTextureMatrix;
  9990. private _storedUniqueId;
  9991. /** @hidden */
  9992. static _SceneComponentInitialization: (scene: Scene) => void;
  9993. /**
  9994. * Creates a ShadowGenerator object.
  9995. * A ShadowGenerator is the required tool to use the shadows.
  9996. * Each light casting shadows needs to use its own ShadowGenerator.
  9997. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9998. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9999. * @param light The light object generating the shadows.
  10000. * @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.
  10001. */
  10002. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10003. private _initializeGenerator;
  10004. private _initializeShadowMap;
  10005. private _initializeBlurRTTAndPostProcesses;
  10006. private _renderForShadowMap;
  10007. private _renderSubMeshForShadowMap;
  10008. private _applyFilterValues;
  10009. /**
  10010. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10011. * @param onCompiled Callback triggered at the and of the effects compilation
  10012. * @param options Sets of optional options forcing the compilation with different modes
  10013. */
  10014. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10015. useInstances: boolean;
  10016. }>): void;
  10017. /**
  10018. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10019. * @param options Sets of optional options forcing the compilation with different modes
  10020. * @returns A promise that resolves when the compilation completes
  10021. */
  10022. forceCompilationAsync(options?: Partial<{
  10023. useInstances: boolean;
  10024. }>): Promise<void>;
  10025. /**
  10026. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10027. * @param subMesh The submesh we want to render in the shadow map
  10028. * @param useInstances Defines wether will draw in the map using instances
  10029. * @returns true if ready otherwise, false
  10030. */
  10031. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10032. /**
  10033. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10034. * @param defines Defines of the material we want to update
  10035. * @param lightIndex Index of the light in the enabled light list of the material
  10036. */
  10037. prepareDefines(defines: any, lightIndex: number): void;
  10038. /**
  10039. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10040. * defined in the generator but impacting the effect).
  10041. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10042. * @param effect The effect we are binfing the information for
  10043. */
  10044. bindShadowLight(lightIndex: string, effect: Effect): void;
  10045. /**
  10046. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10047. * (eq to shadow prjection matrix * light transform matrix)
  10048. * @returns The transform matrix used to create the shadow map
  10049. */
  10050. getTransformMatrix(): Matrix;
  10051. /**
  10052. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10053. * Cube and 2D textures for instance.
  10054. */
  10055. recreateShadowMap(): void;
  10056. private _disposeBlurPostProcesses;
  10057. private _disposeRTTandPostProcesses;
  10058. /**
  10059. * Disposes the ShadowGenerator.
  10060. * Returns nothing.
  10061. */
  10062. dispose(): void;
  10063. /**
  10064. * Serializes the shadow generator setup to a json object.
  10065. * @returns The serialized JSON object
  10066. */
  10067. serialize(): any;
  10068. /**
  10069. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10070. * @param parsedShadowGenerator The JSON object to parse
  10071. * @param scene The scene to create the shadow map for
  10072. * @returns The parsed shadow generator
  10073. */
  10074. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10075. }
  10076. }
  10077. declare module "babylonjs/Lights/light" {
  10078. import { Nullable } from "babylonjs/types";
  10079. import { Scene } from "babylonjs/scene";
  10080. import { Vector3 } from "babylonjs/Maths/math.vector";
  10081. import { Color3 } from "babylonjs/Maths/math.color";
  10082. import { Node } from "babylonjs/node";
  10083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10084. import { Effect } from "babylonjs/Materials/effect";
  10085. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10086. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10087. /**
  10088. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10089. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10090. * 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.
  10091. */
  10092. export abstract class Light extends Node {
  10093. /**
  10094. * Falloff Default: light is falling off following the material specification:
  10095. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10096. */
  10097. static readonly FALLOFF_DEFAULT: number;
  10098. /**
  10099. * Falloff Physical: light is falling off following the inverse squared distance law.
  10100. */
  10101. static readonly FALLOFF_PHYSICAL: number;
  10102. /**
  10103. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10104. * to enhance interoperability with other engines.
  10105. */
  10106. static readonly FALLOFF_GLTF: number;
  10107. /**
  10108. * Falloff Standard: light is falling off like in the standard material
  10109. * to enhance interoperability with other materials.
  10110. */
  10111. static readonly FALLOFF_STANDARD: number;
  10112. /**
  10113. * If every light affecting the material is in this lightmapMode,
  10114. * material.lightmapTexture adds or multiplies
  10115. * (depends on material.useLightmapAsShadowmap)
  10116. * after every other light calculations.
  10117. */
  10118. static readonly LIGHTMAP_DEFAULT: number;
  10119. /**
  10120. * material.lightmapTexture as only diffuse lighting from this light
  10121. * adds only specular lighting from this light
  10122. * adds dynamic shadows
  10123. */
  10124. static readonly LIGHTMAP_SPECULAR: number;
  10125. /**
  10126. * material.lightmapTexture as only lighting
  10127. * no light calculation from this light
  10128. * only adds dynamic shadows from this light
  10129. */
  10130. static readonly LIGHTMAP_SHADOWSONLY: number;
  10131. /**
  10132. * Each light type uses the default quantity according to its type:
  10133. * point/spot lights use luminous intensity
  10134. * directional lights use illuminance
  10135. */
  10136. static readonly INTENSITYMODE_AUTOMATIC: number;
  10137. /**
  10138. * lumen (lm)
  10139. */
  10140. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10141. /**
  10142. * candela (lm/sr)
  10143. */
  10144. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10145. /**
  10146. * lux (lm/m^2)
  10147. */
  10148. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10149. /**
  10150. * nit (cd/m^2)
  10151. */
  10152. static readonly INTENSITYMODE_LUMINANCE: number;
  10153. /**
  10154. * Light type const id of the point light.
  10155. */
  10156. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10157. /**
  10158. * Light type const id of the directional light.
  10159. */
  10160. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10161. /**
  10162. * Light type const id of the spot light.
  10163. */
  10164. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10165. /**
  10166. * Light type const id of the hemispheric light.
  10167. */
  10168. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10169. /**
  10170. * Diffuse gives the basic color to an object.
  10171. */
  10172. diffuse: Color3;
  10173. /**
  10174. * Specular produces a highlight color on an object.
  10175. * Note: This is note affecting PBR materials.
  10176. */
  10177. specular: Color3;
  10178. /**
  10179. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10180. * falling off base on range or angle.
  10181. * This can be set to any values in Light.FALLOFF_x.
  10182. *
  10183. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10184. * other types of materials.
  10185. */
  10186. falloffType: number;
  10187. /**
  10188. * Strength of the light.
  10189. * Note: By default it is define in the framework own unit.
  10190. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10191. */
  10192. intensity: number;
  10193. private _range;
  10194. protected _inverseSquaredRange: number;
  10195. /**
  10196. * Defines how far from the source the light is impacting in scene units.
  10197. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10198. */
  10199. get range(): number;
  10200. /**
  10201. * Defines how far from the source the light is impacting in scene units.
  10202. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10203. */
  10204. set range(value: number);
  10205. /**
  10206. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10207. * of light.
  10208. */
  10209. private _photometricScale;
  10210. private _intensityMode;
  10211. /**
  10212. * Gets the photometric scale used to interpret the intensity.
  10213. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10214. */
  10215. get intensityMode(): number;
  10216. /**
  10217. * Sets the photometric scale used to interpret the intensity.
  10218. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10219. */
  10220. set intensityMode(value: number);
  10221. private _radius;
  10222. /**
  10223. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10224. */
  10225. get radius(): number;
  10226. /**
  10227. * sets the light radius used by PBR Materials to simulate soft area lights.
  10228. */
  10229. set radius(value: number);
  10230. private _renderPriority;
  10231. /**
  10232. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10233. * exceeding the number allowed of the materials.
  10234. */
  10235. renderPriority: number;
  10236. private _shadowEnabled;
  10237. /**
  10238. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10239. * the current shadow generator.
  10240. */
  10241. get shadowEnabled(): boolean;
  10242. /**
  10243. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10244. * the current shadow generator.
  10245. */
  10246. set shadowEnabled(value: boolean);
  10247. private _includedOnlyMeshes;
  10248. /**
  10249. * Gets the only meshes impacted by this light.
  10250. */
  10251. get includedOnlyMeshes(): AbstractMesh[];
  10252. /**
  10253. * Sets the only meshes impacted by this light.
  10254. */
  10255. set includedOnlyMeshes(value: AbstractMesh[]);
  10256. private _excludedMeshes;
  10257. /**
  10258. * Gets the meshes not impacted by this light.
  10259. */
  10260. get excludedMeshes(): AbstractMesh[];
  10261. /**
  10262. * Sets the meshes not impacted by this light.
  10263. */
  10264. set excludedMeshes(value: AbstractMesh[]);
  10265. private _excludeWithLayerMask;
  10266. /**
  10267. * Gets the layer id use to find what meshes are not impacted by the light.
  10268. * Inactive if 0
  10269. */
  10270. get excludeWithLayerMask(): number;
  10271. /**
  10272. * Sets the layer id use to find what meshes are not impacted by the light.
  10273. * Inactive if 0
  10274. */
  10275. set excludeWithLayerMask(value: number);
  10276. private _includeOnlyWithLayerMask;
  10277. /**
  10278. * Gets the layer id use to find what meshes are impacted by the light.
  10279. * Inactive if 0
  10280. */
  10281. get includeOnlyWithLayerMask(): number;
  10282. /**
  10283. * Sets the layer id use to find what meshes are impacted by the light.
  10284. * Inactive if 0
  10285. */
  10286. set includeOnlyWithLayerMask(value: number);
  10287. private _lightmapMode;
  10288. /**
  10289. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10290. */
  10291. get lightmapMode(): number;
  10292. /**
  10293. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10294. */
  10295. set lightmapMode(value: number);
  10296. /**
  10297. * Shadow generator associted to the light.
  10298. * @hidden Internal use only.
  10299. */
  10300. _shadowGenerator: Nullable<IShadowGenerator>;
  10301. /**
  10302. * @hidden Internal use only.
  10303. */
  10304. _excludedMeshesIds: string[];
  10305. /**
  10306. * @hidden Internal use only.
  10307. */
  10308. _includedOnlyMeshesIds: string[];
  10309. /**
  10310. * The current light unifom buffer.
  10311. * @hidden Internal use only.
  10312. */
  10313. _uniformBuffer: UniformBuffer;
  10314. /** @hidden */
  10315. _renderId: number;
  10316. /**
  10317. * Creates a Light object in the scene.
  10318. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10319. * @param name The firendly name of the light
  10320. * @param scene The scene the light belongs too
  10321. */
  10322. constructor(name: string, scene: Scene);
  10323. protected abstract _buildUniformLayout(): void;
  10324. /**
  10325. * Sets the passed Effect "effect" with the Light information.
  10326. * @param effect The effect to update
  10327. * @param lightIndex The index of the light in the effect to update
  10328. * @returns The light
  10329. */
  10330. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10331. /**
  10332. * Sets the passed Effect "effect" with the Light textures.
  10333. * @param effect The effect to update
  10334. * @param lightIndex The index of the light in the effect to update
  10335. * @returns The light
  10336. */
  10337. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10338. /**
  10339. * Binds the lights information from the scene to the effect for the given mesh.
  10340. * @param lightIndex Light index
  10341. * @param scene The scene where the light belongs to
  10342. * @param effect The effect we are binding the data to
  10343. * @param useSpecular Defines if specular is supported
  10344. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10345. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10346. */
  10347. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10348. /**
  10349. * Sets the passed Effect "effect" with the Light information.
  10350. * @param effect The effect to update
  10351. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10352. * @returns The light
  10353. */
  10354. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10355. /**
  10356. * Returns the string "Light".
  10357. * @returns the class name
  10358. */
  10359. getClassName(): string;
  10360. /** @hidden */
  10361. readonly _isLight: boolean;
  10362. /**
  10363. * Converts the light information to a readable string for debug purpose.
  10364. * @param fullDetails Supports for multiple levels of logging within scene loading
  10365. * @returns the human readable light info
  10366. */
  10367. toString(fullDetails?: boolean): string;
  10368. /** @hidden */
  10369. protected _syncParentEnabledState(): void;
  10370. /**
  10371. * Set the enabled state of this node.
  10372. * @param value - the new enabled state
  10373. */
  10374. setEnabled(value: boolean): void;
  10375. /**
  10376. * Returns the Light associated shadow generator if any.
  10377. * @return the associated shadow generator.
  10378. */
  10379. getShadowGenerator(): Nullable<IShadowGenerator>;
  10380. /**
  10381. * Returns a Vector3, the absolute light position in the World.
  10382. * @returns the world space position of the light
  10383. */
  10384. getAbsolutePosition(): Vector3;
  10385. /**
  10386. * Specifies if the light will affect the passed mesh.
  10387. * @param mesh The mesh to test against the light
  10388. * @return true the mesh is affected otherwise, false.
  10389. */
  10390. canAffectMesh(mesh: AbstractMesh): boolean;
  10391. /**
  10392. * Sort function to order lights for rendering.
  10393. * @param a First Light object to compare to second.
  10394. * @param b Second Light object to compare first.
  10395. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10396. */
  10397. static CompareLightsPriority(a: Light, b: Light): number;
  10398. /**
  10399. * Releases resources associated with this node.
  10400. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10401. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10402. */
  10403. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10404. /**
  10405. * Returns the light type ID (integer).
  10406. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10407. */
  10408. getTypeID(): number;
  10409. /**
  10410. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10411. * @returns the scaled intensity in intensity mode unit
  10412. */
  10413. getScaledIntensity(): number;
  10414. /**
  10415. * Returns a new Light object, named "name", from the current one.
  10416. * @param name The name of the cloned light
  10417. * @returns the new created light
  10418. */
  10419. clone(name: string): Nullable<Light>;
  10420. /**
  10421. * Serializes the current light into a Serialization object.
  10422. * @returns the serialized object.
  10423. */
  10424. serialize(): any;
  10425. /**
  10426. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10427. * This new light is named "name" and added to the passed scene.
  10428. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10429. * @param name The friendly name of the light
  10430. * @param scene The scene the new light will belong to
  10431. * @returns the constructor function
  10432. */
  10433. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10434. /**
  10435. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10436. * @param parsedLight The JSON representation of the light
  10437. * @param scene The scene to create the parsed light in
  10438. * @returns the created light after parsing
  10439. */
  10440. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10441. private _hookArrayForExcluded;
  10442. private _hookArrayForIncludedOnly;
  10443. private _resyncMeshes;
  10444. /**
  10445. * Forces the meshes to update their light related information in their rendering used effects
  10446. * @hidden Internal Use Only
  10447. */
  10448. _markMeshesAsLightDirty(): void;
  10449. /**
  10450. * Recomputes the cached photometric scale if needed.
  10451. */
  10452. private _computePhotometricScale;
  10453. /**
  10454. * Returns the Photometric Scale according to the light type and intensity mode.
  10455. */
  10456. private _getPhotometricScale;
  10457. /**
  10458. * Reorder the light in the scene according to their defined priority.
  10459. * @hidden Internal Use Only
  10460. */
  10461. _reorderLightsInScene(): void;
  10462. /**
  10463. * Prepares the list of defines specific to the light type.
  10464. * @param defines the list of defines
  10465. * @param lightIndex defines the index of the light for the effect
  10466. */
  10467. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10468. }
  10469. }
  10470. declare module "babylonjs/Actions/action" {
  10471. import { Observable } from "babylonjs/Misc/observable";
  10472. import { Condition } from "babylonjs/Actions/condition";
  10473. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10474. import { ActionManager } from "babylonjs/Actions/actionManager";
  10475. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10476. /**
  10477. * Interface used to define Action
  10478. */
  10479. export interface IAction {
  10480. /**
  10481. * Trigger for the action
  10482. */
  10483. trigger: number;
  10484. /** Options of the trigger */
  10485. triggerOptions: any;
  10486. /**
  10487. * Gets the trigger parameters
  10488. * @returns the trigger parameters
  10489. */
  10490. getTriggerParameter(): any;
  10491. /**
  10492. * Internal only - executes current action event
  10493. * @hidden
  10494. */
  10495. _executeCurrent(evt?: ActionEvent): void;
  10496. /**
  10497. * Serialize placeholder for child classes
  10498. * @param parent of child
  10499. * @returns the serialized object
  10500. */
  10501. serialize(parent: any): any;
  10502. /**
  10503. * Internal only
  10504. * @hidden
  10505. */
  10506. _prepare(): void;
  10507. /**
  10508. * Internal only - manager for action
  10509. * @hidden
  10510. */
  10511. _actionManager: AbstractActionManager;
  10512. /**
  10513. * Adds action to chain of actions, may be a DoNothingAction
  10514. * @param action defines the next action to execute
  10515. * @returns The action passed in
  10516. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10517. */
  10518. then(action: IAction): IAction;
  10519. }
  10520. /**
  10521. * The action to be carried out following a trigger
  10522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10523. */
  10524. export class Action implements IAction {
  10525. /** the trigger, with or without parameters, for the action */
  10526. triggerOptions: any;
  10527. /**
  10528. * Trigger for the action
  10529. */
  10530. trigger: number;
  10531. /**
  10532. * Internal only - manager for action
  10533. * @hidden
  10534. */
  10535. _actionManager: ActionManager;
  10536. private _nextActiveAction;
  10537. private _child;
  10538. private _condition?;
  10539. private _triggerParameter;
  10540. /**
  10541. * An event triggered prior to action being executed.
  10542. */
  10543. onBeforeExecuteObservable: Observable<Action>;
  10544. /**
  10545. * Creates a new Action
  10546. * @param triggerOptions the trigger, with or without parameters, for the action
  10547. * @param condition an optional determinant of action
  10548. */
  10549. constructor(
  10550. /** the trigger, with or without parameters, for the action */
  10551. triggerOptions: any, condition?: Condition);
  10552. /**
  10553. * Internal only
  10554. * @hidden
  10555. */
  10556. _prepare(): void;
  10557. /**
  10558. * Gets the trigger parameters
  10559. * @returns the trigger parameters
  10560. */
  10561. getTriggerParameter(): any;
  10562. /**
  10563. * Internal only - executes current action event
  10564. * @hidden
  10565. */
  10566. _executeCurrent(evt?: ActionEvent): void;
  10567. /**
  10568. * Execute placeholder for child classes
  10569. * @param evt optional action event
  10570. */
  10571. execute(evt?: ActionEvent): void;
  10572. /**
  10573. * Skips to next active action
  10574. */
  10575. skipToNextActiveAction(): void;
  10576. /**
  10577. * Adds action to chain of actions, may be a DoNothingAction
  10578. * @param action defines the next action to execute
  10579. * @returns The action passed in
  10580. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10581. */
  10582. then(action: Action): Action;
  10583. /**
  10584. * Internal only
  10585. * @hidden
  10586. */
  10587. _getProperty(propertyPath: string): string;
  10588. /**
  10589. * Internal only
  10590. * @hidden
  10591. */
  10592. _getEffectiveTarget(target: any, propertyPath: string): any;
  10593. /**
  10594. * Serialize placeholder for child classes
  10595. * @param parent of child
  10596. * @returns the serialized object
  10597. */
  10598. serialize(parent: any): any;
  10599. /**
  10600. * Internal only called by serialize
  10601. * @hidden
  10602. */
  10603. protected _serialize(serializedAction: any, parent?: any): any;
  10604. /**
  10605. * Internal only
  10606. * @hidden
  10607. */
  10608. static _SerializeValueAsString: (value: any) => string;
  10609. /**
  10610. * Internal only
  10611. * @hidden
  10612. */
  10613. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10614. name: string;
  10615. targetType: string;
  10616. value: string;
  10617. };
  10618. }
  10619. }
  10620. declare module "babylonjs/Actions/condition" {
  10621. import { ActionManager } from "babylonjs/Actions/actionManager";
  10622. /**
  10623. * A Condition applied to an Action
  10624. */
  10625. export class Condition {
  10626. /**
  10627. * Internal only - manager for action
  10628. * @hidden
  10629. */
  10630. _actionManager: ActionManager;
  10631. /**
  10632. * Internal only
  10633. * @hidden
  10634. */
  10635. _evaluationId: number;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. _currentResult: boolean;
  10641. /**
  10642. * Creates a new Condition
  10643. * @param actionManager the manager of the action the condition is applied to
  10644. */
  10645. constructor(actionManager: ActionManager);
  10646. /**
  10647. * Check if the current condition is valid
  10648. * @returns a boolean
  10649. */
  10650. isValid(): boolean;
  10651. /**
  10652. * Internal only
  10653. * @hidden
  10654. */
  10655. _getProperty(propertyPath: string): string;
  10656. /**
  10657. * Internal only
  10658. * @hidden
  10659. */
  10660. _getEffectiveTarget(target: any, propertyPath: string): any;
  10661. /**
  10662. * Serialize placeholder for child classes
  10663. * @returns the serialized object
  10664. */
  10665. serialize(): any;
  10666. /**
  10667. * Internal only
  10668. * @hidden
  10669. */
  10670. protected _serialize(serializedCondition: any): any;
  10671. }
  10672. /**
  10673. * Defines specific conditional operators as extensions of Condition
  10674. */
  10675. export class ValueCondition extends Condition {
  10676. /** path to specify the property of the target the conditional operator uses */
  10677. propertyPath: string;
  10678. /** the value compared by the conditional operator against the current value of the property */
  10679. value: any;
  10680. /** the conditional operator, default ValueCondition.IsEqual */
  10681. operator: number;
  10682. /**
  10683. * Internal only
  10684. * @hidden
  10685. */
  10686. private static _IsEqual;
  10687. /**
  10688. * Internal only
  10689. * @hidden
  10690. */
  10691. private static _IsDifferent;
  10692. /**
  10693. * Internal only
  10694. * @hidden
  10695. */
  10696. private static _IsGreater;
  10697. /**
  10698. * Internal only
  10699. * @hidden
  10700. */
  10701. private static _IsLesser;
  10702. /**
  10703. * returns the number for IsEqual
  10704. */
  10705. static get IsEqual(): number;
  10706. /**
  10707. * Returns the number for IsDifferent
  10708. */
  10709. static get IsDifferent(): number;
  10710. /**
  10711. * Returns the number for IsGreater
  10712. */
  10713. static get IsGreater(): number;
  10714. /**
  10715. * Returns the number for IsLesser
  10716. */
  10717. static get IsLesser(): number;
  10718. /**
  10719. * Internal only The action manager for the condition
  10720. * @hidden
  10721. */
  10722. _actionManager: ActionManager;
  10723. /**
  10724. * Internal only
  10725. * @hidden
  10726. */
  10727. private _target;
  10728. /**
  10729. * Internal only
  10730. * @hidden
  10731. */
  10732. private _effectiveTarget;
  10733. /**
  10734. * Internal only
  10735. * @hidden
  10736. */
  10737. private _property;
  10738. /**
  10739. * Creates a new ValueCondition
  10740. * @param actionManager manager for the action the condition applies to
  10741. * @param target for the action
  10742. * @param propertyPath path to specify the property of the target the conditional operator uses
  10743. * @param value the value compared by the conditional operator against the current value of the property
  10744. * @param operator the conditional operator, default ValueCondition.IsEqual
  10745. */
  10746. constructor(actionManager: ActionManager, target: any,
  10747. /** path to specify the property of the target the conditional operator uses */
  10748. propertyPath: string,
  10749. /** the value compared by the conditional operator against the current value of the property */
  10750. value: any,
  10751. /** the conditional operator, default ValueCondition.IsEqual */
  10752. operator?: number);
  10753. /**
  10754. * Compares the given value with the property value for the specified conditional operator
  10755. * @returns the result of the comparison
  10756. */
  10757. isValid(): boolean;
  10758. /**
  10759. * Serialize the ValueCondition into a JSON compatible object
  10760. * @returns serialization object
  10761. */
  10762. serialize(): any;
  10763. /**
  10764. * Gets the name of the conditional operator for the ValueCondition
  10765. * @param operator the conditional operator
  10766. * @returns the name
  10767. */
  10768. static GetOperatorName(operator: number): string;
  10769. }
  10770. /**
  10771. * Defines a predicate condition as an extension of Condition
  10772. */
  10773. export class PredicateCondition extends Condition {
  10774. /** defines the predicate function used to validate the condition */
  10775. predicate: () => boolean;
  10776. /**
  10777. * Internal only - manager for action
  10778. * @hidden
  10779. */
  10780. _actionManager: ActionManager;
  10781. /**
  10782. * Creates a new PredicateCondition
  10783. * @param actionManager manager for the action the condition applies to
  10784. * @param predicate defines the predicate function used to validate the condition
  10785. */
  10786. constructor(actionManager: ActionManager,
  10787. /** defines the predicate function used to validate the condition */
  10788. predicate: () => boolean);
  10789. /**
  10790. * @returns the validity of the predicate condition
  10791. */
  10792. isValid(): boolean;
  10793. }
  10794. /**
  10795. * Defines a state condition as an extension of Condition
  10796. */
  10797. export class StateCondition extends Condition {
  10798. /** Value to compare with target state */
  10799. value: string;
  10800. /**
  10801. * Internal only - manager for action
  10802. * @hidden
  10803. */
  10804. _actionManager: ActionManager;
  10805. /**
  10806. * Internal only
  10807. * @hidden
  10808. */
  10809. private _target;
  10810. /**
  10811. * Creates a new StateCondition
  10812. * @param actionManager manager for the action the condition applies to
  10813. * @param target of the condition
  10814. * @param value to compare with target state
  10815. */
  10816. constructor(actionManager: ActionManager, target: any,
  10817. /** Value to compare with target state */
  10818. value: string);
  10819. /**
  10820. * Gets a boolean indicating if the current condition is met
  10821. * @returns the validity of the state
  10822. */
  10823. isValid(): boolean;
  10824. /**
  10825. * Serialize the StateCondition into a JSON compatible object
  10826. * @returns serialization object
  10827. */
  10828. serialize(): any;
  10829. }
  10830. }
  10831. declare module "babylonjs/Actions/directActions" {
  10832. import { Action } from "babylonjs/Actions/action";
  10833. import { Condition } from "babylonjs/Actions/condition";
  10834. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10835. /**
  10836. * This defines an action responsible to toggle a boolean once triggered.
  10837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10838. */
  10839. export class SwitchBooleanAction extends Action {
  10840. /**
  10841. * The path to the boolean property in the target object
  10842. */
  10843. propertyPath: string;
  10844. private _target;
  10845. private _effectiveTarget;
  10846. private _property;
  10847. /**
  10848. * Instantiate the action
  10849. * @param triggerOptions defines the trigger options
  10850. * @param target defines the object containing the boolean
  10851. * @param propertyPath defines the path to the boolean property in the target object
  10852. * @param condition defines the trigger related conditions
  10853. */
  10854. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10855. /** @hidden */
  10856. _prepare(): void;
  10857. /**
  10858. * Execute the action toggle the boolean value.
  10859. */
  10860. execute(): void;
  10861. /**
  10862. * Serializes the actions and its related information.
  10863. * @param parent defines the object to serialize in
  10864. * @returns the serialized object
  10865. */
  10866. serialize(parent: any): any;
  10867. }
  10868. /**
  10869. * This defines an action responsible to set a the state field of the target
  10870. * to a desired value once triggered.
  10871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10872. */
  10873. export class SetStateAction extends Action {
  10874. /**
  10875. * The value to store in the state field.
  10876. */
  10877. value: string;
  10878. private _target;
  10879. /**
  10880. * Instantiate the action
  10881. * @param triggerOptions defines the trigger options
  10882. * @param target defines the object containing the state property
  10883. * @param value defines the value to store in the state field
  10884. * @param condition defines the trigger related conditions
  10885. */
  10886. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10887. /**
  10888. * Execute the action and store the value on the target state property.
  10889. */
  10890. execute(): void;
  10891. /**
  10892. * Serializes the actions and its related information.
  10893. * @param parent defines the object to serialize in
  10894. * @returns the serialized object
  10895. */
  10896. serialize(parent: any): any;
  10897. }
  10898. /**
  10899. * This defines an action responsible to set a property of the target
  10900. * to a desired value once triggered.
  10901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10902. */
  10903. export class SetValueAction extends Action {
  10904. /**
  10905. * The path of the property to set in the target.
  10906. */
  10907. propertyPath: string;
  10908. /**
  10909. * The value to set in the property
  10910. */
  10911. value: any;
  10912. private _target;
  10913. private _effectiveTarget;
  10914. private _property;
  10915. /**
  10916. * Instantiate the action
  10917. * @param triggerOptions defines the trigger options
  10918. * @param target defines the object containing the property
  10919. * @param propertyPath defines the path of the property to set in the target
  10920. * @param value defines the value to set in the property
  10921. * @param condition defines the trigger related conditions
  10922. */
  10923. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10924. /** @hidden */
  10925. _prepare(): void;
  10926. /**
  10927. * Execute the action and set the targetted property to the desired value.
  10928. */
  10929. execute(): void;
  10930. /**
  10931. * Serializes the actions and its related information.
  10932. * @param parent defines the object to serialize in
  10933. * @returns the serialized object
  10934. */
  10935. serialize(parent: any): any;
  10936. }
  10937. /**
  10938. * This defines an action responsible to increment the target value
  10939. * to a desired value once triggered.
  10940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10941. */
  10942. export class IncrementValueAction extends Action {
  10943. /**
  10944. * The path of the property to increment in the target.
  10945. */
  10946. propertyPath: string;
  10947. /**
  10948. * The value we should increment the property by.
  10949. */
  10950. value: any;
  10951. private _target;
  10952. private _effectiveTarget;
  10953. private _property;
  10954. /**
  10955. * Instantiate the action
  10956. * @param triggerOptions defines the trigger options
  10957. * @param target defines the object containing the property
  10958. * @param propertyPath defines the path of the property to increment in the target
  10959. * @param value defines the value value we should increment the property by
  10960. * @param condition defines the trigger related conditions
  10961. */
  10962. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10963. /** @hidden */
  10964. _prepare(): void;
  10965. /**
  10966. * Execute the action and increment the target of the value amount.
  10967. */
  10968. execute(): void;
  10969. /**
  10970. * Serializes the actions and its related information.
  10971. * @param parent defines the object to serialize in
  10972. * @returns the serialized object
  10973. */
  10974. serialize(parent: any): any;
  10975. }
  10976. /**
  10977. * This defines an action responsible to start an animation once triggered.
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10979. */
  10980. export class PlayAnimationAction extends Action {
  10981. /**
  10982. * Where the animation should start (animation frame)
  10983. */
  10984. from: number;
  10985. /**
  10986. * Where the animation should stop (animation frame)
  10987. */
  10988. to: number;
  10989. /**
  10990. * Define if the animation should loop or stop after the first play.
  10991. */
  10992. loop?: boolean;
  10993. private _target;
  10994. /**
  10995. * Instantiate the action
  10996. * @param triggerOptions defines the trigger options
  10997. * @param target defines the target animation or animation name
  10998. * @param from defines from where the animation should start (animation frame)
  10999. * @param end defines where the animation should stop (animation frame)
  11000. * @param loop defines if the animation should loop or stop after the first play
  11001. * @param condition defines the trigger related conditions
  11002. */
  11003. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11004. /** @hidden */
  11005. _prepare(): void;
  11006. /**
  11007. * Execute the action and play the animation.
  11008. */
  11009. execute(): void;
  11010. /**
  11011. * Serializes the actions and its related information.
  11012. * @param parent defines the object to serialize in
  11013. * @returns the serialized object
  11014. */
  11015. serialize(parent: any): any;
  11016. }
  11017. /**
  11018. * This defines an action responsible to stop an animation once triggered.
  11019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11020. */
  11021. export class StopAnimationAction extends Action {
  11022. private _target;
  11023. /**
  11024. * Instantiate the action
  11025. * @param triggerOptions defines the trigger options
  11026. * @param target defines the target animation or animation name
  11027. * @param condition defines the trigger related conditions
  11028. */
  11029. constructor(triggerOptions: any, target: any, condition?: Condition);
  11030. /** @hidden */
  11031. _prepare(): void;
  11032. /**
  11033. * Execute the action and stop the animation.
  11034. */
  11035. execute(): void;
  11036. /**
  11037. * Serializes the actions and its related information.
  11038. * @param parent defines the object to serialize in
  11039. * @returns the serialized object
  11040. */
  11041. serialize(parent: any): any;
  11042. }
  11043. /**
  11044. * This defines an action responsible that does nothing once triggered.
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11046. */
  11047. export class DoNothingAction extends Action {
  11048. /**
  11049. * Instantiate the action
  11050. * @param triggerOptions defines the trigger options
  11051. * @param condition defines the trigger related conditions
  11052. */
  11053. constructor(triggerOptions?: any, condition?: Condition);
  11054. /**
  11055. * Execute the action and do nothing.
  11056. */
  11057. execute(): void;
  11058. /**
  11059. * Serializes the actions and its related information.
  11060. * @param parent defines the object to serialize in
  11061. * @returns the serialized object
  11062. */
  11063. serialize(parent: any): any;
  11064. }
  11065. /**
  11066. * This defines an action responsible to trigger several actions once triggered.
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11068. */
  11069. export class CombineAction extends Action {
  11070. /**
  11071. * The list of aggregated animations to run.
  11072. */
  11073. children: Action[];
  11074. /**
  11075. * Instantiate the action
  11076. * @param triggerOptions defines the trigger options
  11077. * @param children defines the list of aggregated animations to run
  11078. * @param condition defines the trigger related conditions
  11079. */
  11080. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11081. /** @hidden */
  11082. _prepare(): void;
  11083. /**
  11084. * Execute the action and executes all the aggregated actions.
  11085. */
  11086. execute(evt: ActionEvent): void;
  11087. /**
  11088. * Serializes the actions and its related information.
  11089. * @param parent defines the object to serialize in
  11090. * @returns the serialized object
  11091. */
  11092. serialize(parent: any): any;
  11093. }
  11094. /**
  11095. * This defines an action responsible to run code (external event) once triggered.
  11096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11097. */
  11098. export class ExecuteCodeAction extends Action {
  11099. /**
  11100. * The callback function to run.
  11101. */
  11102. func: (evt: ActionEvent) => void;
  11103. /**
  11104. * Instantiate the action
  11105. * @param triggerOptions defines the trigger options
  11106. * @param func defines the callback function to run
  11107. * @param condition defines the trigger related conditions
  11108. */
  11109. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11110. /**
  11111. * Execute the action and run the attached code.
  11112. */
  11113. execute(evt: ActionEvent): void;
  11114. }
  11115. /**
  11116. * This defines an action responsible to set the parent property of the target once triggered.
  11117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11118. */
  11119. export class SetParentAction extends Action {
  11120. private _parent;
  11121. private _target;
  11122. /**
  11123. * Instantiate the action
  11124. * @param triggerOptions defines the trigger options
  11125. * @param target defines the target containing the parent property
  11126. * @param parent defines from where the animation should start (animation frame)
  11127. * @param condition defines the trigger related conditions
  11128. */
  11129. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11130. /** @hidden */
  11131. _prepare(): void;
  11132. /**
  11133. * Execute the action and set the parent property.
  11134. */
  11135. execute(): void;
  11136. /**
  11137. * Serializes the actions and its related information.
  11138. * @param parent defines the object to serialize in
  11139. * @returns the serialized object
  11140. */
  11141. serialize(parent: any): any;
  11142. }
  11143. }
  11144. declare module "babylonjs/Actions/actionManager" {
  11145. import { Nullable } from "babylonjs/types";
  11146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11147. import { Scene } from "babylonjs/scene";
  11148. import { IAction } from "babylonjs/Actions/action";
  11149. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11150. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11151. /**
  11152. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11153. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11155. */
  11156. export class ActionManager extends AbstractActionManager {
  11157. /**
  11158. * Nothing
  11159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11160. */
  11161. static readonly NothingTrigger: number;
  11162. /**
  11163. * On pick
  11164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11165. */
  11166. static readonly OnPickTrigger: number;
  11167. /**
  11168. * On left pick
  11169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11170. */
  11171. static readonly OnLeftPickTrigger: number;
  11172. /**
  11173. * On right pick
  11174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11175. */
  11176. static readonly OnRightPickTrigger: number;
  11177. /**
  11178. * On center pick
  11179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11180. */
  11181. static readonly OnCenterPickTrigger: number;
  11182. /**
  11183. * On pick down
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11185. */
  11186. static readonly OnPickDownTrigger: number;
  11187. /**
  11188. * On double pick
  11189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11190. */
  11191. static readonly OnDoublePickTrigger: number;
  11192. /**
  11193. * On pick up
  11194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11195. */
  11196. static readonly OnPickUpTrigger: number;
  11197. /**
  11198. * On pick out.
  11199. * This trigger will only be raised if you also declared a OnPickDown
  11200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11201. */
  11202. static readonly OnPickOutTrigger: number;
  11203. /**
  11204. * On long press
  11205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11206. */
  11207. static readonly OnLongPressTrigger: number;
  11208. /**
  11209. * On pointer over
  11210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11211. */
  11212. static readonly OnPointerOverTrigger: number;
  11213. /**
  11214. * On pointer out
  11215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11216. */
  11217. static readonly OnPointerOutTrigger: number;
  11218. /**
  11219. * On every frame
  11220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11221. */
  11222. static readonly OnEveryFrameTrigger: number;
  11223. /**
  11224. * On intersection enter
  11225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11226. */
  11227. static readonly OnIntersectionEnterTrigger: number;
  11228. /**
  11229. * On intersection exit
  11230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11231. */
  11232. static readonly OnIntersectionExitTrigger: number;
  11233. /**
  11234. * On key down
  11235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11236. */
  11237. static readonly OnKeyDownTrigger: number;
  11238. /**
  11239. * On key up
  11240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11241. */
  11242. static readonly OnKeyUpTrigger: number;
  11243. private _scene;
  11244. /**
  11245. * Creates a new action manager
  11246. * @param scene defines the hosting scene
  11247. */
  11248. constructor(scene: Scene);
  11249. /**
  11250. * Releases all associated resources
  11251. */
  11252. dispose(): void;
  11253. /**
  11254. * Gets hosting scene
  11255. * @returns the hosting scene
  11256. */
  11257. getScene(): Scene;
  11258. /**
  11259. * Does this action manager handles actions of any of the given triggers
  11260. * @param triggers defines the triggers to be tested
  11261. * @return a boolean indicating whether one (or more) of the triggers is handled
  11262. */
  11263. hasSpecificTriggers(triggers: number[]): boolean;
  11264. /**
  11265. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11266. * speed.
  11267. * @param triggerA defines the trigger to be tested
  11268. * @param triggerB defines the trigger to be tested
  11269. * @return a boolean indicating whether one (or more) of the triggers is handled
  11270. */
  11271. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11272. /**
  11273. * Does this action manager handles actions of a given trigger
  11274. * @param trigger defines the trigger to be tested
  11275. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11276. * @return whether the trigger is handled
  11277. */
  11278. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11279. /**
  11280. * Does this action manager has pointer triggers
  11281. */
  11282. get hasPointerTriggers(): boolean;
  11283. /**
  11284. * Does this action manager has pick triggers
  11285. */
  11286. get hasPickTriggers(): boolean;
  11287. /**
  11288. * Registers an action to this action manager
  11289. * @param action defines the action to be registered
  11290. * @return the action amended (prepared) after registration
  11291. */
  11292. registerAction(action: IAction): Nullable<IAction>;
  11293. /**
  11294. * Unregisters an action to this action manager
  11295. * @param action defines the action to be unregistered
  11296. * @return a boolean indicating whether the action has been unregistered
  11297. */
  11298. unregisterAction(action: IAction): Boolean;
  11299. /**
  11300. * Process a specific trigger
  11301. * @param trigger defines the trigger to process
  11302. * @param evt defines the event details to be processed
  11303. */
  11304. processTrigger(trigger: number, evt?: IActionEvent): void;
  11305. /** @hidden */
  11306. _getEffectiveTarget(target: any, propertyPath: string): any;
  11307. /** @hidden */
  11308. _getProperty(propertyPath: string): string;
  11309. /**
  11310. * Serialize this manager to a JSON object
  11311. * @param name defines the property name to store this manager
  11312. * @returns a JSON representation of this manager
  11313. */
  11314. serialize(name: string): any;
  11315. /**
  11316. * Creates a new ActionManager from a JSON data
  11317. * @param parsedActions defines the JSON data to read from
  11318. * @param object defines the hosting mesh
  11319. * @param scene defines the hosting scene
  11320. */
  11321. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11322. /**
  11323. * Get a trigger name by index
  11324. * @param trigger defines the trigger index
  11325. * @returns a trigger name
  11326. */
  11327. static GetTriggerName(trigger: number): string;
  11328. }
  11329. }
  11330. declare module "babylonjs/Culling/ray" {
  11331. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11332. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11334. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11335. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11336. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11337. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11338. import { Plane } from "babylonjs/Maths/math.plane";
  11339. /**
  11340. * Class representing a ray with position and direction
  11341. */
  11342. export class Ray {
  11343. /** origin point */
  11344. origin: Vector3;
  11345. /** direction */
  11346. direction: Vector3;
  11347. /** length of the ray */
  11348. length: number;
  11349. private static readonly TmpVector3;
  11350. private _tmpRay;
  11351. /**
  11352. * Creates a new ray
  11353. * @param origin origin point
  11354. * @param direction direction
  11355. * @param length length of the ray
  11356. */
  11357. constructor(
  11358. /** origin point */
  11359. origin: Vector3,
  11360. /** direction */
  11361. direction: Vector3,
  11362. /** length of the ray */
  11363. length?: number);
  11364. /**
  11365. * Checks if the ray intersects a box
  11366. * @param minimum bound of the box
  11367. * @param maximum bound of the box
  11368. * @param intersectionTreshold extra extend to be added to the box in all direction
  11369. * @returns if the box was hit
  11370. */
  11371. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11372. /**
  11373. * Checks if the ray intersects a box
  11374. * @param box the bounding box to check
  11375. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11376. * @returns if the box was hit
  11377. */
  11378. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11379. /**
  11380. * If the ray hits a sphere
  11381. * @param sphere the bounding sphere to check
  11382. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11383. * @returns true if it hits the sphere
  11384. */
  11385. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11386. /**
  11387. * If the ray hits a triange
  11388. * @param vertex0 triangle vertex
  11389. * @param vertex1 triangle vertex
  11390. * @param vertex2 triangle vertex
  11391. * @returns intersection information if hit
  11392. */
  11393. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11394. /**
  11395. * Checks if ray intersects a plane
  11396. * @param plane the plane to check
  11397. * @returns the distance away it was hit
  11398. */
  11399. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11400. /**
  11401. * Calculate the intercept of a ray on a given axis
  11402. * @param axis to check 'x' | 'y' | 'z'
  11403. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11404. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11405. */
  11406. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11407. /**
  11408. * Checks if ray intersects a mesh
  11409. * @param mesh the mesh to check
  11410. * @param fastCheck if only the bounding box should checked
  11411. * @returns picking info of the intersecton
  11412. */
  11413. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11414. /**
  11415. * Checks if ray intersects a mesh
  11416. * @param meshes the meshes to check
  11417. * @param fastCheck if only the bounding box should checked
  11418. * @param results array to store result in
  11419. * @returns Array of picking infos
  11420. */
  11421. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11422. private _comparePickingInfo;
  11423. private static smallnum;
  11424. private static rayl;
  11425. /**
  11426. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11427. * @param sega the first point of the segment to test the intersection against
  11428. * @param segb the second point of the segment to test the intersection against
  11429. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11430. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11431. */
  11432. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11433. /**
  11434. * Update the ray from viewport position
  11435. * @param x position
  11436. * @param y y position
  11437. * @param viewportWidth viewport width
  11438. * @param viewportHeight viewport height
  11439. * @param world world matrix
  11440. * @param view view matrix
  11441. * @param projection projection matrix
  11442. * @returns this ray updated
  11443. */
  11444. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11445. /**
  11446. * Creates a ray with origin and direction of 0,0,0
  11447. * @returns the new ray
  11448. */
  11449. static Zero(): Ray;
  11450. /**
  11451. * Creates a new ray from screen space and viewport
  11452. * @param x position
  11453. * @param y y position
  11454. * @param viewportWidth viewport width
  11455. * @param viewportHeight viewport height
  11456. * @param world world matrix
  11457. * @param view view matrix
  11458. * @param projection projection matrix
  11459. * @returns new ray
  11460. */
  11461. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11462. /**
  11463. * 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
  11464. * transformed to the given world matrix.
  11465. * @param origin The origin point
  11466. * @param end The end point
  11467. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11468. * @returns the new ray
  11469. */
  11470. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11471. /**
  11472. * Transforms a ray by a matrix
  11473. * @param ray ray to transform
  11474. * @param matrix matrix to apply
  11475. * @returns the resulting new ray
  11476. */
  11477. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11478. /**
  11479. * Transforms a ray by a matrix
  11480. * @param ray ray to transform
  11481. * @param matrix matrix to apply
  11482. * @param result ray to store result in
  11483. */
  11484. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11485. /**
  11486. * Unproject a ray from screen space to object space
  11487. * @param sourceX defines the screen space x coordinate to use
  11488. * @param sourceY defines the screen space y coordinate to use
  11489. * @param viewportWidth defines the current width of the viewport
  11490. * @param viewportHeight defines the current height of the viewport
  11491. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11492. * @param view defines the view matrix to use
  11493. * @param projection defines the projection matrix to use
  11494. */
  11495. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11496. }
  11497. /**
  11498. * Type used to define predicate used to select faces when a mesh intersection is detected
  11499. */
  11500. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11501. module "babylonjs/scene" {
  11502. interface Scene {
  11503. /** @hidden */
  11504. _tempPickingRay: Nullable<Ray>;
  11505. /** @hidden */
  11506. _cachedRayForTransform: Ray;
  11507. /** @hidden */
  11508. _pickWithRayInverseMatrix: Matrix;
  11509. /** @hidden */
  11510. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11511. /** @hidden */
  11512. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11513. }
  11514. }
  11515. }
  11516. declare module "babylonjs/sceneComponent" {
  11517. import { Scene } from "babylonjs/scene";
  11518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11519. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11520. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11521. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11522. import { Nullable } from "babylonjs/types";
  11523. import { Camera } from "babylonjs/Cameras/camera";
  11524. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11525. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11526. import { AbstractScene } from "babylonjs/abstractScene";
  11527. import { Mesh } from "babylonjs/Meshes/mesh";
  11528. /**
  11529. * Groups all the scene component constants in one place to ease maintenance.
  11530. * @hidden
  11531. */
  11532. export class SceneComponentConstants {
  11533. static readonly NAME_EFFECTLAYER: string;
  11534. static readonly NAME_LAYER: string;
  11535. static readonly NAME_LENSFLARESYSTEM: string;
  11536. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11537. static readonly NAME_PARTICLESYSTEM: string;
  11538. static readonly NAME_GAMEPAD: string;
  11539. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11540. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11541. static readonly NAME_DEPTHRENDERER: string;
  11542. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11543. static readonly NAME_SPRITE: string;
  11544. static readonly NAME_OUTLINERENDERER: string;
  11545. static readonly NAME_PROCEDURALTEXTURE: string;
  11546. static readonly NAME_SHADOWGENERATOR: string;
  11547. static readonly NAME_OCTREE: string;
  11548. static readonly NAME_PHYSICSENGINE: string;
  11549. static readonly NAME_AUDIO: string;
  11550. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11551. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11552. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11553. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11554. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11555. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11556. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11557. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11558. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11559. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11560. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11561. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11562. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11563. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11564. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11565. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11566. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11567. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11568. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11569. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11570. static readonly STEP_AFTERRENDER_AUDIO: number;
  11571. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11572. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11573. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11574. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11575. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11576. static readonly STEP_POINTERMOVE_SPRITE: number;
  11577. static readonly STEP_POINTERDOWN_SPRITE: number;
  11578. static readonly STEP_POINTERUP_SPRITE: number;
  11579. }
  11580. /**
  11581. * This represents a scene component.
  11582. *
  11583. * This is used to decouple the dependency the scene is having on the different workloads like
  11584. * layers, post processes...
  11585. */
  11586. export interface ISceneComponent {
  11587. /**
  11588. * The name of the component. Each component must have a unique name.
  11589. */
  11590. name: string;
  11591. /**
  11592. * The scene the component belongs to.
  11593. */
  11594. scene: Scene;
  11595. /**
  11596. * Register the component to one instance of a scene.
  11597. */
  11598. register(): void;
  11599. /**
  11600. * Rebuilds the elements related to this component in case of
  11601. * context lost for instance.
  11602. */
  11603. rebuild(): void;
  11604. /**
  11605. * Disposes the component and the associated ressources.
  11606. */
  11607. dispose(): void;
  11608. }
  11609. /**
  11610. * This represents a SERIALIZABLE scene component.
  11611. *
  11612. * This extends Scene Component to add Serialization methods on top.
  11613. */
  11614. export interface ISceneSerializableComponent extends ISceneComponent {
  11615. /**
  11616. * Adds all the elements from the container to the scene
  11617. * @param container the container holding the elements
  11618. */
  11619. addFromContainer(container: AbstractScene): void;
  11620. /**
  11621. * Removes all the elements in the container from the scene
  11622. * @param container contains the elements to remove
  11623. * @param dispose if the removed element should be disposed (default: false)
  11624. */
  11625. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11626. /**
  11627. * Serializes the component data to the specified json object
  11628. * @param serializationObject The object to serialize to
  11629. */
  11630. serialize(serializationObject: any): void;
  11631. }
  11632. /**
  11633. * Strong typing of a Mesh related stage step action
  11634. */
  11635. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11636. /**
  11637. * Strong typing of a Evaluate Sub Mesh related stage step action
  11638. */
  11639. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11640. /**
  11641. * Strong typing of a Active Mesh related stage step action
  11642. */
  11643. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11644. /**
  11645. * Strong typing of a Camera related stage step action
  11646. */
  11647. export type CameraStageAction = (camera: Camera) => void;
  11648. /**
  11649. * Strong typing of a Camera Frame buffer related stage step action
  11650. */
  11651. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11652. /**
  11653. * Strong typing of a Render Target related stage step action
  11654. */
  11655. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11656. /**
  11657. * Strong typing of a RenderingGroup related stage step action
  11658. */
  11659. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11660. /**
  11661. * Strong typing of a Mesh Render related stage step action
  11662. */
  11663. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11664. /**
  11665. * Strong typing of a simple stage step action
  11666. */
  11667. export type SimpleStageAction = () => void;
  11668. /**
  11669. * Strong typing of a render target action.
  11670. */
  11671. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11672. /**
  11673. * Strong typing of a pointer move action.
  11674. */
  11675. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11676. /**
  11677. * Strong typing of a pointer up/down action.
  11678. */
  11679. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11680. /**
  11681. * Representation of a stage in the scene (Basically a list of ordered steps)
  11682. * @hidden
  11683. */
  11684. export class Stage<T extends Function> extends Array<{
  11685. index: number;
  11686. component: ISceneComponent;
  11687. action: T;
  11688. }> {
  11689. /**
  11690. * Hide ctor from the rest of the world.
  11691. * @param items The items to add.
  11692. */
  11693. private constructor();
  11694. /**
  11695. * Creates a new Stage.
  11696. * @returns A new instance of a Stage
  11697. */
  11698. static Create<T extends Function>(): Stage<T>;
  11699. /**
  11700. * Registers a step in an ordered way in the targeted stage.
  11701. * @param index Defines the position to register the step in
  11702. * @param component Defines the component attached to the step
  11703. * @param action Defines the action to launch during the step
  11704. */
  11705. registerStep(index: number, component: ISceneComponent, action: T): void;
  11706. /**
  11707. * Clears all the steps from the stage.
  11708. */
  11709. clear(): void;
  11710. }
  11711. }
  11712. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11713. import { Nullable } from "babylonjs/types";
  11714. import { Observable } from "babylonjs/Misc/observable";
  11715. import { Scene } from "babylonjs/scene";
  11716. import { Sprite } from "babylonjs/Sprites/sprite";
  11717. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11718. import { Ray } from "babylonjs/Culling/ray";
  11719. import { Camera } from "babylonjs/Cameras/camera";
  11720. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11721. import { ISceneComponent } from "babylonjs/sceneComponent";
  11722. module "babylonjs/scene" {
  11723. interface Scene {
  11724. /** @hidden */
  11725. _pointerOverSprite: Nullable<Sprite>;
  11726. /** @hidden */
  11727. _pickedDownSprite: Nullable<Sprite>;
  11728. /** @hidden */
  11729. _tempSpritePickingRay: Nullable<Ray>;
  11730. /**
  11731. * All of the sprite managers added to this scene
  11732. * @see http://doc.babylonjs.com/babylon101/sprites
  11733. */
  11734. spriteManagers: Array<ISpriteManager>;
  11735. /**
  11736. * An event triggered when sprites rendering is about to start
  11737. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11738. */
  11739. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11740. /**
  11741. * An event triggered when sprites rendering is done
  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. onAfterSpritesRenderingObservable: Observable<Scene>;
  11745. /** @hidden */
  11746. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11747. /** Launch a ray to try to pick a sprite in the scene
  11748. * @param x position on screen
  11749. * @param y position on screen
  11750. * @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
  11751. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11752. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11753. * @returns a PickingInfo
  11754. */
  11755. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11756. /** Use the given ray to pick a sprite in the scene
  11757. * @param ray The ray (in world space) to use to pick meshes
  11758. * @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
  11759. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11760. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11761. * @returns a PickingInfo
  11762. */
  11763. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11764. /** @hidden */
  11765. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11766. /** Launch a ray to try to pick sprites in the scene
  11767. * @param x position on screen
  11768. * @param y position on screen
  11769. * @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
  11770. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11771. * @returns a PickingInfo array
  11772. */
  11773. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11774. /** Use the given ray to pick sprites in the scene
  11775. * @param ray The ray (in world space) to use to pick meshes
  11776. * @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
  11777. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11778. * @returns a PickingInfo array
  11779. */
  11780. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11781. /**
  11782. * Force the sprite under the pointer
  11783. * @param sprite defines the sprite to use
  11784. */
  11785. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11786. /**
  11787. * Gets the sprite under the pointer
  11788. * @returns a Sprite or null if no sprite is under the pointer
  11789. */
  11790. getPointerOverSprite(): Nullable<Sprite>;
  11791. }
  11792. }
  11793. /**
  11794. * Defines the sprite scene component responsible to manage sprites
  11795. * in a given scene.
  11796. */
  11797. export class SpriteSceneComponent implements ISceneComponent {
  11798. /**
  11799. * The component name helpfull to identify the component in the list of scene components.
  11800. */
  11801. readonly name: string;
  11802. /**
  11803. * The scene the component belongs to.
  11804. */
  11805. scene: Scene;
  11806. /** @hidden */
  11807. private _spritePredicate;
  11808. /**
  11809. * Creates a new instance of the component for the given scene
  11810. * @param scene Defines the scene to register the component in
  11811. */
  11812. constructor(scene: Scene);
  11813. /**
  11814. * Registers the component in a given scene
  11815. */
  11816. register(): void;
  11817. /**
  11818. * Rebuilds the elements related to this component in case of
  11819. * context lost for instance.
  11820. */
  11821. rebuild(): void;
  11822. /**
  11823. * Disposes the component and the associated ressources.
  11824. */
  11825. dispose(): void;
  11826. private _pickSpriteButKeepRay;
  11827. private _pointerMove;
  11828. private _pointerDown;
  11829. private _pointerUp;
  11830. }
  11831. }
  11832. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11833. /** @hidden */
  11834. export var fogFragmentDeclaration: {
  11835. name: string;
  11836. shader: string;
  11837. };
  11838. }
  11839. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11840. /** @hidden */
  11841. export var fogFragment: {
  11842. name: string;
  11843. shader: string;
  11844. };
  11845. }
  11846. declare module "babylonjs/Shaders/sprites.fragment" {
  11847. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11848. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11849. /** @hidden */
  11850. export var spritesPixelShader: {
  11851. name: string;
  11852. shader: string;
  11853. };
  11854. }
  11855. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11856. /** @hidden */
  11857. export var fogVertexDeclaration: {
  11858. name: string;
  11859. shader: string;
  11860. };
  11861. }
  11862. declare module "babylonjs/Shaders/sprites.vertex" {
  11863. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11864. /** @hidden */
  11865. export var spritesVertexShader: {
  11866. name: string;
  11867. shader: string;
  11868. };
  11869. }
  11870. declare module "babylonjs/Sprites/spriteManager" {
  11871. import { IDisposable, Scene } from "babylonjs/scene";
  11872. import { Nullable } from "babylonjs/types";
  11873. import { Observable } from "babylonjs/Misc/observable";
  11874. import { Sprite } from "babylonjs/Sprites/sprite";
  11875. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11876. import { Camera } from "babylonjs/Cameras/camera";
  11877. import { Texture } from "babylonjs/Materials/Textures/texture";
  11878. import "babylonjs/Shaders/sprites.fragment";
  11879. import "babylonjs/Shaders/sprites.vertex";
  11880. import { Ray } from "babylonjs/Culling/ray";
  11881. /**
  11882. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11883. */
  11884. export interface ISpriteManager extends IDisposable {
  11885. /**
  11886. * Restricts the camera to viewing objects with the same layerMask.
  11887. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11888. */
  11889. layerMask: number;
  11890. /**
  11891. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11892. */
  11893. isPickable: boolean;
  11894. /**
  11895. * Specifies the rendering group id for this mesh (0 by default)
  11896. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11897. */
  11898. renderingGroupId: number;
  11899. /**
  11900. * Defines the list of sprites managed by the manager.
  11901. */
  11902. sprites: Array<Sprite>;
  11903. /**
  11904. * Tests the intersection of a sprite with a specific ray.
  11905. * @param ray The ray we are sending to test the collision
  11906. * @param camera The camera space we are sending rays in
  11907. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11908. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11909. * @returns picking info or null.
  11910. */
  11911. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11912. /**
  11913. * Intersects the sprites with a ray
  11914. * @param ray defines the ray to intersect with
  11915. * @param camera defines the current active camera
  11916. * @param predicate defines a predicate used to select candidate sprites
  11917. * @returns null if no hit or a PickingInfo array
  11918. */
  11919. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11920. /**
  11921. * Renders the list of sprites on screen.
  11922. */
  11923. render(): void;
  11924. }
  11925. /**
  11926. * Class used to manage multiple sprites on the same spritesheet
  11927. * @see http://doc.babylonjs.com/babylon101/sprites
  11928. */
  11929. export class SpriteManager implements ISpriteManager {
  11930. /** defines the manager's name */
  11931. name: string;
  11932. /** Gets the list of sprites */
  11933. sprites: Sprite[];
  11934. /** Gets or sets the rendering group id (0 by default) */
  11935. renderingGroupId: number;
  11936. /** Gets or sets camera layer mask */
  11937. layerMask: number;
  11938. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11939. fogEnabled: boolean;
  11940. /** Gets or sets a boolean indicating if the sprites are pickable */
  11941. isPickable: boolean;
  11942. /** Defines the default width of a cell in the spritesheet */
  11943. cellWidth: number;
  11944. /** Defines the default height of a cell in the spritesheet */
  11945. cellHeight: number;
  11946. /** Associative array from JSON sprite data file */
  11947. private _cellData;
  11948. /** Array of sprite names from JSON sprite data file */
  11949. private _spriteMap;
  11950. /** True when packed cell data from JSON file is ready*/
  11951. private _packedAndReady;
  11952. /**
  11953. * An event triggered when the manager is disposed.
  11954. */
  11955. onDisposeObservable: Observable<SpriteManager>;
  11956. private _onDisposeObserver;
  11957. /**
  11958. * Callback called when the manager is disposed
  11959. */
  11960. set onDispose(callback: () => void);
  11961. private _capacity;
  11962. private _fromPacked;
  11963. private _spriteTexture;
  11964. private _epsilon;
  11965. private _scene;
  11966. private _vertexData;
  11967. private _buffer;
  11968. private _vertexBuffers;
  11969. private _indexBuffer;
  11970. private _effectBase;
  11971. private _effectFog;
  11972. /**
  11973. * Gets or sets the spritesheet texture
  11974. */
  11975. get texture(): Texture;
  11976. set texture(value: Texture);
  11977. /**
  11978. * Creates a new sprite manager
  11979. * @param name defines the manager's name
  11980. * @param imgUrl defines the sprite sheet url
  11981. * @param capacity defines the maximum allowed number of sprites
  11982. * @param cellSize defines the size of a sprite cell
  11983. * @param scene defines the hosting scene
  11984. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11985. * @param samplingMode defines the smapling mode to use with spritesheet
  11986. * @param fromPacked set to false; do not alter
  11987. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11988. */
  11989. constructor(
  11990. /** defines the manager's name */
  11991. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11992. private _makePacked;
  11993. private _appendSpriteVertex;
  11994. /**
  11995. * Intersects the sprites with a ray
  11996. * @param ray defines the ray to intersect with
  11997. * @param camera defines the current active camera
  11998. * @param predicate defines a predicate used to select candidate sprites
  11999. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12000. * @returns null if no hit or a PickingInfo
  12001. */
  12002. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12003. /**
  12004. * Intersects the sprites with a ray
  12005. * @param ray defines the ray to intersect with
  12006. * @param camera defines the current active camera
  12007. * @param predicate defines a predicate used to select candidate sprites
  12008. * @returns null if no hit or a PickingInfo array
  12009. */
  12010. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  12011. /**
  12012. * Render all child sprites
  12013. */
  12014. render(): void;
  12015. /**
  12016. * Release associated resources
  12017. */
  12018. dispose(): void;
  12019. }
  12020. }
  12021. declare module "babylonjs/Sprites/sprite" {
  12022. import { Vector3 } from "babylonjs/Maths/math.vector";
  12023. import { Nullable } from "babylonjs/types";
  12024. import { ActionManager } from "babylonjs/Actions/actionManager";
  12025. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12026. import { Color4 } from "babylonjs/Maths/math.color";
  12027. /**
  12028. * Class used to represent a sprite
  12029. * @see http://doc.babylonjs.com/babylon101/sprites
  12030. */
  12031. export class Sprite {
  12032. /** defines the name */
  12033. name: string;
  12034. /** Gets or sets the current world position */
  12035. position: Vector3;
  12036. /** Gets or sets the main color */
  12037. color: Color4;
  12038. /** Gets or sets the width */
  12039. width: number;
  12040. /** Gets or sets the height */
  12041. height: number;
  12042. /** Gets or sets rotation angle */
  12043. angle: number;
  12044. /** Gets or sets the cell index in the sprite sheet */
  12045. cellIndex: number;
  12046. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12047. cellRef: string;
  12048. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12049. invertU: number;
  12050. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12051. invertV: number;
  12052. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12053. disposeWhenFinishedAnimating: boolean;
  12054. /** Gets the list of attached animations */
  12055. animations: Animation[];
  12056. /** Gets or sets a boolean indicating if the sprite can be picked */
  12057. isPickable: boolean;
  12058. /**
  12059. * Gets or sets the associated action manager
  12060. */
  12061. actionManager: Nullable<ActionManager>;
  12062. private _animationStarted;
  12063. private _loopAnimation;
  12064. private _fromIndex;
  12065. private _toIndex;
  12066. private _delay;
  12067. private _direction;
  12068. private _manager;
  12069. private _time;
  12070. private _onAnimationEnd;
  12071. /**
  12072. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12073. */
  12074. isVisible: boolean;
  12075. /**
  12076. * Gets or sets the sprite size
  12077. */
  12078. get size(): number;
  12079. set size(value: number);
  12080. /**
  12081. * Creates a new Sprite
  12082. * @param name defines the name
  12083. * @param manager defines the manager
  12084. */
  12085. constructor(
  12086. /** defines the name */
  12087. name: string, manager: ISpriteManager);
  12088. /**
  12089. * Starts an animation
  12090. * @param from defines the initial key
  12091. * @param to defines the end key
  12092. * @param loop defines if the animation must loop
  12093. * @param delay defines the start delay (in ms)
  12094. * @param onAnimationEnd defines a callback to call when animation ends
  12095. */
  12096. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12097. /** Stops current animation (if any) */
  12098. stopAnimation(): void;
  12099. /** @hidden */
  12100. _animate(deltaTime: number): void;
  12101. /** Release associated resources */
  12102. dispose(): void;
  12103. }
  12104. }
  12105. declare module "babylonjs/Collisions/pickingInfo" {
  12106. import { Nullable } from "babylonjs/types";
  12107. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12109. import { Sprite } from "babylonjs/Sprites/sprite";
  12110. import { Ray } from "babylonjs/Culling/ray";
  12111. /**
  12112. * Information about the result of picking within a scene
  12113. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12114. */
  12115. export class PickingInfo {
  12116. /** @hidden */
  12117. _pickingUnavailable: boolean;
  12118. /**
  12119. * If the pick collided with an object
  12120. */
  12121. hit: boolean;
  12122. /**
  12123. * Distance away where the pick collided
  12124. */
  12125. distance: number;
  12126. /**
  12127. * The location of pick collision
  12128. */
  12129. pickedPoint: Nullable<Vector3>;
  12130. /**
  12131. * The mesh corresponding the the pick collision
  12132. */
  12133. pickedMesh: Nullable<AbstractMesh>;
  12134. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12135. bu: number;
  12136. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12137. bv: number;
  12138. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12139. faceId: number;
  12140. /** Id of the the submesh that was picked */
  12141. subMeshId: number;
  12142. /** If a sprite was picked, this will be the sprite the pick collided with */
  12143. pickedSprite: Nullable<Sprite>;
  12144. /**
  12145. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12146. */
  12147. originMesh: Nullable<AbstractMesh>;
  12148. /**
  12149. * The ray that was used to perform the picking.
  12150. */
  12151. ray: Nullable<Ray>;
  12152. /**
  12153. * Gets the normal correspodning to the face the pick collided with
  12154. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12155. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12156. * @returns The normal correspodning to the face the pick collided with
  12157. */
  12158. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12159. /**
  12160. * Gets the texture coordinates of where the pick occured
  12161. * @returns the vector containing the coordnates of the texture
  12162. */
  12163. getTextureCoordinates(): Nullable<Vector2>;
  12164. }
  12165. }
  12166. declare module "babylonjs/Events/pointerEvents" {
  12167. import { Nullable } from "babylonjs/types";
  12168. import { Vector2 } from "babylonjs/Maths/math.vector";
  12169. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12170. import { Ray } from "babylonjs/Culling/ray";
  12171. /**
  12172. * Gather the list of pointer event types as constants.
  12173. */
  12174. export class PointerEventTypes {
  12175. /**
  12176. * 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.
  12177. */
  12178. static readonly POINTERDOWN: number;
  12179. /**
  12180. * The pointerup event is fired when a pointer is no longer active.
  12181. */
  12182. static readonly POINTERUP: number;
  12183. /**
  12184. * The pointermove event is fired when a pointer changes coordinates.
  12185. */
  12186. static readonly POINTERMOVE: number;
  12187. /**
  12188. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12189. */
  12190. static readonly POINTERWHEEL: number;
  12191. /**
  12192. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12193. */
  12194. static readonly POINTERPICK: number;
  12195. /**
  12196. * The pointertap event is fired when a the object has been touched and released without drag.
  12197. */
  12198. static readonly POINTERTAP: number;
  12199. /**
  12200. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12201. */
  12202. static readonly POINTERDOUBLETAP: number;
  12203. }
  12204. /**
  12205. * Base class of pointer info types.
  12206. */
  12207. export class PointerInfoBase {
  12208. /**
  12209. * Defines the type of event (PointerEventTypes)
  12210. */
  12211. type: number;
  12212. /**
  12213. * Defines the related dom event
  12214. */
  12215. event: PointerEvent | MouseWheelEvent;
  12216. /**
  12217. * Instantiates the base class of pointers info.
  12218. * @param type Defines the type of event (PointerEventTypes)
  12219. * @param event Defines the related dom event
  12220. */
  12221. constructor(
  12222. /**
  12223. * Defines the type of event (PointerEventTypes)
  12224. */
  12225. type: number,
  12226. /**
  12227. * Defines the related dom event
  12228. */
  12229. event: PointerEvent | MouseWheelEvent);
  12230. }
  12231. /**
  12232. * This class is used to store pointer related info for the onPrePointerObservable event.
  12233. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12234. */
  12235. export class PointerInfoPre extends PointerInfoBase {
  12236. /**
  12237. * Ray from a pointer if availible (eg. 6dof controller)
  12238. */
  12239. ray: Nullable<Ray>;
  12240. /**
  12241. * Defines the local position of the pointer on the canvas.
  12242. */
  12243. localPosition: Vector2;
  12244. /**
  12245. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12246. */
  12247. skipOnPointerObservable: boolean;
  12248. /**
  12249. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12250. * @param type Defines the type of event (PointerEventTypes)
  12251. * @param event Defines the related dom event
  12252. * @param localX Defines the local x coordinates of the pointer when the event occured
  12253. * @param localY Defines the local y coordinates of the pointer when the event occured
  12254. */
  12255. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12256. }
  12257. /**
  12258. * This type contains all the data related to a pointer event in Babylon.js.
  12259. * 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.
  12260. */
  12261. export class PointerInfo extends PointerInfoBase {
  12262. /**
  12263. * Defines the picking info associated to the info (if any)\
  12264. */
  12265. pickInfo: Nullable<PickingInfo>;
  12266. /**
  12267. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12268. * @param type Defines the type of event (PointerEventTypes)
  12269. * @param event Defines the related dom event
  12270. * @param pickInfo Defines the picking info associated to the info (if any)\
  12271. */
  12272. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12273. /**
  12274. * Defines the picking info associated to the info (if any)\
  12275. */
  12276. pickInfo: Nullable<PickingInfo>);
  12277. }
  12278. /**
  12279. * Data relating to a touch event on the screen.
  12280. */
  12281. export interface PointerTouch {
  12282. /**
  12283. * X coordinate of touch.
  12284. */
  12285. x: number;
  12286. /**
  12287. * Y coordinate of touch.
  12288. */
  12289. y: number;
  12290. /**
  12291. * Id of touch. Unique for each finger.
  12292. */
  12293. pointerId: number;
  12294. /**
  12295. * Event type passed from DOM.
  12296. */
  12297. type: any;
  12298. }
  12299. }
  12300. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12301. import { Observable } from "babylonjs/Misc/observable";
  12302. import { Nullable } from "babylonjs/types";
  12303. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12304. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12305. /**
  12306. * Manage the mouse inputs to control the movement of a free camera.
  12307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12308. */
  12309. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12310. /**
  12311. * Define if touch is enabled in the mouse input
  12312. */
  12313. touchEnabled: boolean;
  12314. /**
  12315. * Defines the camera the input is attached to.
  12316. */
  12317. camera: FreeCamera;
  12318. /**
  12319. * Defines the buttons associated with the input to handle camera move.
  12320. */
  12321. buttons: number[];
  12322. /**
  12323. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12324. */
  12325. angularSensibility: number;
  12326. private _pointerInput;
  12327. private _onMouseMove;
  12328. private _observer;
  12329. private previousPosition;
  12330. /**
  12331. * Observable for when a pointer move event occurs containing the move offset
  12332. */
  12333. onPointerMovedObservable: Observable<{
  12334. offsetX: number;
  12335. offsetY: number;
  12336. }>;
  12337. /**
  12338. * @hidden
  12339. * If the camera should be rotated automatically based on pointer movement
  12340. */
  12341. _allowCameraRotation: boolean;
  12342. /**
  12343. * Manage the mouse inputs to control the movement of a free camera.
  12344. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12345. * @param touchEnabled Defines if touch is enabled or not
  12346. */
  12347. constructor(
  12348. /**
  12349. * Define if touch is enabled in the mouse input
  12350. */
  12351. touchEnabled?: boolean);
  12352. /**
  12353. * Attach the input controls to a specific dom element to get the input from.
  12354. * @param element Defines the element the controls should be listened from
  12355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12356. */
  12357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12358. /**
  12359. * Called on JS contextmenu event.
  12360. * Override this method to provide functionality.
  12361. */
  12362. protected onContextMenu(evt: PointerEvent): void;
  12363. /**
  12364. * Detach the current controls from the specified dom element.
  12365. * @param element Defines the element to stop listening the inputs from
  12366. */
  12367. detachControl(element: Nullable<HTMLElement>): void;
  12368. /**
  12369. * Gets the class name of the current intput.
  12370. * @returns the class name
  12371. */
  12372. getClassName(): string;
  12373. /**
  12374. * Get the friendly name associated with the input class.
  12375. * @returns the input friendly name
  12376. */
  12377. getSimpleName(): string;
  12378. }
  12379. }
  12380. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12381. import { Nullable } from "babylonjs/types";
  12382. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12383. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12384. /**
  12385. * Manage the touch inputs to control the movement of a free camera.
  12386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12387. */
  12388. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12389. /**
  12390. * Defines the camera the input is attached to.
  12391. */
  12392. camera: FreeCamera;
  12393. /**
  12394. * Defines the touch sensibility for rotation.
  12395. * The higher the faster.
  12396. */
  12397. touchAngularSensibility: number;
  12398. /**
  12399. * Defines the touch sensibility for move.
  12400. * The higher the faster.
  12401. */
  12402. touchMoveSensibility: number;
  12403. private _offsetX;
  12404. private _offsetY;
  12405. private _pointerPressed;
  12406. private _pointerInput;
  12407. private _observer;
  12408. private _onLostFocus;
  12409. /**
  12410. * Attach the input controls to a specific dom element to get the input from.
  12411. * @param element Defines the element the controls should be listened from
  12412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12413. */
  12414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12415. /**
  12416. * Detach the current controls from the specified dom element.
  12417. * @param element Defines the element to stop listening the inputs from
  12418. */
  12419. detachControl(element: Nullable<HTMLElement>): void;
  12420. /**
  12421. * Update the current camera state depending on the inputs that have been used this frame.
  12422. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12423. */
  12424. checkInputs(): void;
  12425. /**
  12426. * Gets the class name of the current intput.
  12427. * @returns the class name
  12428. */
  12429. getClassName(): string;
  12430. /**
  12431. * Get the friendly name associated with the input class.
  12432. * @returns the input friendly name
  12433. */
  12434. getSimpleName(): string;
  12435. }
  12436. }
  12437. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12438. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12439. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12440. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12441. import { Nullable } from "babylonjs/types";
  12442. /**
  12443. * Default Inputs manager for the FreeCamera.
  12444. * It groups all the default supported inputs for ease of use.
  12445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12446. */
  12447. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12448. /**
  12449. * @hidden
  12450. */
  12451. _mouseInput: Nullable<FreeCameraMouseInput>;
  12452. /**
  12453. * Instantiates a new FreeCameraInputsManager.
  12454. * @param camera Defines the camera the inputs belong to
  12455. */
  12456. constructor(camera: FreeCamera);
  12457. /**
  12458. * Add keyboard input support to the input manager.
  12459. * @returns the current input manager
  12460. */
  12461. addKeyboard(): FreeCameraInputsManager;
  12462. /**
  12463. * Add mouse input support to the input manager.
  12464. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12465. * @returns the current input manager
  12466. */
  12467. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12468. /**
  12469. * Removes the mouse input support from the manager
  12470. * @returns the current input manager
  12471. */
  12472. removeMouse(): FreeCameraInputsManager;
  12473. /**
  12474. * Add touch input support to the input manager.
  12475. * @returns the current input manager
  12476. */
  12477. addTouch(): FreeCameraInputsManager;
  12478. /**
  12479. * Remove all attached input methods from a camera
  12480. */
  12481. clear(): void;
  12482. }
  12483. }
  12484. declare module "babylonjs/Cameras/freeCamera" {
  12485. import { Vector3 } from "babylonjs/Maths/math.vector";
  12486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12487. import { Scene } from "babylonjs/scene";
  12488. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12489. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12490. /**
  12491. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12492. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12493. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12494. */
  12495. export class FreeCamera extends TargetCamera {
  12496. /**
  12497. * Define the collision ellipsoid of the camera.
  12498. * This is helpful to simulate a camera body like the player body around the camera
  12499. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12500. */
  12501. ellipsoid: Vector3;
  12502. /**
  12503. * Define an offset for the position of the ellipsoid around the camera.
  12504. * This can be helpful to determine the center of the body near the gravity center of the body
  12505. * instead of its head.
  12506. */
  12507. ellipsoidOffset: Vector3;
  12508. /**
  12509. * Enable or disable collisions of the camera with the rest of the scene objects.
  12510. */
  12511. checkCollisions: boolean;
  12512. /**
  12513. * Enable or disable gravity on the camera.
  12514. */
  12515. applyGravity: boolean;
  12516. /**
  12517. * Define the input manager associated to the camera.
  12518. */
  12519. inputs: FreeCameraInputsManager;
  12520. /**
  12521. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12522. * Higher values reduce sensitivity.
  12523. */
  12524. get angularSensibility(): number;
  12525. /**
  12526. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12527. * Higher values reduce sensitivity.
  12528. */
  12529. set angularSensibility(value: number);
  12530. /**
  12531. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12532. */
  12533. get keysUp(): number[];
  12534. set keysUp(value: number[]);
  12535. /**
  12536. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12537. */
  12538. get keysDown(): number[];
  12539. set keysDown(value: number[]);
  12540. /**
  12541. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12542. */
  12543. get keysLeft(): number[];
  12544. set keysLeft(value: number[]);
  12545. /**
  12546. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12547. */
  12548. get keysRight(): number[];
  12549. set keysRight(value: number[]);
  12550. /**
  12551. * Event raised when the camera collide with a mesh in the scene.
  12552. */
  12553. onCollide: (collidedMesh: AbstractMesh) => void;
  12554. private _collider;
  12555. private _needMoveForGravity;
  12556. private _oldPosition;
  12557. private _diffPosition;
  12558. private _newPosition;
  12559. /** @hidden */
  12560. _localDirection: Vector3;
  12561. /** @hidden */
  12562. _transformedDirection: Vector3;
  12563. /**
  12564. * Instantiates a Free Camera.
  12565. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12566. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12567. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12568. * @param name Define the name of the camera in the scene
  12569. * @param position Define the start position of the camera in the scene
  12570. * @param scene Define the scene the camera belongs to
  12571. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12572. */
  12573. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12574. /**
  12575. * Attached controls to the current camera.
  12576. * @param element Defines the element the controls should be listened from
  12577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12578. */
  12579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12580. /**
  12581. * Detach the current controls from the camera.
  12582. * The camera will stop reacting to inputs.
  12583. * @param element Defines the element to stop listening the inputs from
  12584. */
  12585. detachControl(element: HTMLElement): void;
  12586. private _collisionMask;
  12587. /**
  12588. * Define a collision mask to limit the list of object the camera can collide with
  12589. */
  12590. get collisionMask(): number;
  12591. set collisionMask(mask: number);
  12592. /** @hidden */
  12593. _collideWithWorld(displacement: Vector3): void;
  12594. private _onCollisionPositionChange;
  12595. /** @hidden */
  12596. _checkInputs(): void;
  12597. /** @hidden */
  12598. _decideIfNeedsToMove(): boolean;
  12599. /** @hidden */
  12600. _updatePosition(): void;
  12601. /**
  12602. * Destroy the camera and release the current resources hold by it.
  12603. */
  12604. dispose(): void;
  12605. /**
  12606. * Gets the current object class name.
  12607. * @return the class name
  12608. */
  12609. getClassName(): string;
  12610. }
  12611. }
  12612. declare module "babylonjs/Gamepads/gamepad" {
  12613. import { Observable } from "babylonjs/Misc/observable";
  12614. /**
  12615. * Represents a gamepad control stick position
  12616. */
  12617. export class StickValues {
  12618. /**
  12619. * The x component of the control stick
  12620. */
  12621. x: number;
  12622. /**
  12623. * The y component of the control stick
  12624. */
  12625. y: number;
  12626. /**
  12627. * Initializes the gamepad x and y control stick values
  12628. * @param x The x component of the gamepad control stick value
  12629. * @param y The y component of the gamepad control stick value
  12630. */
  12631. constructor(
  12632. /**
  12633. * The x component of the control stick
  12634. */
  12635. x: number,
  12636. /**
  12637. * The y component of the control stick
  12638. */
  12639. y: number);
  12640. }
  12641. /**
  12642. * An interface which manages callbacks for gamepad button changes
  12643. */
  12644. export interface GamepadButtonChanges {
  12645. /**
  12646. * Called when a gamepad has been changed
  12647. */
  12648. changed: boolean;
  12649. /**
  12650. * Called when a gamepad press event has been triggered
  12651. */
  12652. pressChanged: boolean;
  12653. /**
  12654. * Called when a touch event has been triggered
  12655. */
  12656. touchChanged: boolean;
  12657. /**
  12658. * Called when a value has changed
  12659. */
  12660. valueChanged: boolean;
  12661. }
  12662. /**
  12663. * Represents a gamepad
  12664. */
  12665. export class Gamepad {
  12666. /**
  12667. * The id of the gamepad
  12668. */
  12669. id: string;
  12670. /**
  12671. * The index of the gamepad
  12672. */
  12673. index: number;
  12674. /**
  12675. * The browser gamepad
  12676. */
  12677. browserGamepad: any;
  12678. /**
  12679. * Specifies what type of gamepad this represents
  12680. */
  12681. type: number;
  12682. private _leftStick;
  12683. private _rightStick;
  12684. /** @hidden */
  12685. _isConnected: boolean;
  12686. private _leftStickAxisX;
  12687. private _leftStickAxisY;
  12688. private _rightStickAxisX;
  12689. private _rightStickAxisY;
  12690. /**
  12691. * Triggered when the left control stick has been changed
  12692. */
  12693. private _onleftstickchanged;
  12694. /**
  12695. * Triggered when the right control stick has been changed
  12696. */
  12697. private _onrightstickchanged;
  12698. /**
  12699. * Represents a gamepad controller
  12700. */
  12701. static GAMEPAD: number;
  12702. /**
  12703. * Represents a generic controller
  12704. */
  12705. static GENERIC: number;
  12706. /**
  12707. * Represents an XBox controller
  12708. */
  12709. static XBOX: number;
  12710. /**
  12711. * Represents a pose-enabled controller
  12712. */
  12713. static POSE_ENABLED: number;
  12714. /**
  12715. * Represents an Dual Shock controller
  12716. */
  12717. static DUALSHOCK: number;
  12718. /**
  12719. * Specifies whether the left control stick should be Y-inverted
  12720. */
  12721. protected _invertLeftStickY: boolean;
  12722. /**
  12723. * Specifies if the gamepad has been connected
  12724. */
  12725. get isConnected(): boolean;
  12726. /**
  12727. * Initializes the gamepad
  12728. * @param id The id of the gamepad
  12729. * @param index The index of the gamepad
  12730. * @param browserGamepad The browser gamepad
  12731. * @param leftStickX The x component of the left joystick
  12732. * @param leftStickY The y component of the left joystick
  12733. * @param rightStickX The x component of the right joystick
  12734. * @param rightStickY The y component of the right joystick
  12735. */
  12736. constructor(
  12737. /**
  12738. * The id of the gamepad
  12739. */
  12740. id: string,
  12741. /**
  12742. * The index of the gamepad
  12743. */
  12744. index: number,
  12745. /**
  12746. * The browser gamepad
  12747. */
  12748. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12749. /**
  12750. * Callback triggered when the left joystick has changed
  12751. * @param callback
  12752. */
  12753. onleftstickchanged(callback: (values: StickValues) => void): void;
  12754. /**
  12755. * Callback triggered when the right joystick has changed
  12756. * @param callback
  12757. */
  12758. onrightstickchanged(callback: (values: StickValues) => void): void;
  12759. /**
  12760. * Gets the left joystick
  12761. */
  12762. get leftStick(): StickValues;
  12763. /**
  12764. * Sets the left joystick values
  12765. */
  12766. set leftStick(newValues: StickValues);
  12767. /**
  12768. * Gets the right joystick
  12769. */
  12770. get rightStick(): StickValues;
  12771. /**
  12772. * Sets the right joystick value
  12773. */
  12774. set rightStick(newValues: StickValues);
  12775. /**
  12776. * Updates the gamepad joystick positions
  12777. */
  12778. update(): void;
  12779. /**
  12780. * Disposes the gamepad
  12781. */
  12782. dispose(): void;
  12783. }
  12784. /**
  12785. * Represents a generic gamepad
  12786. */
  12787. export class GenericPad extends Gamepad {
  12788. private _buttons;
  12789. private _onbuttondown;
  12790. private _onbuttonup;
  12791. /**
  12792. * Observable triggered when a button has been pressed
  12793. */
  12794. onButtonDownObservable: Observable<number>;
  12795. /**
  12796. * Observable triggered when a button has been released
  12797. */
  12798. onButtonUpObservable: Observable<number>;
  12799. /**
  12800. * Callback triggered when a button has been pressed
  12801. * @param callback Called when a button has been pressed
  12802. */
  12803. onbuttondown(callback: (buttonPressed: number) => void): void;
  12804. /**
  12805. * Callback triggered when a button has been released
  12806. * @param callback Called when a button has been released
  12807. */
  12808. onbuttonup(callback: (buttonReleased: number) => void): void;
  12809. /**
  12810. * Initializes the generic gamepad
  12811. * @param id The id of the generic gamepad
  12812. * @param index The index of the generic gamepad
  12813. * @param browserGamepad The browser gamepad
  12814. */
  12815. constructor(id: string, index: number, browserGamepad: any);
  12816. private _setButtonValue;
  12817. /**
  12818. * Updates the generic gamepad
  12819. */
  12820. update(): void;
  12821. /**
  12822. * Disposes the generic gamepad
  12823. */
  12824. dispose(): void;
  12825. }
  12826. }
  12827. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12828. import { Nullable } from "babylonjs/types";
  12829. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12830. import { Scene } from "babylonjs/scene";
  12831. module "babylonjs/Engines/engine" {
  12832. interface Engine {
  12833. /**
  12834. * Creates a raw texture
  12835. * @param data defines the data to store in the texture
  12836. * @param width defines the width of the texture
  12837. * @param height defines the height of the texture
  12838. * @param format defines the format of the data
  12839. * @param generateMipMaps defines if the engine should generate the mip levels
  12840. * @param invertY defines if data must be stored with Y axis inverted
  12841. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12842. * @param compression defines the compression used (null by default)
  12843. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12844. * @returns the raw texture inside an InternalTexture
  12845. */
  12846. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12847. /**
  12848. * Update a raw texture
  12849. * @param texture defines the texture to update
  12850. * @param data defines the data to store in the texture
  12851. * @param format defines the format of the data
  12852. * @param invertY defines if data must be stored with Y axis inverted
  12853. */
  12854. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12855. /**
  12856. * Update a raw texture
  12857. * @param texture defines the texture to update
  12858. * @param data defines the data to store in the texture
  12859. * @param format defines the format of the data
  12860. * @param invertY defines if data must be stored with Y axis inverted
  12861. * @param compression defines the compression used (null by default)
  12862. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12863. */
  12864. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12865. /**
  12866. * Creates a new raw cube texture
  12867. * @param data defines the array of data to use to create each face
  12868. * @param size defines the size of the textures
  12869. * @param format defines the format of the data
  12870. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12871. * @param generateMipMaps defines if the engine should generate the mip levels
  12872. * @param invertY defines if data must be stored with Y axis inverted
  12873. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12874. * @param compression defines the compression used (null by default)
  12875. * @returns the cube texture as an InternalTexture
  12876. */
  12877. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12878. /**
  12879. * Update a raw cube texture
  12880. * @param texture defines the texture to udpdate
  12881. * @param data defines the data to store
  12882. * @param format defines the data format
  12883. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12884. * @param invertY defines if data must be stored with Y axis inverted
  12885. */
  12886. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12887. /**
  12888. * Update a raw cube texture
  12889. * @param texture defines the texture to udpdate
  12890. * @param data defines the data to store
  12891. * @param format defines the data format
  12892. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12893. * @param invertY defines if data must be stored with Y axis inverted
  12894. * @param compression defines the compression used (null by default)
  12895. */
  12896. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12897. /**
  12898. * Update a raw cube texture
  12899. * @param texture defines the texture to udpdate
  12900. * @param data defines the data to store
  12901. * @param format defines the data format
  12902. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12903. * @param invertY defines if data must be stored with Y axis inverted
  12904. * @param compression defines the compression used (null by default)
  12905. * @param level defines which level of the texture to update
  12906. */
  12907. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12908. /**
  12909. * Creates a new raw cube texture from a specified url
  12910. * @param url defines the url where the data is located
  12911. * @param scene defines the current scene
  12912. * @param size defines the size of the textures
  12913. * @param format defines the format of the data
  12914. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12915. * @param noMipmap defines if the engine should avoid generating the mip levels
  12916. * @param callback defines a callback used to extract texture data from loaded data
  12917. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12918. * @param onLoad defines a callback called when texture is loaded
  12919. * @param onError defines a callback called if there is an error
  12920. * @returns the cube texture as an InternalTexture
  12921. */
  12922. 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;
  12923. /**
  12924. * Creates a new raw cube texture from a specified url
  12925. * @param url defines the url where the data is located
  12926. * @param scene defines the current scene
  12927. * @param size defines the size of the textures
  12928. * @param format defines the format of the data
  12929. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12930. * @param noMipmap defines if the engine should avoid generating the mip levels
  12931. * @param callback defines a callback used to extract texture data from loaded data
  12932. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12933. * @param onLoad defines a callback called when texture is loaded
  12934. * @param onError defines a callback called if there is an error
  12935. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12936. * @param invertY defines if data must be stored with Y axis inverted
  12937. * @returns the cube texture as an InternalTexture
  12938. */
  12939. 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;
  12940. /**
  12941. * Creates a new raw 3D texture
  12942. * @param data defines the data used to create the texture
  12943. * @param width defines the width of the texture
  12944. * @param height defines the height of the texture
  12945. * @param depth defines the depth of the texture
  12946. * @param format defines the format of the texture
  12947. * @param generateMipMaps defines if the engine must generate mip levels
  12948. * @param invertY defines if data must be stored with Y axis inverted
  12949. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12950. * @param compression defines the compressed used (can be null)
  12951. * @param textureType defines the compressed used (can be null)
  12952. * @returns a new raw 3D texture (stored in an InternalTexture)
  12953. */
  12954. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12955. /**
  12956. * Update a raw 3D texture
  12957. * @param texture defines the texture to update
  12958. * @param data defines the data to store
  12959. * @param format defines the data format
  12960. * @param invertY defines if data must be stored with Y axis inverted
  12961. */
  12962. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12963. /**
  12964. * Update a raw 3D texture
  12965. * @param texture defines the texture to update
  12966. * @param data defines the data to store
  12967. * @param format defines the data format
  12968. * @param invertY defines if data must be stored with Y axis inverted
  12969. * @param compression defines the used compression (can be null)
  12970. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12971. */
  12972. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12973. /**
  12974. * Creates a new raw 2D array texture
  12975. * @param data defines the data used to create the texture
  12976. * @param width defines the width of the texture
  12977. * @param height defines the height of the texture
  12978. * @param depth defines the number of layers of the texture
  12979. * @param format defines the format of the texture
  12980. * @param generateMipMaps defines if the engine must generate mip levels
  12981. * @param invertY defines if data must be stored with Y axis inverted
  12982. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12983. * @param compression defines the compressed used (can be null)
  12984. * @param textureType defines the compressed used (can be null)
  12985. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12986. */
  12987. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12988. /**
  12989. * Update a raw 2D array texture
  12990. * @param texture defines the texture to update
  12991. * @param data defines the data to store
  12992. * @param format defines the data format
  12993. * @param invertY defines if data must be stored with Y axis inverted
  12994. */
  12995. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12996. /**
  12997. * Update a raw 2D array texture
  12998. * @param texture defines the texture to update
  12999. * @param data defines the data to store
  13000. * @param format defines the data format
  13001. * @param invertY defines if data must be stored with Y axis inverted
  13002. * @param compression defines the used compression (can be null)
  13003. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13004. */
  13005. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13006. }
  13007. }
  13008. }
  13009. declare module "babylonjs/Materials/Textures/rawTexture" {
  13010. import { Scene } from "babylonjs/scene";
  13011. import { Texture } from "babylonjs/Materials/Textures/texture";
  13012. import "babylonjs/Engines/Extensions/engine.rawTexture";
  13013. /**
  13014. * Raw texture can help creating a texture directly from an array of data.
  13015. * This can be super useful if you either get the data from an uncompressed source or
  13016. * if you wish to create your texture pixel by pixel.
  13017. */
  13018. export class RawTexture extends Texture {
  13019. /**
  13020. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13021. */
  13022. format: number;
  13023. private _engine;
  13024. /**
  13025. * Instantiates a new RawTexture.
  13026. * Raw texture can help creating a texture directly from an array of data.
  13027. * This can be super useful if you either get the data from an uncompressed source or
  13028. * if you wish to create your texture pixel by pixel.
  13029. * @param data define the array of data to use to create the texture
  13030. * @param width define the width of the texture
  13031. * @param height define the height of the texture
  13032. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13033. * @param scene define the scene the texture belongs to
  13034. * @param generateMipMaps define whether mip maps should be generated or not
  13035. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13036. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13037. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13038. */
  13039. constructor(data: ArrayBufferView, width: number, height: number,
  13040. /**
  13041. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13042. */
  13043. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13044. /**
  13045. * Updates the texture underlying data.
  13046. * @param data Define the new data of the texture
  13047. */
  13048. update(data: ArrayBufferView): void;
  13049. /**
  13050. * Creates a luminance texture from some data.
  13051. * @param data Define the texture data
  13052. * @param width Define the width of the texture
  13053. * @param height Define the height of the texture
  13054. * @param scene Define the scene the texture belongs to
  13055. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13056. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13057. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13058. * @returns the luminance texture
  13059. */
  13060. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13061. /**
  13062. * Creates a luminance alpha texture from some data.
  13063. * @param data Define the texture data
  13064. * @param width Define the width of the texture
  13065. * @param height Define the height of the texture
  13066. * @param scene Define the scene the texture belongs to
  13067. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13068. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13069. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13070. * @returns the luminance alpha texture
  13071. */
  13072. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13073. /**
  13074. * Creates an alpha texture from some data.
  13075. * @param data Define the texture data
  13076. * @param width Define the width of the texture
  13077. * @param height Define the height of the texture
  13078. * @param scene Define the scene the texture belongs to
  13079. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13080. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13081. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13082. * @returns the alpha texture
  13083. */
  13084. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13085. /**
  13086. * Creates a RGB texture from some data.
  13087. * @param data Define the texture data
  13088. * @param width Define the width of the texture
  13089. * @param height Define the height of the texture
  13090. * @param scene Define the scene the texture belongs to
  13091. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13092. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13093. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13094. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13095. * @returns the RGB alpha texture
  13096. */
  13097. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13098. /**
  13099. * Creates a RGBA texture from some data.
  13100. * @param data Define the texture data
  13101. * @param width Define the width of the texture
  13102. * @param height Define the height of the texture
  13103. * @param scene Define the scene the texture belongs to
  13104. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13105. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13106. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13107. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13108. * @returns the RGBA texture
  13109. */
  13110. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13111. /**
  13112. * Creates a R texture from some data.
  13113. * @param data Define the texture data
  13114. * @param width Define the width of the texture
  13115. * @param height Define the height of the texture
  13116. * @param scene Define the scene the texture belongs to
  13117. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13118. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13119. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13120. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13121. * @returns the R texture
  13122. */
  13123. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13124. }
  13125. }
  13126. declare module "babylonjs/Maths/math.size" {
  13127. /**
  13128. * Interface for the size containing width and height
  13129. */
  13130. export interface ISize {
  13131. /**
  13132. * Width
  13133. */
  13134. width: number;
  13135. /**
  13136. * Heighht
  13137. */
  13138. height: number;
  13139. }
  13140. /**
  13141. * Size containing widht and height
  13142. */
  13143. export class Size implements ISize {
  13144. /**
  13145. * Width
  13146. */
  13147. width: number;
  13148. /**
  13149. * Height
  13150. */
  13151. height: number;
  13152. /**
  13153. * Creates a Size object from the given width and height (floats).
  13154. * @param width width of the new size
  13155. * @param height height of the new size
  13156. */
  13157. constructor(width: number, height: number);
  13158. /**
  13159. * Returns a string with the Size width and height
  13160. * @returns a string with the Size width and height
  13161. */
  13162. toString(): string;
  13163. /**
  13164. * "Size"
  13165. * @returns the string "Size"
  13166. */
  13167. getClassName(): string;
  13168. /**
  13169. * Returns the Size hash code.
  13170. * @returns a hash code for a unique width and height
  13171. */
  13172. getHashCode(): number;
  13173. /**
  13174. * Updates the current size from the given one.
  13175. * @param src the given size
  13176. */
  13177. copyFrom(src: Size): void;
  13178. /**
  13179. * Updates in place the current Size from the given floats.
  13180. * @param width width of the new size
  13181. * @param height height of the new size
  13182. * @returns the updated Size.
  13183. */
  13184. copyFromFloats(width: number, height: number): Size;
  13185. /**
  13186. * Updates in place the current Size from the given floats.
  13187. * @param width width to set
  13188. * @param height height to set
  13189. * @returns the updated Size.
  13190. */
  13191. set(width: number, height: number): Size;
  13192. /**
  13193. * Multiplies the width and height by numbers
  13194. * @param w factor to multiple the width by
  13195. * @param h factor to multiple the height by
  13196. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13197. */
  13198. multiplyByFloats(w: number, h: number): Size;
  13199. /**
  13200. * Clones the size
  13201. * @returns a new Size copied from the given one.
  13202. */
  13203. clone(): Size;
  13204. /**
  13205. * True if the current Size and the given one width and height are strictly equal.
  13206. * @param other the other size to compare against
  13207. * @returns True if the current Size and the given one width and height are strictly equal.
  13208. */
  13209. equals(other: Size): boolean;
  13210. /**
  13211. * The surface of the Size : width * height (float).
  13212. */
  13213. get surface(): number;
  13214. /**
  13215. * Create a new size of zero
  13216. * @returns a new Size set to (0.0, 0.0)
  13217. */
  13218. static Zero(): Size;
  13219. /**
  13220. * Sums the width and height of two sizes
  13221. * @param otherSize size to add to this size
  13222. * @returns a new Size set as the addition result of the current Size and the given one.
  13223. */
  13224. add(otherSize: Size): Size;
  13225. /**
  13226. * Subtracts the width and height of two
  13227. * @param otherSize size to subtract to this size
  13228. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13229. */
  13230. subtract(otherSize: Size): Size;
  13231. /**
  13232. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13233. * @param start starting size to lerp between
  13234. * @param end end size to lerp between
  13235. * @param amount amount to lerp between the start and end values
  13236. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13237. */
  13238. static Lerp(start: Size, end: Size, amount: number): Size;
  13239. }
  13240. }
  13241. declare module "babylonjs/Animations/runtimeAnimation" {
  13242. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13243. import { Animatable } from "babylonjs/Animations/animatable";
  13244. import { Scene } from "babylonjs/scene";
  13245. /**
  13246. * Defines a runtime animation
  13247. */
  13248. export class RuntimeAnimation {
  13249. private _events;
  13250. /**
  13251. * The current frame of the runtime animation
  13252. */
  13253. private _currentFrame;
  13254. /**
  13255. * The animation used by the runtime animation
  13256. */
  13257. private _animation;
  13258. /**
  13259. * The target of the runtime animation
  13260. */
  13261. private _target;
  13262. /**
  13263. * The initiating animatable
  13264. */
  13265. private _host;
  13266. /**
  13267. * The original value of the runtime animation
  13268. */
  13269. private _originalValue;
  13270. /**
  13271. * The original blend value of the runtime animation
  13272. */
  13273. private _originalBlendValue;
  13274. /**
  13275. * The offsets cache of the runtime animation
  13276. */
  13277. private _offsetsCache;
  13278. /**
  13279. * The high limits cache of the runtime animation
  13280. */
  13281. private _highLimitsCache;
  13282. /**
  13283. * Specifies if the runtime animation has been stopped
  13284. */
  13285. private _stopped;
  13286. /**
  13287. * The blending factor of the runtime animation
  13288. */
  13289. private _blendingFactor;
  13290. /**
  13291. * The BabylonJS scene
  13292. */
  13293. private _scene;
  13294. /**
  13295. * The current value of the runtime animation
  13296. */
  13297. private _currentValue;
  13298. /** @hidden */
  13299. _animationState: _IAnimationState;
  13300. /**
  13301. * The active target of the runtime animation
  13302. */
  13303. private _activeTargets;
  13304. private _currentActiveTarget;
  13305. private _directTarget;
  13306. /**
  13307. * The target path of the runtime animation
  13308. */
  13309. private _targetPath;
  13310. /**
  13311. * The weight of the runtime animation
  13312. */
  13313. private _weight;
  13314. /**
  13315. * The ratio offset of the runtime animation
  13316. */
  13317. private _ratioOffset;
  13318. /**
  13319. * The previous delay of the runtime animation
  13320. */
  13321. private _previousDelay;
  13322. /**
  13323. * The previous ratio of the runtime animation
  13324. */
  13325. private _previousRatio;
  13326. private _enableBlending;
  13327. private _keys;
  13328. private _minFrame;
  13329. private _maxFrame;
  13330. private _minValue;
  13331. private _maxValue;
  13332. private _targetIsArray;
  13333. /**
  13334. * Gets the current frame of the runtime animation
  13335. */
  13336. get currentFrame(): number;
  13337. /**
  13338. * Gets the weight of the runtime animation
  13339. */
  13340. get weight(): number;
  13341. /**
  13342. * Gets the current value of the runtime animation
  13343. */
  13344. get currentValue(): any;
  13345. /**
  13346. * Gets the target path of the runtime animation
  13347. */
  13348. get targetPath(): string;
  13349. /**
  13350. * Gets the actual target of the runtime animation
  13351. */
  13352. get target(): any;
  13353. /** @hidden */
  13354. _onLoop: () => void;
  13355. /**
  13356. * Create a new RuntimeAnimation object
  13357. * @param target defines the target of the animation
  13358. * @param animation defines the source animation object
  13359. * @param scene defines the hosting scene
  13360. * @param host defines the initiating Animatable
  13361. */
  13362. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13363. private _preparePath;
  13364. /**
  13365. * Gets the animation from the runtime animation
  13366. */
  13367. get animation(): Animation;
  13368. /**
  13369. * Resets the runtime animation to the beginning
  13370. * @param restoreOriginal defines whether to restore the target property to the original value
  13371. */
  13372. reset(restoreOriginal?: boolean): void;
  13373. /**
  13374. * Specifies if the runtime animation is stopped
  13375. * @returns Boolean specifying if the runtime animation is stopped
  13376. */
  13377. isStopped(): boolean;
  13378. /**
  13379. * Disposes of the runtime animation
  13380. */
  13381. dispose(): void;
  13382. /**
  13383. * Apply the interpolated value to the target
  13384. * @param currentValue defines the value computed by the animation
  13385. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13386. */
  13387. setValue(currentValue: any, weight: number): void;
  13388. private _getOriginalValues;
  13389. private _setValue;
  13390. /**
  13391. * Gets the loop pmode of the runtime animation
  13392. * @returns Loop Mode
  13393. */
  13394. private _getCorrectLoopMode;
  13395. /**
  13396. * Move the current animation to a given frame
  13397. * @param frame defines the frame to move to
  13398. */
  13399. goToFrame(frame: number): void;
  13400. /**
  13401. * @hidden Internal use only
  13402. */
  13403. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13404. /**
  13405. * Execute the current animation
  13406. * @param delay defines the delay to add to the current frame
  13407. * @param from defines the lower bound of the animation range
  13408. * @param to defines the upper bound of the animation range
  13409. * @param loop defines if the current animation must loop
  13410. * @param speedRatio defines the current speed ratio
  13411. * @param weight defines the weight of the animation (default is -1 so no weight)
  13412. * @param onLoop optional callback called when animation loops
  13413. * @returns a boolean indicating if the animation is running
  13414. */
  13415. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13416. }
  13417. }
  13418. declare module "babylonjs/Animations/animatable" {
  13419. import { Animation } from "babylonjs/Animations/animation";
  13420. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13421. import { Nullable } from "babylonjs/types";
  13422. import { Observable } from "babylonjs/Misc/observable";
  13423. import { Scene } from "babylonjs/scene";
  13424. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13425. import { Node } from "babylonjs/node";
  13426. /**
  13427. * Class used to store an actual running animation
  13428. */
  13429. export class Animatable {
  13430. /** defines the target object */
  13431. target: any;
  13432. /** defines the starting frame number (default is 0) */
  13433. fromFrame: number;
  13434. /** defines the ending frame number (default is 100) */
  13435. toFrame: number;
  13436. /** defines if the animation must loop (default is false) */
  13437. loopAnimation: boolean;
  13438. /** defines a callback to call when animation ends if it is not looping */
  13439. onAnimationEnd?: (() => void) | null | undefined;
  13440. /** defines a callback to call when animation loops */
  13441. onAnimationLoop?: (() => void) | null | undefined;
  13442. private _localDelayOffset;
  13443. private _pausedDelay;
  13444. private _runtimeAnimations;
  13445. private _paused;
  13446. private _scene;
  13447. private _speedRatio;
  13448. private _weight;
  13449. private _syncRoot;
  13450. /**
  13451. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13452. * This will only apply for non looping animation (default is true)
  13453. */
  13454. disposeOnEnd: boolean;
  13455. /**
  13456. * Gets a boolean indicating if the animation has started
  13457. */
  13458. animationStarted: boolean;
  13459. /**
  13460. * Observer raised when the animation ends
  13461. */
  13462. onAnimationEndObservable: Observable<Animatable>;
  13463. /**
  13464. * Observer raised when the animation loops
  13465. */
  13466. onAnimationLoopObservable: Observable<Animatable>;
  13467. /**
  13468. * Gets the root Animatable used to synchronize and normalize animations
  13469. */
  13470. get syncRoot(): Nullable<Animatable>;
  13471. /**
  13472. * Gets the current frame of the first RuntimeAnimation
  13473. * Used to synchronize Animatables
  13474. */
  13475. get masterFrame(): number;
  13476. /**
  13477. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13478. */
  13479. get weight(): number;
  13480. set weight(value: number);
  13481. /**
  13482. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13483. */
  13484. get speedRatio(): number;
  13485. set speedRatio(value: number);
  13486. /**
  13487. * Creates a new Animatable
  13488. * @param scene defines the hosting scene
  13489. * @param target defines the target object
  13490. * @param fromFrame defines the starting frame number (default is 0)
  13491. * @param toFrame defines the ending frame number (default is 100)
  13492. * @param loopAnimation defines if the animation must loop (default is false)
  13493. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13494. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13495. * @param animations defines a group of animation to add to the new Animatable
  13496. * @param onAnimationLoop defines a callback to call when animation loops
  13497. */
  13498. constructor(scene: Scene,
  13499. /** defines the target object */
  13500. target: any,
  13501. /** defines the starting frame number (default is 0) */
  13502. fromFrame?: number,
  13503. /** defines the ending frame number (default is 100) */
  13504. toFrame?: number,
  13505. /** defines if the animation must loop (default is false) */
  13506. loopAnimation?: boolean, speedRatio?: number,
  13507. /** defines a callback to call when animation ends if it is not looping */
  13508. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13509. /** defines a callback to call when animation loops */
  13510. onAnimationLoop?: (() => void) | null | undefined);
  13511. /**
  13512. * Synchronize and normalize current Animatable with a source Animatable
  13513. * This is useful when using animation weights and when animations are not of the same length
  13514. * @param root defines the root Animatable to synchronize with
  13515. * @returns the current Animatable
  13516. */
  13517. syncWith(root: Animatable): Animatable;
  13518. /**
  13519. * Gets the list of runtime animations
  13520. * @returns an array of RuntimeAnimation
  13521. */
  13522. getAnimations(): RuntimeAnimation[];
  13523. /**
  13524. * Adds more animations to the current animatable
  13525. * @param target defines the target of the animations
  13526. * @param animations defines the new animations to add
  13527. */
  13528. appendAnimations(target: any, animations: Animation[]): void;
  13529. /**
  13530. * Gets the source animation for a specific property
  13531. * @param property defines the propertyu to look for
  13532. * @returns null or the source animation for the given property
  13533. */
  13534. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13535. /**
  13536. * Gets the runtime animation for a specific property
  13537. * @param property defines the propertyu to look for
  13538. * @returns null or the runtime animation for the given property
  13539. */
  13540. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13541. /**
  13542. * Resets the animatable to its original state
  13543. */
  13544. reset(): void;
  13545. /**
  13546. * Allows the animatable to blend with current running animations
  13547. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13548. * @param blendingSpeed defines the blending speed to use
  13549. */
  13550. enableBlending(blendingSpeed: number): void;
  13551. /**
  13552. * Disable animation blending
  13553. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13554. */
  13555. disableBlending(): void;
  13556. /**
  13557. * Jump directly to a given frame
  13558. * @param frame defines the frame to jump to
  13559. */
  13560. goToFrame(frame: number): void;
  13561. /**
  13562. * Pause the animation
  13563. */
  13564. pause(): void;
  13565. /**
  13566. * Restart the animation
  13567. */
  13568. restart(): void;
  13569. private _raiseOnAnimationEnd;
  13570. /**
  13571. * Stop and delete the current animation
  13572. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13573. * @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)
  13574. */
  13575. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13576. /**
  13577. * Wait asynchronously for the animation to end
  13578. * @returns a promise which will be fullfilled when the animation ends
  13579. */
  13580. waitAsync(): Promise<Animatable>;
  13581. /** @hidden */
  13582. _animate(delay: number): boolean;
  13583. }
  13584. module "babylonjs/scene" {
  13585. interface Scene {
  13586. /** @hidden */
  13587. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13588. /** @hidden */
  13589. _processLateAnimationBindingsForMatrices(holder: {
  13590. totalWeight: number;
  13591. animations: RuntimeAnimation[];
  13592. originalValue: Matrix;
  13593. }): any;
  13594. /** @hidden */
  13595. _processLateAnimationBindingsForQuaternions(holder: {
  13596. totalWeight: number;
  13597. animations: RuntimeAnimation[];
  13598. originalValue: Quaternion;
  13599. }, refQuaternion: Quaternion): Quaternion;
  13600. /** @hidden */
  13601. _processLateAnimationBindings(): void;
  13602. /**
  13603. * Will start the animation sequence of a given target
  13604. * @param target defines the target
  13605. * @param from defines from which frame should animation start
  13606. * @param to defines until which frame should animation run.
  13607. * @param weight defines the weight to apply to the animation (1.0 by default)
  13608. * @param loop defines if the animation loops
  13609. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13610. * @param onAnimationEnd defines the function to be executed when the animation ends
  13611. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13612. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13613. * @param onAnimationLoop defines the callback to call when an animation loops
  13614. * @returns the animatable object created for this animation
  13615. */
  13616. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13617. /**
  13618. * Will start the animation sequence of a given target
  13619. * @param target defines the target
  13620. * @param from defines from which frame should animation start
  13621. * @param to defines until which frame should animation run.
  13622. * @param loop defines if the animation loops
  13623. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13624. * @param onAnimationEnd defines the function to be executed when the animation ends
  13625. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13626. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13627. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13628. * @param onAnimationLoop defines the callback to call when an animation loops
  13629. * @returns the animatable object created for this animation
  13630. */
  13631. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13632. /**
  13633. * Will start the animation sequence of a given target and its hierarchy
  13634. * @param target defines the target
  13635. * @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.
  13636. * @param from defines from which frame should animation start
  13637. * @param to defines until which frame should animation run.
  13638. * @param loop defines if the animation loops
  13639. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13640. * @param onAnimationEnd defines the function to be executed when the animation ends
  13641. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13642. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13643. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13644. * @param onAnimationLoop defines the callback to call when an animation loops
  13645. * @returns the list of created animatables
  13646. */
  13647. 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[];
  13648. /**
  13649. * Begin a new animation on a given node
  13650. * @param target defines the target where the animation will take place
  13651. * @param animations defines the list of animations to start
  13652. * @param from defines the initial value
  13653. * @param to defines the final value
  13654. * @param loop defines if you want animation to loop (off by default)
  13655. * @param speedRatio defines the speed ratio to apply to all animations
  13656. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13657. * @param onAnimationLoop defines the callback to call when an animation loops
  13658. * @returns the list of created animatables
  13659. */
  13660. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13661. /**
  13662. * Begin a new animation on a given node and its hierarchy
  13663. * @param target defines the root node where the animation will take place
  13664. * @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.
  13665. * @param animations defines the list of animations to start
  13666. * @param from defines the initial value
  13667. * @param to defines the final value
  13668. * @param loop defines if you want animation to loop (off by default)
  13669. * @param speedRatio defines the speed ratio to apply to all animations
  13670. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13671. * @param onAnimationLoop defines the callback to call when an animation loops
  13672. * @returns the list of animatables created for all nodes
  13673. */
  13674. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13675. /**
  13676. * Gets the animatable associated with a specific target
  13677. * @param target defines the target of the animatable
  13678. * @returns the required animatable if found
  13679. */
  13680. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13681. /**
  13682. * Gets all animatables associated with a given target
  13683. * @param target defines the target to look animatables for
  13684. * @returns an array of Animatables
  13685. */
  13686. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13687. /**
  13688. * Stops and removes all animations that have been applied to the scene
  13689. */
  13690. stopAllAnimations(): void;
  13691. /**
  13692. * Gets the current delta time used by animation engine
  13693. */
  13694. deltaTime: number;
  13695. }
  13696. }
  13697. module "babylonjs/Bones/bone" {
  13698. interface Bone {
  13699. /**
  13700. * Copy an animation range from another bone
  13701. * @param source defines the source bone
  13702. * @param rangeName defines the range name to copy
  13703. * @param frameOffset defines the frame offset
  13704. * @param rescaleAsRequired defines if rescaling must be applied if required
  13705. * @param skelDimensionsRatio defines the scaling ratio
  13706. * @returns true if operation was successful
  13707. */
  13708. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13709. }
  13710. }
  13711. }
  13712. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13713. /**
  13714. * Class used to override all child animations of a given target
  13715. */
  13716. export class AnimationPropertiesOverride {
  13717. /**
  13718. * Gets or sets a value indicating if animation blending must be used
  13719. */
  13720. enableBlending: boolean;
  13721. /**
  13722. * Gets or sets the blending speed to use when enableBlending is true
  13723. */
  13724. blendingSpeed: number;
  13725. /**
  13726. * Gets or sets the default loop mode to use
  13727. */
  13728. loopMode: number;
  13729. }
  13730. }
  13731. declare module "babylonjs/Bones/skeleton" {
  13732. import { Bone } from "babylonjs/Bones/bone";
  13733. import { Observable } from "babylonjs/Misc/observable";
  13734. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13735. import { Scene } from "babylonjs/scene";
  13736. import { Nullable } from "babylonjs/types";
  13737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13738. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13739. import { Animatable } from "babylonjs/Animations/animatable";
  13740. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13741. import { Animation } from "babylonjs/Animations/animation";
  13742. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13743. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13744. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13745. /**
  13746. * Class used to handle skinning animations
  13747. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13748. */
  13749. export class Skeleton implements IAnimatable {
  13750. /** defines the skeleton name */
  13751. name: string;
  13752. /** defines the skeleton Id */
  13753. id: string;
  13754. /**
  13755. * Defines the list of child bones
  13756. */
  13757. bones: Bone[];
  13758. /**
  13759. * Defines an estimate of the dimension of the skeleton at rest
  13760. */
  13761. dimensionsAtRest: Vector3;
  13762. /**
  13763. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13764. */
  13765. needInitialSkinMatrix: boolean;
  13766. /**
  13767. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13768. */
  13769. overrideMesh: Nullable<AbstractMesh>;
  13770. /**
  13771. * Gets the list of animations attached to this skeleton
  13772. */
  13773. animations: Array<Animation>;
  13774. private _scene;
  13775. private _isDirty;
  13776. private _transformMatrices;
  13777. private _transformMatrixTexture;
  13778. private _meshesWithPoseMatrix;
  13779. private _animatables;
  13780. private _identity;
  13781. private _synchronizedWithMesh;
  13782. private _ranges;
  13783. private _lastAbsoluteTransformsUpdateId;
  13784. private _canUseTextureForBones;
  13785. private _uniqueId;
  13786. /** @hidden */
  13787. _numBonesWithLinkedTransformNode: number;
  13788. /** @hidden */
  13789. _hasWaitingData: Nullable<boolean>;
  13790. /**
  13791. * Specifies if the skeleton should be serialized
  13792. */
  13793. doNotSerialize: boolean;
  13794. private _useTextureToStoreBoneMatrices;
  13795. /**
  13796. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13797. * Please note that this option is not available if the hardware does not support it
  13798. */
  13799. get useTextureToStoreBoneMatrices(): boolean;
  13800. set useTextureToStoreBoneMatrices(value: boolean);
  13801. private _animationPropertiesOverride;
  13802. /**
  13803. * Gets or sets the animation properties override
  13804. */
  13805. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13806. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13807. /**
  13808. * List of inspectable custom properties (used by the Inspector)
  13809. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13810. */
  13811. inspectableCustomProperties: IInspectable[];
  13812. /**
  13813. * An observable triggered before computing the skeleton's matrices
  13814. */
  13815. onBeforeComputeObservable: Observable<Skeleton>;
  13816. /**
  13817. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13818. */
  13819. get isUsingTextureForMatrices(): boolean;
  13820. /**
  13821. * Gets the unique ID of this skeleton
  13822. */
  13823. get uniqueId(): number;
  13824. /**
  13825. * Creates a new skeleton
  13826. * @param name defines the skeleton name
  13827. * @param id defines the skeleton Id
  13828. * @param scene defines the hosting scene
  13829. */
  13830. constructor(
  13831. /** defines the skeleton name */
  13832. name: string,
  13833. /** defines the skeleton Id */
  13834. id: string, scene: Scene);
  13835. /**
  13836. * Gets the current object class name.
  13837. * @return the class name
  13838. */
  13839. getClassName(): string;
  13840. /**
  13841. * Returns an array containing the root bones
  13842. * @returns an array containing the root bones
  13843. */
  13844. getChildren(): Array<Bone>;
  13845. /**
  13846. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13847. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13848. * @returns a Float32Array containing matrices data
  13849. */
  13850. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13851. /**
  13852. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13853. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13854. * @returns a raw texture containing the data
  13855. */
  13856. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13857. /**
  13858. * Gets the current hosting scene
  13859. * @returns a scene object
  13860. */
  13861. getScene(): Scene;
  13862. /**
  13863. * Gets a string representing the current skeleton data
  13864. * @param fullDetails defines a boolean indicating if we want a verbose version
  13865. * @returns a string representing the current skeleton data
  13866. */
  13867. toString(fullDetails?: boolean): string;
  13868. /**
  13869. * Get bone's index searching by name
  13870. * @param name defines bone's name to search for
  13871. * @return the indice of the bone. Returns -1 if not found
  13872. */
  13873. getBoneIndexByName(name: string): number;
  13874. /**
  13875. * Creater a new animation range
  13876. * @param name defines the name of the range
  13877. * @param from defines the start key
  13878. * @param to defines the end key
  13879. */
  13880. createAnimationRange(name: string, from: number, to: number): void;
  13881. /**
  13882. * Delete a specific animation range
  13883. * @param name defines the name of the range
  13884. * @param deleteFrames defines if frames must be removed as well
  13885. */
  13886. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13887. /**
  13888. * Gets a specific animation range
  13889. * @param name defines the name of the range to look for
  13890. * @returns the requested animation range or null if not found
  13891. */
  13892. getAnimationRange(name: string): Nullable<AnimationRange>;
  13893. /**
  13894. * Gets the list of all animation ranges defined on this skeleton
  13895. * @returns an array
  13896. */
  13897. getAnimationRanges(): Nullable<AnimationRange>[];
  13898. /**
  13899. * Copy animation range from a source skeleton.
  13900. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13901. * @param source defines the source skeleton
  13902. * @param name defines the name of the range to copy
  13903. * @param rescaleAsRequired defines if rescaling must be applied if required
  13904. * @returns true if operation was successful
  13905. */
  13906. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13907. /**
  13908. * Forces the skeleton to go to rest pose
  13909. */
  13910. returnToRest(): void;
  13911. private _getHighestAnimationFrame;
  13912. /**
  13913. * Begin a specific animation range
  13914. * @param name defines the name of the range to start
  13915. * @param loop defines if looping must be turned on (false by default)
  13916. * @param speedRatio defines the speed ratio to apply (1 by default)
  13917. * @param onAnimationEnd defines a callback which will be called when animation will end
  13918. * @returns a new animatable
  13919. */
  13920. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13921. /** @hidden */
  13922. _markAsDirty(): void;
  13923. /** @hidden */
  13924. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13925. /** @hidden */
  13926. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13927. private _computeTransformMatrices;
  13928. /**
  13929. * Build all resources required to render a skeleton
  13930. */
  13931. prepare(): void;
  13932. /**
  13933. * Gets the list of animatables currently running for this skeleton
  13934. * @returns an array of animatables
  13935. */
  13936. getAnimatables(): IAnimatable[];
  13937. /**
  13938. * Clone the current skeleton
  13939. * @param name defines the name of the new skeleton
  13940. * @param id defines the id of the new skeleton
  13941. * @returns the new skeleton
  13942. */
  13943. clone(name: string, id?: string): Skeleton;
  13944. /**
  13945. * Enable animation blending for this skeleton
  13946. * @param blendingSpeed defines the blending speed to apply
  13947. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13948. */
  13949. enableBlending(blendingSpeed?: number): void;
  13950. /**
  13951. * Releases all resources associated with the current skeleton
  13952. */
  13953. dispose(): void;
  13954. /**
  13955. * Serialize the skeleton in a JSON object
  13956. * @returns a JSON object
  13957. */
  13958. serialize(): any;
  13959. /**
  13960. * Creates a new skeleton from serialized data
  13961. * @param parsedSkeleton defines the serialized data
  13962. * @param scene defines the hosting scene
  13963. * @returns a new skeleton
  13964. */
  13965. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13966. /**
  13967. * Compute all node absolute transforms
  13968. * @param forceUpdate defines if computation must be done even if cache is up to date
  13969. */
  13970. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13971. /**
  13972. * Gets the root pose matrix
  13973. * @returns a matrix
  13974. */
  13975. getPoseMatrix(): Nullable<Matrix>;
  13976. /**
  13977. * Sorts bones per internal index
  13978. */
  13979. sortBones(): void;
  13980. private _sortBones;
  13981. }
  13982. }
  13983. declare module "babylonjs/Bones/bone" {
  13984. import { Skeleton } from "babylonjs/Bones/skeleton";
  13985. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13986. import { Nullable } from "babylonjs/types";
  13987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13988. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13989. import { Node } from "babylonjs/node";
  13990. import { Space } from "babylonjs/Maths/math.axis";
  13991. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13992. /**
  13993. * Class used to store bone information
  13994. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13995. */
  13996. export class Bone extends Node {
  13997. /**
  13998. * defines the bone name
  13999. */
  14000. name: string;
  14001. private static _tmpVecs;
  14002. private static _tmpQuat;
  14003. private static _tmpMats;
  14004. /**
  14005. * Gets the list of child bones
  14006. */
  14007. children: Bone[];
  14008. /** Gets the animations associated with this bone */
  14009. animations: import("babylonjs/Animations/animation").Animation[];
  14010. /**
  14011. * Gets or sets bone length
  14012. */
  14013. length: number;
  14014. /**
  14015. * @hidden Internal only
  14016. * Set this value to map this bone to a different index in the transform matrices
  14017. * Set this value to -1 to exclude the bone from the transform matrices
  14018. */
  14019. _index: Nullable<number>;
  14020. private _skeleton;
  14021. private _localMatrix;
  14022. private _restPose;
  14023. private _baseMatrix;
  14024. private _absoluteTransform;
  14025. private _invertedAbsoluteTransform;
  14026. private _parent;
  14027. private _scalingDeterminant;
  14028. private _worldTransform;
  14029. private _localScaling;
  14030. private _localRotation;
  14031. private _localPosition;
  14032. private _needToDecompose;
  14033. private _needToCompose;
  14034. /** @hidden */
  14035. _linkedTransformNode: Nullable<TransformNode>;
  14036. /** @hidden */
  14037. _waitingTransformNodeId: Nullable<string>;
  14038. /** @hidden */
  14039. get _matrix(): Matrix;
  14040. /** @hidden */
  14041. set _matrix(value: Matrix);
  14042. /**
  14043. * Create a new bone
  14044. * @param name defines the bone name
  14045. * @param skeleton defines the parent skeleton
  14046. * @param parentBone defines the parent (can be null if the bone is the root)
  14047. * @param localMatrix defines the local matrix
  14048. * @param restPose defines the rest pose matrix
  14049. * @param baseMatrix defines the base matrix
  14050. * @param index defines index of the bone in the hiearchy
  14051. */
  14052. constructor(
  14053. /**
  14054. * defines the bone name
  14055. */
  14056. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14057. /**
  14058. * Gets the current object class name.
  14059. * @return the class name
  14060. */
  14061. getClassName(): string;
  14062. /**
  14063. * Gets the parent skeleton
  14064. * @returns a skeleton
  14065. */
  14066. getSkeleton(): Skeleton;
  14067. /**
  14068. * Gets parent bone
  14069. * @returns a bone or null if the bone is the root of the bone hierarchy
  14070. */
  14071. getParent(): Nullable<Bone>;
  14072. /**
  14073. * Returns an array containing the root bones
  14074. * @returns an array containing the root bones
  14075. */
  14076. getChildren(): Array<Bone>;
  14077. /**
  14078. * Gets the node index in matrix array generated for rendering
  14079. * @returns the node index
  14080. */
  14081. getIndex(): number;
  14082. /**
  14083. * Sets the parent bone
  14084. * @param parent defines the parent (can be null if the bone is the root)
  14085. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14086. */
  14087. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14088. /**
  14089. * Gets the local matrix
  14090. * @returns a matrix
  14091. */
  14092. getLocalMatrix(): Matrix;
  14093. /**
  14094. * Gets the base matrix (initial matrix which remains unchanged)
  14095. * @returns a matrix
  14096. */
  14097. getBaseMatrix(): Matrix;
  14098. /**
  14099. * Gets the rest pose matrix
  14100. * @returns a matrix
  14101. */
  14102. getRestPose(): Matrix;
  14103. /**
  14104. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14105. */
  14106. getWorldMatrix(): Matrix;
  14107. /**
  14108. * Sets the local matrix to rest pose matrix
  14109. */
  14110. returnToRest(): void;
  14111. /**
  14112. * Gets the inverse of the absolute transform matrix.
  14113. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14114. * @returns a matrix
  14115. */
  14116. getInvertedAbsoluteTransform(): Matrix;
  14117. /**
  14118. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14119. * @returns a matrix
  14120. */
  14121. getAbsoluteTransform(): Matrix;
  14122. /**
  14123. * Links with the given transform node.
  14124. * The local matrix of this bone is copied from the transform node every frame.
  14125. * @param transformNode defines the transform node to link to
  14126. */
  14127. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14128. /**
  14129. * Gets the node used to drive the bone's transformation
  14130. * @returns a transform node or null
  14131. */
  14132. getTransformNode(): Nullable<TransformNode>;
  14133. /** Gets or sets current position (in local space) */
  14134. get position(): Vector3;
  14135. set position(newPosition: Vector3);
  14136. /** Gets or sets current rotation (in local space) */
  14137. get rotation(): Vector3;
  14138. set rotation(newRotation: Vector3);
  14139. /** Gets or sets current rotation quaternion (in local space) */
  14140. get rotationQuaternion(): Quaternion;
  14141. set rotationQuaternion(newRotation: Quaternion);
  14142. /** Gets or sets current scaling (in local space) */
  14143. get scaling(): Vector3;
  14144. set scaling(newScaling: Vector3);
  14145. /**
  14146. * Gets the animation properties override
  14147. */
  14148. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14149. private _decompose;
  14150. private _compose;
  14151. /**
  14152. * Update the base and local matrices
  14153. * @param matrix defines the new base or local matrix
  14154. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14155. * @param updateLocalMatrix defines if the local matrix should be updated
  14156. */
  14157. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14158. /** @hidden */
  14159. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14160. /**
  14161. * Flag the bone as dirty (Forcing it to update everything)
  14162. */
  14163. markAsDirty(): void;
  14164. /** @hidden */
  14165. _markAsDirtyAndCompose(): void;
  14166. private _markAsDirtyAndDecompose;
  14167. /**
  14168. * Translate the bone in local or world space
  14169. * @param vec The amount to translate the bone
  14170. * @param space The space that the translation is in
  14171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14172. */
  14173. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14174. /**
  14175. * Set the postion of the bone in local or world space
  14176. * @param position The position to set the bone
  14177. * @param space The space that the position is in
  14178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14179. */
  14180. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14181. /**
  14182. * Set the absolute position of the bone (world space)
  14183. * @param position The position to set the bone
  14184. * @param mesh The mesh that this bone is attached to
  14185. */
  14186. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14187. /**
  14188. * Scale the bone on the x, y and z axes (in local space)
  14189. * @param x The amount to scale the bone on the x axis
  14190. * @param y The amount to scale the bone on the y axis
  14191. * @param z The amount to scale the bone on the z axis
  14192. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14193. */
  14194. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14195. /**
  14196. * Set the bone scaling in local space
  14197. * @param scale defines the scaling vector
  14198. */
  14199. setScale(scale: Vector3): void;
  14200. /**
  14201. * Gets the current scaling in local space
  14202. * @returns the current scaling vector
  14203. */
  14204. getScale(): Vector3;
  14205. /**
  14206. * Gets the current scaling in local space and stores it in a target vector
  14207. * @param result defines the target vector
  14208. */
  14209. getScaleToRef(result: Vector3): void;
  14210. /**
  14211. * Set the yaw, pitch, and roll of the bone in local or world space
  14212. * @param yaw The rotation of the bone on the y axis
  14213. * @param pitch The rotation of the bone on the x axis
  14214. * @param roll The rotation of the bone on the z axis
  14215. * @param space The space that the axes of rotation are in
  14216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14217. */
  14218. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14219. /**
  14220. * Add a rotation to the bone on an axis in local or world space
  14221. * @param axis The axis to rotate the bone on
  14222. * @param amount The amount to rotate the bone
  14223. * @param space The space that the axis is in
  14224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14225. */
  14226. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14227. /**
  14228. * Set the rotation of the bone to a particular axis angle in local or world space
  14229. * @param axis The axis to rotate the bone on
  14230. * @param angle The angle that the bone should be rotated to
  14231. * @param space The space that the axis is in
  14232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14233. */
  14234. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14235. /**
  14236. * Set the euler rotation of the bone in local of world space
  14237. * @param rotation The euler rotation that the bone should be set to
  14238. * @param space The space that the rotation is in
  14239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14240. */
  14241. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14242. /**
  14243. * Set the quaternion rotation of the bone in local of world space
  14244. * @param quat The quaternion rotation that the bone should be set to
  14245. * @param space The space that the rotation is in
  14246. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14247. */
  14248. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14249. /**
  14250. * Set the rotation matrix of the bone in local of world space
  14251. * @param rotMat The rotation matrix that the bone should be set to
  14252. * @param space The space that the rotation is in
  14253. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14254. */
  14255. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14256. private _rotateWithMatrix;
  14257. private _getNegativeRotationToRef;
  14258. /**
  14259. * Get the position of the bone in local or world space
  14260. * @param space The space that the returned position is in
  14261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14262. * @returns The position of the bone
  14263. */
  14264. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14265. /**
  14266. * Copy the position of the bone to a vector3 in local or world space
  14267. * @param space The space that the returned position is in
  14268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14269. * @param result The vector3 to copy the position to
  14270. */
  14271. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14272. /**
  14273. * Get the absolute position of the bone (world space)
  14274. * @param mesh The mesh that this bone is attached to
  14275. * @returns The absolute position of the bone
  14276. */
  14277. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14278. /**
  14279. * Copy the absolute position of the bone (world space) to the result param
  14280. * @param mesh The mesh that this bone is attached to
  14281. * @param result The vector3 to copy the absolute position to
  14282. */
  14283. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14284. /**
  14285. * Compute the absolute transforms of this bone and its children
  14286. */
  14287. computeAbsoluteTransforms(): void;
  14288. /**
  14289. * Get the world direction from an axis that is in the local space of the bone
  14290. * @param localAxis The local direction that is used to compute the world direction
  14291. * @param mesh The mesh that this bone is attached to
  14292. * @returns The world direction
  14293. */
  14294. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14295. /**
  14296. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14297. * @param localAxis The local direction that is used to compute the world direction
  14298. * @param mesh The mesh that this bone is attached to
  14299. * @param result The vector3 that the world direction will be copied to
  14300. */
  14301. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14302. /**
  14303. * Get the euler rotation of the bone in local or world space
  14304. * @param space The space that the rotation should be in
  14305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14306. * @returns The euler rotation
  14307. */
  14308. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14309. /**
  14310. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14311. * @param space The space that the rotation should be in
  14312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14313. * @param result The vector3 that the rotation should be copied to
  14314. */
  14315. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14316. /**
  14317. * Get the quaternion rotation of the bone in either local or world space
  14318. * @param space The space that the rotation should be in
  14319. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14320. * @returns The quaternion rotation
  14321. */
  14322. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14323. /**
  14324. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14325. * @param space The space that the rotation should be in
  14326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14327. * @param result The quaternion that the rotation should be copied to
  14328. */
  14329. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14330. /**
  14331. * Get the rotation matrix of the bone in local or world space
  14332. * @param space The space that the rotation should be in
  14333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14334. * @returns The rotation matrix
  14335. */
  14336. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14337. /**
  14338. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14339. * @param space The space that the rotation should be in
  14340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14341. * @param result The quaternion that the rotation should be copied to
  14342. */
  14343. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14344. /**
  14345. * Get the world position of a point that is in the local space of the bone
  14346. * @param position The local position
  14347. * @param mesh The mesh that this bone is attached to
  14348. * @returns The world position
  14349. */
  14350. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14351. /**
  14352. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14353. * @param position The local position
  14354. * @param mesh The mesh that this bone is attached to
  14355. * @param result The vector3 that the world position should be copied to
  14356. */
  14357. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14358. /**
  14359. * Get the local position of a point that is in world space
  14360. * @param position The world position
  14361. * @param mesh The mesh that this bone is attached to
  14362. * @returns The local position
  14363. */
  14364. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14365. /**
  14366. * Get the local position of a point that is in world space and copy it to the result param
  14367. * @param position The world position
  14368. * @param mesh The mesh that this bone is attached to
  14369. * @param result The vector3 that the local position should be copied to
  14370. */
  14371. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14372. }
  14373. }
  14374. declare module "babylonjs/Meshes/transformNode" {
  14375. import { DeepImmutable } from "babylonjs/types";
  14376. import { Observable } from "babylonjs/Misc/observable";
  14377. import { Nullable } from "babylonjs/types";
  14378. import { Camera } from "babylonjs/Cameras/camera";
  14379. import { Scene } from "babylonjs/scene";
  14380. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14381. import { Node } from "babylonjs/node";
  14382. import { Bone } from "babylonjs/Bones/bone";
  14383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14384. import { Space } from "babylonjs/Maths/math.axis";
  14385. /**
  14386. * 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.
  14387. * @see https://doc.babylonjs.com/how_to/transformnode
  14388. */
  14389. export class TransformNode extends Node {
  14390. /**
  14391. * Object will not rotate to face the camera
  14392. */
  14393. static BILLBOARDMODE_NONE: number;
  14394. /**
  14395. * Object will rotate to face the camera but only on the x axis
  14396. */
  14397. static BILLBOARDMODE_X: number;
  14398. /**
  14399. * Object will rotate to face the camera but only on the y axis
  14400. */
  14401. static BILLBOARDMODE_Y: number;
  14402. /**
  14403. * Object will rotate to face the camera but only on the z axis
  14404. */
  14405. static BILLBOARDMODE_Z: number;
  14406. /**
  14407. * Object will rotate to face the camera
  14408. */
  14409. static BILLBOARDMODE_ALL: number;
  14410. /**
  14411. * Object will rotate to face the camera's position instead of orientation
  14412. */
  14413. static BILLBOARDMODE_USE_POSITION: number;
  14414. private _forward;
  14415. private _forwardInverted;
  14416. private _up;
  14417. private _right;
  14418. private _rightInverted;
  14419. private _position;
  14420. private _rotation;
  14421. private _rotationQuaternion;
  14422. protected _scaling: Vector3;
  14423. protected _isDirty: boolean;
  14424. private _transformToBoneReferal;
  14425. private _isAbsoluteSynced;
  14426. private _billboardMode;
  14427. /**
  14428. * Gets or sets the billboard mode. Default is 0.
  14429. *
  14430. * | Value | Type | Description |
  14431. * | --- | --- | --- |
  14432. * | 0 | BILLBOARDMODE_NONE | |
  14433. * | 1 | BILLBOARDMODE_X | |
  14434. * | 2 | BILLBOARDMODE_Y | |
  14435. * | 4 | BILLBOARDMODE_Z | |
  14436. * | 7 | BILLBOARDMODE_ALL | |
  14437. *
  14438. */
  14439. get billboardMode(): number;
  14440. set billboardMode(value: number);
  14441. private _preserveParentRotationForBillboard;
  14442. /**
  14443. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14444. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14445. */
  14446. get preserveParentRotationForBillboard(): boolean;
  14447. set preserveParentRotationForBillboard(value: boolean);
  14448. /**
  14449. * 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
  14450. */
  14451. scalingDeterminant: number;
  14452. private _infiniteDistance;
  14453. /**
  14454. * Gets or sets the distance of the object to max, often used by skybox
  14455. */
  14456. get infiniteDistance(): boolean;
  14457. set infiniteDistance(value: boolean);
  14458. /**
  14459. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14460. * By default the system will update normals to compensate
  14461. */
  14462. ignoreNonUniformScaling: boolean;
  14463. /**
  14464. * 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
  14465. */
  14466. reIntegrateRotationIntoRotationQuaternion: boolean;
  14467. /** @hidden */
  14468. _poseMatrix: Nullable<Matrix>;
  14469. /** @hidden */
  14470. _localMatrix: Matrix;
  14471. private _usePivotMatrix;
  14472. private _absolutePosition;
  14473. private _absoluteScaling;
  14474. private _absoluteRotationQuaternion;
  14475. private _pivotMatrix;
  14476. private _pivotMatrixInverse;
  14477. protected _postMultiplyPivotMatrix: boolean;
  14478. protected _isWorldMatrixFrozen: boolean;
  14479. /** @hidden */
  14480. _indexInSceneTransformNodesArray: number;
  14481. /**
  14482. * An event triggered after the world matrix is updated
  14483. */
  14484. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14485. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14486. /**
  14487. * Gets a string identifying the name of the class
  14488. * @returns "TransformNode" string
  14489. */
  14490. getClassName(): string;
  14491. /**
  14492. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14493. */
  14494. get position(): Vector3;
  14495. set position(newPosition: Vector3);
  14496. /**
  14497. * 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)).
  14498. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14499. */
  14500. get rotation(): Vector3;
  14501. set rotation(newRotation: Vector3);
  14502. /**
  14503. * 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)).
  14504. */
  14505. get scaling(): Vector3;
  14506. set scaling(newScaling: Vector3);
  14507. /**
  14508. * 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).
  14509. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14510. */
  14511. get rotationQuaternion(): Nullable<Quaternion>;
  14512. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14513. /**
  14514. * The forward direction of that transform in world space.
  14515. */
  14516. get forward(): Vector3;
  14517. /**
  14518. * The up direction of that transform in world space.
  14519. */
  14520. get up(): Vector3;
  14521. /**
  14522. * The right direction of that transform in world space.
  14523. */
  14524. get right(): Vector3;
  14525. /**
  14526. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14527. * @param matrix the matrix to copy the pose from
  14528. * @returns this TransformNode.
  14529. */
  14530. updatePoseMatrix(matrix: Matrix): TransformNode;
  14531. /**
  14532. * Returns the mesh Pose matrix.
  14533. * @returns the pose matrix
  14534. */
  14535. getPoseMatrix(): Matrix;
  14536. /** @hidden */
  14537. _isSynchronized(): boolean;
  14538. /** @hidden */
  14539. _initCache(): void;
  14540. /**
  14541. * Flag the transform node as dirty (Forcing it to update everything)
  14542. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14543. * @returns this transform node
  14544. */
  14545. markAsDirty(property: string): TransformNode;
  14546. /**
  14547. * Returns the current mesh absolute position.
  14548. * Returns a Vector3.
  14549. */
  14550. get absolutePosition(): Vector3;
  14551. /**
  14552. * Returns the current mesh absolute scaling.
  14553. * Returns a Vector3.
  14554. */
  14555. get absoluteScaling(): Vector3;
  14556. /**
  14557. * Returns the current mesh absolute rotation.
  14558. * Returns a Quaternion.
  14559. */
  14560. get absoluteRotationQuaternion(): Quaternion;
  14561. /**
  14562. * Sets a new matrix to apply before all other transformation
  14563. * @param matrix defines the transform matrix
  14564. * @returns the current TransformNode
  14565. */
  14566. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14567. /**
  14568. * Sets a new pivot matrix to the current node
  14569. * @param matrix defines the new pivot matrix to use
  14570. * @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
  14571. * @returns the current TransformNode
  14572. */
  14573. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14574. /**
  14575. * Returns the mesh pivot matrix.
  14576. * Default : Identity.
  14577. * @returns the matrix
  14578. */
  14579. getPivotMatrix(): Matrix;
  14580. /**
  14581. * Instantiate (when possible) or clone that node with its hierarchy
  14582. * @param newParent defines the new parent to use for the instance (or clone)
  14583. * @param options defines options to configure how copy is done
  14584. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14585. * @returns an instance (or a clone) of the current node with its hiearchy
  14586. */
  14587. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14588. doNotInstantiate: boolean;
  14589. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14590. /**
  14591. * Prevents the World matrix to be computed any longer
  14592. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14593. * @returns the TransformNode.
  14594. */
  14595. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14596. /**
  14597. * Allows back the World matrix computation.
  14598. * @returns the TransformNode.
  14599. */
  14600. unfreezeWorldMatrix(): this;
  14601. /**
  14602. * True if the World matrix has been frozen.
  14603. */
  14604. get isWorldMatrixFrozen(): boolean;
  14605. /**
  14606. * Retuns the mesh absolute position in the World.
  14607. * @returns a Vector3.
  14608. */
  14609. getAbsolutePosition(): Vector3;
  14610. /**
  14611. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14612. * @param absolutePosition the absolute position to set
  14613. * @returns the TransformNode.
  14614. */
  14615. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14616. /**
  14617. * Sets the mesh position in its local space.
  14618. * @param vector3 the position to set in localspace
  14619. * @returns the TransformNode.
  14620. */
  14621. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14622. /**
  14623. * Returns the mesh position in the local space from the current World matrix values.
  14624. * @returns a new Vector3.
  14625. */
  14626. getPositionExpressedInLocalSpace(): Vector3;
  14627. /**
  14628. * Translates the mesh along the passed Vector3 in its local space.
  14629. * @param vector3 the distance to translate in localspace
  14630. * @returns the TransformNode.
  14631. */
  14632. locallyTranslate(vector3: Vector3): TransformNode;
  14633. private static _lookAtVectorCache;
  14634. /**
  14635. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14636. * @param targetPoint the position (must be in same space as current mesh) to look at
  14637. * @param yawCor optional yaw (y-axis) correction in radians
  14638. * @param pitchCor optional pitch (x-axis) correction in radians
  14639. * @param rollCor optional roll (z-axis) correction in radians
  14640. * @param space the choosen space of the target
  14641. * @returns the TransformNode.
  14642. */
  14643. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14644. /**
  14645. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14646. * This Vector3 is expressed in the World space.
  14647. * @param localAxis axis to rotate
  14648. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14649. */
  14650. getDirection(localAxis: Vector3): Vector3;
  14651. /**
  14652. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14653. * localAxis is expressed in the mesh local space.
  14654. * result is computed in the Wordl space from the mesh World matrix.
  14655. * @param localAxis axis to rotate
  14656. * @param result the resulting transformnode
  14657. * @returns this TransformNode.
  14658. */
  14659. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14660. /**
  14661. * Sets this transform node rotation to the given local axis.
  14662. * @param localAxis the axis in local space
  14663. * @param yawCor optional yaw (y-axis) correction in radians
  14664. * @param pitchCor optional pitch (x-axis) correction in radians
  14665. * @param rollCor optional roll (z-axis) correction in radians
  14666. * @returns this TransformNode
  14667. */
  14668. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14669. /**
  14670. * Sets a new pivot point to the current node
  14671. * @param point defines the new pivot point to use
  14672. * @param space defines if the point is in world or local space (local by default)
  14673. * @returns the current TransformNode
  14674. */
  14675. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14676. /**
  14677. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14678. * @returns the pivot point
  14679. */
  14680. getPivotPoint(): Vector3;
  14681. /**
  14682. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14683. * @param result the vector3 to store the result
  14684. * @returns this TransformNode.
  14685. */
  14686. getPivotPointToRef(result: Vector3): TransformNode;
  14687. /**
  14688. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14689. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14690. */
  14691. getAbsolutePivotPoint(): Vector3;
  14692. /**
  14693. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14694. * @param result vector3 to store the result
  14695. * @returns this TransformNode.
  14696. */
  14697. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14698. /**
  14699. * Defines the passed node as the parent of the current node.
  14700. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14701. * @see https://doc.babylonjs.com/how_to/parenting
  14702. * @param node the node ot set as the parent
  14703. * @returns this TransformNode.
  14704. */
  14705. setParent(node: Nullable<Node>): TransformNode;
  14706. private _nonUniformScaling;
  14707. /**
  14708. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14709. */
  14710. get nonUniformScaling(): boolean;
  14711. /** @hidden */
  14712. _updateNonUniformScalingState(value: boolean): boolean;
  14713. /**
  14714. * Attach the current TransformNode to another TransformNode associated with a bone
  14715. * @param bone Bone affecting the TransformNode
  14716. * @param affectedTransformNode TransformNode associated with the bone
  14717. * @returns this object
  14718. */
  14719. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14720. /**
  14721. * Detach the transform node if its associated with a bone
  14722. * @returns this object
  14723. */
  14724. detachFromBone(): TransformNode;
  14725. private static _rotationAxisCache;
  14726. /**
  14727. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14728. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14729. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14730. * The passed axis is also normalized.
  14731. * @param axis the axis to rotate around
  14732. * @param amount the amount to rotate in radians
  14733. * @param space Space to rotate in (Default: local)
  14734. * @returns the TransformNode.
  14735. */
  14736. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14737. /**
  14738. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14739. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14740. * The passed axis is also normalized. .
  14741. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14742. * @param point the point to rotate around
  14743. * @param axis the axis to rotate around
  14744. * @param amount the amount to rotate in radians
  14745. * @returns the TransformNode
  14746. */
  14747. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14748. /**
  14749. * Translates the mesh along the axis vector for the passed distance in the given space.
  14750. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14751. * @param axis the axis to translate in
  14752. * @param distance the distance to translate
  14753. * @param space Space to rotate in (Default: local)
  14754. * @returns the TransformNode.
  14755. */
  14756. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14757. /**
  14758. * Adds a rotation step to the mesh current rotation.
  14759. * x, y, z are Euler angles expressed in radians.
  14760. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14761. * This means this rotation is made in the mesh local space only.
  14762. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14763. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14764. * ```javascript
  14765. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14766. * ```
  14767. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14768. * 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.
  14769. * @param x Rotation to add
  14770. * @param y Rotation to add
  14771. * @param z Rotation to add
  14772. * @returns the TransformNode.
  14773. */
  14774. addRotation(x: number, y: number, z: number): TransformNode;
  14775. /**
  14776. * @hidden
  14777. */
  14778. protected _getEffectiveParent(): Nullable<Node>;
  14779. /**
  14780. * Computes the world matrix of the node
  14781. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14782. * @returns the world matrix
  14783. */
  14784. computeWorldMatrix(force?: boolean): Matrix;
  14785. protected _afterComputeWorldMatrix(): void;
  14786. /**
  14787. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14788. * @param func callback function to add
  14789. *
  14790. * @returns the TransformNode.
  14791. */
  14792. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14793. /**
  14794. * Removes a registered callback function.
  14795. * @param func callback function to remove
  14796. * @returns the TransformNode.
  14797. */
  14798. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14799. /**
  14800. * Gets the position of the current mesh in camera space
  14801. * @param camera defines the camera to use
  14802. * @returns a position
  14803. */
  14804. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14805. /**
  14806. * Returns the distance from the mesh to the active camera
  14807. * @param camera defines the camera to use
  14808. * @returns the distance
  14809. */
  14810. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14811. /**
  14812. * Clone the current transform node
  14813. * @param name Name of the new clone
  14814. * @param newParent New parent for the clone
  14815. * @param doNotCloneChildren Do not clone children hierarchy
  14816. * @returns the new transform node
  14817. */
  14818. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14819. /**
  14820. * Serializes the objects information.
  14821. * @param currentSerializationObject defines the object to serialize in
  14822. * @returns the serialized object
  14823. */
  14824. serialize(currentSerializationObject?: any): any;
  14825. /**
  14826. * Returns a new TransformNode object parsed from the source provided.
  14827. * @param parsedTransformNode is the source.
  14828. * @param scene the scne the object belongs to
  14829. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14830. * @returns a new TransformNode object parsed from the source provided.
  14831. */
  14832. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14833. /**
  14834. * Get all child-transformNodes of this node
  14835. * @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
  14836. * @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
  14837. * @returns an array of TransformNode
  14838. */
  14839. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14840. /**
  14841. * Releases resources associated with this transform node.
  14842. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14843. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14844. */
  14845. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14846. /**
  14847. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14848. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14849. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14850. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14851. * @returns the current mesh
  14852. */
  14853. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14854. private _syncAbsoluteScalingAndRotation;
  14855. }
  14856. }
  14857. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14858. import { Observable } from "babylonjs/Misc/observable";
  14859. import { Nullable } from "babylonjs/types";
  14860. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14861. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14863. import { Ray } from "babylonjs/Culling/ray";
  14864. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14865. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14866. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14867. /**
  14868. * Defines the types of pose enabled controllers that are supported
  14869. */
  14870. export enum PoseEnabledControllerType {
  14871. /**
  14872. * HTC Vive
  14873. */
  14874. VIVE = 0,
  14875. /**
  14876. * Oculus Rift
  14877. */
  14878. OCULUS = 1,
  14879. /**
  14880. * Windows mixed reality
  14881. */
  14882. WINDOWS = 2,
  14883. /**
  14884. * Samsung gear VR
  14885. */
  14886. GEAR_VR = 3,
  14887. /**
  14888. * Google Daydream
  14889. */
  14890. DAYDREAM = 4,
  14891. /**
  14892. * Generic
  14893. */
  14894. GENERIC = 5
  14895. }
  14896. /**
  14897. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14898. */
  14899. export interface MutableGamepadButton {
  14900. /**
  14901. * Value of the button/trigger
  14902. */
  14903. value: number;
  14904. /**
  14905. * If the button/trigger is currently touched
  14906. */
  14907. touched: boolean;
  14908. /**
  14909. * If the button/trigger is currently pressed
  14910. */
  14911. pressed: boolean;
  14912. }
  14913. /**
  14914. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14915. * @hidden
  14916. */
  14917. export interface ExtendedGamepadButton extends GamepadButton {
  14918. /**
  14919. * If the button/trigger is currently pressed
  14920. */
  14921. readonly pressed: boolean;
  14922. /**
  14923. * If the button/trigger is currently touched
  14924. */
  14925. readonly touched: boolean;
  14926. /**
  14927. * Value of the button/trigger
  14928. */
  14929. readonly value: number;
  14930. }
  14931. /** @hidden */
  14932. export interface _GamePadFactory {
  14933. /**
  14934. * Returns wether or not the current gamepad can be created for this type of controller.
  14935. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14936. * @returns true if it can be created, otherwise false
  14937. */
  14938. canCreate(gamepadInfo: any): boolean;
  14939. /**
  14940. * Creates a new instance of the Gamepad.
  14941. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14942. * @returns the new gamepad instance
  14943. */
  14944. create(gamepadInfo: any): Gamepad;
  14945. }
  14946. /**
  14947. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14948. */
  14949. export class PoseEnabledControllerHelper {
  14950. /** @hidden */
  14951. static _ControllerFactories: _GamePadFactory[];
  14952. /** @hidden */
  14953. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14954. /**
  14955. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14956. * @param vrGamepad the gamepad to initialized
  14957. * @returns a vr controller of the type the gamepad identified as
  14958. */
  14959. static InitiateController(vrGamepad: any): Gamepad;
  14960. }
  14961. /**
  14962. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14963. */
  14964. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14965. /**
  14966. * If the controller is used in a webXR session
  14967. */
  14968. isXR: boolean;
  14969. private _deviceRoomPosition;
  14970. private _deviceRoomRotationQuaternion;
  14971. /**
  14972. * The device position in babylon space
  14973. */
  14974. devicePosition: Vector3;
  14975. /**
  14976. * The device rotation in babylon space
  14977. */
  14978. deviceRotationQuaternion: Quaternion;
  14979. /**
  14980. * The scale factor of the device in babylon space
  14981. */
  14982. deviceScaleFactor: number;
  14983. /**
  14984. * (Likely devicePosition should be used instead) The device position in its room space
  14985. */
  14986. position: Vector3;
  14987. /**
  14988. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14989. */
  14990. rotationQuaternion: Quaternion;
  14991. /**
  14992. * The type of controller (Eg. Windows mixed reality)
  14993. */
  14994. controllerType: PoseEnabledControllerType;
  14995. protected _calculatedPosition: Vector3;
  14996. private _calculatedRotation;
  14997. /**
  14998. * The raw pose from the device
  14999. */
  15000. rawPose: DevicePose;
  15001. private _trackPosition;
  15002. private _maxRotationDistFromHeadset;
  15003. private _draggedRoomRotation;
  15004. /**
  15005. * @hidden
  15006. */
  15007. _disableTrackPosition(fixedPosition: Vector3): void;
  15008. /**
  15009. * Internal, the mesh attached to the controller
  15010. * @hidden
  15011. */
  15012. _mesh: Nullable<AbstractMesh>;
  15013. private _poseControlledCamera;
  15014. private _leftHandSystemQuaternion;
  15015. /**
  15016. * Internal, matrix used to convert room space to babylon space
  15017. * @hidden
  15018. */
  15019. _deviceToWorld: Matrix;
  15020. /**
  15021. * Node to be used when casting a ray from the controller
  15022. * @hidden
  15023. */
  15024. _pointingPoseNode: Nullable<TransformNode>;
  15025. /**
  15026. * Name of the child mesh that can be used to cast a ray from the controller
  15027. */
  15028. static readonly POINTING_POSE: string;
  15029. /**
  15030. * Creates a new PoseEnabledController from a gamepad
  15031. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15032. */
  15033. constructor(browserGamepad: any);
  15034. private _workingMatrix;
  15035. /**
  15036. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15037. */
  15038. update(): void;
  15039. /**
  15040. * Updates only the pose device and mesh without doing any button event checking
  15041. */
  15042. protected _updatePoseAndMesh(): void;
  15043. /**
  15044. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15045. * @param poseData raw pose fromthe device
  15046. */
  15047. updateFromDevice(poseData: DevicePose): void;
  15048. /**
  15049. * @hidden
  15050. */
  15051. _meshAttachedObservable: Observable<AbstractMesh>;
  15052. /**
  15053. * Attaches a mesh to the controller
  15054. * @param mesh the mesh to be attached
  15055. */
  15056. attachToMesh(mesh: AbstractMesh): void;
  15057. /**
  15058. * Attaches the controllers mesh to a camera
  15059. * @param camera the camera the mesh should be attached to
  15060. */
  15061. attachToPoseControlledCamera(camera: TargetCamera): void;
  15062. /**
  15063. * Disposes of the controller
  15064. */
  15065. dispose(): void;
  15066. /**
  15067. * The mesh that is attached to the controller
  15068. */
  15069. get mesh(): Nullable<AbstractMesh>;
  15070. /**
  15071. * Gets the ray of the controller in the direction the controller is pointing
  15072. * @param length the length the resulting ray should be
  15073. * @returns a ray in the direction the controller is pointing
  15074. */
  15075. getForwardRay(length?: number): Ray;
  15076. }
  15077. }
  15078. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15079. import { Observable } from "babylonjs/Misc/observable";
  15080. import { Scene } from "babylonjs/scene";
  15081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15082. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15083. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15084. import { Nullable } from "babylonjs/types";
  15085. /**
  15086. * Defines the WebVRController object that represents controllers tracked in 3D space
  15087. */
  15088. export abstract class WebVRController extends PoseEnabledController {
  15089. /**
  15090. * Internal, the default controller model for the controller
  15091. */
  15092. protected _defaultModel: Nullable<AbstractMesh>;
  15093. /**
  15094. * Fired when the trigger state has changed
  15095. */
  15096. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15097. /**
  15098. * Fired when the main button state has changed
  15099. */
  15100. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15101. /**
  15102. * Fired when the secondary button state has changed
  15103. */
  15104. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15105. /**
  15106. * Fired when the pad state has changed
  15107. */
  15108. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15109. /**
  15110. * Fired when controllers stick values have changed
  15111. */
  15112. onPadValuesChangedObservable: Observable<StickValues>;
  15113. /**
  15114. * Array of button availible on the controller
  15115. */
  15116. protected _buttons: Array<MutableGamepadButton>;
  15117. private _onButtonStateChange;
  15118. /**
  15119. * Fired when a controller button's state has changed
  15120. * @param callback the callback containing the button that was modified
  15121. */
  15122. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15123. /**
  15124. * X and Y axis corresponding to the controllers joystick
  15125. */
  15126. pad: StickValues;
  15127. /**
  15128. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15129. */
  15130. hand: string;
  15131. /**
  15132. * The default controller model for the controller
  15133. */
  15134. get defaultModel(): Nullable<AbstractMesh>;
  15135. /**
  15136. * Creates a new WebVRController from a gamepad
  15137. * @param vrGamepad the gamepad that the WebVRController should be created from
  15138. */
  15139. constructor(vrGamepad: any);
  15140. /**
  15141. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15142. */
  15143. update(): void;
  15144. /**
  15145. * Function to be called when a button is modified
  15146. */
  15147. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15148. /**
  15149. * Loads a mesh and attaches it to the controller
  15150. * @param scene the scene the mesh should be added to
  15151. * @param meshLoaded callback for when the mesh has been loaded
  15152. */
  15153. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15154. private _setButtonValue;
  15155. private _changes;
  15156. private _checkChanges;
  15157. /**
  15158. * Disposes of th webVRCOntroller
  15159. */
  15160. dispose(): void;
  15161. }
  15162. }
  15163. declare module "babylonjs/Lights/hemisphericLight" {
  15164. import { Nullable } from "babylonjs/types";
  15165. import { Scene } from "babylonjs/scene";
  15166. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15167. import { Color3 } from "babylonjs/Maths/math.color";
  15168. import { Effect } from "babylonjs/Materials/effect";
  15169. import { Light } from "babylonjs/Lights/light";
  15170. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15171. /**
  15172. * The HemisphericLight simulates the ambient environment light,
  15173. * so the passed direction is the light reflection direction, not the incoming direction.
  15174. */
  15175. export class HemisphericLight extends Light {
  15176. /**
  15177. * The groundColor is the light in the opposite direction to the one specified during creation.
  15178. * 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.
  15179. */
  15180. groundColor: Color3;
  15181. /**
  15182. * The light reflection direction, not the incoming direction.
  15183. */
  15184. direction: Vector3;
  15185. /**
  15186. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15187. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15188. * The HemisphericLight can't cast shadows.
  15189. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15190. * @param name The friendly name of the light
  15191. * @param direction The direction of the light reflection
  15192. * @param scene The scene the light belongs to
  15193. */
  15194. constructor(name: string, direction: Vector3, scene: Scene);
  15195. protected _buildUniformLayout(): void;
  15196. /**
  15197. * Returns the string "HemisphericLight".
  15198. * @return The class name
  15199. */
  15200. getClassName(): string;
  15201. /**
  15202. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15203. * Returns the updated direction.
  15204. * @param target The target the direction should point to
  15205. * @return The computed direction
  15206. */
  15207. setDirectionToTarget(target: Vector3): Vector3;
  15208. /**
  15209. * Returns the shadow generator associated to the light.
  15210. * @returns Always null for hemispheric lights because it does not support shadows.
  15211. */
  15212. getShadowGenerator(): Nullable<IShadowGenerator>;
  15213. /**
  15214. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15215. * @param effect The effect to update
  15216. * @param lightIndex The index of the light in the effect to update
  15217. * @returns The hemispheric light
  15218. */
  15219. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15220. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15221. /**
  15222. * Computes the world matrix of the node
  15223. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15224. * @param useWasUpdatedFlag defines a reserved property
  15225. * @returns the world matrix
  15226. */
  15227. computeWorldMatrix(): Matrix;
  15228. /**
  15229. * Returns the integer 3.
  15230. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15231. */
  15232. getTypeID(): number;
  15233. /**
  15234. * Prepares the list of defines specific to the light type.
  15235. * @param defines the list of defines
  15236. * @param lightIndex defines the index of the light for the effect
  15237. */
  15238. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15239. }
  15240. }
  15241. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15242. /** @hidden */
  15243. export var vrMultiviewToSingleviewPixelShader: {
  15244. name: string;
  15245. shader: string;
  15246. };
  15247. }
  15248. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15249. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15250. import { Scene } from "babylonjs/scene";
  15251. /**
  15252. * Renders to multiple views with a single draw call
  15253. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15254. */
  15255. export class MultiviewRenderTarget extends RenderTargetTexture {
  15256. /**
  15257. * Creates a multiview render target
  15258. * @param scene scene used with the render target
  15259. * @param size the size of the render target (used for each view)
  15260. */
  15261. constructor(scene: Scene, size?: number | {
  15262. width: number;
  15263. height: number;
  15264. } | {
  15265. ratio: number;
  15266. });
  15267. /**
  15268. * @hidden
  15269. * @param faceIndex the face index, if its a cube texture
  15270. */
  15271. _bindFrameBuffer(faceIndex?: number): void;
  15272. /**
  15273. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15274. * @returns the view count
  15275. */
  15276. getViewCount(): number;
  15277. }
  15278. }
  15279. declare module "babylonjs/Maths/math.frustum" {
  15280. import { Matrix } from "babylonjs/Maths/math.vector";
  15281. import { DeepImmutable } from "babylonjs/types";
  15282. import { Plane } from "babylonjs/Maths/math.plane";
  15283. /**
  15284. * Represents a camera frustum
  15285. */
  15286. export class Frustum {
  15287. /**
  15288. * Gets the planes representing the frustum
  15289. * @param transform matrix to be applied to the returned planes
  15290. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15291. */
  15292. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15293. /**
  15294. * Gets the near frustum plane transformed by the transform matrix
  15295. * @param transform transformation matrix to be applied to the resulting frustum plane
  15296. * @param frustumPlane the resuling frustum plane
  15297. */
  15298. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15299. /**
  15300. * Gets the far frustum plane transformed by the transform matrix
  15301. * @param transform transformation matrix to be applied to the resulting frustum plane
  15302. * @param frustumPlane the resuling frustum plane
  15303. */
  15304. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15305. /**
  15306. * Gets the left frustum plane transformed by the transform matrix
  15307. * @param transform transformation matrix to be applied to the resulting frustum plane
  15308. * @param frustumPlane the resuling frustum plane
  15309. */
  15310. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15311. /**
  15312. * Gets the right frustum plane transformed by the transform matrix
  15313. * @param transform transformation matrix to be applied to the resulting frustum plane
  15314. * @param frustumPlane the resuling frustum plane
  15315. */
  15316. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15317. /**
  15318. * Gets the top frustum plane transformed by the transform matrix
  15319. * @param transform transformation matrix to be applied to the resulting frustum plane
  15320. * @param frustumPlane the resuling frustum plane
  15321. */
  15322. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15323. /**
  15324. * Gets the bottom frustum plane transformed by the transform matrix
  15325. * @param transform transformation matrix to be applied to the resulting frustum plane
  15326. * @param frustumPlane the resuling frustum plane
  15327. */
  15328. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15329. /**
  15330. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15331. * @param transform transformation matrix to be applied to the resulting frustum planes
  15332. * @param frustumPlanes the resuling frustum planes
  15333. */
  15334. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15335. }
  15336. }
  15337. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15338. import { Camera } from "babylonjs/Cameras/camera";
  15339. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15340. import { Nullable } from "babylonjs/types";
  15341. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15342. import { Matrix } from "babylonjs/Maths/math.vector";
  15343. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15344. module "babylonjs/Engines/engine" {
  15345. interface Engine {
  15346. /**
  15347. * Creates a new multiview render target
  15348. * @param width defines the width of the texture
  15349. * @param height defines the height of the texture
  15350. * @returns the created multiview texture
  15351. */
  15352. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15353. /**
  15354. * Binds a multiview framebuffer to be drawn to
  15355. * @param multiviewTexture texture to bind
  15356. */
  15357. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15358. }
  15359. }
  15360. module "babylonjs/Cameras/camera" {
  15361. interface Camera {
  15362. /**
  15363. * @hidden
  15364. * 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)
  15365. */
  15366. _useMultiviewToSingleView: boolean;
  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. _multiviewTexture: Nullable<RenderTargetTexture>;
  15372. /**
  15373. * @hidden
  15374. * ensures the multiview texture of the camera exists and has the specified width/height
  15375. * @param width height to set on the multiview texture
  15376. * @param height width to set on the multiview texture
  15377. */
  15378. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15379. }
  15380. }
  15381. module "babylonjs/scene" {
  15382. interface Scene {
  15383. /** @hidden */
  15384. _transformMatrixR: Matrix;
  15385. /** @hidden */
  15386. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15387. /** @hidden */
  15388. _createMultiviewUbo(): void;
  15389. /** @hidden */
  15390. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15391. /** @hidden */
  15392. _renderMultiviewToSingleView(camera: Camera): void;
  15393. }
  15394. }
  15395. }
  15396. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15397. import { Camera } from "babylonjs/Cameras/camera";
  15398. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15399. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15400. import "babylonjs/Engines/Extensions/engine.multiview";
  15401. /**
  15402. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15403. * This will not be used for webXR as it supports displaying texture arrays directly
  15404. */
  15405. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15406. /**
  15407. * Initializes a VRMultiviewToSingleview
  15408. * @param name name of the post process
  15409. * @param camera camera to be applied to
  15410. * @param scaleFactor scaling factor to the size of the output texture
  15411. */
  15412. constructor(name: string, camera: Camera, scaleFactor: number);
  15413. }
  15414. }
  15415. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15416. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15417. import { Nullable } from "babylonjs/types";
  15418. import { Size } from "babylonjs/Maths/math.size";
  15419. import { Observable } from "babylonjs/Misc/observable";
  15420. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15421. /**
  15422. * Interface used to define additional presentation attributes
  15423. */
  15424. export interface IVRPresentationAttributes {
  15425. /**
  15426. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15427. */
  15428. highRefreshRate: boolean;
  15429. /**
  15430. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15431. */
  15432. foveationLevel: number;
  15433. }
  15434. module "babylonjs/Engines/engine" {
  15435. interface Engine {
  15436. /** @hidden */
  15437. _vrDisplay: any;
  15438. /** @hidden */
  15439. _vrSupported: boolean;
  15440. /** @hidden */
  15441. _oldSize: Size;
  15442. /** @hidden */
  15443. _oldHardwareScaleFactor: number;
  15444. /** @hidden */
  15445. _vrExclusivePointerMode: boolean;
  15446. /** @hidden */
  15447. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15448. /** @hidden */
  15449. _onVRDisplayPointerRestricted: () => void;
  15450. /** @hidden */
  15451. _onVRDisplayPointerUnrestricted: () => void;
  15452. /** @hidden */
  15453. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15454. /** @hidden */
  15455. _onVrDisplayDisconnect: Nullable<() => void>;
  15456. /** @hidden */
  15457. _onVrDisplayPresentChange: Nullable<() => void>;
  15458. /**
  15459. * Observable signaled when VR display mode changes
  15460. */
  15461. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15462. /**
  15463. * Observable signaled when VR request present is complete
  15464. */
  15465. onVRRequestPresentComplete: Observable<boolean>;
  15466. /**
  15467. * Observable signaled when VR request present starts
  15468. */
  15469. onVRRequestPresentStart: Observable<Engine>;
  15470. /**
  15471. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15472. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15473. */
  15474. isInVRExclusivePointerMode: boolean;
  15475. /**
  15476. * Gets a boolean indicating if a webVR device was detected
  15477. * @returns true if a webVR device was detected
  15478. */
  15479. isVRDevicePresent(): boolean;
  15480. /**
  15481. * Gets the current webVR device
  15482. * @returns the current webVR device (or null)
  15483. */
  15484. getVRDevice(): any;
  15485. /**
  15486. * Initializes a webVR display and starts listening to display change events
  15487. * The onVRDisplayChangedObservable will be notified upon these changes
  15488. * @returns A promise containing a VRDisplay and if vr is supported
  15489. */
  15490. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15491. /** @hidden */
  15492. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15493. /**
  15494. * Gets or sets the presentation attributes used to configure VR rendering
  15495. */
  15496. vrPresentationAttributes?: IVRPresentationAttributes;
  15497. /**
  15498. * Call this function to switch to webVR mode
  15499. * Will do nothing if webVR is not supported or if there is no webVR device
  15500. * @param options the webvr options provided to the camera. mainly used for multiview
  15501. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15502. */
  15503. enableVR(options: WebVROptions): void;
  15504. /** @hidden */
  15505. _onVRFullScreenTriggered(): void;
  15506. }
  15507. }
  15508. }
  15509. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15510. import { Nullable } from "babylonjs/types";
  15511. import { Observable } from "babylonjs/Misc/observable";
  15512. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15513. import { Scene } from "babylonjs/scene";
  15514. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15515. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15516. import { Node } from "babylonjs/node";
  15517. import { Ray } from "babylonjs/Culling/ray";
  15518. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15519. import "babylonjs/Engines/Extensions/engine.webVR";
  15520. /**
  15521. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15522. * IMPORTANT!! The data is right-hand data.
  15523. * @export
  15524. * @interface DevicePose
  15525. */
  15526. export interface DevicePose {
  15527. /**
  15528. * The position of the device, values in array are [x,y,z].
  15529. */
  15530. readonly position: Nullable<Float32Array>;
  15531. /**
  15532. * The linearVelocity of the device, values in array are [x,y,z].
  15533. */
  15534. readonly linearVelocity: Nullable<Float32Array>;
  15535. /**
  15536. * The linearAcceleration of the device, values in array are [x,y,z].
  15537. */
  15538. readonly linearAcceleration: Nullable<Float32Array>;
  15539. /**
  15540. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15541. */
  15542. readonly orientation: Nullable<Float32Array>;
  15543. /**
  15544. * The angularVelocity of the device, values in array are [x,y,z].
  15545. */
  15546. readonly angularVelocity: Nullable<Float32Array>;
  15547. /**
  15548. * The angularAcceleration of the device, values in array are [x,y,z].
  15549. */
  15550. readonly angularAcceleration: Nullable<Float32Array>;
  15551. }
  15552. /**
  15553. * Interface representing a pose controlled object in Babylon.
  15554. * A pose controlled object has both regular pose values as well as pose values
  15555. * from an external device such as a VR head mounted display
  15556. */
  15557. export interface PoseControlled {
  15558. /**
  15559. * The position of the object in babylon space.
  15560. */
  15561. position: Vector3;
  15562. /**
  15563. * The rotation quaternion of the object in babylon space.
  15564. */
  15565. rotationQuaternion: Quaternion;
  15566. /**
  15567. * The position of the device in babylon space.
  15568. */
  15569. devicePosition?: Vector3;
  15570. /**
  15571. * The rotation quaternion of the device in babylon space.
  15572. */
  15573. deviceRotationQuaternion: Quaternion;
  15574. /**
  15575. * The raw pose coming from the device.
  15576. */
  15577. rawPose: Nullable<DevicePose>;
  15578. /**
  15579. * The scale of the device to be used when translating from device space to babylon space.
  15580. */
  15581. deviceScaleFactor: number;
  15582. /**
  15583. * Updates the poseControlled values based on the input device pose.
  15584. * @param poseData the pose data to update the object with
  15585. */
  15586. updateFromDevice(poseData: DevicePose): void;
  15587. }
  15588. /**
  15589. * Set of options to customize the webVRCamera
  15590. */
  15591. export interface WebVROptions {
  15592. /**
  15593. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15594. */
  15595. trackPosition?: boolean;
  15596. /**
  15597. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15598. */
  15599. positionScale?: number;
  15600. /**
  15601. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15602. */
  15603. displayName?: string;
  15604. /**
  15605. * Should the native controller meshes be initialized. (default: true)
  15606. */
  15607. controllerMeshes?: boolean;
  15608. /**
  15609. * Creating a default HemiLight only on controllers. (default: true)
  15610. */
  15611. defaultLightingOnControllers?: boolean;
  15612. /**
  15613. * If you don't want to use the default VR button of the helper. (default: false)
  15614. */
  15615. useCustomVRButton?: boolean;
  15616. /**
  15617. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15618. */
  15619. customVRButton?: HTMLButtonElement;
  15620. /**
  15621. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15622. */
  15623. rayLength?: number;
  15624. /**
  15625. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15626. */
  15627. defaultHeight?: number;
  15628. /**
  15629. * If multiview should be used if availible (default: false)
  15630. */
  15631. useMultiview?: boolean;
  15632. }
  15633. /**
  15634. * This represents a WebVR camera.
  15635. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15636. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15637. */
  15638. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15639. private webVROptions;
  15640. /**
  15641. * @hidden
  15642. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15643. */
  15644. _vrDevice: any;
  15645. /**
  15646. * The rawPose of the vrDevice.
  15647. */
  15648. rawPose: Nullable<DevicePose>;
  15649. private _onVREnabled;
  15650. private _specsVersion;
  15651. private _attached;
  15652. private _frameData;
  15653. protected _descendants: Array<Node>;
  15654. private _deviceRoomPosition;
  15655. /** @hidden */
  15656. _deviceRoomRotationQuaternion: Quaternion;
  15657. private _standingMatrix;
  15658. /**
  15659. * Represents device position in babylon space.
  15660. */
  15661. devicePosition: Vector3;
  15662. /**
  15663. * Represents device rotation in babylon space.
  15664. */
  15665. deviceRotationQuaternion: Quaternion;
  15666. /**
  15667. * The scale of the device to be used when translating from device space to babylon space.
  15668. */
  15669. deviceScaleFactor: number;
  15670. private _deviceToWorld;
  15671. private _worldToDevice;
  15672. /**
  15673. * References to the webVR controllers for the vrDevice.
  15674. */
  15675. controllers: Array<WebVRController>;
  15676. /**
  15677. * Emits an event when a controller is attached.
  15678. */
  15679. onControllersAttachedObservable: Observable<WebVRController[]>;
  15680. /**
  15681. * Emits an event when a controller's mesh has been loaded;
  15682. */
  15683. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15684. /**
  15685. * Emits an event when the HMD's pose has been updated.
  15686. */
  15687. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15688. private _poseSet;
  15689. /**
  15690. * If the rig cameras be used as parent instead of this camera.
  15691. */
  15692. rigParenting: boolean;
  15693. private _lightOnControllers;
  15694. private _defaultHeight?;
  15695. /**
  15696. * Instantiates a WebVRFreeCamera.
  15697. * @param name The name of the WebVRFreeCamera
  15698. * @param position The starting anchor position for the camera
  15699. * @param scene The scene the camera belongs to
  15700. * @param webVROptions a set of customizable options for the webVRCamera
  15701. */
  15702. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15703. /**
  15704. * Gets the device distance from the ground in meters.
  15705. * @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.
  15706. */
  15707. deviceDistanceToRoomGround(): number;
  15708. /**
  15709. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15710. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15711. */
  15712. useStandingMatrix(callback?: (bool: boolean) => void): void;
  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. * @returns A promise with a boolean set to if the standing matrix is supported.
  15716. */
  15717. useStandingMatrixAsync(): Promise<boolean>;
  15718. /**
  15719. * Disposes the camera
  15720. */
  15721. dispose(): void;
  15722. /**
  15723. * Gets a vrController by name.
  15724. * @param name The name of the controller to retreive
  15725. * @returns the controller matching the name specified or null if not found
  15726. */
  15727. getControllerByName(name: string): Nullable<WebVRController>;
  15728. private _leftController;
  15729. /**
  15730. * The controller corresponding to the users left hand.
  15731. */
  15732. get leftController(): Nullable<WebVRController>;
  15733. private _rightController;
  15734. /**
  15735. * The controller corresponding to the users right hand.
  15736. */
  15737. get rightController(): Nullable<WebVRController>;
  15738. /**
  15739. * Casts a ray forward from the vrCamera's gaze.
  15740. * @param length Length of the ray (default: 100)
  15741. * @returns the ray corresponding to the gaze
  15742. */
  15743. getForwardRay(length?: number): Ray;
  15744. /**
  15745. * @hidden
  15746. * Updates the camera based on device's frame data
  15747. */
  15748. _checkInputs(): void;
  15749. /**
  15750. * Updates the poseControlled values based on the input device pose.
  15751. * @param poseData Pose coming from the device
  15752. */
  15753. updateFromDevice(poseData: DevicePose): void;
  15754. private _htmlElementAttached;
  15755. private _detachIfAttached;
  15756. /**
  15757. * WebVR's attach control will start broadcasting frames to the device.
  15758. * Note that in certain browsers (chrome for example) this function must be called
  15759. * within a user-interaction callback. Example:
  15760. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15761. *
  15762. * @param element html element to attach the vrDevice to
  15763. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15764. */
  15765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15766. /**
  15767. * Detaches the camera from the html element and disables VR
  15768. *
  15769. * @param element html element to detach from
  15770. */
  15771. detachControl(element: HTMLElement): void;
  15772. /**
  15773. * @returns the name of this class
  15774. */
  15775. getClassName(): string;
  15776. /**
  15777. * Calls resetPose on the vrDisplay
  15778. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15779. */
  15780. resetToCurrentRotation(): void;
  15781. /**
  15782. * @hidden
  15783. * Updates the rig cameras (left and right eye)
  15784. */
  15785. _updateRigCameras(): void;
  15786. private _workingVector;
  15787. private _oneVector;
  15788. private _workingMatrix;
  15789. private updateCacheCalled;
  15790. private _correctPositionIfNotTrackPosition;
  15791. /**
  15792. * @hidden
  15793. * Updates the cached values of the camera
  15794. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15795. */
  15796. _updateCache(ignoreParentClass?: boolean): void;
  15797. /**
  15798. * @hidden
  15799. * Get current device position in babylon world
  15800. */
  15801. _computeDevicePosition(): void;
  15802. /**
  15803. * Updates the current device position and rotation in the babylon world
  15804. */
  15805. update(): void;
  15806. /**
  15807. * @hidden
  15808. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15809. * @returns an identity matrix
  15810. */
  15811. _getViewMatrix(): Matrix;
  15812. private _tmpMatrix;
  15813. /**
  15814. * This function is called by the two RIG cameras.
  15815. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15816. * @hidden
  15817. */
  15818. _getWebVRViewMatrix(): Matrix;
  15819. /** @hidden */
  15820. _getWebVRProjectionMatrix(): Matrix;
  15821. private _onGamepadConnectedObserver;
  15822. private _onGamepadDisconnectedObserver;
  15823. private _updateCacheWhenTrackingDisabledObserver;
  15824. /**
  15825. * Initializes the controllers and their meshes
  15826. */
  15827. initControllers(): void;
  15828. }
  15829. }
  15830. declare module "babylonjs/PostProcesses/postProcess" {
  15831. import { Nullable } from "babylonjs/types";
  15832. import { SmartArray } from "babylonjs/Misc/smartArray";
  15833. import { Observable } from "babylonjs/Misc/observable";
  15834. import { Vector2 } from "babylonjs/Maths/math.vector";
  15835. import { Camera } from "babylonjs/Cameras/camera";
  15836. import { Effect } from "babylonjs/Materials/effect";
  15837. import "babylonjs/Shaders/postprocess.vertex";
  15838. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15839. import { Engine } from "babylonjs/Engines/engine";
  15840. import { Color4 } from "babylonjs/Maths/math.color";
  15841. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15843. /**
  15844. * Size options for a post process
  15845. */
  15846. export type PostProcessOptions = {
  15847. width: number;
  15848. height: number;
  15849. };
  15850. /**
  15851. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15852. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15853. */
  15854. export class PostProcess {
  15855. /** Name of the PostProcess. */
  15856. name: string;
  15857. /**
  15858. * Gets or sets the unique id of the post process
  15859. */
  15860. uniqueId: number;
  15861. /**
  15862. * Width of the texture to apply the post process on
  15863. */
  15864. width: number;
  15865. /**
  15866. * Height of the texture to apply the post process on
  15867. */
  15868. height: number;
  15869. /**
  15870. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15871. * @hidden
  15872. */
  15873. _outputTexture: Nullable<InternalTexture>;
  15874. /**
  15875. * Sampling mode used by the shader
  15876. * See https://doc.babylonjs.com/classes/3.1/texture
  15877. */
  15878. renderTargetSamplingMode: number;
  15879. /**
  15880. * Clear color to use when screen clearing
  15881. */
  15882. clearColor: Color4;
  15883. /**
  15884. * If the buffer needs to be cleared before applying the post process. (default: true)
  15885. * Should be set to false if shader will overwrite all previous pixels.
  15886. */
  15887. autoClear: boolean;
  15888. /**
  15889. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15890. */
  15891. alphaMode: number;
  15892. /**
  15893. * Sets the setAlphaBlendConstants of the babylon engine
  15894. */
  15895. alphaConstants: Color4;
  15896. /**
  15897. * Animations to be used for the post processing
  15898. */
  15899. animations: import("babylonjs/Animations/animation").Animation[];
  15900. /**
  15901. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15902. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15903. */
  15904. enablePixelPerfectMode: boolean;
  15905. /**
  15906. * Force the postprocess to be applied without taking in account viewport
  15907. */
  15908. forceFullscreenViewport: boolean;
  15909. /**
  15910. * List of inspectable custom properties (used by the Inspector)
  15911. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15912. */
  15913. inspectableCustomProperties: IInspectable[];
  15914. /**
  15915. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15916. *
  15917. * | Value | Type | Description |
  15918. * | ----- | ----------------------------------- | ----------- |
  15919. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15920. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15921. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15922. *
  15923. */
  15924. scaleMode: number;
  15925. /**
  15926. * Force textures to be a power of two (default: false)
  15927. */
  15928. alwaysForcePOT: boolean;
  15929. private _samples;
  15930. /**
  15931. * Number of sample textures (default: 1)
  15932. */
  15933. get samples(): number;
  15934. set samples(n: number);
  15935. /**
  15936. * Modify the scale of the post process to be the same as the viewport (default: false)
  15937. */
  15938. adaptScaleToCurrentViewport: boolean;
  15939. private _camera;
  15940. private _scene;
  15941. private _engine;
  15942. private _options;
  15943. private _reusable;
  15944. private _textureType;
  15945. /**
  15946. * Smart array of input and output textures for the post process.
  15947. * @hidden
  15948. */
  15949. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15950. /**
  15951. * The index in _textures that corresponds to the output texture.
  15952. * @hidden
  15953. */
  15954. _currentRenderTextureInd: number;
  15955. private _effect;
  15956. private _samplers;
  15957. private _fragmentUrl;
  15958. private _vertexUrl;
  15959. private _parameters;
  15960. private _scaleRatio;
  15961. protected _indexParameters: any;
  15962. private _shareOutputWithPostProcess;
  15963. private _texelSize;
  15964. private _forcedOutputTexture;
  15965. /**
  15966. * Returns the fragment url or shader name used in the post process.
  15967. * @returns the fragment url or name in the shader store.
  15968. */
  15969. getEffectName(): string;
  15970. /**
  15971. * An event triggered when the postprocess is activated.
  15972. */
  15973. onActivateObservable: Observable<Camera>;
  15974. private _onActivateObserver;
  15975. /**
  15976. * A function that is added to the onActivateObservable
  15977. */
  15978. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15979. /**
  15980. * An event triggered when the postprocess changes its size.
  15981. */
  15982. onSizeChangedObservable: Observable<PostProcess>;
  15983. private _onSizeChangedObserver;
  15984. /**
  15985. * A function that is added to the onSizeChangedObservable
  15986. */
  15987. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15988. /**
  15989. * An event triggered when the postprocess applies its effect.
  15990. */
  15991. onApplyObservable: Observable<Effect>;
  15992. private _onApplyObserver;
  15993. /**
  15994. * A function that is added to the onApplyObservable
  15995. */
  15996. set onApply(callback: (effect: Effect) => void);
  15997. /**
  15998. * An event triggered before rendering the postprocess
  15999. */
  16000. onBeforeRenderObservable: Observable<Effect>;
  16001. private _onBeforeRenderObserver;
  16002. /**
  16003. * A function that is added to the onBeforeRenderObservable
  16004. */
  16005. set onBeforeRender(callback: (effect: Effect) => void);
  16006. /**
  16007. * An event triggered after rendering the postprocess
  16008. */
  16009. onAfterRenderObservable: Observable<Effect>;
  16010. private _onAfterRenderObserver;
  16011. /**
  16012. * A function that is added to the onAfterRenderObservable
  16013. */
  16014. set onAfterRender(callback: (efect: Effect) => void);
  16015. /**
  16016. * 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
  16017. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  16018. */
  16019. get inputTexture(): InternalTexture;
  16020. set inputTexture(value: InternalTexture);
  16021. /**
  16022. * Gets the camera which post process is applied to.
  16023. * @returns The camera the post process is applied to.
  16024. */
  16025. getCamera(): Camera;
  16026. /**
  16027. * Gets the texel size of the postprocess.
  16028. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16029. */
  16030. get texelSize(): Vector2;
  16031. /**
  16032. * Creates a new instance PostProcess
  16033. * @param name The name of the PostProcess.
  16034. * @param fragmentUrl The url of the fragment shader to be used.
  16035. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16036. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16037. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16038. * @param camera The camera to apply the render pass to.
  16039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16040. * @param engine The engine which the post process will be applied. (default: current engine)
  16041. * @param reusable If the post process can be reused on the same frame. (default: false)
  16042. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16043. * @param textureType Type of textures used when performing the post process. (default: 0)
  16044. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16045. * @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
  16046. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16047. */
  16048. constructor(
  16049. /** Name of the PostProcess. */
  16050. 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);
  16051. /**
  16052. * Gets a string idenfifying the name of the class
  16053. * @returns "PostProcess" string
  16054. */
  16055. getClassName(): string;
  16056. /**
  16057. * Gets the engine which this post process belongs to.
  16058. * @returns The engine the post process was enabled with.
  16059. */
  16060. getEngine(): Engine;
  16061. /**
  16062. * The effect that is created when initializing the post process.
  16063. * @returns The created effect corresponding the the postprocess.
  16064. */
  16065. getEffect(): Effect;
  16066. /**
  16067. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16068. * @param postProcess The post process to share the output with.
  16069. * @returns This post process.
  16070. */
  16071. shareOutputWith(postProcess: PostProcess): PostProcess;
  16072. /**
  16073. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16074. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16075. */
  16076. useOwnOutput(): void;
  16077. /**
  16078. * Updates the effect with the current post process compile time values and recompiles the shader.
  16079. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16080. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16081. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16082. * @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
  16083. * @param onCompiled Called when the shader has been compiled.
  16084. * @param onError Called if there is an error when compiling a shader.
  16085. */
  16086. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16087. /**
  16088. * The post process is reusable if it can be used multiple times within one frame.
  16089. * @returns If the post process is reusable
  16090. */
  16091. isReusable(): boolean;
  16092. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16093. markTextureDirty(): void;
  16094. /**
  16095. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16096. * 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.
  16097. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16098. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16099. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16100. * @returns The target texture that was bound to be written to.
  16101. */
  16102. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16103. /**
  16104. * If the post process is supported.
  16105. */
  16106. get isSupported(): boolean;
  16107. /**
  16108. * The aspect ratio of the output texture.
  16109. */
  16110. get aspectRatio(): number;
  16111. /**
  16112. * Get a value indicating if the post-process is ready to be used
  16113. * @returns true if the post-process is ready (shader is compiled)
  16114. */
  16115. isReady(): boolean;
  16116. /**
  16117. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16118. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16119. */
  16120. apply(): Nullable<Effect>;
  16121. private _disposeTextures;
  16122. /**
  16123. * Disposes the post process.
  16124. * @param camera The camera to dispose the post process on.
  16125. */
  16126. dispose(camera?: Camera): void;
  16127. }
  16128. }
  16129. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16130. /** @hidden */
  16131. export var kernelBlurVaryingDeclaration: {
  16132. name: string;
  16133. shader: string;
  16134. };
  16135. }
  16136. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16137. /** @hidden */
  16138. export var kernelBlurFragment: {
  16139. name: string;
  16140. shader: string;
  16141. };
  16142. }
  16143. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16144. /** @hidden */
  16145. export var kernelBlurFragment2: {
  16146. name: string;
  16147. shader: string;
  16148. };
  16149. }
  16150. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16151. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16152. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16153. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16154. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16155. /** @hidden */
  16156. export var kernelBlurPixelShader: {
  16157. name: string;
  16158. shader: string;
  16159. };
  16160. }
  16161. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16162. /** @hidden */
  16163. export var kernelBlurVertex: {
  16164. name: string;
  16165. shader: string;
  16166. };
  16167. }
  16168. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16169. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16170. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16171. /** @hidden */
  16172. export var kernelBlurVertexShader: {
  16173. name: string;
  16174. shader: string;
  16175. };
  16176. }
  16177. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16178. import { Vector2 } from "babylonjs/Maths/math.vector";
  16179. import { Nullable } from "babylonjs/types";
  16180. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16181. import { Camera } from "babylonjs/Cameras/camera";
  16182. import { Effect } from "babylonjs/Materials/effect";
  16183. import { Engine } from "babylonjs/Engines/engine";
  16184. import "babylonjs/Shaders/kernelBlur.fragment";
  16185. import "babylonjs/Shaders/kernelBlur.vertex";
  16186. /**
  16187. * The Blur Post Process which blurs an image based on a kernel and direction.
  16188. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16189. */
  16190. export class BlurPostProcess extends PostProcess {
  16191. /** The direction in which to blur the image. */
  16192. direction: Vector2;
  16193. private blockCompilation;
  16194. protected _kernel: number;
  16195. protected _idealKernel: number;
  16196. protected _packedFloat: boolean;
  16197. private _staticDefines;
  16198. /**
  16199. * Sets the length in pixels of the blur sample region
  16200. */
  16201. set kernel(v: number);
  16202. /**
  16203. * Gets the length in pixels of the blur sample region
  16204. */
  16205. get kernel(): number;
  16206. /**
  16207. * Sets wether or not the blur needs to unpack/repack floats
  16208. */
  16209. set packedFloat(v: boolean);
  16210. /**
  16211. * Gets wether or not the blur is unpacking/repacking floats
  16212. */
  16213. get packedFloat(): boolean;
  16214. /**
  16215. * Creates a new instance BlurPostProcess
  16216. * @param name The name of the effect.
  16217. * @param direction The direction in which to blur the image.
  16218. * @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.
  16219. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16220. * @param camera The camera to apply the render pass to.
  16221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16222. * @param engine The engine which the post process will be applied. (default: current engine)
  16223. * @param reusable If the post process can be reused on the same frame. (default: false)
  16224. * @param textureType Type of textures used when performing the post process. (default: 0)
  16225. * @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)
  16226. */
  16227. constructor(name: string,
  16228. /** The direction in which to blur the image. */
  16229. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16230. /**
  16231. * Updates the effect with the current post process compile time values and recompiles the shader.
  16232. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16233. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16234. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16235. * @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
  16236. * @param onCompiled Called when the shader has been compiled.
  16237. * @param onError Called if there is an error when compiling a shader.
  16238. */
  16239. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16240. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16241. /**
  16242. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16243. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16244. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16245. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16246. * The gaps between physical kernels are compensated for in the weighting of the samples
  16247. * @param idealKernel Ideal blur kernel.
  16248. * @return Nearest best kernel.
  16249. */
  16250. protected _nearestBestKernel(idealKernel: number): number;
  16251. /**
  16252. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16253. * @param x The point on the Gaussian distribution to sample.
  16254. * @return the value of the Gaussian function at x.
  16255. */
  16256. protected _gaussianWeight(x: number): number;
  16257. /**
  16258. * Generates a string that can be used as a floating point number in GLSL.
  16259. * @param x Value to print.
  16260. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16261. * @return GLSL float string.
  16262. */
  16263. protected _glslFloat(x: number, decimalFigures?: number): string;
  16264. }
  16265. }
  16266. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16267. import { Scene } from "babylonjs/scene";
  16268. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16269. import { Plane } from "babylonjs/Maths/math.plane";
  16270. /**
  16271. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16272. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16273. * You can then easily use it as a reflectionTexture on a flat surface.
  16274. * In case the surface is not a plane, please consider relying on reflection probes.
  16275. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16276. */
  16277. export class MirrorTexture extends RenderTargetTexture {
  16278. private scene;
  16279. /**
  16280. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16281. * 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.
  16282. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16283. */
  16284. mirrorPlane: Plane;
  16285. /**
  16286. * Define the blur ratio used to blur the reflection if needed.
  16287. */
  16288. set blurRatio(value: number);
  16289. get blurRatio(): number;
  16290. /**
  16291. * Define the adaptive blur kernel used to blur the reflection if needed.
  16292. * This will autocompute the closest best match for the `blurKernel`
  16293. */
  16294. set adaptiveBlurKernel(value: number);
  16295. /**
  16296. * Define the blur kernel used to blur the reflection if needed.
  16297. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16298. */
  16299. set blurKernel(value: number);
  16300. /**
  16301. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16302. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16303. */
  16304. set blurKernelX(value: number);
  16305. get blurKernelX(): number;
  16306. /**
  16307. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16308. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16309. */
  16310. set blurKernelY(value: number);
  16311. get blurKernelY(): number;
  16312. private _autoComputeBlurKernel;
  16313. protected _onRatioRescale(): void;
  16314. private _updateGammaSpace;
  16315. private _imageProcessingConfigChangeObserver;
  16316. private _transformMatrix;
  16317. private _mirrorMatrix;
  16318. private _savedViewMatrix;
  16319. private _blurX;
  16320. private _blurY;
  16321. private _adaptiveBlurKernel;
  16322. private _blurKernelX;
  16323. private _blurKernelY;
  16324. private _blurRatio;
  16325. /**
  16326. * Instantiates a Mirror Texture.
  16327. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16328. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16329. * You can then easily use it as a reflectionTexture on a flat surface.
  16330. * In case the surface is not a plane, please consider relying on reflection probes.
  16331. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16332. * @param name
  16333. * @param size
  16334. * @param scene
  16335. * @param generateMipMaps
  16336. * @param type
  16337. * @param samplingMode
  16338. * @param generateDepthBuffer
  16339. */
  16340. constructor(name: string, size: number | {
  16341. width: number;
  16342. height: number;
  16343. } | {
  16344. ratio: number;
  16345. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16346. private _preparePostProcesses;
  16347. /**
  16348. * Clone the mirror texture.
  16349. * @returns the cloned texture
  16350. */
  16351. clone(): MirrorTexture;
  16352. /**
  16353. * Serialize the texture to a JSON representation you could use in Parse later on
  16354. * @returns the serialized JSON representation
  16355. */
  16356. serialize(): any;
  16357. /**
  16358. * Dispose the texture and release its associated resources.
  16359. */
  16360. dispose(): void;
  16361. }
  16362. }
  16363. declare module "babylonjs/Materials/Textures/texture" {
  16364. import { Observable } from "babylonjs/Misc/observable";
  16365. import { Nullable } from "babylonjs/types";
  16366. import { Matrix } from "babylonjs/Maths/math.vector";
  16367. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16368. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16369. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16370. import { Scene } from "babylonjs/scene";
  16371. /**
  16372. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16373. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16374. */
  16375. export class Texture extends BaseTexture {
  16376. /**
  16377. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16378. */
  16379. static SerializeBuffers: boolean;
  16380. /** @hidden */
  16381. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16382. /** @hidden */
  16383. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16384. /** @hidden */
  16385. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16386. /** nearest is mag = nearest and min = nearest and mip = linear */
  16387. static readonly NEAREST_SAMPLINGMODE: number;
  16388. /** nearest is mag = nearest and min = nearest and mip = linear */
  16389. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16390. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16391. static readonly BILINEAR_SAMPLINGMODE: number;
  16392. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16393. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16394. /** Trilinear is mag = linear and min = linear and mip = linear */
  16395. static readonly TRILINEAR_SAMPLINGMODE: number;
  16396. /** Trilinear is mag = linear and min = linear and mip = linear */
  16397. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16398. /** mag = nearest and min = nearest and mip = nearest */
  16399. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16400. /** mag = nearest and min = linear and mip = nearest */
  16401. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16402. /** mag = nearest and min = linear and mip = linear */
  16403. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16404. /** mag = nearest and min = linear and mip = none */
  16405. static readonly NEAREST_LINEAR: number;
  16406. /** mag = nearest and min = nearest and mip = none */
  16407. static readonly NEAREST_NEAREST: number;
  16408. /** mag = linear and min = nearest and mip = nearest */
  16409. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16410. /** mag = linear and min = nearest and mip = linear */
  16411. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16412. /** mag = linear and min = linear and mip = none */
  16413. static readonly LINEAR_LINEAR: number;
  16414. /** mag = linear and min = nearest and mip = none */
  16415. static readonly LINEAR_NEAREST: number;
  16416. /** Explicit coordinates mode */
  16417. static readonly EXPLICIT_MODE: number;
  16418. /** Spherical coordinates mode */
  16419. static readonly SPHERICAL_MODE: number;
  16420. /** Planar coordinates mode */
  16421. static readonly PLANAR_MODE: number;
  16422. /** Cubic coordinates mode */
  16423. static readonly CUBIC_MODE: number;
  16424. /** Projection coordinates mode */
  16425. static readonly PROJECTION_MODE: number;
  16426. /** Inverse Cubic coordinates mode */
  16427. static readonly SKYBOX_MODE: number;
  16428. /** Inverse Cubic coordinates mode */
  16429. static readonly INVCUBIC_MODE: number;
  16430. /** Equirectangular coordinates mode */
  16431. static readonly EQUIRECTANGULAR_MODE: number;
  16432. /** Equirectangular Fixed coordinates mode */
  16433. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16434. /** Equirectangular Fixed Mirrored coordinates mode */
  16435. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16436. /** Texture is not repeating outside of 0..1 UVs */
  16437. static readonly CLAMP_ADDRESSMODE: number;
  16438. /** Texture is repeating outside of 0..1 UVs */
  16439. static readonly WRAP_ADDRESSMODE: number;
  16440. /** Texture is repeating and mirrored */
  16441. static readonly MIRROR_ADDRESSMODE: number;
  16442. /**
  16443. * 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
  16444. */
  16445. static UseSerializedUrlIfAny: boolean;
  16446. /**
  16447. * Define the url of the texture.
  16448. */
  16449. url: Nullable<string>;
  16450. /**
  16451. * Define an offset on the texture to offset the u coordinates of the UVs
  16452. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16453. */
  16454. uOffset: number;
  16455. /**
  16456. * Define an offset on the texture to offset the v coordinates of the UVs
  16457. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16458. */
  16459. vOffset: number;
  16460. /**
  16461. * Define an offset on the texture to scale the u coordinates of the UVs
  16462. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16463. */
  16464. uScale: number;
  16465. /**
  16466. * Define an offset on the texture to scale the v coordinates of the UVs
  16467. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16468. */
  16469. vScale: number;
  16470. /**
  16471. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16472. * @see http://doc.babylonjs.com/how_to/more_materials
  16473. */
  16474. uAng: number;
  16475. /**
  16476. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16477. * @see http://doc.babylonjs.com/how_to/more_materials
  16478. */
  16479. vAng: number;
  16480. /**
  16481. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16482. * @see http://doc.babylonjs.com/how_to/more_materials
  16483. */
  16484. wAng: number;
  16485. /**
  16486. * Defines the center of rotation (U)
  16487. */
  16488. uRotationCenter: number;
  16489. /**
  16490. * Defines the center of rotation (V)
  16491. */
  16492. vRotationCenter: number;
  16493. /**
  16494. * Defines the center of rotation (W)
  16495. */
  16496. wRotationCenter: number;
  16497. /**
  16498. * Are mip maps generated for this texture or not.
  16499. */
  16500. get noMipmap(): boolean;
  16501. /**
  16502. * List of inspectable custom properties (used by the Inspector)
  16503. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16504. */
  16505. inspectableCustomProperties: Nullable<IInspectable[]>;
  16506. private _noMipmap;
  16507. /** @hidden */
  16508. _invertY: boolean;
  16509. private _rowGenerationMatrix;
  16510. private _cachedTextureMatrix;
  16511. private _projectionModeMatrix;
  16512. private _t0;
  16513. private _t1;
  16514. private _t2;
  16515. private _cachedUOffset;
  16516. private _cachedVOffset;
  16517. private _cachedUScale;
  16518. private _cachedVScale;
  16519. private _cachedUAng;
  16520. private _cachedVAng;
  16521. private _cachedWAng;
  16522. private _cachedProjectionMatrixId;
  16523. private _cachedCoordinatesMode;
  16524. /** @hidden */
  16525. protected _initialSamplingMode: number;
  16526. /** @hidden */
  16527. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16528. private _deleteBuffer;
  16529. protected _format: Nullable<number>;
  16530. private _delayedOnLoad;
  16531. private _delayedOnError;
  16532. private _mimeType?;
  16533. /**
  16534. * Observable triggered once the texture has been loaded.
  16535. */
  16536. onLoadObservable: Observable<Texture>;
  16537. protected _isBlocking: boolean;
  16538. /**
  16539. * Is the texture preventing material to render while loading.
  16540. * If false, a default texture will be used instead of the loading one during the preparation step.
  16541. */
  16542. set isBlocking(value: boolean);
  16543. get isBlocking(): boolean;
  16544. /**
  16545. * Get the current sampling mode associated with the texture.
  16546. */
  16547. get samplingMode(): number;
  16548. /**
  16549. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16550. */
  16551. get invertY(): boolean;
  16552. /**
  16553. * Instantiates a new texture.
  16554. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16555. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16556. * @param url defines the url of the picture to load as a texture
  16557. * @param scene defines the scene or engine the texture will belong to
  16558. * @param noMipmap defines if the texture will require mip maps or not
  16559. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16560. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16561. * @param onLoad defines a callback triggered when the texture has been loaded
  16562. * @param onError defines a callback triggered when an error occurred during the loading session
  16563. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16564. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16565. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16566. * @param mimeType defines an optional mime type information
  16567. */
  16568. 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);
  16569. /**
  16570. * Update the url (and optional buffer) of this texture if url was null during construction.
  16571. * @param url the url of the texture
  16572. * @param buffer the buffer of the texture (defaults to null)
  16573. * @param onLoad callback called when the texture is loaded (defaults to null)
  16574. */
  16575. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16576. /**
  16577. * Finish the loading sequence of a texture flagged as delayed load.
  16578. * @hidden
  16579. */
  16580. delayLoad(): void;
  16581. private _prepareRowForTextureGeneration;
  16582. /**
  16583. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16584. * @returns the transform matrix of the texture.
  16585. */
  16586. getTextureMatrix(uBase?: number): Matrix;
  16587. /**
  16588. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16589. * @returns The reflection texture transform
  16590. */
  16591. getReflectionTextureMatrix(): Matrix;
  16592. /**
  16593. * Clones the texture.
  16594. * @returns the cloned texture
  16595. */
  16596. clone(): Texture;
  16597. /**
  16598. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16599. * @returns The JSON representation of the texture
  16600. */
  16601. serialize(): any;
  16602. /**
  16603. * Get the current class name of the texture useful for serialization or dynamic coding.
  16604. * @returns "Texture"
  16605. */
  16606. getClassName(): string;
  16607. /**
  16608. * Dispose the texture and release its associated resources.
  16609. */
  16610. dispose(): void;
  16611. /**
  16612. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16613. * @param parsedTexture Define the JSON representation of the texture
  16614. * @param scene Define the scene the parsed texture should be instantiated in
  16615. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16616. * @returns The parsed texture if successful
  16617. */
  16618. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16619. /**
  16620. * Creates a texture from its base 64 representation.
  16621. * @param data Define the base64 payload without the data: prefix
  16622. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16623. * @param scene Define the scene the texture should belong to
  16624. * @param noMipmap Forces the texture to not create mip map information if true
  16625. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16626. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16627. * @param onLoad define a callback triggered when the texture has been loaded
  16628. * @param onError define a callback triggered when an error occurred during the loading session
  16629. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16630. * @returns the created texture
  16631. */
  16632. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16633. /**
  16634. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16635. * @param data Define the base64 payload without the data: prefix
  16636. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16637. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16638. * @param scene Define the scene the texture should belong to
  16639. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16640. * @param noMipmap Forces the texture to not create mip map information if true
  16641. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16642. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16643. * @param onLoad define a callback triggered when the texture has been loaded
  16644. * @param onError define a callback triggered when an error occurred during the loading session
  16645. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16646. * @returns the created texture
  16647. */
  16648. 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;
  16649. }
  16650. }
  16651. declare module "babylonjs/PostProcesses/postProcessManager" {
  16652. import { Nullable } from "babylonjs/types";
  16653. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16654. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16655. import { Scene } from "babylonjs/scene";
  16656. /**
  16657. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16658. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16659. */
  16660. export class PostProcessManager {
  16661. private _scene;
  16662. private _indexBuffer;
  16663. private _vertexBuffers;
  16664. /**
  16665. * Creates a new instance PostProcess
  16666. * @param scene The scene that the post process is associated with.
  16667. */
  16668. constructor(scene: Scene);
  16669. private _prepareBuffers;
  16670. private _buildIndexBuffer;
  16671. /**
  16672. * Rebuilds the vertex buffers of the manager.
  16673. * @hidden
  16674. */
  16675. _rebuild(): void;
  16676. /**
  16677. * Prepares a frame to be run through a post process.
  16678. * @param sourceTexture The input texture to the post procesess. (default: null)
  16679. * @param postProcesses An array of post processes to be run. (default: null)
  16680. * @returns True if the post processes were able to be run.
  16681. * @hidden
  16682. */
  16683. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16684. /**
  16685. * Manually render a set of post processes to a texture.
  16686. * @param postProcesses An array of post processes to be run.
  16687. * @param targetTexture The target texture to render to.
  16688. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16689. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16690. * @param lodLevel defines which lod of the texture to render to
  16691. */
  16692. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16693. /**
  16694. * Finalize the result of the output of the postprocesses.
  16695. * @param doNotPresent If true the result will not be displayed to the screen.
  16696. * @param targetTexture The target texture to render to.
  16697. * @param faceIndex The index of the face to bind the target texture to.
  16698. * @param postProcesses The array of post processes to render.
  16699. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16700. * @hidden
  16701. */
  16702. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16703. /**
  16704. * Disposes of the post process manager.
  16705. */
  16706. dispose(): void;
  16707. }
  16708. }
  16709. declare module "babylonjs/Misc/gradients" {
  16710. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16711. /** Interface used by value gradients (color, factor, ...) */
  16712. export interface IValueGradient {
  16713. /**
  16714. * Gets or sets the gradient value (between 0 and 1)
  16715. */
  16716. gradient: number;
  16717. }
  16718. /** Class used to store color4 gradient */
  16719. export class ColorGradient implements IValueGradient {
  16720. /**
  16721. * Gets or sets the gradient value (between 0 and 1)
  16722. */
  16723. gradient: number;
  16724. /**
  16725. * Gets or sets first associated color
  16726. */
  16727. color1: Color4;
  16728. /**
  16729. * Gets or sets second associated color
  16730. */
  16731. color2?: Color4;
  16732. /**
  16733. * Will get a color picked randomly between color1 and color2.
  16734. * If color2 is undefined then color1 will be used
  16735. * @param result defines the target Color4 to store the result in
  16736. */
  16737. getColorToRef(result: Color4): void;
  16738. }
  16739. /** Class used to store color 3 gradient */
  16740. export class Color3Gradient implements IValueGradient {
  16741. /**
  16742. * Gets or sets the gradient value (between 0 and 1)
  16743. */
  16744. gradient: number;
  16745. /**
  16746. * Gets or sets the associated color
  16747. */
  16748. color: Color3;
  16749. }
  16750. /** Class used to store factor gradient */
  16751. export class FactorGradient implements IValueGradient {
  16752. /**
  16753. * Gets or sets the gradient value (between 0 and 1)
  16754. */
  16755. gradient: number;
  16756. /**
  16757. * Gets or sets first associated factor
  16758. */
  16759. factor1: number;
  16760. /**
  16761. * Gets or sets second associated factor
  16762. */
  16763. factor2?: number;
  16764. /**
  16765. * Will get a number picked randomly between factor1 and factor2.
  16766. * If factor2 is undefined then factor1 will be used
  16767. * @returns the picked number
  16768. */
  16769. getFactor(): number;
  16770. }
  16771. /**
  16772. * Helper used to simplify some generic gradient tasks
  16773. */
  16774. export class GradientHelper {
  16775. /**
  16776. * Gets the current gradient from an array of IValueGradient
  16777. * @param ratio defines the current ratio to get
  16778. * @param gradients defines the array of IValueGradient
  16779. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16780. */
  16781. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16782. }
  16783. }
  16784. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16785. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16786. import { Nullable } from "babylonjs/types";
  16787. module "babylonjs/Engines/thinEngine" {
  16788. interface ThinEngine {
  16789. /**
  16790. * Creates a dynamic texture
  16791. * @param width defines the width of the texture
  16792. * @param height defines the height of the texture
  16793. * @param generateMipMaps defines if the engine should generate the mip levels
  16794. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16795. * @returns the dynamic texture inside an InternalTexture
  16796. */
  16797. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16798. /**
  16799. * Update the content of a dynamic texture
  16800. * @param texture defines the texture to update
  16801. * @param canvas defines the canvas containing the source
  16802. * @param invertY defines if data must be stored with Y axis inverted
  16803. * @param premulAlpha defines if alpha is stored as premultiplied
  16804. * @param format defines the format of the data
  16805. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16806. */
  16807. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16808. }
  16809. }
  16810. }
  16811. declare module "babylonjs/Misc/canvasGenerator" {
  16812. /**
  16813. * Helper class used to generate a canvas to manipulate images
  16814. */
  16815. export class CanvasGenerator {
  16816. /**
  16817. * Create a new canvas (or offscreen canvas depending on the context)
  16818. * @param width defines the expected width
  16819. * @param height defines the expected height
  16820. * @return a new canvas or offscreen canvas
  16821. */
  16822. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16823. }
  16824. }
  16825. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16826. import { Scene } from "babylonjs/scene";
  16827. import { Texture } from "babylonjs/Materials/Textures/texture";
  16828. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16829. /**
  16830. * A class extending Texture allowing drawing on a texture
  16831. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16832. */
  16833. export class DynamicTexture extends Texture {
  16834. private _generateMipMaps;
  16835. private _canvas;
  16836. private _context;
  16837. private _engine;
  16838. /**
  16839. * Creates a DynamicTexture
  16840. * @param name defines the name of the texture
  16841. * @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
  16842. * @param scene defines the scene where you want the texture
  16843. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16844. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16845. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16846. */
  16847. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16848. /**
  16849. * Get the current class name of the texture useful for serialization or dynamic coding.
  16850. * @returns "DynamicTexture"
  16851. */
  16852. getClassName(): string;
  16853. /**
  16854. * Gets the current state of canRescale
  16855. */
  16856. get canRescale(): boolean;
  16857. private _recreate;
  16858. /**
  16859. * Scales the texture
  16860. * @param ratio the scale factor to apply to both width and height
  16861. */
  16862. scale(ratio: number): void;
  16863. /**
  16864. * Resizes the texture
  16865. * @param width the new width
  16866. * @param height the new height
  16867. */
  16868. scaleTo(width: number, height: number): void;
  16869. /**
  16870. * Gets the context of the canvas used by the texture
  16871. * @returns the canvas context of the dynamic texture
  16872. */
  16873. getContext(): CanvasRenderingContext2D;
  16874. /**
  16875. * Clears the texture
  16876. */
  16877. clear(): void;
  16878. /**
  16879. * Updates the texture
  16880. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16881. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16882. */
  16883. update(invertY?: boolean, premulAlpha?: boolean): void;
  16884. /**
  16885. * Draws text onto the texture
  16886. * @param text defines the text to be drawn
  16887. * @param x defines the placement of the text from the left
  16888. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16889. * @param font defines the font to be used with font-style, font-size, font-name
  16890. * @param color defines the color used for the text
  16891. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16892. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16893. * @param update defines whether texture is immediately update (default is true)
  16894. */
  16895. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16896. /**
  16897. * Clones the texture
  16898. * @returns the clone of the texture.
  16899. */
  16900. clone(): DynamicTexture;
  16901. /**
  16902. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16903. * @returns a serialized dynamic texture object
  16904. */
  16905. serialize(): any;
  16906. /** @hidden */
  16907. _rebuild(): void;
  16908. }
  16909. }
  16910. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16911. import { Scene } from "babylonjs/scene";
  16912. import { ISceneComponent } from "babylonjs/sceneComponent";
  16913. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16914. module "babylonjs/abstractScene" {
  16915. interface AbstractScene {
  16916. /**
  16917. * The list of procedural textures added to the scene
  16918. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16919. */
  16920. proceduralTextures: Array<ProceduralTexture>;
  16921. }
  16922. }
  16923. /**
  16924. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16925. * in a given scene.
  16926. */
  16927. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16928. /**
  16929. * The component name helpfull to identify the component in the list of scene components.
  16930. */
  16931. readonly name: string;
  16932. /**
  16933. * The scene the component belongs to.
  16934. */
  16935. scene: Scene;
  16936. /**
  16937. * Creates a new instance of the component for the given scene
  16938. * @param scene Defines the scene to register the component in
  16939. */
  16940. constructor(scene: Scene);
  16941. /**
  16942. * Registers the component in a given scene
  16943. */
  16944. register(): void;
  16945. /**
  16946. * Rebuilds the elements related to this component in case of
  16947. * context lost for instance.
  16948. */
  16949. rebuild(): void;
  16950. /**
  16951. * Disposes the component and the associated ressources.
  16952. */
  16953. dispose(): void;
  16954. private _beforeClear;
  16955. }
  16956. }
  16957. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16958. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16959. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16960. module "babylonjs/Engines/thinEngine" {
  16961. interface ThinEngine {
  16962. /**
  16963. * Creates a new render target cube texture
  16964. * @param size defines the size of the texture
  16965. * @param options defines the options used to create the texture
  16966. * @returns a new render target cube texture stored in an InternalTexture
  16967. */
  16968. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16969. }
  16970. }
  16971. }
  16972. declare module "babylonjs/Shaders/procedural.vertex" {
  16973. /** @hidden */
  16974. export var proceduralVertexShader: {
  16975. name: string;
  16976. shader: string;
  16977. };
  16978. }
  16979. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16980. import { Observable } from "babylonjs/Misc/observable";
  16981. import { Nullable } from "babylonjs/types";
  16982. import { Scene } from "babylonjs/scene";
  16983. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16984. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16985. import { Effect } from "babylonjs/Materials/effect";
  16986. import { Texture } from "babylonjs/Materials/Textures/texture";
  16987. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16988. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16989. import "babylonjs/Shaders/procedural.vertex";
  16990. /**
  16991. * 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.
  16992. * This is the base class of any Procedural texture and contains most of the shareable code.
  16993. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16994. */
  16995. export class ProceduralTexture extends Texture {
  16996. isCube: boolean;
  16997. /**
  16998. * Define if the texture is enabled or not (disabled texture will not render)
  16999. */
  17000. isEnabled: boolean;
  17001. /**
  17002. * Define if the texture must be cleared before rendering (default is true)
  17003. */
  17004. autoClear: boolean;
  17005. /**
  17006. * Callback called when the texture is generated
  17007. */
  17008. onGenerated: () => void;
  17009. /**
  17010. * Event raised when the texture is generated
  17011. */
  17012. onGeneratedObservable: Observable<ProceduralTexture>;
  17013. /** @hidden */
  17014. _generateMipMaps: boolean;
  17015. /** @hidden **/
  17016. _effect: Effect;
  17017. /** @hidden */
  17018. _textures: {
  17019. [key: string]: Texture;
  17020. };
  17021. private _size;
  17022. private _currentRefreshId;
  17023. private _frameId;
  17024. private _refreshRate;
  17025. private _vertexBuffers;
  17026. private _indexBuffer;
  17027. private _uniforms;
  17028. private _samplers;
  17029. private _fragment;
  17030. private _floats;
  17031. private _ints;
  17032. private _floatsArrays;
  17033. private _colors3;
  17034. private _colors4;
  17035. private _vectors2;
  17036. private _vectors3;
  17037. private _matrices;
  17038. private _fallbackTexture;
  17039. private _fallbackTextureUsed;
  17040. private _engine;
  17041. private _cachedDefines;
  17042. private _contentUpdateId;
  17043. private _contentData;
  17044. /**
  17045. * Instantiates a new procedural texture.
  17046. * 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.
  17047. * This is the base class of any Procedural texture and contains most of the shareable code.
  17048. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17049. * @param name Define the name of the texture
  17050. * @param size Define the size of the texture to create
  17051. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17052. * @param scene Define the scene the texture belongs to
  17053. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17054. * @param generateMipMaps Define if the texture should creates mip maps or not
  17055. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17056. */
  17057. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17058. /**
  17059. * The effect that is created when initializing the post process.
  17060. * @returns The created effect corresponding the the postprocess.
  17061. */
  17062. getEffect(): Effect;
  17063. /**
  17064. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17065. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17066. */
  17067. getContent(): Nullable<ArrayBufferView>;
  17068. private _createIndexBuffer;
  17069. /** @hidden */
  17070. _rebuild(): void;
  17071. /**
  17072. * Resets the texture in order to recreate its associated resources.
  17073. * This can be called in case of context loss
  17074. */
  17075. reset(): void;
  17076. protected _getDefines(): string;
  17077. /**
  17078. * Is the texture ready to be used ? (rendered at least once)
  17079. * @returns true if ready, otherwise, false.
  17080. */
  17081. isReady(): boolean;
  17082. /**
  17083. * Resets the refresh counter of the texture and start bak from scratch.
  17084. * Could be useful to regenerate the texture if it is setup to render only once.
  17085. */
  17086. resetRefreshCounter(): void;
  17087. /**
  17088. * Set the fragment shader to use in order to render the texture.
  17089. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17090. */
  17091. setFragment(fragment: any): void;
  17092. /**
  17093. * Define the refresh rate of the texture or the rendering frequency.
  17094. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17095. */
  17096. get refreshRate(): number;
  17097. set refreshRate(value: number);
  17098. /** @hidden */
  17099. _shouldRender(): boolean;
  17100. /**
  17101. * Get the size the texture is rendering at.
  17102. * @returns the size (texture is always squared)
  17103. */
  17104. getRenderSize(): number;
  17105. /**
  17106. * Resize the texture to new value.
  17107. * @param size Define the new size the texture should have
  17108. * @param generateMipMaps Define whether the new texture should create mip maps
  17109. */
  17110. resize(size: number, generateMipMaps: boolean): void;
  17111. private _checkUniform;
  17112. /**
  17113. * Set a texture in the shader program used to render.
  17114. * @param name Define the name of the uniform samplers as defined in the shader
  17115. * @param texture Define the texture to bind to this sampler
  17116. * @return the texture itself allowing "fluent" like uniform updates
  17117. */
  17118. setTexture(name: string, texture: Texture): ProceduralTexture;
  17119. /**
  17120. * Set a float in the shader.
  17121. * @param name Define the name of the uniform as defined in the shader
  17122. * @param value Define the value to give to the uniform
  17123. * @return the texture itself allowing "fluent" like uniform updates
  17124. */
  17125. setFloat(name: string, value: number): ProceduralTexture;
  17126. /**
  17127. * Set a int 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. setInt(name: string, value: number): ProceduralTexture;
  17133. /**
  17134. * Set an array of floats 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. setFloats(name: string, value: number[]): ProceduralTexture;
  17140. /**
  17141. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ProceduralTexture;
  17147. /**
  17148. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ProceduralTexture;
  17154. /**
  17155. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ProceduralTexture;
  17161. /**
  17162. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ProceduralTexture;
  17168. /**
  17169. * Set a mat4 in the shader from a MAtrix.
  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. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17175. /**
  17176. * Render the texture to its associated render target.
  17177. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17178. */
  17179. render(useCameraPostProcess?: boolean): void;
  17180. /**
  17181. * Clone the texture.
  17182. * @returns the cloned texture
  17183. */
  17184. clone(): ProceduralTexture;
  17185. /**
  17186. * Dispose the texture and release its asoociated resources.
  17187. */
  17188. dispose(): void;
  17189. }
  17190. }
  17191. declare module "babylonjs/Particles/baseParticleSystem" {
  17192. import { Nullable } from "babylonjs/types";
  17193. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17195. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17196. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17197. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17198. import { Scene } from "babylonjs/scene";
  17199. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17200. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17201. import { Texture } from "babylonjs/Materials/Textures/texture";
  17202. import { Color4 } from "babylonjs/Maths/math.color";
  17203. import { Animation } from "babylonjs/Animations/animation";
  17204. /**
  17205. * This represents the base class for particle system in Babylon.
  17206. * 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.
  17207. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17208. * @example https://doc.babylonjs.com/babylon101/particles
  17209. */
  17210. export class BaseParticleSystem {
  17211. /**
  17212. * Source color is added to the destination color without alpha affecting the result
  17213. */
  17214. static BLENDMODE_ONEONE: number;
  17215. /**
  17216. * Blend current color and particle color using particle’s alpha
  17217. */
  17218. static BLENDMODE_STANDARD: number;
  17219. /**
  17220. * Add current color and particle color multiplied by particle’s alpha
  17221. */
  17222. static BLENDMODE_ADD: number;
  17223. /**
  17224. * Multiply current color with particle color
  17225. */
  17226. static BLENDMODE_MULTIPLY: number;
  17227. /**
  17228. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17229. */
  17230. static BLENDMODE_MULTIPLYADD: number;
  17231. /**
  17232. * List of animations used by the particle system.
  17233. */
  17234. animations: Animation[];
  17235. /**
  17236. * The id of the Particle system.
  17237. */
  17238. id: string;
  17239. /**
  17240. * The friendly name of the Particle system.
  17241. */
  17242. name: string;
  17243. /**
  17244. * The rendering group used by the Particle system to chose when to render.
  17245. */
  17246. renderingGroupId: number;
  17247. /**
  17248. * The emitter represents the Mesh or position we are attaching the particle system to.
  17249. */
  17250. emitter: Nullable<AbstractMesh | Vector3>;
  17251. /**
  17252. * The maximum number of particles to emit per frame
  17253. */
  17254. emitRate: number;
  17255. /**
  17256. * If you want to launch only a few particles at once, that can be done, as well.
  17257. */
  17258. manualEmitCount: number;
  17259. /**
  17260. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17261. */
  17262. updateSpeed: number;
  17263. /**
  17264. * The amount of time the particle system is running (depends of the overall update speed).
  17265. */
  17266. targetStopDuration: number;
  17267. /**
  17268. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17269. */
  17270. disposeOnStop: boolean;
  17271. /**
  17272. * Minimum power of emitting particles.
  17273. */
  17274. minEmitPower: number;
  17275. /**
  17276. * Maximum power of emitting particles.
  17277. */
  17278. maxEmitPower: number;
  17279. /**
  17280. * Minimum life time of emitting particles.
  17281. */
  17282. minLifeTime: number;
  17283. /**
  17284. * Maximum life time of emitting particles.
  17285. */
  17286. maxLifeTime: number;
  17287. /**
  17288. * Minimum Size of emitting particles.
  17289. */
  17290. minSize: number;
  17291. /**
  17292. * Maximum Size of emitting particles.
  17293. */
  17294. maxSize: number;
  17295. /**
  17296. * Minimum scale of emitting particles on X axis.
  17297. */
  17298. minScaleX: number;
  17299. /**
  17300. * Maximum scale of emitting particles on X axis.
  17301. */
  17302. maxScaleX: number;
  17303. /**
  17304. * Minimum scale of emitting particles on Y axis.
  17305. */
  17306. minScaleY: number;
  17307. /**
  17308. * Maximum scale of emitting particles on Y axis.
  17309. */
  17310. maxScaleY: number;
  17311. /**
  17312. * Gets or sets the minimal initial rotation in radians.
  17313. */
  17314. minInitialRotation: number;
  17315. /**
  17316. * Gets or sets the maximal initial rotation in radians.
  17317. */
  17318. maxInitialRotation: number;
  17319. /**
  17320. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17321. */
  17322. minAngularSpeed: number;
  17323. /**
  17324. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17325. */
  17326. maxAngularSpeed: number;
  17327. /**
  17328. * The texture used to render each particle. (this can be a spritesheet)
  17329. */
  17330. particleTexture: Nullable<Texture>;
  17331. /**
  17332. * The layer mask we are rendering the particles through.
  17333. */
  17334. layerMask: number;
  17335. /**
  17336. * This can help using your own shader to render the particle system.
  17337. * The according effect will be created
  17338. */
  17339. customShader: any;
  17340. /**
  17341. * By default particle system starts as soon as they are created. This prevents the
  17342. * automatic start to happen and let you decide when to start emitting particles.
  17343. */
  17344. preventAutoStart: boolean;
  17345. private _noiseTexture;
  17346. /**
  17347. * Gets or sets a texture used to add random noise to particle positions
  17348. */
  17349. get noiseTexture(): Nullable<ProceduralTexture>;
  17350. set noiseTexture(value: Nullable<ProceduralTexture>);
  17351. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17352. noiseStrength: Vector3;
  17353. /**
  17354. * Callback triggered when the particle animation is ending.
  17355. */
  17356. onAnimationEnd: Nullable<() => void>;
  17357. /**
  17358. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17359. */
  17360. blendMode: number;
  17361. /**
  17362. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17363. * to override the particles.
  17364. */
  17365. forceDepthWrite: boolean;
  17366. /** 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 */
  17367. preWarmCycles: number;
  17368. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17369. preWarmStepOffset: number;
  17370. /**
  17371. * 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)
  17372. */
  17373. spriteCellChangeSpeed: number;
  17374. /**
  17375. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17376. */
  17377. startSpriteCellID: number;
  17378. /**
  17379. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17380. */
  17381. endSpriteCellID: number;
  17382. /**
  17383. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17384. */
  17385. spriteCellWidth: number;
  17386. /**
  17387. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17388. */
  17389. spriteCellHeight: number;
  17390. /**
  17391. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17392. */
  17393. spriteRandomStartCell: boolean;
  17394. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17395. translationPivot: Vector2;
  17396. /** @hidden */
  17397. protected _isAnimationSheetEnabled: boolean;
  17398. /**
  17399. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17400. */
  17401. beginAnimationOnStart: boolean;
  17402. /**
  17403. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17404. */
  17405. beginAnimationFrom: number;
  17406. /**
  17407. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17408. */
  17409. beginAnimationTo: number;
  17410. /**
  17411. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17412. */
  17413. beginAnimationLoop: boolean;
  17414. /**
  17415. * Gets or sets a world offset applied to all particles
  17416. */
  17417. worldOffset: Vector3;
  17418. /**
  17419. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17420. */
  17421. get isAnimationSheetEnabled(): boolean;
  17422. set isAnimationSheetEnabled(value: boolean);
  17423. /**
  17424. * Get hosting scene
  17425. * @returns the scene
  17426. */
  17427. getScene(): Scene;
  17428. /**
  17429. * You can use gravity if you want to give an orientation to your particles.
  17430. */
  17431. gravity: Vector3;
  17432. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17433. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17434. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17435. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17436. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17437. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17438. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17439. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17440. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17441. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17442. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17443. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17444. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17445. /**
  17446. * Defines the delay in milliseconds before starting the system (0 by default)
  17447. */
  17448. startDelay: number;
  17449. /**
  17450. * Gets the current list of drag gradients.
  17451. * You must use addDragGradient and removeDragGradient to udpate this list
  17452. * @returns the list of drag gradients
  17453. */
  17454. getDragGradients(): Nullable<Array<FactorGradient>>;
  17455. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17456. limitVelocityDamping: number;
  17457. /**
  17458. * Gets the current list of limit velocity gradients.
  17459. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17460. * @returns the list of limit velocity gradients
  17461. */
  17462. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17463. /**
  17464. * Gets the current list of color gradients.
  17465. * You must use addColorGradient and removeColorGradient to udpate this list
  17466. * @returns the list of color gradients
  17467. */
  17468. getColorGradients(): Nullable<Array<ColorGradient>>;
  17469. /**
  17470. * Gets the current list of size gradients.
  17471. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17472. * @returns the list of size gradients
  17473. */
  17474. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17475. /**
  17476. * Gets the current list of color remap gradients.
  17477. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17478. * @returns the list of color remap gradients
  17479. */
  17480. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17481. /**
  17482. * Gets the current list of alpha remap gradients.
  17483. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17484. * @returns the list of alpha remap gradients
  17485. */
  17486. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17487. /**
  17488. * Gets the current list of life time gradients.
  17489. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17490. * @returns the list of life time gradients
  17491. */
  17492. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17493. /**
  17494. * Gets the current list of angular speed gradients.
  17495. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17496. * @returns the list of angular speed gradients
  17497. */
  17498. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17499. /**
  17500. * Gets the current list of velocity gradients.
  17501. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17502. * @returns the list of velocity gradients
  17503. */
  17504. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17505. /**
  17506. * Gets the current list of start size gradients.
  17507. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17508. * @returns the list of start size gradients
  17509. */
  17510. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17511. /**
  17512. * Gets the current list of emit rate gradients.
  17513. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17514. * @returns the list of emit rate gradients
  17515. */
  17516. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17517. /**
  17518. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17519. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17520. */
  17521. get direction1(): Vector3;
  17522. set direction1(value: Vector3);
  17523. /**
  17524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17525. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17526. */
  17527. get direction2(): Vector3;
  17528. set direction2(value: Vector3);
  17529. /**
  17530. * 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.
  17531. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17532. */
  17533. get minEmitBox(): Vector3;
  17534. set minEmitBox(value: Vector3);
  17535. /**
  17536. * 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.
  17537. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17538. */
  17539. get maxEmitBox(): Vector3;
  17540. set maxEmitBox(value: Vector3);
  17541. /**
  17542. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17543. */
  17544. color1: Color4;
  17545. /**
  17546. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17547. */
  17548. color2: Color4;
  17549. /**
  17550. * Color the particle will have at the end of its lifetime
  17551. */
  17552. colorDead: Color4;
  17553. /**
  17554. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17555. */
  17556. textureMask: Color4;
  17557. /**
  17558. * The particle emitter type defines the emitter used by the particle system.
  17559. * It can be for example box, sphere, or cone...
  17560. */
  17561. particleEmitterType: IParticleEmitterType;
  17562. /** @hidden */
  17563. _isSubEmitter: boolean;
  17564. /**
  17565. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17566. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17567. */
  17568. billboardMode: number;
  17569. protected _isBillboardBased: boolean;
  17570. /**
  17571. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17572. */
  17573. get isBillboardBased(): boolean;
  17574. set isBillboardBased(value: boolean);
  17575. /**
  17576. * The scene the particle system belongs to.
  17577. */
  17578. protected _scene: Scene;
  17579. /**
  17580. * Local cache of defines for image processing.
  17581. */
  17582. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17583. /**
  17584. * Default configuration related to image processing available in the standard Material.
  17585. */
  17586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17587. /**
  17588. * Gets the image processing configuration used either in this material.
  17589. */
  17590. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17591. /**
  17592. * Sets the Default image processing configuration used either in the this material.
  17593. *
  17594. * If sets to null, the scene one is in use.
  17595. */
  17596. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17597. /**
  17598. * Attaches a new image processing configuration to the Standard Material.
  17599. * @param configuration
  17600. */
  17601. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17602. /** @hidden */
  17603. protected _reset(): void;
  17604. /** @hidden */
  17605. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17606. /**
  17607. * Instantiates a particle system.
  17608. * 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.
  17609. * @param name The name of the particle system
  17610. */
  17611. constructor(name: string);
  17612. /**
  17613. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17614. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17615. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17616. * @returns the emitter
  17617. */
  17618. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17619. /**
  17620. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17621. * @param radius The radius of the hemisphere to emit from
  17622. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17623. * @returns the emitter
  17624. */
  17625. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17626. /**
  17627. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17628. * @param radius The radius of the sphere to emit from
  17629. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17630. * @returns the emitter
  17631. */
  17632. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17633. /**
  17634. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17635. * @param radius The radius of the sphere to emit from
  17636. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17637. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17638. * @returns the emitter
  17639. */
  17640. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17641. /**
  17642. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17643. * @param radius The radius of the emission cylinder
  17644. * @param height The height of the emission cylinder
  17645. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17646. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17647. * @returns the emitter
  17648. */
  17649. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17650. /**
  17651. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17652. * @param radius The radius of the cylinder to emit from
  17653. * @param height The height of the emission cylinder
  17654. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17655. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17656. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17657. * @returns the emitter
  17658. */
  17659. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17660. /**
  17661. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17662. * @param radius The radius of the cone to emit from
  17663. * @param angle The base angle of the cone
  17664. * @returns the emitter
  17665. */
  17666. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17667. /**
  17668. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17671. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17672. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17673. * @returns the emitter
  17674. */
  17675. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17676. }
  17677. }
  17678. declare module "babylonjs/Particles/subEmitter" {
  17679. import { Scene } from "babylonjs/scene";
  17680. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17681. /**
  17682. * Type of sub emitter
  17683. */
  17684. export enum SubEmitterType {
  17685. /**
  17686. * Attached to the particle over it's lifetime
  17687. */
  17688. ATTACHED = 0,
  17689. /**
  17690. * Created when the particle dies
  17691. */
  17692. END = 1
  17693. }
  17694. /**
  17695. * Sub emitter class used to emit particles from an existing particle
  17696. */
  17697. export class SubEmitter {
  17698. /**
  17699. * the particle system to be used by the sub emitter
  17700. */
  17701. particleSystem: ParticleSystem;
  17702. /**
  17703. * Type of the submitter (Default: END)
  17704. */
  17705. type: SubEmitterType;
  17706. /**
  17707. * 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)
  17708. * Note: This only is supported when using an emitter of type Mesh
  17709. */
  17710. inheritDirection: boolean;
  17711. /**
  17712. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17713. */
  17714. inheritedVelocityAmount: number;
  17715. /**
  17716. * Creates a sub emitter
  17717. * @param particleSystem the particle system to be used by the sub emitter
  17718. */
  17719. constructor(
  17720. /**
  17721. * the particle system to be used by the sub emitter
  17722. */
  17723. particleSystem: ParticleSystem);
  17724. /**
  17725. * Clones the sub emitter
  17726. * @returns the cloned sub emitter
  17727. */
  17728. clone(): SubEmitter;
  17729. /**
  17730. * Serialize current object to a JSON object
  17731. * @returns the serialized object
  17732. */
  17733. serialize(): any;
  17734. /** @hidden */
  17735. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17736. /**
  17737. * Creates a new SubEmitter from a serialized JSON version
  17738. * @param serializationObject defines the JSON object to read from
  17739. * @param scene defines the hosting scene
  17740. * @param rootUrl defines the rootUrl for data loading
  17741. * @returns a new SubEmitter
  17742. */
  17743. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17744. /** Release associated resources */
  17745. dispose(): void;
  17746. }
  17747. }
  17748. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17749. /** @hidden */
  17750. export var clipPlaneFragmentDeclaration: {
  17751. name: string;
  17752. shader: string;
  17753. };
  17754. }
  17755. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17756. /** @hidden */
  17757. export var imageProcessingDeclaration: {
  17758. name: string;
  17759. shader: string;
  17760. };
  17761. }
  17762. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17763. /** @hidden */
  17764. export var imageProcessingFunctions: {
  17765. name: string;
  17766. shader: string;
  17767. };
  17768. }
  17769. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17770. /** @hidden */
  17771. export var clipPlaneFragment: {
  17772. name: string;
  17773. shader: string;
  17774. };
  17775. }
  17776. declare module "babylonjs/Shaders/particles.fragment" {
  17777. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17778. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17779. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17780. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17781. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17782. /** @hidden */
  17783. export var particlesPixelShader: {
  17784. name: string;
  17785. shader: string;
  17786. };
  17787. }
  17788. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17789. /** @hidden */
  17790. export var clipPlaneVertexDeclaration: {
  17791. name: string;
  17792. shader: string;
  17793. };
  17794. }
  17795. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17796. /** @hidden */
  17797. export var clipPlaneVertex: {
  17798. name: string;
  17799. shader: string;
  17800. };
  17801. }
  17802. declare module "babylonjs/Shaders/particles.vertex" {
  17803. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17804. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17805. /** @hidden */
  17806. export var particlesVertexShader: {
  17807. name: string;
  17808. shader: string;
  17809. };
  17810. }
  17811. declare module "babylonjs/Particles/particleSystem" {
  17812. import { Nullable } from "babylonjs/types";
  17813. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17814. import { Observable } from "babylonjs/Misc/observable";
  17815. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17816. import { Effect } from "babylonjs/Materials/effect";
  17817. import { Scene, IDisposable } from "babylonjs/scene";
  17818. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17819. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17820. import { Particle } from "babylonjs/Particles/particle";
  17821. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17822. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17823. import "babylonjs/Shaders/particles.fragment";
  17824. import "babylonjs/Shaders/particles.vertex";
  17825. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17826. /**
  17827. * This represents a particle system in Babylon.
  17828. * 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.
  17829. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17830. * @example https://doc.babylonjs.com/babylon101/particles
  17831. */
  17832. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17833. /**
  17834. * Billboard mode will only apply to Y axis
  17835. */
  17836. static readonly BILLBOARDMODE_Y: number;
  17837. /**
  17838. * Billboard mode will apply to all axes
  17839. */
  17840. static readonly BILLBOARDMODE_ALL: number;
  17841. /**
  17842. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17843. */
  17844. static readonly BILLBOARDMODE_STRETCHED: number;
  17845. /**
  17846. * This function can be defined to provide custom update for active particles.
  17847. * This function will be called instead of regular update (age, position, color, etc.).
  17848. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17849. */
  17850. updateFunction: (particles: Particle[]) => void;
  17851. private _emitterWorldMatrix;
  17852. /**
  17853. * This function can be defined to specify initial direction for every new particle.
  17854. * It by default use the emitterType defined function
  17855. */
  17856. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17857. /**
  17858. * This function can be defined to specify initial position for every new particle.
  17859. * It by default use the emitterType defined function
  17860. */
  17861. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17862. /**
  17863. * @hidden
  17864. */
  17865. _inheritedVelocityOffset: Vector3;
  17866. /**
  17867. * An event triggered when the system is disposed
  17868. */
  17869. onDisposeObservable: Observable<ParticleSystem>;
  17870. private _onDisposeObserver;
  17871. /**
  17872. * Sets a callback that will be triggered when the system is disposed
  17873. */
  17874. set onDispose(callback: () => void);
  17875. private _particles;
  17876. private _epsilon;
  17877. private _capacity;
  17878. private _stockParticles;
  17879. private _newPartsExcess;
  17880. private _vertexData;
  17881. private _vertexBuffer;
  17882. private _vertexBuffers;
  17883. private _spriteBuffer;
  17884. private _indexBuffer;
  17885. private _effect;
  17886. private _customEffect;
  17887. private _cachedDefines;
  17888. private _scaledColorStep;
  17889. private _colorDiff;
  17890. private _scaledDirection;
  17891. private _scaledGravity;
  17892. private _currentRenderId;
  17893. private _alive;
  17894. private _useInstancing;
  17895. private _started;
  17896. private _stopped;
  17897. private _actualFrame;
  17898. private _scaledUpdateSpeed;
  17899. private _vertexBufferSize;
  17900. /** @hidden */
  17901. _currentEmitRateGradient: Nullable<FactorGradient>;
  17902. /** @hidden */
  17903. _currentEmitRate1: number;
  17904. /** @hidden */
  17905. _currentEmitRate2: number;
  17906. /** @hidden */
  17907. _currentStartSizeGradient: Nullable<FactorGradient>;
  17908. /** @hidden */
  17909. _currentStartSize1: number;
  17910. /** @hidden */
  17911. _currentStartSize2: number;
  17912. private readonly _rawTextureWidth;
  17913. private _rampGradientsTexture;
  17914. private _useRampGradients;
  17915. /** Gets or sets a boolean indicating that ramp gradients must be used
  17916. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17917. */
  17918. get useRampGradients(): boolean;
  17919. set useRampGradients(value: boolean);
  17920. /**
  17921. * 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.
  17922. * 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: [])
  17923. */
  17924. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17925. private _subEmitters;
  17926. /**
  17927. * @hidden
  17928. * If the particle systems emitter should be disposed when the particle system is disposed
  17929. */
  17930. _disposeEmitterOnDispose: boolean;
  17931. /**
  17932. * The current active Sub-systems, this property is used by the root particle system only.
  17933. */
  17934. activeSubSystems: Array<ParticleSystem>;
  17935. private _rootParticleSystem;
  17936. /**
  17937. * Gets the current list of active particles
  17938. */
  17939. get particles(): Particle[];
  17940. /**
  17941. * Returns the string "ParticleSystem"
  17942. * @returns a string containing the class name
  17943. */
  17944. getClassName(): string;
  17945. /**
  17946. * Instantiates a particle system.
  17947. * 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.
  17948. * @param name The name of the particle system
  17949. * @param capacity The max number of particles alive at the same time
  17950. * @param scene The scene the particle system belongs to
  17951. * @param customEffect a custom effect used to change the way particles are rendered by default
  17952. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17953. * @param epsilon Offset used to render the particles
  17954. */
  17955. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17956. private _addFactorGradient;
  17957. private _removeFactorGradient;
  17958. /**
  17959. * Adds a new life time gradient
  17960. * @param gradient defines the gradient to use (between 0 and 1)
  17961. * @param factor defines the life time factor to affect to the specified gradient
  17962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17963. * @returns the current particle system
  17964. */
  17965. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17966. /**
  17967. * Remove a specific life time gradient
  17968. * @param gradient defines the gradient to remove
  17969. * @returns the current particle system
  17970. */
  17971. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17972. /**
  17973. * Adds a new size gradient
  17974. * @param gradient defines the gradient to use (between 0 and 1)
  17975. * @param factor defines the size factor to affect to the specified gradient
  17976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17977. * @returns the current particle system
  17978. */
  17979. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17980. /**
  17981. * Remove a specific size gradient
  17982. * @param gradient defines the gradient to remove
  17983. * @returns the current particle system
  17984. */
  17985. removeSizeGradient(gradient: number): IParticleSystem;
  17986. /**
  17987. * Adds a new color remap gradient
  17988. * @param gradient defines the gradient to use (between 0 and 1)
  17989. * @param min defines the color remap minimal range
  17990. * @param max defines the color remap maximal range
  17991. * @returns the current particle system
  17992. */
  17993. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17994. /**
  17995. * Remove a specific color remap gradient
  17996. * @param gradient defines the gradient to remove
  17997. * @returns the current particle system
  17998. */
  17999. removeColorRemapGradient(gradient: number): IParticleSystem;
  18000. /**
  18001. * Adds a new alpha remap gradient
  18002. * @param gradient defines the gradient to use (between 0 and 1)
  18003. * @param min defines the alpha remap minimal range
  18004. * @param max defines the alpha remap maximal range
  18005. * @returns the current particle system
  18006. */
  18007. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18008. /**
  18009. * Remove a specific alpha remap gradient
  18010. * @param gradient defines the gradient to remove
  18011. * @returns the current particle system
  18012. */
  18013. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  18014. /**
  18015. * Adds a new angular speed gradient
  18016. * @param gradient defines the gradient to use (between 0 and 1)
  18017. * @param factor defines the angular speed to affect to the specified gradient
  18018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18019. * @returns the current particle system
  18020. */
  18021. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18022. /**
  18023. * Remove a specific angular speed gradient
  18024. * @param gradient defines the gradient to remove
  18025. * @returns the current particle system
  18026. */
  18027. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18028. /**
  18029. * Adds a new velocity gradient
  18030. * @param gradient defines the gradient to use (between 0 and 1)
  18031. * @param factor defines the velocity to affect to the specified gradient
  18032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18033. * @returns the current particle system
  18034. */
  18035. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18036. /**
  18037. * Remove a specific velocity gradient
  18038. * @param gradient defines the gradient to remove
  18039. * @returns the current particle system
  18040. */
  18041. removeVelocityGradient(gradient: number): IParticleSystem;
  18042. /**
  18043. * Adds a new limit velocity gradient
  18044. * @param gradient defines the gradient to use (between 0 and 1)
  18045. * @param factor defines the limit velocity value to affect to the specified gradient
  18046. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18047. * @returns the current particle system
  18048. */
  18049. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18050. /**
  18051. * Remove a specific limit velocity gradient
  18052. * @param gradient defines the gradient to remove
  18053. * @returns the current particle system
  18054. */
  18055. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18056. /**
  18057. * Adds a new drag gradient
  18058. * @param gradient defines the gradient to use (between 0 and 1)
  18059. * @param factor defines the drag value to affect to the specified gradient
  18060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18061. * @returns the current particle system
  18062. */
  18063. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18064. /**
  18065. * Remove a specific drag gradient
  18066. * @param gradient defines the gradient to remove
  18067. * @returns the current particle system
  18068. */
  18069. removeDragGradient(gradient: number): IParticleSystem;
  18070. /**
  18071. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18072. * @param gradient defines the gradient to use (between 0 and 1)
  18073. * @param factor defines the emit rate value to affect to the specified gradient
  18074. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18075. * @returns the current particle system
  18076. */
  18077. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18078. /**
  18079. * Remove a specific emit rate gradient
  18080. * @param gradient defines the gradient to remove
  18081. * @returns the current particle system
  18082. */
  18083. removeEmitRateGradient(gradient: number): IParticleSystem;
  18084. /**
  18085. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18086. * @param gradient defines the gradient to use (between 0 and 1)
  18087. * @param factor defines the start size value to affect to the specified gradient
  18088. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18089. * @returns the current particle system
  18090. */
  18091. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18092. /**
  18093. * Remove a specific start size gradient
  18094. * @param gradient defines the gradient to remove
  18095. * @returns the current particle system
  18096. */
  18097. removeStartSizeGradient(gradient: number): IParticleSystem;
  18098. private _createRampGradientTexture;
  18099. /**
  18100. * Gets the current list of ramp gradients.
  18101. * You must use addRampGradient and removeRampGradient to udpate this list
  18102. * @returns the list of ramp gradients
  18103. */
  18104. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18105. /**
  18106. * Adds a new ramp gradient used to remap particle colors
  18107. * @param gradient defines the gradient to use (between 0 and 1)
  18108. * @param color defines the color to affect to the specified gradient
  18109. * @returns the current particle system
  18110. */
  18111. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18112. /**
  18113. * Remove a specific ramp gradient
  18114. * @param gradient defines the gradient to remove
  18115. * @returns the current particle system
  18116. */
  18117. removeRampGradient(gradient: number): ParticleSystem;
  18118. /**
  18119. * Adds a new color gradient
  18120. * @param gradient defines the gradient to use (between 0 and 1)
  18121. * @param color1 defines the color to affect to the specified gradient
  18122. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18123. * @returns this particle system
  18124. */
  18125. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18126. /**
  18127. * Remove a specific color gradient
  18128. * @param gradient defines the gradient to remove
  18129. * @returns this particle system
  18130. */
  18131. removeColorGradient(gradient: number): IParticleSystem;
  18132. private _fetchR;
  18133. protected _reset(): void;
  18134. private _resetEffect;
  18135. private _createVertexBuffers;
  18136. private _createIndexBuffer;
  18137. /**
  18138. * Gets the maximum number of particles active at the same time.
  18139. * @returns The max number of active particles.
  18140. */
  18141. getCapacity(): number;
  18142. /**
  18143. * Gets whether there are still active particles in the system.
  18144. * @returns True if it is alive, otherwise false.
  18145. */
  18146. isAlive(): boolean;
  18147. /**
  18148. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18149. * @returns True if it has been started, otherwise false.
  18150. */
  18151. isStarted(): boolean;
  18152. private _prepareSubEmitterInternalArray;
  18153. /**
  18154. * Starts the particle system and begins to emit
  18155. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18156. */
  18157. start(delay?: number): void;
  18158. /**
  18159. * Stops the particle system.
  18160. * @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.
  18161. */
  18162. stop(stopSubEmitters?: boolean): void;
  18163. /**
  18164. * Remove all active particles
  18165. */
  18166. reset(): void;
  18167. /**
  18168. * @hidden (for internal use only)
  18169. */
  18170. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18171. /**
  18172. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18173. * Its lifetime will start back at 0.
  18174. */
  18175. recycleParticle: (particle: Particle) => void;
  18176. private _stopSubEmitters;
  18177. private _createParticle;
  18178. private _removeFromRoot;
  18179. private _emitFromParticle;
  18180. private _update;
  18181. /** @hidden */
  18182. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18183. /** @hidden */
  18184. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18185. /** @hidden */
  18186. private _getEffect;
  18187. /**
  18188. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18189. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18190. */
  18191. animate(preWarmOnly?: boolean): void;
  18192. private _appendParticleVertices;
  18193. /**
  18194. * Rebuilds the particle system.
  18195. */
  18196. rebuild(): void;
  18197. /**
  18198. * Is this system ready to be used/rendered
  18199. * @return true if the system is ready
  18200. */
  18201. isReady(): boolean;
  18202. private _render;
  18203. /**
  18204. * Renders the particle system in its current state.
  18205. * @returns the current number of particles
  18206. */
  18207. render(): number;
  18208. /**
  18209. * Disposes the particle system and free the associated resources
  18210. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18211. */
  18212. dispose(disposeTexture?: boolean): void;
  18213. /**
  18214. * Clones the particle system.
  18215. * @param name The name of the cloned object
  18216. * @param newEmitter The new emitter to use
  18217. * @returns the cloned particle system
  18218. */
  18219. clone(name: string, newEmitter: any): ParticleSystem;
  18220. /**
  18221. * Serializes the particle system to a JSON object.
  18222. * @returns the JSON object
  18223. */
  18224. serialize(): any;
  18225. /** @hidden */
  18226. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18227. /** @hidden */
  18228. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18229. /**
  18230. * Parses a JSON object to create a particle system.
  18231. * @param parsedParticleSystem The JSON object to parse
  18232. * @param scene The scene to create the particle system in
  18233. * @param rootUrl The root url to use to load external dependencies like texture
  18234. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18235. * @returns the Parsed particle system
  18236. */
  18237. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18238. }
  18239. }
  18240. declare module "babylonjs/Particles/particle" {
  18241. import { Nullable } from "babylonjs/types";
  18242. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18243. import { Color4 } from "babylonjs/Maths/math.color";
  18244. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18245. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18246. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18247. /**
  18248. * A particle represents one of the element emitted by a particle system.
  18249. * This is mainly define by its coordinates, direction, velocity and age.
  18250. */
  18251. export class Particle {
  18252. /**
  18253. * The particle system the particle belongs to.
  18254. */
  18255. particleSystem: ParticleSystem;
  18256. private static _Count;
  18257. /**
  18258. * Unique ID of the particle
  18259. */
  18260. id: number;
  18261. /**
  18262. * The world position of the particle in the scene.
  18263. */
  18264. position: Vector3;
  18265. /**
  18266. * The world direction of the particle in the scene.
  18267. */
  18268. direction: Vector3;
  18269. /**
  18270. * The color of the particle.
  18271. */
  18272. color: Color4;
  18273. /**
  18274. * The color change of the particle per step.
  18275. */
  18276. colorStep: Color4;
  18277. /**
  18278. * Defines how long will the life of the particle be.
  18279. */
  18280. lifeTime: number;
  18281. /**
  18282. * The current age of the particle.
  18283. */
  18284. age: number;
  18285. /**
  18286. * The current size of the particle.
  18287. */
  18288. size: number;
  18289. /**
  18290. * The current scale of the particle.
  18291. */
  18292. scale: Vector2;
  18293. /**
  18294. * The current angle of the particle.
  18295. */
  18296. angle: number;
  18297. /**
  18298. * Defines how fast is the angle changing.
  18299. */
  18300. angularSpeed: number;
  18301. /**
  18302. * Defines the cell index used by the particle to be rendered from a sprite.
  18303. */
  18304. cellIndex: number;
  18305. /**
  18306. * The information required to support color remapping
  18307. */
  18308. remapData: Vector4;
  18309. /** @hidden */
  18310. _randomCellOffset?: number;
  18311. /** @hidden */
  18312. _initialDirection: Nullable<Vector3>;
  18313. /** @hidden */
  18314. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18315. /** @hidden */
  18316. _initialStartSpriteCellID: number;
  18317. /** @hidden */
  18318. _initialEndSpriteCellID: number;
  18319. /** @hidden */
  18320. _currentColorGradient: Nullable<ColorGradient>;
  18321. /** @hidden */
  18322. _currentColor1: Color4;
  18323. /** @hidden */
  18324. _currentColor2: Color4;
  18325. /** @hidden */
  18326. _currentSizeGradient: Nullable<FactorGradient>;
  18327. /** @hidden */
  18328. _currentSize1: number;
  18329. /** @hidden */
  18330. _currentSize2: number;
  18331. /** @hidden */
  18332. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18333. /** @hidden */
  18334. _currentAngularSpeed1: number;
  18335. /** @hidden */
  18336. _currentAngularSpeed2: number;
  18337. /** @hidden */
  18338. _currentVelocityGradient: Nullable<FactorGradient>;
  18339. /** @hidden */
  18340. _currentVelocity1: number;
  18341. /** @hidden */
  18342. _currentVelocity2: number;
  18343. /** @hidden */
  18344. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18345. /** @hidden */
  18346. _currentLimitVelocity1: number;
  18347. /** @hidden */
  18348. _currentLimitVelocity2: number;
  18349. /** @hidden */
  18350. _currentDragGradient: Nullable<FactorGradient>;
  18351. /** @hidden */
  18352. _currentDrag1: number;
  18353. /** @hidden */
  18354. _currentDrag2: number;
  18355. /** @hidden */
  18356. _randomNoiseCoordinates1: Vector3;
  18357. /** @hidden */
  18358. _randomNoiseCoordinates2: Vector3;
  18359. /**
  18360. * Creates a new instance Particle
  18361. * @param particleSystem the particle system the particle belongs to
  18362. */
  18363. constructor(
  18364. /**
  18365. * The particle system the particle belongs to.
  18366. */
  18367. particleSystem: ParticleSystem);
  18368. private updateCellInfoFromSystem;
  18369. /**
  18370. * Defines how the sprite cell index is updated for the particle
  18371. */
  18372. updateCellIndex(): void;
  18373. /** @hidden */
  18374. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18375. /** @hidden */
  18376. _inheritParticleInfoToSubEmitters(): void;
  18377. /** @hidden */
  18378. _reset(): void;
  18379. /**
  18380. * Copy the properties of particle to another one.
  18381. * @param other the particle to copy the information to.
  18382. */
  18383. copyTo(other: Particle): void;
  18384. }
  18385. }
  18386. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18387. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18388. import { Effect } from "babylonjs/Materials/effect";
  18389. import { Particle } from "babylonjs/Particles/particle";
  18390. /**
  18391. * Particle emitter represents a volume emitting particles.
  18392. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18393. */
  18394. export interface IParticleEmitterType {
  18395. /**
  18396. * Called by the particle System when the direction is computed for the created particle.
  18397. * @param worldMatrix is the world matrix of the particle system
  18398. * @param directionToUpdate is the direction vector to update with the result
  18399. * @param particle is the particle we are computed the direction for
  18400. */
  18401. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18402. /**
  18403. * Called by the particle System when the position is computed for the created particle.
  18404. * @param worldMatrix is the world matrix of the particle system
  18405. * @param positionToUpdate is the position vector to update with the result
  18406. * @param particle is the particle we are computed the position for
  18407. */
  18408. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18409. /**
  18410. * Clones the current emitter and returns a copy of it
  18411. * @returns the new emitter
  18412. */
  18413. clone(): IParticleEmitterType;
  18414. /**
  18415. * Called by the GPUParticleSystem to setup the update shader
  18416. * @param effect defines the update shader
  18417. */
  18418. applyToShader(effect: Effect): void;
  18419. /**
  18420. * Returns a string to use to update the GPU particles update shader
  18421. * @returns the effect defines string
  18422. */
  18423. getEffectDefines(): string;
  18424. /**
  18425. * Returns a string representing the class name
  18426. * @returns a string containing the class name
  18427. */
  18428. getClassName(): string;
  18429. /**
  18430. * Serializes the particle system to a JSON object.
  18431. * @returns the JSON object
  18432. */
  18433. serialize(): any;
  18434. /**
  18435. * Parse properties from a JSON object
  18436. * @param serializationObject defines the JSON object
  18437. */
  18438. parse(serializationObject: any): void;
  18439. }
  18440. }
  18441. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18442. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18443. import { Effect } from "babylonjs/Materials/effect";
  18444. import { Particle } from "babylonjs/Particles/particle";
  18445. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18446. /**
  18447. * Particle emitter emitting particles from the inside of a box.
  18448. * It emits the particles randomly between 2 given directions.
  18449. */
  18450. export class BoxParticleEmitter implements IParticleEmitterType {
  18451. /**
  18452. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18453. */
  18454. direction1: Vector3;
  18455. /**
  18456. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18457. */
  18458. direction2: Vector3;
  18459. /**
  18460. * 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.
  18461. */
  18462. minEmitBox: Vector3;
  18463. /**
  18464. * 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.
  18465. */
  18466. maxEmitBox: Vector3;
  18467. /**
  18468. * Creates a new instance BoxParticleEmitter
  18469. */
  18470. constructor();
  18471. /**
  18472. * Called by the particle System when the direction is computed for the created particle.
  18473. * @param worldMatrix is the world matrix of the particle system
  18474. * @param directionToUpdate is the direction vector to update with the result
  18475. * @param particle is the particle we are computed the direction for
  18476. */
  18477. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18478. /**
  18479. * Called by the particle System when the position is computed for the created particle.
  18480. * @param worldMatrix is the world matrix of the particle system
  18481. * @param positionToUpdate is the position vector to update with the result
  18482. * @param particle is the particle we are computed the position for
  18483. */
  18484. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18485. /**
  18486. * Clones the current emitter and returns a copy of it
  18487. * @returns the new emitter
  18488. */
  18489. clone(): BoxParticleEmitter;
  18490. /**
  18491. * Called by the GPUParticleSystem to setup the update shader
  18492. * @param effect defines the update shader
  18493. */
  18494. applyToShader(effect: Effect): void;
  18495. /**
  18496. * Returns a string to use to update the GPU particles update shader
  18497. * @returns a string containng the defines string
  18498. */
  18499. getEffectDefines(): string;
  18500. /**
  18501. * Returns the string "BoxParticleEmitter"
  18502. * @returns a string containing the class name
  18503. */
  18504. getClassName(): string;
  18505. /**
  18506. * Serializes the particle system to a JSON object.
  18507. * @returns the JSON object
  18508. */
  18509. serialize(): any;
  18510. /**
  18511. * Parse properties from a JSON object
  18512. * @param serializationObject defines the JSON object
  18513. */
  18514. parse(serializationObject: any): void;
  18515. }
  18516. }
  18517. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18518. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18519. import { Effect } from "babylonjs/Materials/effect";
  18520. import { Particle } from "babylonjs/Particles/particle";
  18521. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18522. /**
  18523. * Particle emitter emitting particles from the inside of a cone.
  18524. * It emits the particles alongside the cone volume from the base to the particle.
  18525. * The emission direction might be randomized.
  18526. */
  18527. export class ConeParticleEmitter implements IParticleEmitterType {
  18528. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18529. directionRandomizer: number;
  18530. private _radius;
  18531. private _angle;
  18532. private _height;
  18533. /**
  18534. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18535. */
  18536. radiusRange: number;
  18537. /**
  18538. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18539. */
  18540. heightRange: number;
  18541. /**
  18542. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18543. */
  18544. emitFromSpawnPointOnly: boolean;
  18545. /**
  18546. * Gets or sets the radius of the emission cone
  18547. */
  18548. get radius(): number;
  18549. set radius(value: number);
  18550. /**
  18551. * Gets or sets the angle of the emission cone
  18552. */
  18553. get angle(): number;
  18554. set angle(value: number);
  18555. private _buildHeight;
  18556. /**
  18557. * Creates a new instance ConeParticleEmitter
  18558. * @param radius the radius of the emission cone (1 by default)
  18559. * @param angle the cone base angle (PI by default)
  18560. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18561. */
  18562. constructor(radius?: number, angle?: number,
  18563. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18564. directionRandomizer?: number);
  18565. /**
  18566. * Called by the particle System when the direction is computed for the created particle.
  18567. * @param worldMatrix is the world matrix of the particle system
  18568. * @param directionToUpdate is the direction vector to update with the result
  18569. * @param particle is the particle we are computed the direction for
  18570. */
  18571. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18572. /**
  18573. * Called by the particle System when the position is computed for the created particle.
  18574. * @param worldMatrix is the world matrix of the particle system
  18575. * @param positionToUpdate is the position vector to update with the result
  18576. * @param particle is the particle we are computed the position for
  18577. */
  18578. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18579. /**
  18580. * Clones the current emitter and returns a copy of it
  18581. * @returns the new emitter
  18582. */
  18583. clone(): ConeParticleEmitter;
  18584. /**
  18585. * Called by the GPUParticleSystem to setup the update shader
  18586. * @param effect defines the update shader
  18587. */
  18588. applyToShader(effect: Effect): void;
  18589. /**
  18590. * Returns a string to use to update the GPU particles update shader
  18591. * @returns a string containng the defines string
  18592. */
  18593. getEffectDefines(): string;
  18594. /**
  18595. * Returns the string "ConeParticleEmitter"
  18596. * @returns a string containing the class name
  18597. */
  18598. getClassName(): string;
  18599. /**
  18600. * Serializes the particle system to a JSON object.
  18601. * @returns the JSON object
  18602. */
  18603. serialize(): any;
  18604. /**
  18605. * Parse properties from a JSON object
  18606. * @param serializationObject defines the JSON object
  18607. */
  18608. parse(serializationObject: any): void;
  18609. }
  18610. }
  18611. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18612. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18613. import { Effect } from "babylonjs/Materials/effect";
  18614. import { Particle } from "babylonjs/Particles/particle";
  18615. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18616. /**
  18617. * Particle emitter emitting particles from the inside of a cylinder.
  18618. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18619. */
  18620. export class CylinderParticleEmitter implements IParticleEmitterType {
  18621. /**
  18622. * The radius of the emission cylinder.
  18623. */
  18624. radius: number;
  18625. /**
  18626. * The height of the emission cylinder.
  18627. */
  18628. height: number;
  18629. /**
  18630. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18631. */
  18632. radiusRange: number;
  18633. /**
  18634. * How much to randomize the particle direction [0-1].
  18635. */
  18636. directionRandomizer: number;
  18637. /**
  18638. * Creates a new instance CylinderParticleEmitter
  18639. * @param radius the radius of the emission cylinder (1 by default)
  18640. * @param height the height of the emission cylinder (1 by default)
  18641. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18642. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18643. */
  18644. constructor(
  18645. /**
  18646. * The radius of the emission cylinder.
  18647. */
  18648. radius?: number,
  18649. /**
  18650. * The height of the emission cylinder.
  18651. */
  18652. height?: number,
  18653. /**
  18654. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18655. */
  18656. radiusRange?: number,
  18657. /**
  18658. * How much to randomize the particle direction [0-1].
  18659. */
  18660. directionRandomizer?: number);
  18661. /**
  18662. * Called by the particle System when the direction is computed for the created particle.
  18663. * @param worldMatrix is the world matrix of the particle system
  18664. * @param directionToUpdate is the direction vector to update with the result
  18665. * @param particle is the particle we are computed the direction for
  18666. */
  18667. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18668. /**
  18669. * Called by the particle System when the position is computed for the created particle.
  18670. * @param worldMatrix is the world matrix of the particle system
  18671. * @param positionToUpdate is the position vector to update with the result
  18672. * @param particle is the particle we are computed the position for
  18673. */
  18674. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18675. /**
  18676. * Clones the current emitter and returns a copy of it
  18677. * @returns the new emitter
  18678. */
  18679. clone(): CylinderParticleEmitter;
  18680. /**
  18681. * Called by the GPUParticleSystem to setup the update shader
  18682. * @param effect defines the update shader
  18683. */
  18684. applyToShader(effect: Effect): void;
  18685. /**
  18686. * Returns a string to use to update the GPU particles update shader
  18687. * @returns a string containng the defines string
  18688. */
  18689. getEffectDefines(): string;
  18690. /**
  18691. * Returns the string "CylinderParticleEmitter"
  18692. * @returns a string containing the class name
  18693. */
  18694. getClassName(): string;
  18695. /**
  18696. * Serializes the particle system to a JSON object.
  18697. * @returns the JSON object
  18698. */
  18699. serialize(): any;
  18700. /**
  18701. * Parse properties from a JSON object
  18702. * @param serializationObject defines the JSON object
  18703. */
  18704. parse(serializationObject: any): void;
  18705. }
  18706. /**
  18707. * Particle emitter emitting particles from the inside of a cylinder.
  18708. * It emits the particles randomly between two vectors.
  18709. */
  18710. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18711. /**
  18712. * The min limit of the emission direction.
  18713. */
  18714. direction1: Vector3;
  18715. /**
  18716. * The max limit of the emission direction.
  18717. */
  18718. direction2: Vector3;
  18719. /**
  18720. * Creates a new instance CylinderDirectedParticleEmitter
  18721. * @param radius the radius of the emission cylinder (1 by default)
  18722. * @param height the height of the emission cylinder (1 by default)
  18723. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18724. * @param direction1 the min limit of the emission direction (up vector by default)
  18725. * @param direction2 the max limit of the emission direction (up vector by default)
  18726. */
  18727. constructor(radius?: number, height?: number, radiusRange?: number,
  18728. /**
  18729. * The min limit of the emission direction.
  18730. */
  18731. direction1?: Vector3,
  18732. /**
  18733. * The max limit of the emission direction.
  18734. */
  18735. direction2?: Vector3);
  18736. /**
  18737. * Called by the particle System when the direction is computed for the created particle.
  18738. * @param worldMatrix is the world matrix of the particle system
  18739. * @param directionToUpdate is the direction vector to update with the result
  18740. * @param particle is the particle we are computed the direction for
  18741. */
  18742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18743. /**
  18744. * Clones the current emitter and returns a copy of it
  18745. * @returns the new emitter
  18746. */
  18747. clone(): CylinderDirectedParticleEmitter;
  18748. /**
  18749. * Called by the GPUParticleSystem to setup the update shader
  18750. * @param effect defines the update shader
  18751. */
  18752. applyToShader(effect: Effect): void;
  18753. /**
  18754. * Returns a string to use to update the GPU particles update shader
  18755. * @returns a string containng the defines string
  18756. */
  18757. getEffectDefines(): string;
  18758. /**
  18759. * Returns the string "CylinderDirectedParticleEmitter"
  18760. * @returns a string containing the class name
  18761. */
  18762. getClassName(): string;
  18763. /**
  18764. * Serializes the particle system to a JSON object.
  18765. * @returns the JSON object
  18766. */
  18767. serialize(): any;
  18768. /**
  18769. * Parse properties from a JSON object
  18770. * @param serializationObject defines the JSON object
  18771. */
  18772. parse(serializationObject: any): void;
  18773. }
  18774. }
  18775. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18776. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18777. import { Effect } from "babylonjs/Materials/effect";
  18778. import { Particle } from "babylonjs/Particles/particle";
  18779. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18780. /**
  18781. * Particle emitter emitting particles from the inside of a hemisphere.
  18782. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18783. */
  18784. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18785. /**
  18786. * The radius of the emission hemisphere.
  18787. */
  18788. radius: number;
  18789. /**
  18790. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18791. */
  18792. radiusRange: number;
  18793. /**
  18794. * How much to randomize the particle direction [0-1].
  18795. */
  18796. directionRandomizer: number;
  18797. /**
  18798. * Creates a new instance HemisphericParticleEmitter
  18799. * @param radius the radius of the emission hemisphere (1 by default)
  18800. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18801. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18802. */
  18803. constructor(
  18804. /**
  18805. * The radius of the emission hemisphere.
  18806. */
  18807. radius?: number,
  18808. /**
  18809. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18810. */
  18811. radiusRange?: number,
  18812. /**
  18813. * How much to randomize the particle direction [0-1].
  18814. */
  18815. directionRandomizer?: number);
  18816. /**
  18817. * Called by the particle System when the direction is computed for the created particle.
  18818. * @param worldMatrix is the world matrix of the particle system
  18819. * @param directionToUpdate is the direction vector to update with the result
  18820. * @param particle is the particle we are computed the direction for
  18821. */
  18822. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18823. /**
  18824. * Called by the particle System when the position is computed for the created particle.
  18825. * @param worldMatrix is the world matrix of the particle system
  18826. * @param positionToUpdate is the position vector to update with the result
  18827. * @param particle is the particle we are computed the position for
  18828. */
  18829. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18830. /**
  18831. * Clones the current emitter and returns a copy of it
  18832. * @returns the new emitter
  18833. */
  18834. clone(): HemisphericParticleEmitter;
  18835. /**
  18836. * Called by the GPUParticleSystem to setup the update shader
  18837. * @param effect defines the update shader
  18838. */
  18839. applyToShader(effect: Effect): void;
  18840. /**
  18841. * Returns a string to use to update the GPU particles update shader
  18842. * @returns a string containng the defines string
  18843. */
  18844. getEffectDefines(): string;
  18845. /**
  18846. * Returns the string "HemisphericParticleEmitter"
  18847. * @returns a string containing the class name
  18848. */
  18849. getClassName(): string;
  18850. /**
  18851. * Serializes the particle system to a JSON object.
  18852. * @returns the JSON object
  18853. */
  18854. serialize(): any;
  18855. /**
  18856. * Parse properties from a JSON object
  18857. * @param serializationObject defines the JSON object
  18858. */
  18859. parse(serializationObject: any): void;
  18860. }
  18861. }
  18862. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18863. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18864. import { Effect } from "babylonjs/Materials/effect";
  18865. import { Particle } from "babylonjs/Particles/particle";
  18866. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18867. /**
  18868. * Particle emitter emitting particles from a point.
  18869. * It emits the particles randomly between 2 given directions.
  18870. */
  18871. export class PointParticleEmitter implements IParticleEmitterType {
  18872. /**
  18873. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18874. */
  18875. direction1: Vector3;
  18876. /**
  18877. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18878. */
  18879. direction2: Vector3;
  18880. /**
  18881. * Creates a new instance PointParticleEmitter
  18882. */
  18883. constructor();
  18884. /**
  18885. * Called by the particle System when the direction is computed for the created particle.
  18886. * @param worldMatrix is the world matrix of the particle system
  18887. * @param directionToUpdate is the direction vector to update with the result
  18888. * @param particle is the particle we are computed the direction for
  18889. */
  18890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18891. /**
  18892. * Called by the particle System when the position is computed for the created particle.
  18893. * @param worldMatrix is the world matrix of the particle system
  18894. * @param positionToUpdate is the position vector to update with the result
  18895. * @param particle is the particle we are computed the position for
  18896. */
  18897. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18898. /**
  18899. * Clones the current emitter and returns a copy of it
  18900. * @returns the new emitter
  18901. */
  18902. clone(): PointParticleEmitter;
  18903. /**
  18904. * Called by the GPUParticleSystem to setup the update shader
  18905. * @param effect defines the update shader
  18906. */
  18907. applyToShader(effect: Effect): void;
  18908. /**
  18909. * Returns a string to use to update the GPU particles update shader
  18910. * @returns a string containng the defines string
  18911. */
  18912. getEffectDefines(): string;
  18913. /**
  18914. * Returns the string "PointParticleEmitter"
  18915. * @returns a string containing the class name
  18916. */
  18917. getClassName(): string;
  18918. /**
  18919. * Serializes the particle system to a JSON object.
  18920. * @returns the JSON object
  18921. */
  18922. serialize(): any;
  18923. /**
  18924. * Parse properties from a JSON object
  18925. * @param serializationObject defines the JSON object
  18926. */
  18927. parse(serializationObject: any): void;
  18928. }
  18929. }
  18930. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18931. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18932. import { Effect } from "babylonjs/Materials/effect";
  18933. import { Particle } from "babylonjs/Particles/particle";
  18934. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18935. /**
  18936. * Particle emitter emitting particles from the inside of a sphere.
  18937. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18938. */
  18939. export class SphereParticleEmitter implements IParticleEmitterType {
  18940. /**
  18941. * The radius of the emission sphere.
  18942. */
  18943. radius: number;
  18944. /**
  18945. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18946. */
  18947. radiusRange: number;
  18948. /**
  18949. * How much to randomize the particle direction [0-1].
  18950. */
  18951. directionRandomizer: number;
  18952. /**
  18953. * Creates a new instance SphereParticleEmitter
  18954. * @param radius the radius of the emission sphere (1 by default)
  18955. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18956. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18957. */
  18958. constructor(
  18959. /**
  18960. * The radius of the emission sphere.
  18961. */
  18962. radius?: number,
  18963. /**
  18964. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18965. */
  18966. radiusRange?: number,
  18967. /**
  18968. * How much to randomize the particle direction [0-1].
  18969. */
  18970. directionRandomizer?: number);
  18971. /**
  18972. * Called by the particle System when the direction is computed for the created particle.
  18973. * @param worldMatrix is the world matrix of the particle system
  18974. * @param directionToUpdate is the direction vector to update with the result
  18975. * @param particle is the particle we are computed the direction for
  18976. */
  18977. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18978. /**
  18979. * Called by the particle System when the position is computed for the created particle.
  18980. * @param worldMatrix is the world matrix of the particle system
  18981. * @param positionToUpdate is the position vector to update with the result
  18982. * @param particle is the particle we are computed the position for
  18983. */
  18984. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18985. /**
  18986. * Clones the current emitter and returns a copy of it
  18987. * @returns the new emitter
  18988. */
  18989. clone(): SphereParticleEmitter;
  18990. /**
  18991. * Called by the GPUParticleSystem to setup the update shader
  18992. * @param effect defines the update shader
  18993. */
  18994. applyToShader(effect: Effect): void;
  18995. /**
  18996. * Returns a string to use to update the GPU particles update shader
  18997. * @returns a string containng the defines string
  18998. */
  18999. getEffectDefines(): string;
  19000. /**
  19001. * Returns the string "SphereParticleEmitter"
  19002. * @returns a string containing the class name
  19003. */
  19004. getClassName(): string;
  19005. /**
  19006. * Serializes the particle system to a JSON object.
  19007. * @returns the JSON object
  19008. */
  19009. serialize(): any;
  19010. /**
  19011. * Parse properties from a JSON object
  19012. * @param serializationObject defines the JSON object
  19013. */
  19014. parse(serializationObject: any): void;
  19015. }
  19016. /**
  19017. * Particle emitter emitting particles from the inside of a sphere.
  19018. * It emits the particles randomly between two vectors.
  19019. */
  19020. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  19021. /**
  19022. * The min limit of the emission direction.
  19023. */
  19024. direction1: Vector3;
  19025. /**
  19026. * The max limit of the emission direction.
  19027. */
  19028. direction2: Vector3;
  19029. /**
  19030. * Creates a new instance SphereDirectedParticleEmitter
  19031. * @param radius the radius of the emission sphere (1 by default)
  19032. * @param direction1 the min limit of the emission direction (up vector by default)
  19033. * @param direction2 the max limit of the emission direction (up vector by default)
  19034. */
  19035. constructor(radius?: number,
  19036. /**
  19037. * The min limit of the emission direction.
  19038. */
  19039. direction1?: Vector3,
  19040. /**
  19041. * The max limit of the emission direction.
  19042. */
  19043. direction2?: Vector3);
  19044. /**
  19045. * Called by the particle System when the direction is computed for the created particle.
  19046. * @param worldMatrix is the world matrix of the particle system
  19047. * @param directionToUpdate is the direction vector to update with the result
  19048. * @param particle is the particle we are computed the direction for
  19049. */
  19050. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19051. /**
  19052. * Clones the current emitter and returns a copy of it
  19053. * @returns the new emitter
  19054. */
  19055. clone(): SphereDirectedParticleEmitter;
  19056. /**
  19057. * Called by the GPUParticleSystem to setup the update shader
  19058. * @param effect defines the update shader
  19059. */
  19060. applyToShader(effect: Effect): void;
  19061. /**
  19062. * Returns a string to use to update the GPU particles update shader
  19063. * @returns a string containng the defines string
  19064. */
  19065. getEffectDefines(): string;
  19066. /**
  19067. * Returns the string "SphereDirectedParticleEmitter"
  19068. * @returns a string containing the class name
  19069. */
  19070. getClassName(): string;
  19071. /**
  19072. * Serializes the particle system to a JSON object.
  19073. * @returns the JSON object
  19074. */
  19075. serialize(): any;
  19076. /**
  19077. * Parse properties from a JSON object
  19078. * @param serializationObject defines the JSON object
  19079. */
  19080. parse(serializationObject: any): void;
  19081. }
  19082. }
  19083. declare module "babylonjs/Particles/EmitterTypes/index" {
  19084. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19085. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19086. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19087. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19088. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19089. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19090. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19091. }
  19092. declare module "babylonjs/Particles/IParticleSystem" {
  19093. import { Nullable } from "babylonjs/types";
  19094. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19095. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19097. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19098. import { Texture } from "babylonjs/Materials/Textures/texture";
  19099. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19100. import { Scene } from "babylonjs/scene";
  19101. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19102. import { Animation } from "babylonjs/Animations/animation";
  19103. /**
  19104. * Interface representing a particle system in Babylon.js.
  19105. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19106. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19107. */
  19108. export interface IParticleSystem {
  19109. /**
  19110. * List of animations used by the particle system.
  19111. */
  19112. animations: Animation[];
  19113. /**
  19114. * The id of the Particle system.
  19115. */
  19116. id: string;
  19117. /**
  19118. * The name of the Particle system.
  19119. */
  19120. name: string;
  19121. /**
  19122. * The emitter represents the Mesh or position we are attaching the particle system to.
  19123. */
  19124. emitter: Nullable<AbstractMesh | Vector3>;
  19125. /**
  19126. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19127. */
  19128. isBillboardBased: boolean;
  19129. /**
  19130. * The rendering group used by the Particle system to chose when to render.
  19131. */
  19132. renderingGroupId: number;
  19133. /**
  19134. * The layer mask we are rendering the particles through.
  19135. */
  19136. layerMask: number;
  19137. /**
  19138. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19139. */
  19140. updateSpeed: number;
  19141. /**
  19142. * The amount of time the particle system is running (depends of the overall update speed).
  19143. */
  19144. targetStopDuration: number;
  19145. /**
  19146. * The texture used to render each particle. (this can be a spritesheet)
  19147. */
  19148. particleTexture: Nullable<Texture>;
  19149. /**
  19150. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19151. */
  19152. blendMode: number;
  19153. /**
  19154. * Minimum life time of emitting particles.
  19155. */
  19156. minLifeTime: number;
  19157. /**
  19158. * Maximum life time of emitting particles.
  19159. */
  19160. maxLifeTime: number;
  19161. /**
  19162. * Minimum Size of emitting particles.
  19163. */
  19164. minSize: number;
  19165. /**
  19166. * Maximum Size of emitting particles.
  19167. */
  19168. maxSize: number;
  19169. /**
  19170. * Minimum scale of emitting particles on X axis.
  19171. */
  19172. minScaleX: number;
  19173. /**
  19174. * Maximum scale of emitting particles on X axis.
  19175. */
  19176. maxScaleX: number;
  19177. /**
  19178. * Minimum scale of emitting particles on Y axis.
  19179. */
  19180. minScaleY: number;
  19181. /**
  19182. * Maximum scale of emitting particles on Y axis.
  19183. */
  19184. maxScaleY: number;
  19185. /**
  19186. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19187. */
  19188. color1: Color4;
  19189. /**
  19190. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19191. */
  19192. color2: Color4;
  19193. /**
  19194. * Color the particle will have at the end of its lifetime.
  19195. */
  19196. colorDead: Color4;
  19197. /**
  19198. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19199. */
  19200. emitRate: number;
  19201. /**
  19202. * You can use gravity if you want to give an orientation to your particles.
  19203. */
  19204. gravity: Vector3;
  19205. /**
  19206. * Minimum power of emitting particles.
  19207. */
  19208. minEmitPower: number;
  19209. /**
  19210. * Maximum power of emitting particles.
  19211. */
  19212. maxEmitPower: number;
  19213. /**
  19214. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19215. */
  19216. minAngularSpeed: number;
  19217. /**
  19218. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19219. */
  19220. maxAngularSpeed: number;
  19221. /**
  19222. * Gets or sets the minimal initial rotation in radians.
  19223. */
  19224. minInitialRotation: number;
  19225. /**
  19226. * Gets or sets the maximal initial rotation in radians.
  19227. */
  19228. maxInitialRotation: number;
  19229. /**
  19230. * The particle emitter type defines the emitter used by the particle system.
  19231. * It can be for example box, sphere, or cone...
  19232. */
  19233. particleEmitterType: Nullable<IParticleEmitterType>;
  19234. /**
  19235. * Defines the delay in milliseconds before starting the system (0 by default)
  19236. */
  19237. startDelay: number;
  19238. /**
  19239. * 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
  19240. */
  19241. preWarmCycles: number;
  19242. /**
  19243. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19244. */
  19245. preWarmStepOffset: number;
  19246. /**
  19247. * 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)
  19248. */
  19249. spriteCellChangeSpeed: number;
  19250. /**
  19251. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19252. */
  19253. startSpriteCellID: number;
  19254. /**
  19255. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19256. */
  19257. endSpriteCellID: number;
  19258. /**
  19259. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19260. */
  19261. spriteCellWidth: number;
  19262. /**
  19263. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19264. */
  19265. spriteCellHeight: number;
  19266. /**
  19267. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19268. */
  19269. spriteRandomStartCell: boolean;
  19270. /**
  19271. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19272. */
  19273. isAnimationSheetEnabled: boolean;
  19274. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19275. translationPivot: Vector2;
  19276. /**
  19277. * Gets or sets a texture used to add random noise to particle positions
  19278. */
  19279. noiseTexture: Nullable<BaseTexture>;
  19280. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19281. noiseStrength: Vector3;
  19282. /**
  19283. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19284. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19285. */
  19286. billboardMode: number;
  19287. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19288. limitVelocityDamping: number;
  19289. /**
  19290. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19291. */
  19292. beginAnimationOnStart: boolean;
  19293. /**
  19294. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19295. */
  19296. beginAnimationFrom: number;
  19297. /**
  19298. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19299. */
  19300. beginAnimationTo: number;
  19301. /**
  19302. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19303. */
  19304. beginAnimationLoop: boolean;
  19305. /**
  19306. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19307. */
  19308. disposeOnStop: boolean;
  19309. /**
  19310. * Gets the maximum number of particles active at the same time.
  19311. * @returns The max number of active particles.
  19312. */
  19313. getCapacity(): number;
  19314. /**
  19315. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19316. * @returns True if it has been started, otherwise false.
  19317. */
  19318. isStarted(): boolean;
  19319. /**
  19320. * Animates the particle system for this frame.
  19321. */
  19322. animate(): void;
  19323. /**
  19324. * Renders the particle system in its current state.
  19325. * @returns the current number of particles
  19326. */
  19327. render(): number;
  19328. /**
  19329. * Dispose the particle system and frees its associated resources.
  19330. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19331. */
  19332. dispose(disposeTexture?: boolean): void;
  19333. /**
  19334. * Clones the particle system.
  19335. * @param name The name of the cloned object
  19336. * @param newEmitter The new emitter to use
  19337. * @returns the cloned particle system
  19338. */
  19339. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19340. /**
  19341. * Serializes the particle system to a JSON object.
  19342. * @returns the JSON object
  19343. */
  19344. serialize(): any;
  19345. /**
  19346. * Rebuild the particle system
  19347. */
  19348. rebuild(): void;
  19349. /**
  19350. * Starts the particle system and begins to emit
  19351. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19352. */
  19353. start(delay?: number): void;
  19354. /**
  19355. * Stops the particle system.
  19356. */
  19357. stop(): void;
  19358. /**
  19359. * Remove all active particles
  19360. */
  19361. reset(): void;
  19362. /**
  19363. * Is this system ready to be used/rendered
  19364. * @return true if the system is ready
  19365. */
  19366. isReady(): boolean;
  19367. /**
  19368. * Adds a new color gradient
  19369. * @param gradient defines the gradient to use (between 0 and 1)
  19370. * @param color1 defines the color to affect to the specified gradient
  19371. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19372. * @returns the current particle system
  19373. */
  19374. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19375. /**
  19376. * Remove a specific color gradient
  19377. * @param gradient defines the gradient to remove
  19378. * @returns the current particle system
  19379. */
  19380. removeColorGradient(gradient: number): IParticleSystem;
  19381. /**
  19382. * Adds a new size gradient
  19383. * @param gradient defines the gradient to use (between 0 and 1)
  19384. * @param factor defines the size factor to affect to the specified gradient
  19385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19386. * @returns the current particle system
  19387. */
  19388. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19389. /**
  19390. * Remove a specific size gradient
  19391. * @param gradient defines the gradient to remove
  19392. * @returns the current particle system
  19393. */
  19394. removeSizeGradient(gradient: number): IParticleSystem;
  19395. /**
  19396. * Gets the current list of color gradients.
  19397. * You must use addColorGradient and removeColorGradient to udpate this list
  19398. * @returns the list of color gradients
  19399. */
  19400. getColorGradients(): Nullable<Array<ColorGradient>>;
  19401. /**
  19402. * Gets the current list of size gradients.
  19403. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19404. * @returns the list of size gradients
  19405. */
  19406. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19407. /**
  19408. * Gets the current list of angular speed gradients.
  19409. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19410. * @returns the list of angular speed gradients
  19411. */
  19412. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19413. /**
  19414. * Adds a new angular speed gradient
  19415. * @param gradient defines the gradient to use (between 0 and 1)
  19416. * @param factor defines the angular speed to affect to the specified gradient
  19417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19418. * @returns the current particle system
  19419. */
  19420. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19421. /**
  19422. * Remove a specific angular speed gradient
  19423. * @param gradient defines the gradient to remove
  19424. * @returns the current particle system
  19425. */
  19426. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19427. /**
  19428. * Gets the current list of velocity gradients.
  19429. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19430. * @returns the list of velocity gradients
  19431. */
  19432. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19433. /**
  19434. * Adds a new velocity gradient
  19435. * @param gradient defines the gradient to use (between 0 and 1)
  19436. * @param factor defines the velocity to affect to the specified gradient
  19437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19438. * @returns the current particle system
  19439. */
  19440. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19441. /**
  19442. * Remove a specific velocity gradient
  19443. * @param gradient defines the gradient to remove
  19444. * @returns the current particle system
  19445. */
  19446. removeVelocityGradient(gradient: number): IParticleSystem;
  19447. /**
  19448. * Gets the current list of limit velocity gradients.
  19449. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19450. * @returns the list of limit velocity gradients
  19451. */
  19452. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19453. /**
  19454. * Adds a new limit velocity gradient
  19455. * @param gradient defines the gradient to use (between 0 and 1)
  19456. * @param factor defines the limit velocity to affect to the specified gradient
  19457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19458. * @returns the current particle system
  19459. */
  19460. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19461. /**
  19462. * Remove a specific limit velocity gradient
  19463. * @param gradient defines the gradient to remove
  19464. * @returns the current particle system
  19465. */
  19466. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19467. /**
  19468. * Adds a new drag gradient
  19469. * @param gradient defines the gradient to use (between 0 and 1)
  19470. * @param factor defines the drag to affect to the specified gradient
  19471. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19472. * @returns the current particle system
  19473. */
  19474. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19475. /**
  19476. * Remove a specific drag gradient
  19477. * @param gradient defines the gradient to remove
  19478. * @returns the current particle system
  19479. */
  19480. removeDragGradient(gradient: number): IParticleSystem;
  19481. /**
  19482. * Gets the current list of drag gradients.
  19483. * You must use addDragGradient and removeDragGradient to udpate this list
  19484. * @returns the list of drag gradients
  19485. */
  19486. getDragGradients(): Nullable<Array<FactorGradient>>;
  19487. /**
  19488. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19489. * @param gradient defines the gradient to use (between 0 and 1)
  19490. * @param factor defines the emit rate to affect to the specified gradient
  19491. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19492. * @returns the current particle system
  19493. */
  19494. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19495. /**
  19496. * Remove a specific emit rate gradient
  19497. * @param gradient defines the gradient to remove
  19498. * @returns the current particle system
  19499. */
  19500. removeEmitRateGradient(gradient: number): IParticleSystem;
  19501. /**
  19502. * Gets the current list of emit rate gradients.
  19503. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19504. * @returns the list of emit rate gradients
  19505. */
  19506. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19507. /**
  19508. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19509. * @param gradient defines the gradient to use (between 0 and 1)
  19510. * @param factor defines the start size to affect to the specified gradient
  19511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19512. * @returns the current particle system
  19513. */
  19514. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19515. /**
  19516. * Remove a specific start size gradient
  19517. * @param gradient defines the gradient to remove
  19518. * @returns the current particle system
  19519. */
  19520. removeStartSizeGradient(gradient: number): IParticleSystem;
  19521. /**
  19522. * Gets the current list of start size gradients.
  19523. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19524. * @returns the list of start size gradients
  19525. */
  19526. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19527. /**
  19528. * Adds a new life time gradient
  19529. * @param gradient defines the gradient to use (between 0 and 1)
  19530. * @param factor defines the life time factor to affect to the specified gradient
  19531. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19532. * @returns the current particle system
  19533. */
  19534. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19535. /**
  19536. * Remove a specific life time gradient
  19537. * @param gradient defines the gradient to remove
  19538. * @returns the current particle system
  19539. */
  19540. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19541. /**
  19542. * Gets the current list of life time gradients.
  19543. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19544. * @returns the list of life time gradients
  19545. */
  19546. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19547. /**
  19548. * Gets the current list of color gradients.
  19549. * You must use addColorGradient and removeColorGradient to udpate this list
  19550. * @returns the list of color gradients
  19551. */
  19552. getColorGradients(): Nullable<Array<ColorGradient>>;
  19553. /**
  19554. * Adds a new ramp gradient used to remap particle colors
  19555. * @param gradient defines the gradient to use (between 0 and 1)
  19556. * @param color defines the color to affect to the specified gradient
  19557. * @returns the current particle system
  19558. */
  19559. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19560. /**
  19561. * Gets the current list of ramp gradients.
  19562. * You must use addRampGradient and removeRampGradient to udpate this list
  19563. * @returns the list of ramp gradients
  19564. */
  19565. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19566. /** Gets or sets a boolean indicating that ramp gradients must be used
  19567. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19568. */
  19569. useRampGradients: boolean;
  19570. /**
  19571. * Adds a new color remap gradient
  19572. * @param gradient defines the gradient to use (between 0 and 1)
  19573. * @param min defines the color remap minimal range
  19574. * @param max defines the color remap maximal range
  19575. * @returns the current particle system
  19576. */
  19577. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19578. /**
  19579. * Gets the current list of color remap gradients.
  19580. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19581. * @returns the list of color remap gradients
  19582. */
  19583. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19584. /**
  19585. * Adds a new alpha remap gradient
  19586. * @param gradient defines the gradient to use (between 0 and 1)
  19587. * @param min defines the alpha remap minimal range
  19588. * @param max defines the alpha remap maximal range
  19589. * @returns the current particle system
  19590. */
  19591. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19592. /**
  19593. * Gets the current list of alpha remap gradients.
  19594. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19595. * @returns the list of alpha remap gradients
  19596. */
  19597. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19598. /**
  19599. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19602. * @returns the emitter
  19603. */
  19604. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19605. /**
  19606. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19607. * @param radius The radius of the hemisphere to emit from
  19608. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19609. * @returns the emitter
  19610. */
  19611. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19612. /**
  19613. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19614. * @param radius The radius of the sphere to emit from
  19615. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19616. * @returns the emitter
  19617. */
  19618. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19619. /**
  19620. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19621. * @param radius The radius of the sphere to emit from
  19622. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19623. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19624. * @returns the emitter
  19625. */
  19626. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19627. /**
  19628. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19629. * @param radius The radius of the emission cylinder
  19630. * @param height The height of the emission cylinder
  19631. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19632. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19633. * @returns the emitter
  19634. */
  19635. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19636. /**
  19637. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19638. * @param radius The radius of the cylinder to emit from
  19639. * @param height The height of the emission cylinder
  19640. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19643. * @returns the emitter
  19644. */
  19645. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19646. /**
  19647. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19648. * @param radius The radius of the cone to emit from
  19649. * @param angle The base angle of the cone
  19650. * @returns the emitter
  19651. */
  19652. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19653. /**
  19654. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19655. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19656. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19657. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19658. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19659. * @returns the emitter
  19660. */
  19661. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19662. /**
  19663. * Get hosting scene
  19664. * @returns the scene
  19665. */
  19666. getScene(): Scene;
  19667. }
  19668. }
  19669. declare module "babylonjs/Meshes/instancedMesh" {
  19670. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19671. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19672. import { Camera } from "babylonjs/Cameras/camera";
  19673. import { Node } from "babylonjs/node";
  19674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19675. import { Mesh } from "babylonjs/Meshes/mesh";
  19676. import { Material } from "babylonjs/Materials/material";
  19677. import { Skeleton } from "babylonjs/Bones/skeleton";
  19678. import { Light } from "babylonjs/Lights/light";
  19679. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19680. /**
  19681. * Creates an instance based on a source mesh.
  19682. */
  19683. export class InstancedMesh extends AbstractMesh {
  19684. private _sourceMesh;
  19685. private _currentLOD;
  19686. /** @hidden */
  19687. _indexInSourceMeshInstanceArray: number;
  19688. constructor(name: string, source: Mesh);
  19689. /**
  19690. * Returns the string "InstancedMesh".
  19691. */
  19692. getClassName(): string;
  19693. /** Gets the list of lights affecting that mesh */
  19694. get lightSources(): Light[];
  19695. _resyncLightSources(): void;
  19696. _resyncLightSource(light: Light): void;
  19697. _removeLightSource(light: Light, dispose: boolean): void;
  19698. /**
  19699. * If the source mesh receives shadows
  19700. */
  19701. get receiveShadows(): boolean;
  19702. /**
  19703. * The material of the source mesh
  19704. */
  19705. get material(): Nullable<Material>;
  19706. /**
  19707. * Visibility of the source mesh
  19708. */
  19709. get visibility(): number;
  19710. /**
  19711. * Skeleton of the source mesh
  19712. */
  19713. get skeleton(): Nullable<Skeleton>;
  19714. /**
  19715. * Rendering ground id of the source mesh
  19716. */
  19717. get renderingGroupId(): number;
  19718. set renderingGroupId(value: number);
  19719. /**
  19720. * Returns the total number of vertices (integer).
  19721. */
  19722. getTotalVertices(): number;
  19723. /**
  19724. * Returns a positive integer : the total number of indices in this mesh geometry.
  19725. * @returns the numner of indices or zero if the mesh has no geometry.
  19726. */
  19727. getTotalIndices(): number;
  19728. /**
  19729. * The source mesh of the instance
  19730. */
  19731. get sourceMesh(): Mesh;
  19732. /**
  19733. * Is this node ready to be used/rendered
  19734. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19735. * @return {boolean} is it ready
  19736. */
  19737. isReady(completeCheck?: boolean): boolean;
  19738. /**
  19739. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19740. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19741. * @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.
  19742. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19743. */
  19744. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19745. /**
  19746. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19747. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19748. * The `data` are either a numeric array either a Float32Array.
  19749. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19750. * 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).
  19751. * Note that a new underlying VertexBuffer object is created each call.
  19752. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19753. *
  19754. * Possible `kind` values :
  19755. * - VertexBuffer.PositionKind
  19756. * - VertexBuffer.UVKind
  19757. * - VertexBuffer.UV2Kind
  19758. * - VertexBuffer.UV3Kind
  19759. * - VertexBuffer.UV4Kind
  19760. * - VertexBuffer.UV5Kind
  19761. * - VertexBuffer.UV6Kind
  19762. * - VertexBuffer.ColorKind
  19763. * - VertexBuffer.MatricesIndicesKind
  19764. * - VertexBuffer.MatricesIndicesExtraKind
  19765. * - VertexBuffer.MatricesWeightsKind
  19766. * - VertexBuffer.MatricesWeightsExtraKind
  19767. *
  19768. * Returns the Mesh.
  19769. */
  19770. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19771. /**
  19772. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19773. * If the mesh has no geometry, it is simply returned as it is.
  19774. * The `data` are either a numeric array either a Float32Array.
  19775. * No new underlying VertexBuffer object is created.
  19776. * 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.
  19777. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19778. *
  19779. * Possible `kind` values :
  19780. * - VertexBuffer.PositionKind
  19781. * - VertexBuffer.UVKind
  19782. * - VertexBuffer.UV2Kind
  19783. * - VertexBuffer.UV3Kind
  19784. * - VertexBuffer.UV4Kind
  19785. * - VertexBuffer.UV5Kind
  19786. * - VertexBuffer.UV6Kind
  19787. * - VertexBuffer.ColorKind
  19788. * - VertexBuffer.MatricesIndicesKind
  19789. * - VertexBuffer.MatricesIndicesExtraKind
  19790. * - VertexBuffer.MatricesWeightsKind
  19791. * - VertexBuffer.MatricesWeightsExtraKind
  19792. *
  19793. * Returns the Mesh.
  19794. */
  19795. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19796. /**
  19797. * Sets the mesh indices.
  19798. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19799. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19800. * This method creates a new index buffer each call.
  19801. * Returns the Mesh.
  19802. */
  19803. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19804. /**
  19805. * Boolean : True if the mesh owns the requested kind of data.
  19806. */
  19807. isVerticesDataPresent(kind: string): boolean;
  19808. /**
  19809. * Returns an array of indices (IndicesArray).
  19810. */
  19811. getIndices(): Nullable<IndicesArray>;
  19812. get _positions(): Nullable<Vector3[]>;
  19813. /**
  19814. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19815. * This means the mesh underlying bounding box and sphere are recomputed.
  19816. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19817. * @returns the current mesh
  19818. */
  19819. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19820. /** @hidden */
  19821. _preActivate(): InstancedMesh;
  19822. /** @hidden */
  19823. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19824. /** @hidden */
  19825. _postActivate(): void;
  19826. getWorldMatrix(): Matrix;
  19827. get isAnInstance(): boolean;
  19828. /**
  19829. * Returns the current associated LOD AbstractMesh.
  19830. */
  19831. getLOD(camera: Camera): AbstractMesh;
  19832. /** @hidden */
  19833. _syncSubMeshes(): InstancedMesh;
  19834. /** @hidden */
  19835. _generatePointsArray(): boolean;
  19836. /**
  19837. * Creates a new InstancedMesh from the current mesh.
  19838. * - name (string) : the cloned mesh name
  19839. * - newParent (optional Node) : the optional Node to parent the clone to.
  19840. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19841. *
  19842. * Returns the clone.
  19843. */
  19844. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19845. /**
  19846. * Disposes the InstancedMesh.
  19847. * Returns nothing.
  19848. */
  19849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19850. }
  19851. module "babylonjs/Meshes/mesh" {
  19852. interface Mesh {
  19853. /**
  19854. * Register a custom buffer that will be instanced
  19855. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19856. * @param kind defines the buffer kind
  19857. * @param stride defines the stride in floats
  19858. */
  19859. registerInstancedBuffer(kind: string, stride: number): void;
  19860. /** @hidden */
  19861. _userInstancedBuffersStorage: {
  19862. data: {
  19863. [key: string]: Float32Array;
  19864. };
  19865. sizes: {
  19866. [key: string]: number;
  19867. };
  19868. vertexBuffers: {
  19869. [key: string]: Nullable<VertexBuffer>;
  19870. };
  19871. strides: {
  19872. [key: string]: number;
  19873. };
  19874. };
  19875. }
  19876. }
  19877. module "babylonjs/Meshes/abstractMesh" {
  19878. interface AbstractMesh {
  19879. /**
  19880. * Object used to store instanced buffers defined by user
  19881. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19882. */
  19883. instancedBuffers: {
  19884. [key: string]: any;
  19885. };
  19886. }
  19887. }
  19888. }
  19889. declare module "babylonjs/Materials/shaderMaterial" {
  19890. import { Scene } from "babylonjs/scene";
  19891. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19893. import { Mesh } from "babylonjs/Meshes/mesh";
  19894. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19896. import { Texture } from "babylonjs/Materials/Textures/texture";
  19897. import { Material } from "babylonjs/Materials/material";
  19898. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19899. /**
  19900. * Defines the options associated with the creation of a shader material.
  19901. */
  19902. export interface IShaderMaterialOptions {
  19903. /**
  19904. * Does the material work in alpha blend mode
  19905. */
  19906. needAlphaBlending: boolean;
  19907. /**
  19908. * Does the material work in alpha test mode
  19909. */
  19910. needAlphaTesting: boolean;
  19911. /**
  19912. * The list of attribute names used in the shader
  19913. */
  19914. attributes: string[];
  19915. /**
  19916. * The list of unifrom names used in the shader
  19917. */
  19918. uniforms: string[];
  19919. /**
  19920. * The list of UBO names used in the shader
  19921. */
  19922. uniformBuffers: string[];
  19923. /**
  19924. * The list of sampler names used in the shader
  19925. */
  19926. samplers: string[];
  19927. /**
  19928. * The list of defines used in the shader
  19929. */
  19930. defines: string[];
  19931. }
  19932. /**
  19933. * 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.
  19934. *
  19935. * This returned material effects how the mesh will look based on the code in the shaders.
  19936. *
  19937. * @see http://doc.babylonjs.com/how_to/shader_material
  19938. */
  19939. export class ShaderMaterial extends Material {
  19940. private _shaderPath;
  19941. private _options;
  19942. private _textures;
  19943. private _textureArrays;
  19944. private _floats;
  19945. private _ints;
  19946. private _floatsArrays;
  19947. private _colors3;
  19948. private _colors3Arrays;
  19949. private _colors4;
  19950. private _colors4Arrays;
  19951. private _vectors2;
  19952. private _vectors3;
  19953. private _vectors4;
  19954. private _matrices;
  19955. private _matrixArrays;
  19956. private _matrices3x3;
  19957. private _matrices2x2;
  19958. private _vectors2Arrays;
  19959. private _vectors3Arrays;
  19960. private _vectors4Arrays;
  19961. private _cachedWorldViewMatrix;
  19962. private _cachedWorldViewProjectionMatrix;
  19963. private _renderId;
  19964. private _multiview;
  19965. /**
  19966. * Instantiate a new shader material.
  19967. * 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.
  19968. * This returned material effects how the mesh will look based on the code in the shaders.
  19969. * @see http://doc.babylonjs.com/how_to/shader_material
  19970. * @param name Define the name of the material in the scene
  19971. * @param scene Define the scene the material belongs to
  19972. * @param shaderPath Defines the route to the shader code in one of three ways:
  19973. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19974. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19975. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19976. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19977. * @param options Define the options used to create the shader
  19978. */
  19979. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19980. /**
  19981. * Gets the shader path used to define the shader code
  19982. * It can be modified to trigger a new compilation
  19983. */
  19984. get shaderPath(): any;
  19985. /**
  19986. * Sets the shader path used to define the shader code
  19987. * It can be modified to trigger a new compilation
  19988. */
  19989. set shaderPath(shaderPath: any);
  19990. /**
  19991. * Gets the options used to compile the shader.
  19992. * They can be modified to trigger a new compilation
  19993. */
  19994. get options(): IShaderMaterialOptions;
  19995. /**
  19996. * Gets the current class name of the material e.g. "ShaderMaterial"
  19997. * Mainly use in serialization.
  19998. * @returns the class name
  19999. */
  20000. getClassName(): string;
  20001. /**
  20002. * Specifies if the material will require alpha blending
  20003. * @returns a boolean specifying if alpha blending is needed
  20004. */
  20005. needAlphaBlending(): boolean;
  20006. /**
  20007. * Specifies if this material should be rendered in alpha test mode
  20008. * @returns a boolean specifying if an alpha test is needed.
  20009. */
  20010. needAlphaTesting(): boolean;
  20011. private _checkUniform;
  20012. /**
  20013. * Set a texture in the shader.
  20014. * @param name Define the name of the uniform samplers as defined in the shader
  20015. * @param texture Define the texture to bind to this sampler
  20016. * @return the material itself allowing "fluent" like uniform updates
  20017. */
  20018. setTexture(name: string, texture: Texture): ShaderMaterial;
  20019. /**
  20020. * Set a texture array in the shader.
  20021. * @param name Define the name of the uniform sampler array as defined in the shader
  20022. * @param textures Define the list of textures to bind to this sampler
  20023. * @return the material itself allowing "fluent" like uniform updates
  20024. */
  20025. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  20026. /**
  20027. * Set a float in the shader.
  20028. * @param name Define the name of the uniform as defined in the shader
  20029. * @param value Define the value to give to the uniform
  20030. * @return the material itself allowing "fluent" like uniform updates
  20031. */
  20032. setFloat(name: string, value: number): ShaderMaterial;
  20033. /**
  20034. * Set a int in the shader.
  20035. * @param name Define the name of the uniform as defined in the shader
  20036. * @param value Define the value to give to the uniform
  20037. * @return the material itself allowing "fluent" like uniform updates
  20038. */
  20039. setInt(name: string, value: number): ShaderMaterial;
  20040. /**
  20041. * Set an array of floats in the shader.
  20042. * @param name Define the name of the uniform as defined in the shader
  20043. * @param value Define the value to give to the uniform
  20044. * @return the material itself allowing "fluent" like uniform updates
  20045. */
  20046. setFloats(name: string, value: number[]): ShaderMaterial;
  20047. /**
  20048. * Set a vec3 in the shader from a Color3.
  20049. * @param name Define the name of the uniform as defined in the shader
  20050. * @param value Define the value to give to the uniform
  20051. * @return the material itself allowing "fluent" like uniform updates
  20052. */
  20053. setColor3(name: string, value: Color3): ShaderMaterial;
  20054. /**
  20055. * Set a vec3 array in the shader from a Color3 array.
  20056. * @param name Define the name of the uniform as defined in the shader
  20057. * @param value Define the value to give to the uniform
  20058. * @return the material itself allowing "fluent" like uniform updates
  20059. */
  20060. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20061. /**
  20062. * Set a vec4 in the shader from a Color4.
  20063. * @param name Define the name of the uniform as defined in the shader
  20064. * @param value Define the value to give to the uniform
  20065. * @return the material itself allowing "fluent" like uniform updates
  20066. */
  20067. setColor4(name: string, value: Color4): ShaderMaterial;
  20068. /**
  20069. * Set a vec4 array in the shader from a Color4 array.
  20070. * @param name Define the name of the uniform as defined in the shader
  20071. * @param value Define the value to give to the uniform
  20072. * @return the material itself allowing "fluent" like uniform updates
  20073. */
  20074. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20075. /**
  20076. * Set a vec2 in the shader from a Vector2.
  20077. * @param name Define the name of the uniform as defined in the shader
  20078. * @param value Define the value to give to the uniform
  20079. * @return the material itself allowing "fluent" like uniform updates
  20080. */
  20081. setVector2(name: string, value: Vector2): ShaderMaterial;
  20082. /**
  20083. * Set a vec3 in the shader from a Vector3.
  20084. * @param name Define the name of the uniform as defined in the shader
  20085. * @param value Define the value to give to the uniform
  20086. * @return the material itself allowing "fluent" like uniform updates
  20087. */
  20088. setVector3(name: string, value: Vector3): ShaderMaterial;
  20089. /**
  20090. * Set a vec4 in the shader from a Vector4.
  20091. * @param name Define the name of the uniform as defined in the shader
  20092. * @param value Define the value to give to the uniform
  20093. * @return the material itself allowing "fluent" like uniform updates
  20094. */
  20095. setVector4(name: string, value: Vector4): ShaderMaterial;
  20096. /**
  20097. * Set a mat4 in the shader from a Matrix.
  20098. * @param name Define the name of the uniform as defined in the shader
  20099. * @param value Define the value to give to the uniform
  20100. * @return the material itself allowing "fluent" like uniform updates
  20101. */
  20102. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20103. /**
  20104. * Set a float32Array in the shader from a matrix array.
  20105. * @param name Define the name of the uniform as defined in the shader
  20106. * @param value Define the value to give to the uniform
  20107. * @return the material itself allowing "fluent" like uniform updates
  20108. */
  20109. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20110. /**
  20111. * Set a mat3 in the shader from a Float32Array.
  20112. * @param name Define the name of the uniform as defined in the shader
  20113. * @param value Define the value to give to the uniform
  20114. * @return the material itself allowing "fluent" like uniform updates
  20115. */
  20116. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20117. /**
  20118. * Set a mat2 in the shader from a Float32Array.
  20119. * @param name Define the name of the uniform as defined in the shader
  20120. * @param value Define the value to give to the uniform
  20121. * @return the material itself allowing "fluent" like uniform updates
  20122. */
  20123. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20124. /**
  20125. * Set a vec2 array in the shader from a number array.
  20126. * @param name Define the name of the uniform as defined in the shader
  20127. * @param value Define the value to give to the uniform
  20128. * @return the material itself allowing "fluent" like uniform updates
  20129. */
  20130. setArray2(name: string, value: number[]): ShaderMaterial;
  20131. /**
  20132. * Set a vec3 array in the shader from a number array.
  20133. * @param name Define the name of the uniform as defined in the shader
  20134. * @param value Define the value to give to the uniform
  20135. * @return the material itself allowing "fluent" like uniform updates
  20136. */
  20137. setArray3(name: string, value: number[]): ShaderMaterial;
  20138. /**
  20139. * Set a vec4 array in the shader from a number array.
  20140. * @param name Define the name of the uniform as defined in the shader
  20141. * @param value Define the value to give to the uniform
  20142. * @return the material itself allowing "fluent" like uniform updates
  20143. */
  20144. setArray4(name: string, value: number[]): ShaderMaterial;
  20145. private _checkCache;
  20146. /**
  20147. * Specifies that the submesh is ready to be used
  20148. * @param mesh defines the mesh to check
  20149. * @param subMesh defines which submesh to check
  20150. * @param useInstances specifies that instances should be used
  20151. * @returns a boolean indicating that the submesh is ready or not
  20152. */
  20153. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20154. /**
  20155. * Checks if the material is ready to render the requested mesh
  20156. * @param mesh Define the mesh to render
  20157. * @param useInstances Define whether or not the material is used with instances
  20158. * @returns true if ready, otherwise false
  20159. */
  20160. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20161. /**
  20162. * Binds the world matrix to the material
  20163. * @param world defines the world transformation matrix
  20164. */
  20165. bindOnlyWorldMatrix(world: Matrix): void;
  20166. /**
  20167. * Binds the material to the mesh
  20168. * @param world defines the world transformation matrix
  20169. * @param mesh defines the mesh to bind the material to
  20170. */
  20171. bind(world: Matrix, mesh?: Mesh): void;
  20172. /**
  20173. * Gets the active textures from the material
  20174. * @returns an array of textures
  20175. */
  20176. getActiveTextures(): BaseTexture[];
  20177. /**
  20178. * Specifies if the material uses a texture
  20179. * @param texture defines the texture to check against the material
  20180. * @returns a boolean specifying if the material uses the texture
  20181. */
  20182. hasTexture(texture: BaseTexture): boolean;
  20183. /**
  20184. * Makes a duplicate of the material, and gives it a new name
  20185. * @param name defines the new name for the duplicated material
  20186. * @returns the cloned material
  20187. */
  20188. clone(name: string): ShaderMaterial;
  20189. /**
  20190. * Disposes the material
  20191. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20192. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20193. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20194. */
  20195. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20196. /**
  20197. * Serializes this material in a JSON representation
  20198. * @returns the serialized material object
  20199. */
  20200. serialize(): any;
  20201. /**
  20202. * Creates a shader material from parsed shader material data
  20203. * @param source defines the JSON represnetation of the material
  20204. * @param scene defines the hosting scene
  20205. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20206. * @returns a new material
  20207. */
  20208. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20209. }
  20210. }
  20211. declare module "babylonjs/Shaders/color.fragment" {
  20212. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20213. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20214. /** @hidden */
  20215. export var colorPixelShader: {
  20216. name: string;
  20217. shader: string;
  20218. };
  20219. }
  20220. declare module "babylonjs/Shaders/color.vertex" {
  20221. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20222. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20223. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20224. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20225. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20226. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20227. /** @hidden */
  20228. export var colorVertexShader: {
  20229. name: string;
  20230. shader: string;
  20231. };
  20232. }
  20233. declare module "babylonjs/Meshes/linesMesh" {
  20234. import { Nullable } from "babylonjs/types";
  20235. import { Scene } from "babylonjs/scene";
  20236. import { Color3 } from "babylonjs/Maths/math.color";
  20237. import { Node } from "babylonjs/node";
  20238. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20239. import { Mesh } from "babylonjs/Meshes/mesh";
  20240. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20241. import { Effect } from "babylonjs/Materials/effect";
  20242. import { Material } from "babylonjs/Materials/material";
  20243. import "babylonjs/Shaders/color.fragment";
  20244. import "babylonjs/Shaders/color.vertex";
  20245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20246. /**
  20247. * Line mesh
  20248. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20249. */
  20250. export class LinesMesh extends Mesh {
  20251. /**
  20252. * If vertex color should be applied to the mesh
  20253. */
  20254. readonly useVertexColor?: boolean | undefined;
  20255. /**
  20256. * If vertex alpha should be applied to the mesh
  20257. */
  20258. readonly useVertexAlpha?: boolean | undefined;
  20259. /**
  20260. * Color of the line (Default: White)
  20261. */
  20262. color: Color3;
  20263. /**
  20264. * Alpha of the line (Default: 1)
  20265. */
  20266. alpha: number;
  20267. /**
  20268. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20269. * This margin is expressed in world space coordinates, so its value may vary.
  20270. * Default value is 0.1
  20271. */
  20272. intersectionThreshold: number;
  20273. private _colorShader;
  20274. private color4;
  20275. /**
  20276. * Creates a new LinesMesh
  20277. * @param name defines the name
  20278. * @param scene defines the hosting scene
  20279. * @param parent defines the parent mesh if any
  20280. * @param source defines the optional source LinesMesh used to clone data from
  20281. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20282. * When false, achieved by calling a clone(), also passing False.
  20283. * This will make creation of children, recursive.
  20284. * @param useVertexColor defines if this LinesMesh supports vertex color
  20285. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20286. */
  20287. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20288. /**
  20289. * If vertex color should be applied to the mesh
  20290. */
  20291. useVertexColor?: boolean | undefined,
  20292. /**
  20293. * If vertex alpha should be applied to the mesh
  20294. */
  20295. useVertexAlpha?: boolean | undefined);
  20296. private _addClipPlaneDefine;
  20297. private _removeClipPlaneDefine;
  20298. isReady(): boolean;
  20299. /**
  20300. * Returns the string "LineMesh"
  20301. */
  20302. getClassName(): string;
  20303. /**
  20304. * @hidden
  20305. */
  20306. get material(): Material;
  20307. /**
  20308. * @hidden
  20309. */
  20310. set material(value: Material);
  20311. /**
  20312. * @hidden
  20313. */
  20314. get checkCollisions(): boolean;
  20315. /** @hidden */
  20316. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20317. /** @hidden */
  20318. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20319. /**
  20320. * Disposes of the line mesh
  20321. * @param doNotRecurse If children should be disposed
  20322. */
  20323. dispose(doNotRecurse?: boolean): void;
  20324. /**
  20325. * Returns a new LineMesh object cloned from the current one.
  20326. */
  20327. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20328. /**
  20329. * Creates a new InstancedLinesMesh object from the mesh model.
  20330. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20331. * @param name defines the name of the new instance
  20332. * @returns a new InstancedLinesMesh
  20333. */
  20334. createInstance(name: string): InstancedLinesMesh;
  20335. }
  20336. /**
  20337. * Creates an instance based on a source LinesMesh
  20338. */
  20339. export class InstancedLinesMesh extends InstancedMesh {
  20340. /**
  20341. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20342. * This margin is expressed in world space coordinates, so its value may vary.
  20343. * Initilized with the intersectionThreshold value of the source LinesMesh
  20344. */
  20345. intersectionThreshold: number;
  20346. constructor(name: string, source: LinesMesh);
  20347. /**
  20348. * Returns the string "InstancedLinesMesh".
  20349. */
  20350. getClassName(): string;
  20351. }
  20352. }
  20353. declare module "babylonjs/Shaders/line.fragment" {
  20354. /** @hidden */
  20355. export var linePixelShader: {
  20356. name: string;
  20357. shader: string;
  20358. };
  20359. }
  20360. declare module "babylonjs/Shaders/line.vertex" {
  20361. /** @hidden */
  20362. export var lineVertexShader: {
  20363. name: string;
  20364. shader: string;
  20365. };
  20366. }
  20367. declare module "babylonjs/Rendering/edgesRenderer" {
  20368. import { Nullable } from "babylonjs/types";
  20369. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20371. import { Vector3 } from "babylonjs/Maths/math.vector";
  20372. import { IDisposable } from "babylonjs/scene";
  20373. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20374. import "babylonjs/Shaders/line.fragment";
  20375. import "babylonjs/Shaders/line.vertex";
  20376. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20377. module "babylonjs/Meshes/abstractMesh" {
  20378. interface AbstractMesh {
  20379. /**
  20380. * Gets the edgesRenderer associated with the mesh
  20381. */
  20382. edgesRenderer: Nullable<EdgesRenderer>;
  20383. }
  20384. }
  20385. module "babylonjs/Meshes/linesMesh" {
  20386. interface LinesMesh {
  20387. /**
  20388. * Enables the edge rendering mode on the mesh.
  20389. * This mode makes the mesh edges visible
  20390. * @param epsilon defines the maximal distance between two angles to detect a face
  20391. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20392. * @returns the currentAbstractMesh
  20393. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20394. */
  20395. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20396. }
  20397. }
  20398. module "babylonjs/Meshes/linesMesh" {
  20399. interface InstancedLinesMesh {
  20400. /**
  20401. * Enables the edge rendering mode on the mesh.
  20402. * This mode makes the mesh edges visible
  20403. * @param epsilon defines the maximal distance between two angles to detect a face
  20404. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20405. * @returns the current InstancedLinesMesh
  20406. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20407. */
  20408. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20409. }
  20410. }
  20411. /**
  20412. * Defines the minimum contract an Edges renderer should follow.
  20413. */
  20414. export interface IEdgesRenderer extends IDisposable {
  20415. /**
  20416. * Gets or sets a boolean indicating if the edgesRenderer is active
  20417. */
  20418. isEnabled: boolean;
  20419. /**
  20420. * Renders the edges of the attached mesh,
  20421. */
  20422. render(): void;
  20423. /**
  20424. * Checks wether or not the edges renderer is ready to render.
  20425. * @return true if ready, otherwise false.
  20426. */
  20427. isReady(): boolean;
  20428. }
  20429. /**
  20430. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20431. */
  20432. export class EdgesRenderer implements IEdgesRenderer {
  20433. /**
  20434. * Define the size of the edges with an orthographic camera
  20435. */
  20436. edgesWidthScalerForOrthographic: number;
  20437. /**
  20438. * Define the size of the edges with a perspective camera
  20439. */
  20440. edgesWidthScalerForPerspective: number;
  20441. protected _source: AbstractMesh;
  20442. protected _linesPositions: number[];
  20443. protected _linesNormals: number[];
  20444. protected _linesIndices: number[];
  20445. protected _epsilon: number;
  20446. protected _indicesCount: number;
  20447. protected _lineShader: ShaderMaterial;
  20448. protected _ib: DataBuffer;
  20449. protected _buffers: {
  20450. [key: string]: Nullable<VertexBuffer>;
  20451. };
  20452. protected _checkVerticesInsteadOfIndices: boolean;
  20453. private _meshRebuildObserver;
  20454. private _meshDisposeObserver;
  20455. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20456. isEnabled: boolean;
  20457. /**
  20458. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20459. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20460. * @param source Mesh used to create edges
  20461. * @param epsilon sum of angles in adjacency to check for edge
  20462. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20463. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20464. */
  20465. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20466. protected _prepareRessources(): void;
  20467. /** @hidden */
  20468. _rebuild(): void;
  20469. /**
  20470. * Releases the required resources for the edges renderer
  20471. */
  20472. dispose(): void;
  20473. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20474. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20475. /**
  20476. * Checks if the pair of p0 and p1 is en edge
  20477. * @param faceIndex
  20478. * @param edge
  20479. * @param faceNormals
  20480. * @param p0
  20481. * @param p1
  20482. * @private
  20483. */
  20484. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20485. /**
  20486. * push line into the position, normal and index buffer
  20487. * @protected
  20488. */
  20489. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20490. /**
  20491. * Generates lines edges from adjacencjes
  20492. * @private
  20493. */
  20494. _generateEdgesLines(): void;
  20495. /**
  20496. * Checks wether or not the edges renderer is ready to render.
  20497. * @return true if ready, otherwise false.
  20498. */
  20499. isReady(): boolean;
  20500. /**
  20501. * Renders the edges of the attached mesh,
  20502. */
  20503. render(): void;
  20504. }
  20505. /**
  20506. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20507. */
  20508. export class LineEdgesRenderer extends EdgesRenderer {
  20509. /**
  20510. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20511. * @param source LineMesh used to generate edges
  20512. * @param epsilon not important (specified angle for edge detection)
  20513. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20514. */
  20515. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20516. /**
  20517. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20518. */
  20519. _generateEdgesLines(): void;
  20520. }
  20521. }
  20522. declare module "babylonjs/Rendering/renderingGroup" {
  20523. import { SmartArray } from "babylonjs/Misc/smartArray";
  20524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20526. import { Nullable } from "babylonjs/types";
  20527. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20528. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20529. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20530. import { Material } from "babylonjs/Materials/material";
  20531. import { Scene } from "babylonjs/scene";
  20532. /**
  20533. * This represents the object necessary to create a rendering group.
  20534. * This is exclusively used and created by the rendering manager.
  20535. * To modify the behavior, you use the available helpers in your scene or meshes.
  20536. * @hidden
  20537. */
  20538. export class RenderingGroup {
  20539. index: number;
  20540. private static _zeroVector;
  20541. private _scene;
  20542. private _opaqueSubMeshes;
  20543. private _transparentSubMeshes;
  20544. private _alphaTestSubMeshes;
  20545. private _depthOnlySubMeshes;
  20546. private _particleSystems;
  20547. private _spriteManagers;
  20548. private _opaqueSortCompareFn;
  20549. private _alphaTestSortCompareFn;
  20550. private _transparentSortCompareFn;
  20551. private _renderOpaque;
  20552. private _renderAlphaTest;
  20553. private _renderTransparent;
  20554. /** @hidden */
  20555. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20556. onBeforeTransparentRendering: () => void;
  20557. /**
  20558. * Set the opaque sort comparison function.
  20559. * If null the sub meshes will be render in the order they were created
  20560. */
  20561. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20562. /**
  20563. * Set the alpha test sort comparison function.
  20564. * If null the sub meshes will be render in the order they were created
  20565. */
  20566. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20567. /**
  20568. * Set the transparent sort comparison function.
  20569. * If null the sub meshes will be render in the order they were created
  20570. */
  20571. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20572. /**
  20573. * Creates a new rendering group.
  20574. * @param index The rendering group index
  20575. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20576. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20577. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20578. */
  20579. 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>);
  20580. /**
  20581. * Render all the sub meshes contained in the group.
  20582. * @param customRenderFunction Used to override the default render behaviour of the group.
  20583. * @returns true if rendered some submeshes.
  20584. */
  20585. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20586. /**
  20587. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20588. * @param subMeshes The submeshes to render
  20589. */
  20590. private renderOpaqueSorted;
  20591. /**
  20592. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20593. * @param subMeshes The submeshes to render
  20594. */
  20595. private renderAlphaTestSorted;
  20596. /**
  20597. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20598. * @param subMeshes The submeshes to render
  20599. */
  20600. private renderTransparentSorted;
  20601. /**
  20602. * Renders the submeshes in a specified order.
  20603. * @param subMeshes The submeshes to sort before render
  20604. * @param sortCompareFn The comparison function use to sort
  20605. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20606. * @param transparent Specifies to activate blending if true
  20607. */
  20608. private static renderSorted;
  20609. /**
  20610. * Renders the submeshes in the order they were dispatched (no sort applied).
  20611. * @param subMeshes The submeshes to render
  20612. */
  20613. private static renderUnsorted;
  20614. /**
  20615. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20616. * are rendered back to front if in the same alpha index.
  20617. *
  20618. * @param a The first submesh
  20619. * @param b The second submesh
  20620. * @returns The result of the comparison
  20621. */
  20622. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20623. /**
  20624. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20625. * are rendered back to front.
  20626. *
  20627. * @param a The first submesh
  20628. * @param b The second submesh
  20629. * @returns The result of the comparison
  20630. */
  20631. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20632. /**
  20633. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20634. * are rendered front to back (prevent overdraw).
  20635. *
  20636. * @param a The first submesh
  20637. * @param b The second submesh
  20638. * @returns The result of the comparison
  20639. */
  20640. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20641. /**
  20642. * Resets the different lists of submeshes to prepare a new frame.
  20643. */
  20644. prepare(): void;
  20645. dispose(): void;
  20646. /**
  20647. * Inserts the submesh in its correct queue depending on its material.
  20648. * @param subMesh The submesh to dispatch
  20649. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20650. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20651. */
  20652. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20653. dispatchSprites(spriteManager: ISpriteManager): void;
  20654. dispatchParticles(particleSystem: IParticleSystem): void;
  20655. private _renderParticles;
  20656. private _renderSprites;
  20657. }
  20658. }
  20659. declare module "babylonjs/Rendering/renderingManager" {
  20660. import { Nullable } from "babylonjs/types";
  20661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20662. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20663. import { SmartArray } from "babylonjs/Misc/smartArray";
  20664. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20665. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20666. import { Material } from "babylonjs/Materials/material";
  20667. import { Scene } from "babylonjs/scene";
  20668. import { Camera } from "babylonjs/Cameras/camera";
  20669. /**
  20670. * Interface describing the different options available in the rendering manager
  20671. * regarding Auto Clear between groups.
  20672. */
  20673. export interface IRenderingManagerAutoClearSetup {
  20674. /**
  20675. * Defines whether or not autoclear is enable.
  20676. */
  20677. autoClear: boolean;
  20678. /**
  20679. * Defines whether or not to autoclear the depth buffer.
  20680. */
  20681. depth: boolean;
  20682. /**
  20683. * Defines whether or not to autoclear the stencil buffer.
  20684. */
  20685. stencil: boolean;
  20686. }
  20687. /**
  20688. * This class is used by the onRenderingGroupObservable
  20689. */
  20690. export class RenderingGroupInfo {
  20691. /**
  20692. * The Scene that being rendered
  20693. */
  20694. scene: Scene;
  20695. /**
  20696. * The camera currently used for the rendering pass
  20697. */
  20698. camera: Nullable<Camera>;
  20699. /**
  20700. * The ID of the renderingGroup being processed
  20701. */
  20702. renderingGroupId: number;
  20703. }
  20704. /**
  20705. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20706. * It is enable to manage the different groups as well as the different necessary sort functions.
  20707. * This should not be used directly aside of the few static configurations
  20708. */
  20709. export class RenderingManager {
  20710. /**
  20711. * The max id used for rendering groups (not included)
  20712. */
  20713. static MAX_RENDERINGGROUPS: number;
  20714. /**
  20715. * The min id used for rendering groups (included)
  20716. */
  20717. static MIN_RENDERINGGROUPS: number;
  20718. /**
  20719. * Used to globally prevent autoclearing scenes.
  20720. */
  20721. static AUTOCLEAR: boolean;
  20722. /**
  20723. * @hidden
  20724. */
  20725. _useSceneAutoClearSetup: boolean;
  20726. private _scene;
  20727. private _renderingGroups;
  20728. private _depthStencilBufferAlreadyCleaned;
  20729. private _autoClearDepthStencil;
  20730. private _customOpaqueSortCompareFn;
  20731. private _customAlphaTestSortCompareFn;
  20732. private _customTransparentSortCompareFn;
  20733. private _renderingGroupInfo;
  20734. /**
  20735. * Instantiates a new rendering group for a particular scene
  20736. * @param scene Defines the scene the groups belongs to
  20737. */
  20738. constructor(scene: Scene);
  20739. private _clearDepthStencilBuffer;
  20740. /**
  20741. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20742. * @hidden
  20743. */
  20744. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20745. /**
  20746. * Resets the different information of the group to prepare a new frame
  20747. * @hidden
  20748. */
  20749. reset(): void;
  20750. /**
  20751. * Dispose and release the group and its associated resources.
  20752. * @hidden
  20753. */
  20754. dispose(): void;
  20755. /**
  20756. * Clear the info related to rendering groups preventing retention points during dispose.
  20757. */
  20758. freeRenderingGroups(): void;
  20759. private _prepareRenderingGroup;
  20760. /**
  20761. * Add a sprite manager to the rendering manager in order to render it this frame.
  20762. * @param spriteManager Define the sprite manager to render
  20763. */
  20764. dispatchSprites(spriteManager: ISpriteManager): void;
  20765. /**
  20766. * Add a particle system to the rendering manager in order to render it this frame.
  20767. * @param particleSystem Define the particle system to render
  20768. */
  20769. dispatchParticles(particleSystem: IParticleSystem): void;
  20770. /**
  20771. * Add a submesh to the manager in order to render it this frame
  20772. * @param subMesh The submesh to dispatch
  20773. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20774. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20775. */
  20776. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20777. /**
  20778. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20779. * This allowed control for front to back rendering or reversly depending of the special needs.
  20780. *
  20781. * @param renderingGroupId The rendering group id corresponding to its index
  20782. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20783. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20784. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20785. */
  20786. 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;
  20787. /**
  20788. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20789. *
  20790. * @param renderingGroupId The rendering group id corresponding to its index
  20791. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20792. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20793. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20794. */
  20795. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20796. /**
  20797. * Gets the current auto clear configuration for one rendering group of the rendering
  20798. * manager.
  20799. * @param index the rendering group index to get the information for
  20800. * @returns The auto clear setup for the requested rendering group
  20801. */
  20802. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20803. }
  20804. }
  20805. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20806. import { Observable } from "babylonjs/Misc/observable";
  20807. import { SmartArray } from "babylonjs/Misc/smartArray";
  20808. import { Nullable } from "babylonjs/types";
  20809. import { Camera } from "babylonjs/Cameras/camera";
  20810. import { Scene } from "babylonjs/scene";
  20811. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20812. import { Color4 } from "babylonjs/Maths/math.color";
  20813. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20815. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20816. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20817. import { Texture } from "babylonjs/Materials/Textures/texture";
  20818. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20819. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20820. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20821. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20822. import { Engine } from "babylonjs/Engines/engine";
  20823. /**
  20824. * This Helps creating a texture that will be created from a camera in your scene.
  20825. * It is basically a dynamic texture that could be used to create special effects for instance.
  20826. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20827. */
  20828. export class RenderTargetTexture extends Texture {
  20829. isCube: boolean;
  20830. /**
  20831. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20832. */
  20833. static readonly REFRESHRATE_RENDER_ONCE: number;
  20834. /**
  20835. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20836. */
  20837. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20838. /**
  20839. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20840. * the central point of your effect and can save a lot of performances.
  20841. */
  20842. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20843. /**
  20844. * Use this predicate to dynamically define the list of mesh you want to render.
  20845. * If set, the renderList property will be overwritten.
  20846. */
  20847. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20848. private _renderList;
  20849. /**
  20850. * Use this list to define the list of mesh you want to render.
  20851. */
  20852. get renderList(): Nullable<Array<AbstractMesh>>;
  20853. set renderList(value: Nullable<Array<AbstractMesh>>);
  20854. private _hookArray;
  20855. /**
  20856. * Define if particles should be rendered in your texture.
  20857. */
  20858. renderParticles: boolean;
  20859. /**
  20860. * Define if sprites should be rendered in your texture.
  20861. */
  20862. renderSprites: boolean;
  20863. /**
  20864. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20865. */
  20866. coordinatesMode: number;
  20867. /**
  20868. * Define the camera used to render the texture.
  20869. */
  20870. activeCamera: Nullable<Camera>;
  20871. /**
  20872. * Override the render function of the texture with your own one.
  20873. */
  20874. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20875. /**
  20876. * Define if camera post processes should be use while rendering the texture.
  20877. */
  20878. useCameraPostProcesses: boolean;
  20879. /**
  20880. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20881. */
  20882. ignoreCameraViewport: boolean;
  20883. private _postProcessManager;
  20884. private _postProcesses;
  20885. private _resizeObserver;
  20886. /**
  20887. * An event triggered when the texture is unbind.
  20888. */
  20889. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20890. /**
  20891. * An event triggered when the texture is unbind.
  20892. */
  20893. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20894. private _onAfterUnbindObserver;
  20895. /**
  20896. * Set a after unbind callback in the texture.
  20897. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20898. */
  20899. set onAfterUnbind(callback: () => void);
  20900. /**
  20901. * An event triggered before rendering the texture
  20902. */
  20903. onBeforeRenderObservable: Observable<number>;
  20904. private _onBeforeRenderObserver;
  20905. /**
  20906. * Set a before render callback in the texture.
  20907. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20908. */
  20909. set onBeforeRender(callback: (faceIndex: number) => void);
  20910. /**
  20911. * An event triggered after rendering the texture
  20912. */
  20913. onAfterRenderObservable: Observable<number>;
  20914. private _onAfterRenderObserver;
  20915. /**
  20916. * Set a after render callback in the texture.
  20917. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20918. */
  20919. set onAfterRender(callback: (faceIndex: number) => void);
  20920. /**
  20921. * An event triggered after the texture clear
  20922. */
  20923. onClearObservable: Observable<Engine>;
  20924. private _onClearObserver;
  20925. /**
  20926. * Set a clear callback in the texture.
  20927. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20928. */
  20929. set onClear(callback: (Engine: Engine) => void);
  20930. /**
  20931. * An event triggered when the texture is resized.
  20932. */
  20933. onResizeObservable: Observable<RenderTargetTexture>;
  20934. /**
  20935. * Define the clear color of the Render Target if it should be different from the scene.
  20936. */
  20937. clearColor: Color4;
  20938. protected _size: number | {
  20939. width: number;
  20940. height: number;
  20941. };
  20942. protected _initialSizeParameter: number | {
  20943. width: number;
  20944. height: number;
  20945. } | {
  20946. ratio: number;
  20947. };
  20948. protected _sizeRatio: Nullable<number>;
  20949. /** @hidden */
  20950. _generateMipMaps: boolean;
  20951. protected _renderingManager: RenderingManager;
  20952. /** @hidden */
  20953. _waitingRenderList: string[];
  20954. protected _doNotChangeAspectRatio: boolean;
  20955. protected _currentRefreshId: number;
  20956. protected _refreshRate: number;
  20957. protected _textureMatrix: Matrix;
  20958. protected _samples: number;
  20959. protected _renderTargetOptions: RenderTargetCreationOptions;
  20960. /**
  20961. * Gets render target creation options that were used.
  20962. */
  20963. get renderTargetOptions(): RenderTargetCreationOptions;
  20964. protected _engine: Engine;
  20965. protected _onRatioRescale(): void;
  20966. /**
  20967. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20968. * It must define where the camera used to render the texture is set
  20969. */
  20970. boundingBoxPosition: Vector3;
  20971. private _boundingBoxSize;
  20972. /**
  20973. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20974. * When defined, the cubemap will switch to local mode
  20975. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20976. * @example https://www.babylonjs-playground.com/#RNASML
  20977. */
  20978. set boundingBoxSize(value: Vector3);
  20979. get boundingBoxSize(): Vector3;
  20980. /**
  20981. * In case the RTT has been created with a depth texture, get the associated
  20982. * depth texture.
  20983. * Otherwise, return null.
  20984. */
  20985. depthStencilTexture: Nullable<InternalTexture>;
  20986. /**
  20987. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20988. * or used a shadow, depth texture...
  20989. * @param name The friendly name of the texture
  20990. * @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)
  20991. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20992. * @param generateMipMaps True if mip maps need to be generated after render.
  20993. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20994. * @param type The type of the buffer in the RTT (int, half float, float...)
  20995. * @param isCube True if a cube texture needs to be created
  20996. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20997. * @param generateDepthBuffer True to generate a depth buffer
  20998. * @param generateStencilBuffer True to generate a stencil buffer
  20999. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21000. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21001. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21002. */
  21003. constructor(name: string, size: number | {
  21004. width: number;
  21005. height: number;
  21006. } | {
  21007. ratio: number;
  21008. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21009. /**
  21010. * Creates a depth stencil texture.
  21011. * This is only available in WebGL 2 or with the depth texture extension available.
  21012. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21013. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21014. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21015. */
  21016. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21017. private _processSizeParameter;
  21018. /**
  21019. * Define the number of samples to use in case of MSAA.
  21020. * It defaults to one meaning no MSAA has been enabled.
  21021. */
  21022. get samples(): number;
  21023. set samples(value: number);
  21024. /**
  21025. * Resets the refresh counter of the texture and start bak from scratch.
  21026. * Could be useful to regenerate the texture if it is setup to render only once.
  21027. */
  21028. resetRefreshCounter(): void;
  21029. /**
  21030. * Define the refresh rate of the texture or the rendering frequency.
  21031. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21032. */
  21033. get refreshRate(): number;
  21034. set refreshRate(value: number);
  21035. /**
  21036. * Adds a post process to the render target rendering passes.
  21037. * @param postProcess define the post process to add
  21038. */
  21039. addPostProcess(postProcess: PostProcess): void;
  21040. /**
  21041. * Clear all the post processes attached to the render target
  21042. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21043. */
  21044. clearPostProcesses(dispose?: boolean): void;
  21045. /**
  21046. * Remove one of the post process from the list of attached post processes to the texture
  21047. * @param postProcess define the post process to remove from the list
  21048. */
  21049. removePostProcess(postProcess: PostProcess): void;
  21050. /** @hidden */
  21051. _shouldRender(): boolean;
  21052. /**
  21053. * Gets the actual render size of the texture.
  21054. * @returns the width of the render size
  21055. */
  21056. getRenderSize(): number;
  21057. /**
  21058. * Gets the actual render width of the texture.
  21059. * @returns the width of the render size
  21060. */
  21061. getRenderWidth(): number;
  21062. /**
  21063. * Gets the actual render height of the texture.
  21064. * @returns the height of the render size
  21065. */
  21066. getRenderHeight(): number;
  21067. /**
  21068. * Get if the texture can be rescaled or not.
  21069. */
  21070. get canRescale(): boolean;
  21071. /**
  21072. * Resize the texture using a ratio.
  21073. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21074. */
  21075. scale(ratio: number): void;
  21076. /**
  21077. * Get the texture reflection matrix used to rotate/transform the reflection.
  21078. * @returns the reflection matrix
  21079. */
  21080. getReflectionTextureMatrix(): Matrix;
  21081. /**
  21082. * Resize the texture to a new desired size.
  21083. * Be carrefull as it will recreate all the data in the new texture.
  21084. * @param size Define the new size. It can be:
  21085. * - a number for squared texture,
  21086. * - an object containing { width: number, height: number }
  21087. * - or an object containing a ratio { ratio: number }
  21088. */
  21089. resize(size: number | {
  21090. width: number;
  21091. height: number;
  21092. } | {
  21093. ratio: number;
  21094. }): void;
  21095. /**
  21096. * Renders all the objects from the render list into the texture.
  21097. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21098. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21099. */
  21100. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21101. private _bestReflectionRenderTargetDimension;
  21102. /**
  21103. * @hidden
  21104. * @param faceIndex face index to bind to if this is a cubetexture
  21105. */
  21106. _bindFrameBuffer(faceIndex?: number): void;
  21107. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21108. private renderToTarget;
  21109. /**
  21110. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21111. * This allowed control for front to back rendering or reversly depending of the special needs.
  21112. *
  21113. * @param renderingGroupId The rendering group id corresponding to its index
  21114. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21115. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21116. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21117. */
  21118. 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;
  21119. /**
  21120. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21121. *
  21122. * @param renderingGroupId The rendering group id corresponding to its index
  21123. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21124. */
  21125. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21126. /**
  21127. * Clones the texture.
  21128. * @returns the cloned texture
  21129. */
  21130. clone(): RenderTargetTexture;
  21131. /**
  21132. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21133. * @returns The JSON representation of the texture
  21134. */
  21135. serialize(): any;
  21136. /**
  21137. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21138. */
  21139. disposeFramebufferObjects(): void;
  21140. /**
  21141. * Dispose the texture and release its associated resources.
  21142. */
  21143. dispose(): void;
  21144. /** @hidden */
  21145. _rebuild(): void;
  21146. /**
  21147. * Clear the info related to rendering groups preventing retention point in material dispose.
  21148. */
  21149. freeRenderingGroups(): void;
  21150. /**
  21151. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21152. * @returns the view count
  21153. */
  21154. getViewCount(): number;
  21155. }
  21156. }
  21157. declare module "babylonjs/Materials/material" {
  21158. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21159. import { SmartArray } from "babylonjs/Misc/smartArray";
  21160. import { Observable } from "babylonjs/Misc/observable";
  21161. import { Nullable } from "babylonjs/types";
  21162. import { Scene } from "babylonjs/scene";
  21163. import { Matrix } from "babylonjs/Maths/math.vector";
  21164. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21166. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21167. import { Effect } from "babylonjs/Materials/effect";
  21168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21169. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21170. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21171. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21172. import { Mesh } from "babylonjs/Meshes/mesh";
  21173. import { Animation } from "babylonjs/Animations/animation";
  21174. /**
  21175. * Options for compiling materials.
  21176. */
  21177. export interface IMaterialCompilationOptions {
  21178. /**
  21179. * Defines whether clip planes are enabled.
  21180. */
  21181. clipPlane: boolean;
  21182. /**
  21183. * Defines whether instances are enabled.
  21184. */
  21185. useInstances: boolean;
  21186. }
  21187. /**
  21188. * Base class for the main features of a material in Babylon.js
  21189. */
  21190. export class Material implements IAnimatable {
  21191. /**
  21192. * Returns the triangle fill mode
  21193. */
  21194. static readonly TriangleFillMode: number;
  21195. /**
  21196. * Returns the wireframe mode
  21197. */
  21198. static readonly WireFrameFillMode: number;
  21199. /**
  21200. * Returns the point fill mode
  21201. */
  21202. static readonly PointFillMode: number;
  21203. /**
  21204. * Returns the point list draw mode
  21205. */
  21206. static readonly PointListDrawMode: number;
  21207. /**
  21208. * Returns the line list draw mode
  21209. */
  21210. static readonly LineListDrawMode: number;
  21211. /**
  21212. * Returns the line loop draw mode
  21213. */
  21214. static readonly LineLoopDrawMode: number;
  21215. /**
  21216. * Returns the line strip draw mode
  21217. */
  21218. static readonly LineStripDrawMode: number;
  21219. /**
  21220. * Returns the triangle strip draw mode
  21221. */
  21222. static readonly TriangleStripDrawMode: number;
  21223. /**
  21224. * Returns the triangle fan draw mode
  21225. */
  21226. static readonly TriangleFanDrawMode: number;
  21227. /**
  21228. * Stores the clock-wise side orientation
  21229. */
  21230. static readonly ClockWiseSideOrientation: number;
  21231. /**
  21232. * Stores the counter clock-wise side orientation
  21233. */
  21234. static readonly CounterClockWiseSideOrientation: number;
  21235. /**
  21236. * The dirty texture flag value
  21237. */
  21238. static readonly TextureDirtyFlag: number;
  21239. /**
  21240. * The dirty light flag value
  21241. */
  21242. static readonly LightDirtyFlag: number;
  21243. /**
  21244. * The dirty fresnel flag value
  21245. */
  21246. static readonly FresnelDirtyFlag: number;
  21247. /**
  21248. * The dirty attribute flag value
  21249. */
  21250. static readonly AttributesDirtyFlag: number;
  21251. /**
  21252. * The dirty misc flag value
  21253. */
  21254. static readonly MiscDirtyFlag: number;
  21255. /**
  21256. * The all dirty flag value
  21257. */
  21258. static readonly AllDirtyFlag: number;
  21259. /**
  21260. * The ID of the material
  21261. */
  21262. id: string;
  21263. /**
  21264. * Gets or sets the unique id of the material
  21265. */
  21266. uniqueId: number;
  21267. /**
  21268. * The name of the material
  21269. */
  21270. name: string;
  21271. /**
  21272. * Gets or sets user defined metadata
  21273. */
  21274. metadata: any;
  21275. /**
  21276. * For internal use only. Please do not use.
  21277. */
  21278. reservedDataStore: any;
  21279. /**
  21280. * Specifies if the ready state should be checked on each call
  21281. */
  21282. checkReadyOnEveryCall: boolean;
  21283. /**
  21284. * Specifies if the ready state should be checked once
  21285. */
  21286. checkReadyOnlyOnce: boolean;
  21287. /**
  21288. * The state of the material
  21289. */
  21290. state: string;
  21291. /**
  21292. * The alpha value of the material
  21293. */
  21294. protected _alpha: number;
  21295. /**
  21296. * List of inspectable custom properties (used by the Inspector)
  21297. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21298. */
  21299. inspectableCustomProperties: IInspectable[];
  21300. /**
  21301. * Sets the alpha value of the material
  21302. */
  21303. set alpha(value: number);
  21304. /**
  21305. * Gets the alpha value of the material
  21306. */
  21307. get alpha(): number;
  21308. /**
  21309. * Specifies if back face culling is enabled
  21310. */
  21311. protected _backFaceCulling: boolean;
  21312. /**
  21313. * Sets the back-face culling state
  21314. */
  21315. set backFaceCulling(value: boolean);
  21316. /**
  21317. * Gets the back-face culling state
  21318. */
  21319. get backFaceCulling(): boolean;
  21320. /**
  21321. * Stores the value for side orientation
  21322. */
  21323. sideOrientation: number;
  21324. /**
  21325. * Callback triggered when the material is compiled
  21326. */
  21327. onCompiled: Nullable<(effect: Effect) => void>;
  21328. /**
  21329. * Callback triggered when an error occurs
  21330. */
  21331. onError: Nullable<(effect: Effect, errors: string) => void>;
  21332. /**
  21333. * Callback triggered to get the render target textures
  21334. */
  21335. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21336. /**
  21337. * Gets a boolean indicating that current material needs to register RTT
  21338. */
  21339. get hasRenderTargetTextures(): boolean;
  21340. /**
  21341. * Specifies if the material should be serialized
  21342. */
  21343. doNotSerialize: boolean;
  21344. /**
  21345. * @hidden
  21346. */
  21347. _storeEffectOnSubMeshes: boolean;
  21348. /**
  21349. * Stores the animations for the material
  21350. */
  21351. animations: Nullable<Array<Animation>>;
  21352. /**
  21353. * An event triggered when the material is disposed
  21354. */
  21355. onDisposeObservable: Observable<Material>;
  21356. /**
  21357. * An observer which watches for dispose events
  21358. */
  21359. private _onDisposeObserver;
  21360. private _onUnBindObservable;
  21361. /**
  21362. * Called during a dispose event
  21363. */
  21364. set onDispose(callback: () => void);
  21365. private _onBindObservable;
  21366. /**
  21367. * An event triggered when the material is bound
  21368. */
  21369. get onBindObservable(): Observable<AbstractMesh>;
  21370. /**
  21371. * An observer which watches for bind events
  21372. */
  21373. private _onBindObserver;
  21374. /**
  21375. * Called during a bind event
  21376. */
  21377. set onBind(callback: (Mesh: AbstractMesh) => void);
  21378. /**
  21379. * An event triggered when the material is unbound
  21380. */
  21381. get onUnBindObservable(): Observable<Material>;
  21382. /**
  21383. * Stores the value of the alpha mode
  21384. */
  21385. private _alphaMode;
  21386. /**
  21387. * Sets the value of the alpha mode.
  21388. *
  21389. * | Value | Type | Description |
  21390. * | --- | --- | --- |
  21391. * | 0 | ALPHA_DISABLE | |
  21392. * | 1 | ALPHA_ADD | |
  21393. * | 2 | ALPHA_COMBINE | |
  21394. * | 3 | ALPHA_SUBTRACT | |
  21395. * | 4 | ALPHA_MULTIPLY | |
  21396. * | 5 | ALPHA_MAXIMIZED | |
  21397. * | 6 | ALPHA_ONEONE | |
  21398. * | 7 | ALPHA_PREMULTIPLIED | |
  21399. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21400. * | 9 | ALPHA_INTERPOLATE | |
  21401. * | 10 | ALPHA_SCREENMODE | |
  21402. *
  21403. */
  21404. set alphaMode(value: number);
  21405. /**
  21406. * Gets the value of the alpha mode
  21407. */
  21408. get alphaMode(): number;
  21409. /**
  21410. * Stores the state of the need depth pre-pass value
  21411. */
  21412. private _needDepthPrePass;
  21413. /**
  21414. * Sets the need depth pre-pass value
  21415. */
  21416. set needDepthPrePass(value: boolean);
  21417. /**
  21418. * Gets the depth pre-pass value
  21419. */
  21420. get needDepthPrePass(): boolean;
  21421. /**
  21422. * Specifies if depth writing should be disabled
  21423. */
  21424. disableDepthWrite: boolean;
  21425. /**
  21426. * Specifies if depth writing should be forced
  21427. */
  21428. forceDepthWrite: boolean;
  21429. /**
  21430. * Specifies the depth function that should be used. 0 means the default engine function
  21431. */
  21432. depthFunction: number;
  21433. /**
  21434. * Specifies if there should be a separate pass for culling
  21435. */
  21436. separateCullingPass: boolean;
  21437. /**
  21438. * Stores the state specifing if fog should be enabled
  21439. */
  21440. private _fogEnabled;
  21441. /**
  21442. * Sets the state for enabling fog
  21443. */
  21444. set fogEnabled(value: boolean);
  21445. /**
  21446. * Gets the value of the fog enabled state
  21447. */
  21448. get fogEnabled(): boolean;
  21449. /**
  21450. * Stores the size of points
  21451. */
  21452. pointSize: number;
  21453. /**
  21454. * Stores the z offset value
  21455. */
  21456. zOffset: number;
  21457. /**
  21458. * Gets a value specifying if wireframe mode is enabled
  21459. */
  21460. get wireframe(): boolean;
  21461. /**
  21462. * Sets the state of wireframe mode
  21463. */
  21464. set wireframe(value: boolean);
  21465. /**
  21466. * Gets the value specifying if point clouds are enabled
  21467. */
  21468. get pointsCloud(): boolean;
  21469. /**
  21470. * Sets the state of point cloud mode
  21471. */
  21472. set pointsCloud(value: boolean);
  21473. /**
  21474. * Gets the material fill mode
  21475. */
  21476. get fillMode(): number;
  21477. /**
  21478. * Sets the material fill mode
  21479. */
  21480. set fillMode(value: number);
  21481. /**
  21482. * @hidden
  21483. * Stores the effects for the material
  21484. */
  21485. _effect: Nullable<Effect>;
  21486. /**
  21487. * Specifies if uniform buffers should be used
  21488. */
  21489. private _useUBO;
  21490. /**
  21491. * Stores a reference to the scene
  21492. */
  21493. private _scene;
  21494. /**
  21495. * Stores the fill mode state
  21496. */
  21497. private _fillMode;
  21498. /**
  21499. * Specifies if the depth write state should be cached
  21500. */
  21501. private _cachedDepthWriteState;
  21502. /**
  21503. * Specifies if the depth function state should be cached
  21504. */
  21505. private _cachedDepthFunctionState;
  21506. /**
  21507. * Stores the uniform buffer
  21508. */
  21509. protected _uniformBuffer: UniformBuffer;
  21510. /** @hidden */
  21511. _indexInSceneMaterialArray: number;
  21512. /** @hidden */
  21513. meshMap: Nullable<{
  21514. [id: string]: AbstractMesh | undefined;
  21515. }>;
  21516. /**
  21517. * Creates a material instance
  21518. * @param name defines the name of the material
  21519. * @param scene defines the scene to reference
  21520. * @param doNotAdd specifies if the material should be added to the scene
  21521. */
  21522. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21523. /**
  21524. * Returns a string representation of the current material
  21525. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21526. * @returns a string with material information
  21527. */
  21528. toString(fullDetails?: boolean): string;
  21529. /**
  21530. * Gets the class name of the material
  21531. * @returns a string with the class name of the material
  21532. */
  21533. getClassName(): string;
  21534. /**
  21535. * Specifies if updates for the material been locked
  21536. */
  21537. get isFrozen(): boolean;
  21538. /**
  21539. * Locks updates for the material
  21540. */
  21541. freeze(): void;
  21542. /**
  21543. * Unlocks updates for the material
  21544. */
  21545. unfreeze(): void;
  21546. /**
  21547. * Specifies if the material is ready to be used
  21548. * @param mesh defines the mesh to check
  21549. * @param useInstances specifies if instances should be used
  21550. * @returns a boolean indicating if the material is ready to be used
  21551. */
  21552. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21553. /**
  21554. * Specifies that the submesh is ready to be used
  21555. * @param mesh defines the mesh to check
  21556. * @param subMesh defines which submesh to check
  21557. * @param useInstances specifies that instances should be used
  21558. * @returns a boolean indicating that the submesh is ready or not
  21559. */
  21560. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21561. /**
  21562. * Returns the material effect
  21563. * @returns the effect associated with the material
  21564. */
  21565. getEffect(): Nullable<Effect>;
  21566. /**
  21567. * Returns the current scene
  21568. * @returns a Scene
  21569. */
  21570. getScene(): Scene;
  21571. /**
  21572. * Specifies if the material will require alpha blending
  21573. * @returns a boolean specifying if alpha blending is needed
  21574. */
  21575. needAlphaBlending(): boolean;
  21576. /**
  21577. * Specifies if the mesh will require alpha blending
  21578. * @param mesh defines the mesh to check
  21579. * @returns a boolean specifying if alpha blending is needed for the mesh
  21580. */
  21581. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21582. /**
  21583. * Specifies if this material should be rendered in alpha test mode
  21584. * @returns a boolean specifying if an alpha test is needed.
  21585. */
  21586. needAlphaTesting(): boolean;
  21587. /**
  21588. * Gets the texture used for the alpha test
  21589. * @returns the texture to use for alpha testing
  21590. */
  21591. getAlphaTestTexture(): Nullable<BaseTexture>;
  21592. /**
  21593. * Marks the material to indicate that it needs to be re-calculated
  21594. */
  21595. markDirty(): void;
  21596. /** @hidden */
  21597. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21598. /**
  21599. * Binds the material to the mesh
  21600. * @param world defines the world transformation matrix
  21601. * @param mesh defines the mesh to bind the material to
  21602. */
  21603. bind(world: Matrix, mesh?: Mesh): void;
  21604. /**
  21605. * Binds the submesh to the material
  21606. * @param world defines the world transformation matrix
  21607. * @param mesh defines the mesh containing the submesh
  21608. * @param subMesh defines the submesh to bind the material to
  21609. */
  21610. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21611. /**
  21612. * Binds the world matrix to the material
  21613. * @param world defines the world transformation matrix
  21614. */
  21615. bindOnlyWorldMatrix(world: Matrix): void;
  21616. /**
  21617. * Binds the scene's uniform buffer to the effect.
  21618. * @param effect defines the effect to bind to the scene uniform buffer
  21619. * @param sceneUbo defines the uniform buffer storing scene data
  21620. */
  21621. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21622. /**
  21623. * Binds the view matrix to the effect
  21624. * @param effect defines the effect to bind the view matrix to
  21625. */
  21626. bindView(effect: Effect): void;
  21627. /**
  21628. * Binds the view projection matrix to the effect
  21629. * @param effect defines the effect to bind the view projection matrix to
  21630. */
  21631. bindViewProjection(effect: Effect): void;
  21632. /**
  21633. * Specifies if material alpha testing should be turned on for the mesh
  21634. * @param mesh defines the mesh to check
  21635. */
  21636. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21637. /**
  21638. * Processes to execute after binding the material to a mesh
  21639. * @param mesh defines the rendered mesh
  21640. */
  21641. protected _afterBind(mesh?: Mesh): void;
  21642. /**
  21643. * Unbinds the material from the mesh
  21644. */
  21645. unbind(): void;
  21646. /**
  21647. * Gets the active textures from the material
  21648. * @returns an array of textures
  21649. */
  21650. getActiveTextures(): BaseTexture[];
  21651. /**
  21652. * Specifies if the material uses a texture
  21653. * @param texture defines the texture to check against the material
  21654. * @returns a boolean specifying if the material uses the texture
  21655. */
  21656. hasTexture(texture: BaseTexture): boolean;
  21657. /**
  21658. * Makes a duplicate of the material, and gives it a new name
  21659. * @param name defines the new name for the duplicated material
  21660. * @returns the cloned material
  21661. */
  21662. clone(name: string): Nullable<Material>;
  21663. /**
  21664. * Gets the meshes bound to the material
  21665. * @returns an array of meshes bound to the material
  21666. */
  21667. getBindedMeshes(): AbstractMesh[];
  21668. /**
  21669. * Force shader compilation
  21670. * @param mesh defines the mesh associated with this material
  21671. * @param onCompiled defines a function to execute once the material is compiled
  21672. * @param options defines the options to configure the compilation
  21673. * @param onError defines a function to execute if the material fails compiling
  21674. */
  21675. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21676. /**
  21677. * Force shader compilation
  21678. * @param mesh defines the mesh that will use this material
  21679. * @param options defines additional options for compiling the shaders
  21680. * @returns a promise that resolves when the compilation completes
  21681. */
  21682. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21683. private static readonly _AllDirtyCallBack;
  21684. private static readonly _ImageProcessingDirtyCallBack;
  21685. private static readonly _TextureDirtyCallBack;
  21686. private static readonly _FresnelDirtyCallBack;
  21687. private static readonly _MiscDirtyCallBack;
  21688. private static readonly _LightsDirtyCallBack;
  21689. private static readonly _AttributeDirtyCallBack;
  21690. private static _FresnelAndMiscDirtyCallBack;
  21691. private static _TextureAndMiscDirtyCallBack;
  21692. private static readonly _DirtyCallbackArray;
  21693. private static readonly _RunDirtyCallBacks;
  21694. /**
  21695. * Marks a define in the material to indicate that it needs to be re-computed
  21696. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21697. */
  21698. markAsDirty(flag: number): void;
  21699. /**
  21700. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21701. * @param func defines a function which checks material defines against the submeshes
  21702. */
  21703. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21704. /**
  21705. * Indicates that we need to re-calculated for all submeshes
  21706. */
  21707. protected _markAllSubMeshesAsAllDirty(): void;
  21708. /**
  21709. * Indicates that image processing needs to be re-calculated for all submeshes
  21710. */
  21711. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21712. /**
  21713. * Indicates that textures need to be re-calculated for all submeshes
  21714. */
  21715. protected _markAllSubMeshesAsTexturesDirty(): void;
  21716. /**
  21717. * Indicates that fresnel needs to be re-calculated for all submeshes
  21718. */
  21719. protected _markAllSubMeshesAsFresnelDirty(): void;
  21720. /**
  21721. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21722. */
  21723. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21724. /**
  21725. * Indicates that lights need to be re-calculated for all submeshes
  21726. */
  21727. protected _markAllSubMeshesAsLightsDirty(): void;
  21728. /**
  21729. * Indicates that attributes need to be re-calculated for all submeshes
  21730. */
  21731. protected _markAllSubMeshesAsAttributesDirty(): void;
  21732. /**
  21733. * Indicates that misc needs to be re-calculated for all submeshes
  21734. */
  21735. protected _markAllSubMeshesAsMiscDirty(): void;
  21736. /**
  21737. * Indicates that textures and misc need to be re-calculated for all submeshes
  21738. */
  21739. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21740. /**
  21741. * Disposes the material
  21742. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21743. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21744. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21745. */
  21746. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21747. /** @hidden */
  21748. private releaseVertexArrayObject;
  21749. /**
  21750. * Serializes this material
  21751. * @returns the serialized material object
  21752. */
  21753. serialize(): any;
  21754. /**
  21755. * Creates a material from parsed material data
  21756. * @param parsedMaterial defines parsed material data
  21757. * @param scene defines the hosting scene
  21758. * @param rootUrl defines the root URL to use to load textures
  21759. * @returns a new material
  21760. */
  21761. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21762. }
  21763. }
  21764. declare module "babylonjs/Materials/multiMaterial" {
  21765. import { Nullable } from "babylonjs/types";
  21766. import { Scene } from "babylonjs/scene";
  21767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21768. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21770. import { Material } from "babylonjs/Materials/material";
  21771. /**
  21772. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21773. * separate meshes. This can be use to improve performances.
  21774. * @see http://doc.babylonjs.com/how_to/multi_materials
  21775. */
  21776. export class MultiMaterial extends Material {
  21777. private _subMaterials;
  21778. /**
  21779. * Gets or Sets the list of Materials used within the multi material.
  21780. * They need to be ordered according to the submeshes order in the associated mesh
  21781. */
  21782. get subMaterials(): Nullable<Material>[];
  21783. set subMaterials(value: Nullable<Material>[]);
  21784. /**
  21785. * Function used to align with Node.getChildren()
  21786. * @returns the list of Materials used within the multi material
  21787. */
  21788. getChildren(): Nullable<Material>[];
  21789. /**
  21790. * Instantiates a new Multi Material
  21791. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21792. * separate meshes. This can be use to improve performances.
  21793. * @see http://doc.babylonjs.com/how_to/multi_materials
  21794. * @param name Define the name in the scene
  21795. * @param scene Define the scene the material belongs to
  21796. */
  21797. constructor(name: string, scene: Scene);
  21798. private _hookArray;
  21799. /**
  21800. * Get one of the submaterial by its index in the submaterials array
  21801. * @param index The index to look the sub material at
  21802. * @returns The Material if the index has been defined
  21803. */
  21804. getSubMaterial(index: number): Nullable<Material>;
  21805. /**
  21806. * Get the list of active textures for the whole sub materials list.
  21807. * @returns All the textures that will be used during the rendering
  21808. */
  21809. getActiveTextures(): BaseTexture[];
  21810. /**
  21811. * Gets the current class name of the material e.g. "MultiMaterial"
  21812. * Mainly use in serialization.
  21813. * @returns the class name
  21814. */
  21815. getClassName(): string;
  21816. /**
  21817. * Checks if the material is ready to render the requested sub mesh
  21818. * @param mesh Define the mesh the submesh belongs to
  21819. * @param subMesh Define the sub mesh to look readyness for
  21820. * @param useInstances Define whether or not the material is used with instances
  21821. * @returns true if ready, otherwise false
  21822. */
  21823. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21824. /**
  21825. * Clones the current material and its related sub materials
  21826. * @param name Define the name of the newly cloned material
  21827. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21828. * @returns the cloned material
  21829. */
  21830. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21831. /**
  21832. * Serializes the materials into a JSON representation.
  21833. * @returns the JSON representation
  21834. */
  21835. serialize(): any;
  21836. /**
  21837. * Dispose the material and release its associated resources
  21838. * @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)
  21839. * @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)
  21840. * @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)
  21841. */
  21842. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21843. /**
  21844. * Creates a MultiMaterial from parsed MultiMaterial data.
  21845. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21846. * @param scene defines the hosting scene
  21847. * @returns a new MultiMaterial
  21848. */
  21849. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21850. }
  21851. }
  21852. declare module "babylonjs/Meshes/subMesh" {
  21853. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21854. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21855. import { Engine } from "babylonjs/Engines/engine";
  21856. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21857. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21858. import { Effect } from "babylonjs/Materials/effect";
  21859. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21860. import { Plane } from "babylonjs/Maths/math.plane";
  21861. import { Collider } from "babylonjs/Collisions/collider";
  21862. import { Material } from "babylonjs/Materials/material";
  21863. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21865. import { Mesh } from "babylonjs/Meshes/mesh";
  21866. import { Ray } from "babylonjs/Culling/ray";
  21867. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21868. /**
  21869. * Base class for submeshes
  21870. */
  21871. export class BaseSubMesh {
  21872. /** @hidden */
  21873. _materialDefines: Nullable<MaterialDefines>;
  21874. /** @hidden */
  21875. _materialEffect: Nullable<Effect>;
  21876. /**
  21877. * Gets material defines used by the effect associated to the sub mesh
  21878. */
  21879. get materialDefines(): Nullable<MaterialDefines>;
  21880. /**
  21881. * Sets material defines used by the effect associated to the sub mesh
  21882. */
  21883. set materialDefines(defines: Nullable<MaterialDefines>);
  21884. /**
  21885. * Gets associated effect
  21886. */
  21887. get effect(): Nullable<Effect>;
  21888. /**
  21889. * Sets associated effect (effect used to render this submesh)
  21890. * @param effect defines the effect to associate with
  21891. * @param defines defines the set of defines used to compile this effect
  21892. */
  21893. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21894. }
  21895. /**
  21896. * Defines a subdivision inside a mesh
  21897. */
  21898. export class SubMesh extends BaseSubMesh implements ICullable {
  21899. /** the material index to use */
  21900. materialIndex: number;
  21901. /** vertex index start */
  21902. verticesStart: number;
  21903. /** vertices count */
  21904. verticesCount: number;
  21905. /** index start */
  21906. indexStart: number;
  21907. /** indices count */
  21908. indexCount: number;
  21909. /** @hidden */
  21910. _linesIndexCount: number;
  21911. private _mesh;
  21912. private _renderingMesh;
  21913. private _boundingInfo;
  21914. private _linesIndexBuffer;
  21915. /** @hidden */
  21916. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21917. /** @hidden */
  21918. _trianglePlanes: Plane[];
  21919. /** @hidden */
  21920. _lastColliderTransformMatrix: Nullable<Matrix>;
  21921. /** @hidden */
  21922. _renderId: number;
  21923. /** @hidden */
  21924. _alphaIndex: number;
  21925. /** @hidden */
  21926. _distanceToCamera: number;
  21927. /** @hidden */
  21928. _id: number;
  21929. private _currentMaterial;
  21930. /**
  21931. * Add a new submesh to a mesh
  21932. * @param materialIndex defines the material index to use
  21933. * @param verticesStart defines vertex index start
  21934. * @param verticesCount defines vertices count
  21935. * @param indexStart defines index start
  21936. * @param indexCount defines indices count
  21937. * @param mesh defines the parent mesh
  21938. * @param renderingMesh defines an optional rendering mesh
  21939. * @param createBoundingBox defines if bounding box should be created for this submesh
  21940. * @returns the new submesh
  21941. */
  21942. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21943. /**
  21944. * Creates a new submesh
  21945. * @param materialIndex defines the material index to use
  21946. * @param verticesStart defines vertex index start
  21947. * @param verticesCount defines vertices count
  21948. * @param indexStart defines index start
  21949. * @param indexCount defines indices count
  21950. * @param mesh defines the parent mesh
  21951. * @param renderingMesh defines an optional rendering mesh
  21952. * @param createBoundingBox defines if bounding box should be created for this submesh
  21953. */
  21954. constructor(
  21955. /** the material index to use */
  21956. materialIndex: number,
  21957. /** vertex index start */
  21958. verticesStart: number,
  21959. /** vertices count */
  21960. verticesCount: number,
  21961. /** index start */
  21962. indexStart: number,
  21963. /** indices count */
  21964. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21965. /**
  21966. * Returns true if this submesh covers the entire parent mesh
  21967. * @ignorenaming
  21968. */
  21969. get IsGlobal(): boolean;
  21970. /**
  21971. * Returns the submesh BoudingInfo object
  21972. * @returns current bounding info (or mesh's one if the submesh is global)
  21973. */
  21974. getBoundingInfo(): BoundingInfo;
  21975. /**
  21976. * Sets the submesh BoundingInfo
  21977. * @param boundingInfo defines the new bounding info to use
  21978. * @returns the SubMesh
  21979. */
  21980. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21981. /**
  21982. * Returns the mesh of the current submesh
  21983. * @return the parent mesh
  21984. */
  21985. getMesh(): AbstractMesh;
  21986. /**
  21987. * Returns the rendering mesh of the submesh
  21988. * @returns the rendering mesh (could be different from parent mesh)
  21989. */
  21990. getRenderingMesh(): Mesh;
  21991. /**
  21992. * Returns the submesh material
  21993. * @returns null or the current material
  21994. */
  21995. getMaterial(): Nullable<Material>;
  21996. /**
  21997. * Sets a new updated BoundingInfo object to the submesh
  21998. * @param data defines an optional position array to use to determine the bounding info
  21999. * @returns the SubMesh
  22000. */
  22001. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22002. /** @hidden */
  22003. _checkCollision(collider: Collider): boolean;
  22004. /**
  22005. * Updates the submesh BoundingInfo
  22006. * @param world defines the world matrix to use to update the bounding info
  22007. * @returns the submesh
  22008. */
  22009. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22010. /**
  22011. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22012. * @param frustumPlanes defines the frustum planes
  22013. * @returns true if the submesh is intersecting with the frustum
  22014. */
  22015. isInFrustum(frustumPlanes: Plane[]): boolean;
  22016. /**
  22017. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22018. * @param frustumPlanes defines the frustum planes
  22019. * @returns true if the submesh is inside the frustum
  22020. */
  22021. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22022. /**
  22023. * Renders the submesh
  22024. * @param enableAlphaMode defines if alpha needs to be used
  22025. * @returns the submesh
  22026. */
  22027. render(enableAlphaMode: boolean): SubMesh;
  22028. /**
  22029. * @hidden
  22030. */
  22031. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22032. /**
  22033. * Checks if the submesh intersects with a ray
  22034. * @param ray defines the ray to test
  22035. * @returns true is the passed ray intersects the submesh bounding box
  22036. */
  22037. canIntersects(ray: Ray): boolean;
  22038. /**
  22039. * Intersects current submesh with a ray
  22040. * @param ray defines the ray to test
  22041. * @param positions defines mesh's positions array
  22042. * @param indices defines mesh's indices array
  22043. * @param fastCheck defines if only bounding info should be used
  22044. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22045. * @returns intersection info or null if no intersection
  22046. */
  22047. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22048. /** @hidden */
  22049. private _intersectLines;
  22050. /** @hidden */
  22051. private _intersectUnIndexedLines;
  22052. /** @hidden */
  22053. private _intersectTriangles;
  22054. /** @hidden */
  22055. private _intersectUnIndexedTriangles;
  22056. /** @hidden */
  22057. _rebuild(): void;
  22058. /**
  22059. * Creates a new submesh from the passed mesh
  22060. * @param newMesh defines the new hosting mesh
  22061. * @param newRenderingMesh defines an optional rendering mesh
  22062. * @returns the new submesh
  22063. */
  22064. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22065. /**
  22066. * Release associated resources
  22067. */
  22068. dispose(): void;
  22069. /**
  22070. * Gets the class name
  22071. * @returns the string "SubMesh".
  22072. */
  22073. getClassName(): string;
  22074. /**
  22075. * Creates a new submesh from indices data
  22076. * @param materialIndex the index of the main mesh material
  22077. * @param startIndex the index where to start the copy in the mesh indices array
  22078. * @param indexCount the number of indices to copy then from the startIndex
  22079. * @param mesh the main mesh to create the submesh from
  22080. * @param renderingMesh the optional rendering mesh
  22081. * @returns a new submesh
  22082. */
  22083. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22084. }
  22085. }
  22086. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22087. /**
  22088. * Class used to represent data loading progression
  22089. */
  22090. export class SceneLoaderFlags {
  22091. private static _ForceFullSceneLoadingForIncremental;
  22092. private static _ShowLoadingScreen;
  22093. private static _CleanBoneMatrixWeights;
  22094. private static _loggingLevel;
  22095. /**
  22096. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22097. */
  22098. static get ForceFullSceneLoadingForIncremental(): boolean;
  22099. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22100. /**
  22101. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22102. */
  22103. static get ShowLoadingScreen(): boolean;
  22104. static set ShowLoadingScreen(value: boolean);
  22105. /**
  22106. * Defines the current logging level (while loading the scene)
  22107. * @ignorenaming
  22108. */
  22109. static get loggingLevel(): number;
  22110. static set loggingLevel(value: number);
  22111. /**
  22112. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22113. */
  22114. static get CleanBoneMatrixWeights(): boolean;
  22115. static set CleanBoneMatrixWeights(value: boolean);
  22116. }
  22117. }
  22118. declare module "babylonjs/Meshes/geometry" {
  22119. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22120. import { Scene } from "babylonjs/scene";
  22121. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22122. import { Engine } from "babylonjs/Engines/engine";
  22123. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22124. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22125. import { Effect } from "babylonjs/Materials/effect";
  22126. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22127. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22128. import { Mesh } from "babylonjs/Meshes/mesh";
  22129. /**
  22130. * Class used to store geometry data (vertex buffers + index buffer)
  22131. */
  22132. export class Geometry implements IGetSetVerticesData {
  22133. /**
  22134. * Gets or sets the ID of the geometry
  22135. */
  22136. id: string;
  22137. /**
  22138. * Gets or sets the unique ID of the geometry
  22139. */
  22140. uniqueId: number;
  22141. /**
  22142. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22143. */
  22144. delayLoadState: number;
  22145. /**
  22146. * Gets the file containing the data to load when running in delay load state
  22147. */
  22148. delayLoadingFile: Nullable<string>;
  22149. /**
  22150. * Callback called when the geometry is updated
  22151. */
  22152. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22153. private _scene;
  22154. private _engine;
  22155. private _meshes;
  22156. private _totalVertices;
  22157. /** @hidden */
  22158. _indices: IndicesArray;
  22159. /** @hidden */
  22160. _vertexBuffers: {
  22161. [key: string]: VertexBuffer;
  22162. };
  22163. private _isDisposed;
  22164. private _extend;
  22165. private _boundingBias;
  22166. /** @hidden */
  22167. _delayInfo: Array<string>;
  22168. private _indexBuffer;
  22169. private _indexBufferIsUpdatable;
  22170. /** @hidden */
  22171. _boundingInfo: Nullable<BoundingInfo>;
  22172. /** @hidden */
  22173. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22174. /** @hidden */
  22175. _softwareSkinningFrameId: number;
  22176. private _vertexArrayObjects;
  22177. private _updatable;
  22178. /** @hidden */
  22179. _positions: Nullable<Vector3[]>;
  22180. /**
  22181. * 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
  22182. */
  22183. get boundingBias(): Vector2;
  22184. /**
  22185. * 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
  22186. */
  22187. set boundingBias(value: Vector2);
  22188. /**
  22189. * Static function used to attach a new empty geometry to a mesh
  22190. * @param mesh defines the mesh to attach the geometry to
  22191. * @returns the new Geometry
  22192. */
  22193. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22194. /**
  22195. * Creates a new geometry
  22196. * @param id defines the unique ID
  22197. * @param scene defines the hosting scene
  22198. * @param vertexData defines the VertexData used to get geometry data
  22199. * @param updatable defines if geometry must be updatable (false by default)
  22200. * @param mesh defines the mesh that will be associated with the geometry
  22201. */
  22202. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22203. /**
  22204. * Gets the current extend of the geometry
  22205. */
  22206. get extend(): {
  22207. minimum: Vector3;
  22208. maximum: Vector3;
  22209. };
  22210. /**
  22211. * Gets the hosting scene
  22212. * @returns the hosting Scene
  22213. */
  22214. getScene(): Scene;
  22215. /**
  22216. * Gets the hosting engine
  22217. * @returns the hosting Engine
  22218. */
  22219. getEngine(): Engine;
  22220. /**
  22221. * Defines if the geometry is ready to use
  22222. * @returns true if the geometry is ready to be used
  22223. */
  22224. isReady(): boolean;
  22225. /**
  22226. * Gets a value indicating that the geometry should not be serialized
  22227. */
  22228. get doNotSerialize(): boolean;
  22229. /** @hidden */
  22230. _rebuild(): void;
  22231. /**
  22232. * Affects all geometry data in one call
  22233. * @param vertexData defines the geometry data
  22234. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22235. */
  22236. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22237. /**
  22238. * Set specific vertex data
  22239. * @param kind defines the data kind (Position, normal, etc...)
  22240. * @param data defines the vertex data to use
  22241. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22242. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22243. */
  22244. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22245. /**
  22246. * Removes a specific vertex data
  22247. * @param kind defines the data kind (Position, normal, etc...)
  22248. */
  22249. removeVerticesData(kind: string): void;
  22250. /**
  22251. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22252. * @param buffer defines the vertex buffer to use
  22253. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22254. */
  22255. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22256. /**
  22257. * Update a specific vertex buffer
  22258. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22259. * It will do nothing if the buffer is not updatable
  22260. * @param kind defines the data kind (Position, normal, etc...)
  22261. * @param data defines the data to use
  22262. * @param offset defines the offset in the target buffer where to store the data
  22263. * @param useBytes set to true if the offset is in bytes
  22264. */
  22265. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22266. /**
  22267. * Update a specific vertex buffer
  22268. * This function will create a new buffer if the current one is not updatable
  22269. * @param kind defines the data kind (Position, normal, etc...)
  22270. * @param data defines the data to use
  22271. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22272. */
  22273. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22274. private _updateBoundingInfo;
  22275. /** @hidden */
  22276. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22277. /**
  22278. * Gets total number of vertices
  22279. * @returns the total number of vertices
  22280. */
  22281. getTotalVertices(): number;
  22282. /**
  22283. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22284. * @param kind defines the data kind (Position, normal, etc...)
  22285. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22286. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22287. * @returns a float array containing vertex data
  22288. */
  22289. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22290. /**
  22291. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22292. * @param kind defines the data kind (Position, normal, etc...)
  22293. * @returns true if the vertex buffer with the specified kind is updatable
  22294. */
  22295. isVertexBufferUpdatable(kind: string): boolean;
  22296. /**
  22297. * Gets a specific vertex buffer
  22298. * @param kind defines the data kind (Position, normal, etc...)
  22299. * @returns a VertexBuffer
  22300. */
  22301. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22302. /**
  22303. * Returns all vertex buffers
  22304. * @return an object holding all vertex buffers indexed by kind
  22305. */
  22306. getVertexBuffers(): Nullable<{
  22307. [key: string]: VertexBuffer;
  22308. }>;
  22309. /**
  22310. * Gets a boolean indicating if specific vertex buffer is present
  22311. * @param kind defines the data kind (Position, normal, etc...)
  22312. * @returns true if data is present
  22313. */
  22314. isVerticesDataPresent(kind: string): boolean;
  22315. /**
  22316. * Gets a list of all attached data kinds (Position, normal, etc...)
  22317. * @returns a list of string containing all kinds
  22318. */
  22319. getVerticesDataKinds(): string[];
  22320. /**
  22321. * Update index buffer
  22322. * @param indices defines the indices to store in the index buffer
  22323. * @param offset defines the offset in the target buffer where to store the data
  22324. * @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)
  22325. */
  22326. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22327. /**
  22328. * Creates a new index buffer
  22329. * @param indices defines the indices to store in the index buffer
  22330. * @param totalVertices defines the total number of vertices (could be null)
  22331. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22332. */
  22333. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22334. /**
  22335. * Return the total number of indices
  22336. * @returns the total number of indices
  22337. */
  22338. getTotalIndices(): number;
  22339. /**
  22340. * Gets the index buffer array
  22341. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22342. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22343. * @returns the index buffer array
  22344. */
  22345. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22346. /**
  22347. * Gets the index buffer
  22348. * @return the index buffer
  22349. */
  22350. getIndexBuffer(): Nullable<DataBuffer>;
  22351. /** @hidden */
  22352. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22353. /**
  22354. * Release the associated resources for a specific mesh
  22355. * @param mesh defines the source mesh
  22356. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22357. */
  22358. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22359. /**
  22360. * Apply current geometry to a given mesh
  22361. * @param mesh defines the mesh to apply geometry to
  22362. */
  22363. applyToMesh(mesh: Mesh): void;
  22364. private _updateExtend;
  22365. private _applyToMesh;
  22366. private notifyUpdate;
  22367. /**
  22368. * Load the geometry if it was flagged as delay loaded
  22369. * @param scene defines the hosting scene
  22370. * @param onLoaded defines a callback called when the geometry is loaded
  22371. */
  22372. load(scene: Scene, onLoaded?: () => void): void;
  22373. private _queueLoad;
  22374. /**
  22375. * Invert the geometry to move from a right handed system to a left handed one.
  22376. */
  22377. toLeftHanded(): void;
  22378. /** @hidden */
  22379. _resetPointsArrayCache(): void;
  22380. /** @hidden */
  22381. _generatePointsArray(): boolean;
  22382. /**
  22383. * Gets a value indicating if the geometry is disposed
  22384. * @returns true if the geometry was disposed
  22385. */
  22386. isDisposed(): boolean;
  22387. private _disposeVertexArrayObjects;
  22388. /**
  22389. * Free all associated resources
  22390. */
  22391. dispose(): void;
  22392. /**
  22393. * Clone the current geometry into a new geometry
  22394. * @param id defines the unique ID of the new geometry
  22395. * @returns a new geometry object
  22396. */
  22397. copy(id: string): Geometry;
  22398. /**
  22399. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22400. * @return a JSON representation of the current geometry data (without the vertices data)
  22401. */
  22402. serialize(): any;
  22403. private toNumberArray;
  22404. /**
  22405. * Serialize all vertices data into a JSON oject
  22406. * @returns a JSON representation of the current geometry data
  22407. */
  22408. serializeVerticeData(): any;
  22409. /**
  22410. * Extracts a clone of a mesh geometry
  22411. * @param mesh defines the source mesh
  22412. * @param id defines the unique ID of the new geometry object
  22413. * @returns the new geometry object
  22414. */
  22415. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22416. /**
  22417. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22418. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22419. * Be aware Math.random() could cause collisions, but:
  22420. * "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"
  22421. * @returns a string containing a new GUID
  22422. */
  22423. static RandomId(): string;
  22424. /** @hidden */
  22425. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22426. private static _CleanMatricesWeights;
  22427. /**
  22428. * Create a new geometry from persisted data (Using .babylon file format)
  22429. * @param parsedVertexData defines the persisted data
  22430. * @param scene defines the hosting scene
  22431. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22432. * @returns the new geometry object
  22433. */
  22434. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22435. }
  22436. }
  22437. declare module "babylonjs/Meshes/mesh.vertexData" {
  22438. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22439. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22440. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22441. import { Geometry } from "babylonjs/Meshes/geometry";
  22442. import { Mesh } from "babylonjs/Meshes/mesh";
  22443. /**
  22444. * Define an interface for all classes that will get and set the data on vertices
  22445. */
  22446. export interface IGetSetVerticesData {
  22447. /**
  22448. * Gets a boolean indicating if specific vertex data is present
  22449. * @param kind defines the vertex data kind to use
  22450. * @returns true is data kind is present
  22451. */
  22452. isVerticesDataPresent(kind: string): boolean;
  22453. /**
  22454. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22455. * @param kind defines the data kind (Position, normal, etc...)
  22456. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22458. * @returns a float array containing vertex data
  22459. */
  22460. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22461. /**
  22462. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22463. * @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.
  22464. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22465. * @returns the indices array or an empty array if the mesh has no geometry
  22466. */
  22467. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22468. /**
  22469. * Set specific vertex data
  22470. * @param kind defines the data kind (Position, normal, etc...)
  22471. * @param data defines the vertex data to use
  22472. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22473. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22474. */
  22475. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22476. /**
  22477. * Update a specific associated vertex buffer
  22478. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22479. * - VertexBuffer.PositionKind
  22480. * - VertexBuffer.UVKind
  22481. * - VertexBuffer.UV2Kind
  22482. * - VertexBuffer.UV3Kind
  22483. * - VertexBuffer.UV4Kind
  22484. * - VertexBuffer.UV5Kind
  22485. * - VertexBuffer.UV6Kind
  22486. * - VertexBuffer.ColorKind
  22487. * - VertexBuffer.MatricesIndicesKind
  22488. * - VertexBuffer.MatricesIndicesExtraKind
  22489. * - VertexBuffer.MatricesWeightsKind
  22490. * - VertexBuffer.MatricesWeightsExtraKind
  22491. * @param data defines the data source
  22492. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22493. * @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)
  22494. */
  22495. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22496. /**
  22497. * Creates a new index buffer
  22498. * @param indices defines the indices to store in the index buffer
  22499. * @param totalVertices defines the total number of vertices (could be null)
  22500. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22501. */
  22502. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22503. }
  22504. /**
  22505. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22506. */
  22507. export class VertexData {
  22508. /**
  22509. * Mesh side orientation : usually the external or front surface
  22510. */
  22511. static readonly FRONTSIDE: number;
  22512. /**
  22513. * Mesh side orientation : usually the internal or back surface
  22514. */
  22515. static readonly BACKSIDE: number;
  22516. /**
  22517. * Mesh side orientation : both internal and external or front and back surfaces
  22518. */
  22519. static readonly DOUBLESIDE: number;
  22520. /**
  22521. * Mesh side orientation : by default, `FRONTSIDE`
  22522. */
  22523. static readonly DEFAULTSIDE: number;
  22524. /**
  22525. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22526. */
  22527. positions: Nullable<FloatArray>;
  22528. /**
  22529. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22530. */
  22531. normals: Nullable<FloatArray>;
  22532. /**
  22533. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22534. */
  22535. tangents: Nullable<FloatArray>;
  22536. /**
  22537. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22538. */
  22539. uvs: Nullable<FloatArray>;
  22540. /**
  22541. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22542. */
  22543. uvs2: Nullable<FloatArray>;
  22544. /**
  22545. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22546. */
  22547. uvs3: Nullable<FloatArray>;
  22548. /**
  22549. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22550. */
  22551. uvs4: Nullable<FloatArray>;
  22552. /**
  22553. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22554. */
  22555. uvs5: Nullable<FloatArray>;
  22556. /**
  22557. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22558. */
  22559. uvs6: Nullable<FloatArray>;
  22560. /**
  22561. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22562. */
  22563. colors: Nullable<FloatArray>;
  22564. /**
  22565. * 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).
  22566. */
  22567. matricesIndices: Nullable<FloatArray>;
  22568. /**
  22569. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22570. */
  22571. matricesWeights: Nullable<FloatArray>;
  22572. /**
  22573. * An array extending the number of possible indices
  22574. */
  22575. matricesIndicesExtra: Nullable<FloatArray>;
  22576. /**
  22577. * An array extending the number of possible weights when the number of indices is extended
  22578. */
  22579. matricesWeightsExtra: Nullable<FloatArray>;
  22580. /**
  22581. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22582. */
  22583. indices: Nullable<IndicesArray>;
  22584. /**
  22585. * Uses the passed data array to set the set the values for the specified kind of data
  22586. * @param data a linear array of floating numbers
  22587. * @param kind the type of data that is being set, eg positions, colors etc
  22588. */
  22589. set(data: FloatArray, kind: string): void;
  22590. /**
  22591. * Associates the vertexData to the passed Mesh.
  22592. * Sets it as updatable or not (default `false`)
  22593. * @param mesh the mesh the vertexData is applied to
  22594. * @param updatable when used and having the value true allows new data to update the vertexData
  22595. * @returns the VertexData
  22596. */
  22597. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22598. /**
  22599. * Associates the vertexData to the passed Geometry.
  22600. * Sets it as updatable or not (default `false`)
  22601. * @param geometry the geometry the vertexData is applied to
  22602. * @param updatable when used and having the value true allows new data to update the vertexData
  22603. * @returns VertexData
  22604. */
  22605. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22606. /**
  22607. * Updates the associated mesh
  22608. * @param mesh the mesh to be updated
  22609. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22610. * @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
  22611. * @returns VertexData
  22612. */
  22613. updateMesh(mesh: Mesh): VertexData;
  22614. /**
  22615. * Updates the associated geometry
  22616. * @param geometry the geometry to be updated
  22617. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22618. * @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
  22619. * @returns VertexData.
  22620. */
  22621. updateGeometry(geometry: Geometry): VertexData;
  22622. private _applyTo;
  22623. private _update;
  22624. /**
  22625. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22626. * @param matrix the transforming matrix
  22627. * @returns the VertexData
  22628. */
  22629. transform(matrix: Matrix): VertexData;
  22630. /**
  22631. * Merges the passed VertexData into the current one
  22632. * @param other the VertexData to be merged into the current one
  22633. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22634. * @returns the modified VertexData
  22635. */
  22636. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22637. private _mergeElement;
  22638. private _validate;
  22639. /**
  22640. * Serializes the VertexData
  22641. * @returns a serialized object
  22642. */
  22643. serialize(): any;
  22644. /**
  22645. * Extracts the vertexData from a mesh
  22646. * @param mesh the mesh from which to extract the VertexData
  22647. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22648. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22649. * @returns the object VertexData associated to the passed mesh
  22650. */
  22651. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22652. /**
  22653. * Extracts the vertexData from the geometry
  22654. * @param geometry the geometry from which to extract the VertexData
  22655. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22656. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22657. * @returns the object VertexData associated to the passed mesh
  22658. */
  22659. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22660. private static _ExtractFrom;
  22661. /**
  22662. * Creates the VertexData for a Ribbon
  22663. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22664. * * pathArray array of paths, each of which an array of successive Vector3
  22665. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22666. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22667. * * 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
  22668. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22669. * * 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)
  22670. * * 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)
  22671. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22672. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22673. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22674. * @returns the VertexData of the ribbon
  22675. */
  22676. static CreateRibbon(options: {
  22677. pathArray: Vector3[][];
  22678. closeArray?: boolean;
  22679. closePath?: boolean;
  22680. offset?: number;
  22681. sideOrientation?: number;
  22682. frontUVs?: Vector4;
  22683. backUVs?: Vector4;
  22684. invertUV?: boolean;
  22685. uvs?: Vector2[];
  22686. colors?: Color4[];
  22687. }): VertexData;
  22688. /**
  22689. * Creates the VertexData for a box
  22690. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22691. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22692. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22693. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22694. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22695. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22696. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22697. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22698. * * 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)
  22699. * * 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)
  22700. * @returns the VertexData of the box
  22701. */
  22702. static CreateBox(options: {
  22703. size?: number;
  22704. width?: number;
  22705. height?: number;
  22706. depth?: number;
  22707. faceUV?: Vector4[];
  22708. faceColors?: Color4[];
  22709. sideOrientation?: number;
  22710. frontUVs?: Vector4;
  22711. backUVs?: Vector4;
  22712. }): VertexData;
  22713. /**
  22714. * Creates the VertexData for a tiled box
  22715. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22716. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22717. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22718. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22720. * @returns the VertexData of the box
  22721. */
  22722. static CreateTiledBox(options: {
  22723. pattern?: number;
  22724. width?: number;
  22725. height?: number;
  22726. depth?: number;
  22727. tileSize?: number;
  22728. tileWidth?: number;
  22729. tileHeight?: number;
  22730. alignHorizontal?: number;
  22731. alignVertical?: number;
  22732. faceUV?: Vector4[];
  22733. faceColors?: Color4[];
  22734. sideOrientation?: number;
  22735. }): VertexData;
  22736. /**
  22737. * Creates the VertexData for a tiled plane
  22738. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22739. * * pattern a limited pattern arrangement depending on the number
  22740. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22741. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22742. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22744. * * 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)
  22745. * * 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)
  22746. * @returns the VertexData of the tiled plane
  22747. */
  22748. static CreateTiledPlane(options: {
  22749. pattern?: number;
  22750. tileSize?: number;
  22751. tileWidth?: number;
  22752. tileHeight?: number;
  22753. size?: number;
  22754. width?: number;
  22755. height?: number;
  22756. alignHorizontal?: number;
  22757. alignVertical?: number;
  22758. sideOrientation?: number;
  22759. frontUVs?: Vector4;
  22760. backUVs?: Vector4;
  22761. }): VertexData;
  22762. /**
  22763. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22764. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22765. * * segments sets the number of horizontal strips optional, default 32
  22766. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22767. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22768. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22769. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22770. * * 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
  22771. * * 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
  22772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22773. * * 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)
  22774. * * 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)
  22775. * @returns the VertexData of the ellipsoid
  22776. */
  22777. static CreateSphere(options: {
  22778. segments?: number;
  22779. diameter?: number;
  22780. diameterX?: number;
  22781. diameterY?: number;
  22782. diameterZ?: number;
  22783. arc?: number;
  22784. slice?: number;
  22785. sideOrientation?: number;
  22786. frontUVs?: Vector4;
  22787. backUVs?: Vector4;
  22788. }): VertexData;
  22789. /**
  22790. * Creates the VertexData for a cylinder, cone or prism
  22791. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22792. * * height sets the height (y direction) of the cylinder, optional, default 2
  22793. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22794. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22795. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22796. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22797. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22798. * * 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
  22799. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22800. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22801. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22802. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22803. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22804. * * 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)
  22805. * * 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)
  22806. * @returns the VertexData of the cylinder, cone or prism
  22807. */
  22808. static CreateCylinder(options: {
  22809. height?: number;
  22810. diameterTop?: number;
  22811. diameterBottom?: number;
  22812. diameter?: number;
  22813. tessellation?: number;
  22814. subdivisions?: number;
  22815. arc?: number;
  22816. faceColors?: Color4[];
  22817. faceUV?: Vector4[];
  22818. hasRings?: boolean;
  22819. enclose?: boolean;
  22820. sideOrientation?: number;
  22821. frontUVs?: Vector4;
  22822. backUVs?: Vector4;
  22823. }): VertexData;
  22824. /**
  22825. * Creates the VertexData for a torus
  22826. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22827. * * diameter the diameter of the torus, optional default 1
  22828. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22829. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22830. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22831. * * 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)
  22832. * * 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)
  22833. * @returns the VertexData of the torus
  22834. */
  22835. static CreateTorus(options: {
  22836. diameter?: number;
  22837. thickness?: number;
  22838. tessellation?: number;
  22839. sideOrientation?: number;
  22840. frontUVs?: Vector4;
  22841. backUVs?: Vector4;
  22842. }): VertexData;
  22843. /**
  22844. * Creates the VertexData of the LineSystem
  22845. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22846. * - lines an array of lines, each line being an array of successive Vector3
  22847. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22848. * @returns the VertexData of the LineSystem
  22849. */
  22850. static CreateLineSystem(options: {
  22851. lines: Vector3[][];
  22852. colors?: Nullable<Color4[][]>;
  22853. }): VertexData;
  22854. /**
  22855. * Create the VertexData for a DashedLines
  22856. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22857. * - points an array successive Vector3
  22858. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22859. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22860. * - dashNb the intended total number of dashes, optional, default 200
  22861. * @returns the VertexData for the DashedLines
  22862. */
  22863. static CreateDashedLines(options: {
  22864. points: Vector3[];
  22865. dashSize?: number;
  22866. gapSize?: number;
  22867. dashNb?: number;
  22868. }): VertexData;
  22869. /**
  22870. * Creates the VertexData for a Ground
  22871. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22872. * - width the width (x direction) of the ground, optional, default 1
  22873. * - height the height (z direction) of the ground, optional, default 1
  22874. * - subdivisions the number of subdivisions per side, optional, default 1
  22875. * @returns the VertexData of the Ground
  22876. */
  22877. static CreateGround(options: {
  22878. width?: number;
  22879. height?: number;
  22880. subdivisions?: number;
  22881. subdivisionsX?: number;
  22882. subdivisionsY?: number;
  22883. }): VertexData;
  22884. /**
  22885. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22886. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22887. * * xmin the ground minimum X coordinate, optional, default -1
  22888. * * zmin the ground minimum Z coordinate, optional, default -1
  22889. * * xmax the ground maximum X coordinate, optional, default 1
  22890. * * zmax the ground maximum Z coordinate, optional, default 1
  22891. * * 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}
  22892. * * 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}
  22893. * @returns the VertexData of the TiledGround
  22894. */
  22895. static CreateTiledGround(options: {
  22896. xmin: number;
  22897. zmin: number;
  22898. xmax: number;
  22899. zmax: number;
  22900. subdivisions?: {
  22901. w: number;
  22902. h: number;
  22903. };
  22904. precision?: {
  22905. w: number;
  22906. h: number;
  22907. };
  22908. }): VertexData;
  22909. /**
  22910. * Creates the VertexData of the Ground designed from a heightmap
  22911. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22912. * * width the width (x direction) of the ground
  22913. * * height the height (z direction) of the ground
  22914. * * subdivisions the number of subdivisions per side
  22915. * * minHeight the minimum altitude on the ground, optional, default 0
  22916. * * maxHeight the maximum altitude on the ground, optional default 1
  22917. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22918. * * buffer the array holding the image color data
  22919. * * bufferWidth the width of image
  22920. * * bufferHeight the height of image
  22921. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22922. * @returns the VertexData of the Ground designed from a heightmap
  22923. */
  22924. static CreateGroundFromHeightMap(options: {
  22925. width: number;
  22926. height: number;
  22927. subdivisions: number;
  22928. minHeight: number;
  22929. maxHeight: number;
  22930. colorFilter: Color3;
  22931. buffer: Uint8Array;
  22932. bufferWidth: number;
  22933. bufferHeight: number;
  22934. alphaFilter: number;
  22935. }): VertexData;
  22936. /**
  22937. * Creates the VertexData for a Plane
  22938. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22939. * * size sets the width and height of the plane to the value of size, optional default 1
  22940. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22941. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22942. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22943. * * 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)
  22944. * * 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)
  22945. * @returns the VertexData of the box
  22946. */
  22947. static CreatePlane(options: {
  22948. size?: number;
  22949. width?: number;
  22950. height?: number;
  22951. sideOrientation?: number;
  22952. frontUVs?: Vector4;
  22953. backUVs?: Vector4;
  22954. }): VertexData;
  22955. /**
  22956. * Creates the VertexData of the Disc or regular Polygon
  22957. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22958. * * radius the radius of the disc, optional default 0.5
  22959. * * tessellation the number of polygon sides, optional, default 64
  22960. * * 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
  22961. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22962. * * 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)
  22963. * * 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)
  22964. * @returns the VertexData of the box
  22965. */
  22966. static CreateDisc(options: {
  22967. radius?: number;
  22968. tessellation?: number;
  22969. arc?: number;
  22970. sideOrientation?: number;
  22971. frontUVs?: Vector4;
  22972. backUVs?: Vector4;
  22973. }): VertexData;
  22974. /**
  22975. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22976. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22977. * @param polygon a mesh built from polygonTriangulation.build()
  22978. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22979. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22980. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22981. * @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)
  22982. * @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)
  22983. * @returns the VertexData of the Polygon
  22984. */
  22985. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22986. /**
  22987. * Creates the VertexData of the IcoSphere
  22988. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22989. * * radius the radius of the IcoSphere, optional default 1
  22990. * * radiusX allows stretching in the x direction, optional, default radius
  22991. * * radiusY allows stretching in the y direction, optional, default radius
  22992. * * radiusZ allows stretching in the z direction, optional, default radius
  22993. * * flat when true creates a flat shaded mesh, optional, default true
  22994. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22995. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22996. * * 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)
  22997. * * 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)
  22998. * @returns the VertexData of the IcoSphere
  22999. */
  23000. static CreateIcoSphere(options: {
  23001. radius?: number;
  23002. radiusX?: number;
  23003. radiusY?: number;
  23004. radiusZ?: number;
  23005. flat?: boolean;
  23006. subdivisions?: number;
  23007. sideOrientation?: number;
  23008. frontUVs?: Vector4;
  23009. backUVs?: Vector4;
  23010. }): VertexData;
  23011. /**
  23012. * Creates the VertexData for a Polyhedron
  23013. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23014. * * type provided types are:
  23015. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23016. * * 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)
  23017. * * size the size of the IcoSphere, optional default 1
  23018. * * sizeX allows stretching in the x direction, optional, default size
  23019. * * sizeY allows stretching in the y direction, optional, default size
  23020. * * sizeZ allows stretching in the z direction, optional, default size
  23021. * * 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
  23022. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23023. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23024. * * flat when true creates a flat shaded mesh, optional, default true
  23025. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23027. * * 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)
  23028. * * 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)
  23029. * @returns the VertexData of the Polyhedron
  23030. */
  23031. static CreatePolyhedron(options: {
  23032. type?: number;
  23033. size?: number;
  23034. sizeX?: number;
  23035. sizeY?: number;
  23036. sizeZ?: number;
  23037. custom?: any;
  23038. faceUV?: Vector4[];
  23039. faceColors?: Color4[];
  23040. flat?: boolean;
  23041. sideOrientation?: number;
  23042. frontUVs?: Vector4;
  23043. backUVs?: Vector4;
  23044. }): VertexData;
  23045. /**
  23046. * Creates the VertexData for a TorusKnot
  23047. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23048. * * radius the radius of the torus knot, optional, default 2
  23049. * * tube the thickness of the tube, optional, default 0.5
  23050. * * radialSegments the number of sides on each tube segments, optional, default 32
  23051. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23052. * * p the number of windings around the z axis, optional, default 2
  23053. * * q the number of windings around the x axis, optional, default 3
  23054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23055. * * 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)
  23056. * * 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)
  23057. * @returns the VertexData of the Torus Knot
  23058. */
  23059. static CreateTorusKnot(options: {
  23060. radius?: number;
  23061. tube?: number;
  23062. radialSegments?: number;
  23063. tubularSegments?: number;
  23064. p?: number;
  23065. q?: number;
  23066. sideOrientation?: number;
  23067. frontUVs?: Vector4;
  23068. backUVs?: Vector4;
  23069. }): VertexData;
  23070. /**
  23071. * Compute normals for given positions and indices
  23072. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23073. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23074. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23075. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23076. * * facetNormals : optional array of facet normals (vector3)
  23077. * * facetPositions : optional array of facet positions (vector3)
  23078. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23079. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23080. * * bInfo : optional bounding info, required for facetPartitioning computation
  23081. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23082. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23083. * * useRightHandedSystem: optional boolean to for right handed system computation
  23084. * * depthSort : optional boolean to enable the facet depth sort computation
  23085. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23086. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23087. */
  23088. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23089. facetNormals?: any;
  23090. facetPositions?: any;
  23091. facetPartitioning?: any;
  23092. ratio?: number;
  23093. bInfo?: any;
  23094. bbSize?: Vector3;
  23095. subDiv?: any;
  23096. useRightHandedSystem?: boolean;
  23097. depthSort?: boolean;
  23098. distanceTo?: Vector3;
  23099. depthSortedFacets?: any;
  23100. }): void;
  23101. /** @hidden */
  23102. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23103. /**
  23104. * Applies VertexData created from the imported parameters to the geometry
  23105. * @param parsedVertexData the parsed data from an imported file
  23106. * @param geometry the geometry to apply the VertexData to
  23107. */
  23108. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23109. }
  23110. }
  23111. declare module "babylonjs/Morph/morphTarget" {
  23112. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23113. import { Observable } from "babylonjs/Misc/observable";
  23114. import { Nullable, FloatArray } from "babylonjs/types";
  23115. import { Scene } from "babylonjs/scene";
  23116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23117. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23118. /**
  23119. * Defines a target to use with MorphTargetManager
  23120. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23121. */
  23122. export class MorphTarget implements IAnimatable {
  23123. /** defines the name of the target */
  23124. name: string;
  23125. /**
  23126. * Gets or sets the list of animations
  23127. */
  23128. animations: import("babylonjs/Animations/animation").Animation[];
  23129. private _scene;
  23130. private _positions;
  23131. private _normals;
  23132. private _tangents;
  23133. private _uvs;
  23134. private _influence;
  23135. private _uniqueId;
  23136. /**
  23137. * Observable raised when the influence changes
  23138. */
  23139. onInfluenceChanged: Observable<boolean>;
  23140. /** @hidden */
  23141. _onDataLayoutChanged: Observable<void>;
  23142. /**
  23143. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23144. */
  23145. get influence(): number;
  23146. set influence(influence: number);
  23147. /**
  23148. * Gets or sets the id of the morph Target
  23149. */
  23150. id: string;
  23151. private _animationPropertiesOverride;
  23152. /**
  23153. * Gets or sets the animation properties override
  23154. */
  23155. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23156. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23157. /**
  23158. * Creates a new MorphTarget
  23159. * @param name defines the name of the target
  23160. * @param influence defines the influence to use
  23161. * @param scene defines the scene the morphtarget belongs to
  23162. */
  23163. constructor(
  23164. /** defines the name of the target */
  23165. name: string, influence?: number, scene?: Nullable<Scene>);
  23166. /**
  23167. * Gets the unique ID of this manager
  23168. */
  23169. get uniqueId(): number;
  23170. /**
  23171. * Gets a boolean defining if the target contains position data
  23172. */
  23173. get hasPositions(): boolean;
  23174. /**
  23175. * Gets a boolean defining if the target contains normal data
  23176. */
  23177. get hasNormals(): boolean;
  23178. /**
  23179. * Gets a boolean defining if the target contains tangent data
  23180. */
  23181. get hasTangents(): boolean;
  23182. /**
  23183. * Gets a boolean defining if the target contains texture coordinates data
  23184. */
  23185. get hasUVs(): boolean;
  23186. /**
  23187. * Affects position data to this target
  23188. * @param data defines the position data to use
  23189. */
  23190. setPositions(data: Nullable<FloatArray>): void;
  23191. /**
  23192. * Gets the position data stored in this target
  23193. * @returns a FloatArray containing the position data (or null if not present)
  23194. */
  23195. getPositions(): Nullable<FloatArray>;
  23196. /**
  23197. * Affects normal data to this target
  23198. * @param data defines the normal data to use
  23199. */
  23200. setNormals(data: Nullable<FloatArray>): void;
  23201. /**
  23202. * Gets the normal data stored in this target
  23203. * @returns a FloatArray containing the normal data (or null if not present)
  23204. */
  23205. getNormals(): Nullable<FloatArray>;
  23206. /**
  23207. * Affects tangent data to this target
  23208. * @param data defines the tangent data to use
  23209. */
  23210. setTangents(data: Nullable<FloatArray>): void;
  23211. /**
  23212. * Gets the tangent data stored in this target
  23213. * @returns a FloatArray containing the tangent data (or null if not present)
  23214. */
  23215. getTangents(): Nullable<FloatArray>;
  23216. /**
  23217. * Affects texture coordinates data to this target
  23218. * @param data defines the texture coordinates data to use
  23219. */
  23220. setUVs(data: Nullable<FloatArray>): void;
  23221. /**
  23222. * Gets the texture coordinates data stored in this target
  23223. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23224. */
  23225. getUVs(): Nullable<FloatArray>;
  23226. /**
  23227. * Clone the current target
  23228. * @returns a new MorphTarget
  23229. */
  23230. clone(): MorphTarget;
  23231. /**
  23232. * Serializes the current target into a Serialization object
  23233. * @returns the serialized object
  23234. */
  23235. serialize(): any;
  23236. /**
  23237. * Returns the string "MorphTarget"
  23238. * @returns "MorphTarget"
  23239. */
  23240. getClassName(): string;
  23241. /**
  23242. * Creates a new target from serialized data
  23243. * @param serializationObject defines the serialized data to use
  23244. * @returns a new MorphTarget
  23245. */
  23246. static Parse(serializationObject: any): MorphTarget;
  23247. /**
  23248. * Creates a MorphTarget from mesh data
  23249. * @param mesh defines the source mesh
  23250. * @param name defines the name to use for the new target
  23251. * @param influence defines the influence to attach to the target
  23252. * @returns a new MorphTarget
  23253. */
  23254. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23255. }
  23256. }
  23257. declare module "babylonjs/Morph/morphTargetManager" {
  23258. import { Nullable } from "babylonjs/types";
  23259. import { Scene } from "babylonjs/scene";
  23260. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23261. /**
  23262. * This class is used to deform meshes using morphing between different targets
  23263. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23264. */
  23265. export class MorphTargetManager {
  23266. private _targets;
  23267. private _targetInfluenceChangedObservers;
  23268. private _targetDataLayoutChangedObservers;
  23269. private _activeTargets;
  23270. private _scene;
  23271. private _influences;
  23272. private _supportsNormals;
  23273. private _supportsTangents;
  23274. private _supportsUVs;
  23275. private _vertexCount;
  23276. private _uniqueId;
  23277. private _tempInfluences;
  23278. /**
  23279. * Gets or sets a boolean indicating if normals must be morphed
  23280. */
  23281. enableNormalMorphing: boolean;
  23282. /**
  23283. * Gets or sets a boolean indicating if tangents must be morphed
  23284. */
  23285. enableTangentMorphing: boolean;
  23286. /**
  23287. * Gets or sets a boolean indicating if UV must be morphed
  23288. */
  23289. enableUVMorphing: boolean;
  23290. /**
  23291. * Creates a new MorphTargetManager
  23292. * @param scene defines the current scene
  23293. */
  23294. constructor(scene?: Nullable<Scene>);
  23295. /**
  23296. * Gets the unique ID of this manager
  23297. */
  23298. get uniqueId(): number;
  23299. /**
  23300. * Gets the number of vertices handled by this manager
  23301. */
  23302. get vertexCount(): number;
  23303. /**
  23304. * Gets a boolean indicating if this manager supports morphing of normals
  23305. */
  23306. get supportsNormals(): boolean;
  23307. /**
  23308. * Gets a boolean indicating if this manager supports morphing of tangents
  23309. */
  23310. get supportsTangents(): boolean;
  23311. /**
  23312. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23313. */
  23314. get supportsUVs(): boolean;
  23315. /**
  23316. * Gets the number of targets stored in this manager
  23317. */
  23318. get numTargets(): number;
  23319. /**
  23320. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23321. */
  23322. get numInfluencers(): number;
  23323. /**
  23324. * Gets the list of influences (one per target)
  23325. */
  23326. get influences(): Float32Array;
  23327. /**
  23328. * Gets the active target at specified index. An active target is a target with an influence > 0
  23329. * @param index defines the index to check
  23330. * @returns the requested target
  23331. */
  23332. getActiveTarget(index: number): MorphTarget;
  23333. /**
  23334. * Gets the target at specified index
  23335. * @param index defines the index to check
  23336. * @returns the requested target
  23337. */
  23338. getTarget(index: number): MorphTarget;
  23339. /**
  23340. * Add a new target to this manager
  23341. * @param target defines the target to add
  23342. */
  23343. addTarget(target: MorphTarget): void;
  23344. /**
  23345. * Removes a target from the manager
  23346. * @param target defines the target to remove
  23347. */
  23348. removeTarget(target: MorphTarget): void;
  23349. /**
  23350. * Clone the current manager
  23351. * @returns a new MorphTargetManager
  23352. */
  23353. clone(): MorphTargetManager;
  23354. /**
  23355. * Serializes the current manager into a Serialization object
  23356. * @returns the serialized object
  23357. */
  23358. serialize(): any;
  23359. private _syncActiveTargets;
  23360. /**
  23361. * Syncrhonize the targets with all the meshes using this morph target manager
  23362. */
  23363. synchronize(): void;
  23364. /**
  23365. * Creates a new MorphTargetManager from serialized data
  23366. * @param serializationObject defines the serialized data
  23367. * @param scene defines the hosting scene
  23368. * @returns the new MorphTargetManager
  23369. */
  23370. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23371. }
  23372. }
  23373. declare module "babylonjs/Meshes/meshLODLevel" {
  23374. import { Mesh } from "babylonjs/Meshes/mesh";
  23375. import { Nullable } from "babylonjs/types";
  23376. /**
  23377. * Class used to represent a specific level of detail of a mesh
  23378. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23379. */
  23380. export class MeshLODLevel {
  23381. /** Defines the distance where this level should start being displayed */
  23382. distance: number;
  23383. /** Defines the mesh to use to render this level */
  23384. mesh: Nullable<Mesh>;
  23385. /**
  23386. * Creates a new LOD level
  23387. * @param distance defines the distance where this level should star being displayed
  23388. * @param mesh defines the mesh to use to render this level
  23389. */
  23390. constructor(
  23391. /** Defines the distance where this level should start being displayed */
  23392. distance: number,
  23393. /** Defines the mesh to use to render this level */
  23394. mesh: Nullable<Mesh>);
  23395. }
  23396. }
  23397. declare module "babylonjs/Meshes/groundMesh" {
  23398. import { Scene } from "babylonjs/scene";
  23399. import { Vector3 } from "babylonjs/Maths/math.vector";
  23400. import { Mesh } from "babylonjs/Meshes/mesh";
  23401. /**
  23402. * Mesh representing the gorund
  23403. */
  23404. export class GroundMesh extends Mesh {
  23405. /** If octree should be generated */
  23406. generateOctree: boolean;
  23407. private _heightQuads;
  23408. /** @hidden */
  23409. _subdivisionsX: number;
  23410. /** @hidden */
  23411. _subdivisionsY: number;
  23412. /** @hidden */
  23413. _width: number;
  23414. /** @hidden */
  23415. _height: number;
  23416. /** @hidden */
  23417. _minX: number;
  23418. /** @hidden */
  23419. _maxX: number;
  23420. /** @hidden */
  23421. _minZ: number;
  23422. /** @hidden */
  23423. _maxZ: number;
  23424. constructor(name: string, scene: Scene);
  23425. /**
  23426. * "GroundMesh"
  23427. * @returns "GroundMesh"
  23428. */
  23429. getClassName(): string;
  23430. /**
  23431. * The minimum of x and y subdivisions
  23432. */
  23433. get subdivisions(): number;
  23434. /**
  23435. * X subdivisions
  23436. */
  23437. get subdivisionsX(): number;
  23438. /**
  23439. * Y subdivisions
  23440. */
  23441. get subdivisionsY(): number;
  23442. /**
  23443. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23444. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23445. * @param chunksCount the number of subdivisions for x and y
  23446. * @param octreeBlocksSize (Default: 32)
  23447. */
  23448. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23449. /**
  23450. * Returns a height (y) value in the Worl system :
  23451. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23452. * @param x x coordinate
  23453. * @param z z coordinate
  23454. * @returns the ground y position if (x, z) are outside the ground surface.
  23455. */
  23456. getHeightAtCoordinates(x: number, z: number): number;
  23457. /**
  23458. * Returns a normalized vector (Vector3) orthogonal to the ground
  23459. * at the ground coordinates (x, z) expressed in the World system.
  23460. * @param x x coordinate
  23461. * @param z z coordinate
  23462. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23463. */
  23464. getNormalAtCoordinates(x: number, z: number): Vector3;
  23465. /**
  23466. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23467. * at the ground coordinates (x, z) expressed in the World system.
  23468. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23469. * @param x x coordinate
  23470. * @param z z coordinate
  23471. * @param ref vector to store the result
  23472. * @returns the GroundMesh.
  23473. */
  23474. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23475. /**
  23476. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23477. * if the ground has been updated.
  23478. * This can be used in the render loop.
  23479. * @returns the GroundMesh.
  23480. */
  23481. updateCoordinateHeights(): GroundMesh;
  23482. private _getFacetAt;
  23483. private _initHeightQuads;
  23484. private _computeHeightQuads;
  23485. /**
  23486. * Serializes this ground mesh
  23487. * @param serializationObject object to write serialization to
  23488. */
  23489. serialize(serializationObject: any): void;
  23490. /**
  23491. * Parses a serialized ground mesh
  23492. * @param parsedMesh the serialized mesh
  23493. * @param scene the scene to create the ground mesh in
  23494. * @returns the created ground mesh
  23495. */
  23496. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23497. }
  23498. }
  23499. declare module "babylonjs/Physics/physicsJoint" {
  23500. import { Vector3 } from "babylonjs/Maths/math.vector";
  23501. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23502. /**
  23503. * Interface for Physics-Joint data
  23504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23505. */
  23506. export interface PhysicsJointData {
  23507. /**
  23508. * The main pivot of the joint
  23509. */
  23510. mainPivot?: Vector3;
  23511. /**
  23512. * The connected pivot of the joint
  23513. */
  23514. connectedPivot?: Vector3;
  23515. /**
  23516. * The main axis of the joint
  23517. */
  23518. mainAxis?: Vector3;
  23519. /**
  23520. * The connected axis of the joint
  23521. */
  23522. connectedAxis?: Vector3;
  23523. /**
  23524. * The collision of the joint
  23525. */
  23526. collision?: boolean;
  23527. /**
  23528. * Native Oimo/Cannon/Energy data
  23529. */
  23530. nativeParams?: any;
  23531. }
  23532. /**
  23533. * This is a holder class for the physics joint created by the physics plugin
  23534. * It holds a set of functions to control the underlying joint
  23535. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23536. */
  23537. export class PhysicsJoint {
  23538. /**
  23539. * The type of the physics joint
  23540. */
  23541. type: number;
  23542. /**
  23543. * The data for the physics joint
  23544. */
  23545. jointData: PhysicsJointData;
  23546. private _physicsJoint;
  23547. protected _physicsPlugin: IPhysicsEnginePlugin;
  23548. /**
  23549. * Initializes the physics joint
  23550. * @param type The type of the physics joint
  23551. * @param jointData The data for the physics joint
  23552. */
  23553. constructor(
  23554. /**
  23555. * The type of the physics joint
  23556. */
  23557. type: number,
  23558. /**
  23559. * The data for the physics joint
  23560. */
  23561. jointData: PhysicsJointData);
  23562. /**
  23563. * Gets the physics joint
  23564. */
  23565. get physicsJoint(): any;
  23566. /**
  23567. * Sets the physics joint
  23568. */
  23569. set physicsJoint(newJoint: any);
  23570. /**
  23571. * Sets the physics plugin
  23572. */
  23573. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23574. /**
  23575. * Execute a function that is physics-plugin specific.
  23576. * @param {Function} func the function that will be executed.
  23577. * It accepts two parameters: the physics world and the physics joint
  23578. */
  23579. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23580. /**
  23581. * Distance-Joint type
  23582. */
  23583. static DistanceJoint: number;
  23584. /**
  23585. * Hinge-Joint type
  23586. */
  23587. static HingeJoint: number;
  23588. /**
  23589. * Ball-and-Socket joint type
  23590. */
  23591. static BallAndSocketJoint: number;
  23592. /**
  23593. * Wheel-Joint type
  23594. */
  23595. static WheelJoint: number;
  23596. /**
  23597. * Slider-Joint type
  23598. */
  23599. static SliderJoint: number;
  23600. /**
  23601. * Prismatic-Joint type
  23602. */
  23603. static PrismaticJoint: number;
  23604. /**
  23605. * Universal-Joint type
  23606. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23607. */
  23608. static UniversalJoint: number;
  23609. /**
  23610. * Hinge-Joint 2 type
  23611. */
  23612. static Hinge2Joint: number;
  23613. /**
  23614. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23615. */
  23616. static PointToPointJoint: number;
  23617. /**
  23618. * Spring-Joint type
  23619. */
  23620. static SpringJoint: number;
  23621. /**
  23622. * Lock-Joint type
  23623. */
  23624. static LockJoint: number;
  23625. }
  23626. /**
  23627. * A class representing a physics distance joint
  23628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23629. */
  23630. export class DistanceJoint extends PhysicsJoint {
  23631. /**
  23632. *
  23633. * @param jointData The data for the Distance-Joint
  23634. */
  23635. constructor(jointData: DistanceJointData);
  23636. /**
  23637. * Update the predefined distance.
  23638. * @param maxDistance The maximum preferred distance
  23639. * @param minDistance The minimum preferred distance
  23640. */
  23641. updateDistance(maxDistance: number, minDistance?: number): void;
  23642. }
  23643. /**
  23644. * Represents a Motor-Enabled Joint
  23645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23646. */
  23647. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23648. /**
  23649. * Initializes the Motor-Enabled Joint
  23650. * @param type The type of the joint
  23651. * @param jointData The physica joint data for the joint
  23652. */
  23653. constructor(type: number, jointData: PhysicsJointData);
  23654. /**
  23655. * Set the motor values.
  23656. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23657. * @param force the force to apply
  23658. * @param maxForce max force for this motor.
  23659. */
  23660. setMotor(force?: number, maxForce?: number): void;
  23661. /**
  23662. * Set the motor's limits.
  23663. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23664. * @param upperLimit The upper limit of the motor
  23665. * @param lowerLimit The lower limit of the motor
  23666. */
  23667. setLimit(upperLimit: number, lowerLimit?: number): void;
  23668. }
  23669. /**
  23670. * This class represents a single physics Hinge-Joint
  23671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23672. */
  23673. export class HingeJoint extends MotorEnabledJoint {
  23674. /**
  23675. * Initializes the Hinge-Joint
  23676. * @param jointData The joint data for the Hinge-Joint
  23677. */
  23678. constructor(jointData: PhysicsJointData);
  23679. /**
  23680. * Set the motor values.
  23681. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23682. * @param {number} force the force to apply
  23683. * @param {number} maxForce max force for this motor.
  23684. */
  23685. setMotor(force?: number, maxForce?: number): void;
  23686. /**
  23687. * Set the motor's limits.
  23688. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23689. * @param upperLimit The upper limit of the motor
  23690. * @param lowerLimit The lower limit of the motor
  23691. */
  23692. setLimit(upperLimit: number, lowerLimit?: number): void;
  23693. }
  23694. /**
  23695. * This class represents a dual hinge physics joint (same as wheel joint)
  23696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23697. */
  23698. export class Hinge2Joint extends MotorEnabledJoint {
  23699. /**
  23700. * Initializes the Hinge2-Joint
  23701. * @param jointData The joint data for the Hinge2-Joint
  23702. */
  23703. constructor(jointData: PhysicsJointData);
  23704. /**
  23705. * Set the motor values.
  23706. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23707. * @param {number} targetSpeed the speed the motor is to reach
  23708. * @param {number} maxForce max force for this motor.
  23709. * @param {motorIndex} the motor's index, 0 or 1.
  23710. */
  23711. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23712. /**
  23713. * Set the motor limits.
  23714. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23715. * @param {number} upperLimit the upper limit
  23716. * @param {number} lowerLimit lower limit
  23717. * @param {motorIndex} the motor's index, 0 or 1.
  23718. */
  23719. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23720. }
  23721. /**
  23722. * Interface for a motor enabled joint
  23723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23724. */
  23725. export interface IMotorEnabledJoint {
  23726. /**
  23727. * Physics joint
  23728. */
  23729. physicsJoint: any;
  23730. /**
  23731. * Sets the motor of the motor-enabled joint
  23732. * @param force The force of the motor
  23733. * @param maxForce The maximum force of the motor
  23734. * @param motorIndex The index of the motor
  23735. */
  23736. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23737. /**
  23738. * Sets the limit of the motor
  23739. * @param upperLimit The upper limit of the motor
  23740. * @param lowerLimit The lower limit of the motor
  23741. * @param motorIndex The index of the motor
  23742. */
  23743. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23744. }
  23745. /**
  23746. * Joint data for a Distance-Joint
  23747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23748. */
  23749. export interface DistanceJointData extends PhysicsJointData {
  23750. /**
  23751. * Max distance the 2 joint objects can be apart
  23752. */
  23753. maxDistance: number;
  23754. }
  23755. /**
  23756. * Joint data from a spring joint
  23757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23758. */
  23759. export interface SpringJointData extends PhysicsJointData {
  23760. /**
  23761. * Length of the spring
  23762. */
  23763. length: number;
  23764. /**
  23765. * Stiffness of the spring
  23766. */
  23767. stiffness: number;
  23768. /**
  23769. * Damping of the spring
  23770. */
  23771. damping: number;
  23772. /** this callback will be called when applying the force to the impostors. */
  23773. forceApplicationCallback: () => void;
  23774. }
  23775. }
  23776. declare module "babylonjs/Physics/physicsRaycastResult" {
  23777. import { Vector3 } from "babylonjs/Maths/math.vector";
  23778. /**
  23779. * Holds the data for the raycast result
  23780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23781. */
  23782. export class PhysicsRaycastResult {
  23783. private _hasHit;
  23784. private _hitDistance;
  23785. private _hitNormalWorld;
  23786. private _hitPointWorld;
  23787. private _rayFromWorld;
  23788. private _rayToWorld;
  23789. /**
  23790. * Gets if there was a hit
  23791. */
  23792. get hasHit(): boolean;
  23793. /**
  23794. * Gets the distance from the hit
  23795. */
  23796. get hitDistance(): number;
  23797. /**
  23798. * Gets the hit normal/direction in the world
  23799. */
  23800. get hitNormalWorld(): Vector3;
  23801. /**
  23802. * Gets the hit point in the world
  23803. */
  23804. get hitPointWorld(): Vector3;
  23805. /**
  23806. * Gets the ray "start point" of the ray in the world
  23807. */
  23808. get rayFromWorld(): Vector3;
  23809. /**
  23810. * Gets the ray "end point" of the ray in the world
  23811. */
  23812. get rayToWorld(): Vector3;
  23813. /**
  23814. * Sets the hit data (normal & point in world space)
  23815. * @param hitNormalWorld defines the normal in world space
  23816. * @param hitPointWorld defines the point in world space
  23817. */
  23818. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23819. /**
  23820. * Sets the distance from the start point to the hit point
  23821. * @param distance
  23822. */
  23823. setHitDistance(distance: number): void;
  23824. /**
  23825. * Calculates the distance manually
  23826. */
  23827. calculateHitDistance(): void;
  23828. /**
  23829. * Resets all the values to default
  23830. * @param from The from point on world space
  23831. * @param to The to point on world space
  23832. */
  23833. reset(from?: Vector3, to?: Vector3): void;
  23834. }
  23835. /**
  23836. * Interface for the size containing width and height
  23837. */
  23838. interface IXYZ {
  23839. /**
  23840. * X
  23841. */
  23842. x: number;
  23843. /**
  23844. * Y
  23845. */
  23846. y: number;
  23847. /**
  23848. * Z
  23849. */
  23850. z: number;
  23851. }
  23852. }
  23853. declare module "babylonjs/Physics/IPhysicsEngine" {
  23854. import { Nullable } from "babylonjs/types";
  23855. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23857. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23858. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23859. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23860. /**
  23861. * Interface used to describe a physics joint
  23862. */
  23863. export interface PhysicsImpostorJoint {
  23864. /** Defines the main impostor to which the joint is linked */
  23865. mainImpostor: PhysicsImpostor;
  23866. /** Defines the impostor that is connected to the main impostor using this joint */
  23867. connectedImpostor: PhysicsImpostor;
  23868. /** Defines the joint itself */
  23869. joint: PhysicsJoint;
  23870. }
  23871. /** @hidden */
  23872. export interface IPhysicsEnginePlugin {
  23873. world: any;
  23874. name: string;
  23875. setGravity(gravity: Vector3): void;
  23876. setTimeStep(timeStep: number): void;
  23877. getTimeStep(): number;
  23878. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23879. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23880. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23881. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23882. removePhysicsBody(impostor: PhysicsImpostor): void;
  23883. generateJoint(joint: PhysicsImpostorJoint): void;
  23884. removeJoint(joint: PhysicsImpostorJoint): void;
  23885. isSupported(): boolean;
  23886. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23887. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23888. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23889. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23890. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23891. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23892. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23893. getBodyMass(impostor: PhysicsImpostor): number;
  23894. getBodyFriction(impostor: PhysicsImpostor): number;
  23895. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23896. getBodyRestitution(impostor: PhysicsImpostor): number;
  23897. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23898. getBodyPressure?(impostor: PhysicsImpostor): number;
  23899. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23900. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23901. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23902. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23903. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23904. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23905. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23906. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23907. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23908. sleepBody(impostor: PhysicsImpostor): void;
  23909. wakeUpBody(impostor: PhysicsImpostor): void;
  23910. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23911. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23912. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23913. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23914. getRadius(impostor: PhysicsImpostor): number;
  23915. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23916. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23917. dispose(): void;
  23918. }
  23919. /**
  23920. * Interface used to define a physics engine
  23921. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23922. */
  23923. export interface IPhysicsEngine {
  23924. /**
  23925. * Gets the gravity vector used by the simulation
  23926. */
  23927. gravity: Vector3;
  23928. /**
  23929. * Sets the gravity vector used by the simulation
  23930. * @param gravity defines the gravity vector to use
  23931. */
  23932. setGravity(gravity: Vector3): void;
  23933. /**
  23934. * Set the time step of the physics engine.
  23935. * Default is 1/60.
  23936. * To slow it down, enter 1/600 for example.
  23937. * To speed it up, 1/30
  23938. * @param newTimeStep the new timestep to apply to this world.
  23939. */
  23940. setTimeStep(newTimeStep: number): void;
  23941. /**
  23942. * Get the time step of the physics engine.
  23943. * @returns the current time step
  23944. */
  23945. getTimeStep(): number;
  23946. /**
  23947. * Set the sub time step of the physics engine.
  23948. * Default is 0 meaning there is no sub steps
  23949. * To increase physics resolution precision, set a small value (like 1 ms)
  23950. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23951. */
  23952. setSubTimeStep(subTimeStep: number): void;
  23953. /**
  23954. * Get the sub time step of the physics engine.
  23955. * @returns the current sub time step
  23956. */
  23957. getSubTimeStep(): number;
  23958. /**
  23959. * Release all resources
  23960. */
  23961. dispose(): void;
  23962. /**
  23963. * Gets the name of the current physics plugin
  23964. * @returns the name of the plugin
  23965. */
  23966. getPhysicsPluginName(): string;
  23967. /**
  23968. * Adding a new impostor for the impostor tracking.
  23969. * This will be done by the impostor itself.
  23970. * @param impostor the impostor to add
  23971. */
  23972. addImpostor(impostor: PhysicsImpostor): void;
  23973. /**
  23974. * Remove an impostor from the engine.
  23975. * This impostor and its mesh will not longer be updated by the physics engine.
  23976. * @param impostor the impostor to remove
  23977. */
  23978. removeImpostor(impostor: PhysicsImpostor): void;
  23979. /**
  23980. * Add a joint to the physics engine
  23981. * @param mainImpostor defines the main impostor to which the joint is added.
  23982. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23983. * @param joint defines the joint that will connect both impostors.
  23984. */
  23985. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23986. /**
  23987. * Removes a joint from the simulation
  23988. * @param mainImpostor defines the impostor used with the joint
  23989. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23990. * @param joint defines the joint to remove
  23991. */
  23992. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23993. /**
  23994. * Gets the current plugin used to run the simulation
  23995. * @returns current plugin
  23996. */
  23997. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23998. /**
  23999. * Gets the list of physic impostors
  24000. * @returns an array of PhysicsImpostor
  24001. */
  24002. getImpostors(): Array<PhysicsImpostor>;
  24003. /**
  24004. * Gets the impostor for a physics enabled object
  24005. * @param object defines the object impersonated by the impostor
  24006. * @returns the PhysicsImpostor or null if not found
  24007. */
  24008. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24009. /**
  24010. * Gets the impostor for a physics body object
  24011. * @param body defines physics body used by the impostor
  24012. * @returns the PhysicsImpostor or null if not found
  24013. */
  24014. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24015. /**
  24016. * Does a raycast in the physics world
  24017. * @param from when should the ray start?
  24018. * @param to when should the ray end?
  24019. * @returns PhysicsRaycastResult
  24020. */
  24021. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24022. /**
  24023. * Called by the scene. No need to call it.
  24024. * @param delta defines the timespam between frames
  24025. */
  24026. _step(delta: number): void;
  24027. }
  24028. }
  24029. declare module "babylonjs/Physics/physicsImpostor" {
  24030. import { Nullable, IndicesArray } from "babylonjs/types";
  24031. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24032. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24034. import { Scene } from "babylonjs/scene";
  24035. import { Bone } from "babylonjs/Bones/bone";
  24036. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24037. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24038. import { Space } from "babylonjs/Maths/math.axis";
  24039. /**
  24040. * The interface for the physics imposter parameters
  24041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24042. */
  24043. export interface PhysicsImpostorParameters {
  24044. /**
  24045. * The mass of the physics imposter
  24046. */
  24047. mass: number;
  24048. /**
  24049. * The friction of the physics imposter
  24050. */
  24051. friction?: number;
  24052. /**
  24053. * The coefficient of restitution of the physics imposter
  24054. */
  24055. restitution?: number;
  24056. /**
  24057. * The native options of the physics imposter
  24058. */
  24059. nativeOptions?: any;
  24060. /**
  24061. * Specifies if the parent should be ignored
  24062. */
  24063. ignoreParent?: boolean;
  24064. /**
  24065. * Specifies if bi-directional transformations should be disabled
  24066. */
  24067. disableBidirectionalTransformation?: boolean;
  24068. /**
  24069. * The pressure inside the physics imposter, soft object only
  24070. */
  24071. pressure?: number;
  24072. /**
  24073. * The stiffness the physics imposter, soft object only
  24074. */
  24075. stiffness?: number;
  24076. /**
  24077. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24078. */
  24079. velocityIterations?: number;
  24080. /**
  24081. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24082. */
  24083. positionIterations?: number;
  24084. /**
  24085. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24086. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24087. * Add to fix multiple points
  24088. */
  24089. fixedPoints?: number;
  24090. /**
  24091. * The collision margin around a soft object
  24092. */
  24093. margin?: number;
  24094. /**
  24095. * The collision margin around a soft object
  24096. */
  24097. damping?: number;
  24098. /**
  24099. * The path for a rope based on an extrusion
  24100. */
  24101. path?: any;
  24102. /**
  24103. * The shape of an extrusion used for a rope based on an extrusion
  24104. */
  24105. shape?: any;
  24106. }
  24107. /**
  24108. * Interface for a physics-enabled object
  24109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24110. */
  24111. export interface IPhysicsEnabledObject {
  24112. /**
  24113. * The position of the physics-enabled object
  24114. */
  24115. position: Vector3;
  24116. /**
  24117. * The rotation of the physics-enabled object
  24118. */
  24119. rotationQuaternion: Nullable<Quaternion>;
  24120. /**
  24121. * The scale of the physics-enabled object
  24122. */
  24123. scaling: Vector3;
  24124. /**
  24125. * The rotation of the physics-enabled object
  24126. */
  24127. rotation?: Vector3;
  24128. /**
  24129. * The parent of the physics-enabled object
  24130. */
  24131. parent?: any;
  24132. /**
  24133. * The bounding info of the physics-enabled object
  24134. * @returns The bounding info of the physics-enabled object
  24135. */
  24136. getBoundingInfo(): BoundingInfo;
  24137. /**
  24138. * Computes the world matrix
  24139. * @param force Specifies if the world matrix should be computed by force
  24140. * @returns A world matrix
  24141. */
  24142. computeWorldMatrix(force: boolean): Matrix;
  24143. /**
  24144. * Gets the world matrix
  24145. * @returns A world matrix
  24146. */
  24147. getWorldMatrix?(): Matrix;
  24148. /**
  24149. * Gets the child meshes
  24150. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24151. * @returns An array of abstract meshes
  24152. */
  24153. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24154. /**
  24155. * Gets the vertex data
  24156. * @param kind The type of vertex data
  24157. * @returns A nullable array of numbers, or a float32 array
  24158. */
  24159. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24160. /**
  24161. * Gets the indices from the mesh
  24162. * @returns A nullable array of index arrays
  24163. */
  24164. getIndices?(): Nullable<IndicesArray>;
  24165. /**
  24166. * Gets the scene from the mesh
  24167. * @returns the indices array or null
  24168. */
  24169. getScene?(): Scene;
  24170. /**
  24171. * Gets the absolute position from the mesh
  24172. * @returns the absolute position
  24173. */
  24174. getAbsolutePosition(): Vector3;
  24175. /**
  24176. * Gets the absolute pivot point from the mesh
  24177. * @returns the absolute pivot point
  24178. */
  24179. getAbsolutePivotPoint(): Vector3;
  24180. /**
  24181. * Rotates the mesh
  24182. * @param axis The axis of rotation
  24183. * @param amount The amount of rotation
  24184. * @param space The space of the rotation
  24185. * @returns The rotation transform node
  24186. */
  24187. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24188. /**
  24189. * Translates the mesh
  24190. * @param axis The axis of translation
  24191. * @param distance The distance of translation
  24192. * @param space The space of the translation
  24193. * @returns The transform node
  24194. */
  24195. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24196. /**
  24197. * Sets the absolute position of the mesh
  24198. * @param absolutePosition The absolute position of the mesh
  24199. * @returns The transform node
  24200. */
  24201. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24202. /**
  24203. * Gets the class name of the mesh
  24204. * @returns The class name
  24205. */
  24206. getClassName(): string;
  24207. }
  24208. /**
  24209. * Represents a physics imposter
  24210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24211. */
  24212. export class PhysicsImpostor {
  24213. /**
  24214. * The physics-enabled object used as the physics imposter
  24215. */
  24216. object: IPhysicsEnabledObject;
  24217. /**
  24218. * The type of the physics imposter
  24219. */
  24220. type: number;
  24221. private _options;
  24222. private _scene?;
  24223. /**
  24224. * The default object size of the imposter
  24225. */
  24226. static DEFAULT_OBJECT_SIZE: Vector3;
  24227. /**
  24228. * The identity quaternion of the imposter
  24229. */
  24230. static IDENTITY_QUATERNION: Quaternion;
  24231. /** @hidden */
  24232. _pluginData: any;
  24233. private _physicsEngine;
  24234. private _physicsBody;
  24235. private _bodyUpdateRequired;
  24236. private _onBeforePhysicsStepCallbacks;
  24237. private _onAfterPhysicsStepCallbacks;
  24238. /** @hidden */
  24239. _onPhysicsCollideCallbacks: Array<{
  24240. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24241. otherImpostors: Array<PhysicsImpostor>;
  24242. }>;
  24243. private _deltaPosition;
  24244. private _deltaRotation;
  24245. private _deltaRotationConjugated;
  24246. /** @hidden */
  24247. _isFromLine: boolean;
  24248. private _parent;
  24249. private _isDisposed;
  24250. private static _tmpVecs;
  24251. private static _tmpQuat;
  24252. /**
  24253. * Specifies if the physics imposter is disposed
  24254. */
  24255. get isDisposed(): boolean;
  24256. /**
  24257. * Gets the mass of the physics imposter
  24258. */
  24259. get mass(): number;
  24260. set mass(value: number);
  24261. /**
  24262. * Gets the coefficient of friction
  24263. */
  24264. get friction(): number;
  24265. /**
  24266. * Sets the coefficient of friction
  24267. */
  24268. set friction(value: number);
  24269. /**
  24270. * Gets the coefficient of restitution
  24271. */
  24272. get restitution(): number;
  24273. /**
  24274. * Sets the coefficient of restitution
  24275. */
  24276. set restitution(value: number);
  24277. /**
  24278. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24279. */
  24280. get pressure(): number;
  24281. /**
  24282. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24283. */
  24284. set pressure(value: number);
  24285. /**
  24286. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24287. */
  24288. get stiffness(): number;
  24289. /**
  24290. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24291. */
  24292. set stiffness(value: number);
  24293. /**
  24294. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24295. */
  24296. get velocityIterations(): number;
  24297. /**
  24298. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24299. */
  24300. set velocityIterations(value: number);
  24301. /**
  24302. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24303. */
  24304. get positionIterations(): number;
  24305. /**
  24306. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24307. */
  24308. set positionIterations(value: number);
  24309. /**
  24310. * The unique id of the physics imposter
  24311. * set by the physics engine when adding this impostor to the array
  24312. */
  24313. uniqueId: number;
  24314. /**
  24315. * @hidden
  24316. */
  24317. soft: boolean;
  24318. /**
  24319. * @hidden
  24320. */
  24321. segments: number;
  24322. private _joints;
  24323. /**
  24324. * Initializes the physics imposter
  24325. * @param object The physics-enabled object used as the physics imposter
  24326. * @param type The type of the physics imposter
  24327. * @param _options The options for the physics imposter
  24328. * @param _scene The Babylon scene
  24329. */
  24330. constructor(
  24331. /**
  24332. * The physics-enabled object used as the physics imposter
  24333. */
  24334. object: IPhysicsEnabledObject,
  24335. /**
  24336. * The type of the physics imposter
  24337. */
  24338. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24339. /**
  24340. * This function will completly initialize this impostor.
  24341. * It will create a new body - but only if this mesh has no parent.
  24342. * If it has, this impostor will not be used other than to define the impostor
  24343. * of the child mesh.
  24344. * @hidden
  24345. */
  24346. _init(): void;
  24347. private _getPhysicsParent;
  24348. /**
  24349. * Should a new body be generated.
  24350. * @returns boolean specifying if body initialization is required
  24351. */
  24352. isBodyInitRequired(): boolean;
  24353. /**
  24354. * Sets the updated scaling
  24355. * @param updated Specifies if the scaling is updated
  24356. */
  24357. setScalingUpdated(): void;
  24358. /**
  24359. * Force a regeneration of this or the parent's impostor's body.
  24360. * Use under cautious - This will remove all joints already implemented.
  24361. */
  24362. forceUpdate(): void;
  24363. /**
  24364. * Gets the body that holds this impostor. Either its own, or its parent.
  24365. */
  24366. get physicsBody(): any;
  24367. /**
  24368. * Get the parent of the physics imposter
  24369. * @returns Physics imposter or null
  24370. */
  24371. get parent(): Nullable<PhysicsImpostor>;
  24372. /**
  24373. * Sets the parent of the physics imposter
  24374. */
  24375. set parent(value: Nullable<PhysicsImpostor>);
  24376. /**
  24377. * Set the physics body. Used mainly by the physics engine/plugin
  24378. */
  24379. set physicsBody(physicsBody: any);
  24380. /**
  24381. * Resets the update flags
  24382. */
  24383. resetUpdateFlags(): void;
  24384. /**
  24385. * Gets the object extend size
  24386. * @returns the object extend size
  24387. */
  24388. getObjectExtendSize(): Vector3;
  24389. /**
  24390. * Gets the object center
  24391. * @returns The object center
  24392. */
  24393. getObjectCenter(): Vector3;
  24394. /**
  24395. * Get a specific parametes from the options parameter
  24396. * @param paramName The object parameter name
  24397. * @returns The object parameter
  24398. */
  24399. getParam(paramName: string): any;
  24400. /**
  24401. * Sets a specific parameter in the options given to the physics plugin
  24402. * @param paramName The parameter name
  24403. * @param value The value of the parameter
  24404. */
  24405. setParam(paramName: string, value: number): void;
  24406. /**
  24407. * Specifically change the body's mass option. Won't recreate the physics body object
  24408. * @param mass The mass of the physics imposter
  24409. */
  24410. setMass(mass: number): void;
  24411. /**
  24412. * Gets the linear velocity
  24413. * @returns linear velocity or null
  24414. */
  24415. getLinearVelocity(): Nullable<Vector3>;
  24416. /**
  24417. * Sets the linear velocity
  24418. * @param velocity linear velocity or null
  24419. */
  24420. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24421. /**
  24422. * Gets the angular velocity
  24423. * @returns angular velocity or null
  24424. */
  24425. getAngularVelocity(): Nullable<Vector3>;
  24426. /**
  24427. * Sets the angular velocity
  24428. * @param velocity The velocity or null
  24429. */
  24430. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24431. /**
  24432. * Execute a function with the physics plugin native code
  24433. * Provide a function the will have two variables - the world object and the physics body object
  24434. * @param func The function to execute with the physics plugin native code
  24435. */
  24436. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24437. /**
  24438. * Register a function that will be executed before the physics world is stepping forward
  24439. * @param func The function to execute before the physics world is stepped forward
  24440. */
  24441. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24442. /**
  24443. * Unregister a function that will be executed before the physics world is stepping forward
  24444. * @param func The function to execute before the physics world is stepped forward
  24445. */
  24446. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24447. /**
  24448. * Register a function that will be executed after the physics step
  24449. * @param func The function to execute after physics step
  24450. */
  24451. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24452. /**
  24453. * Unregisters a function that will be executed after the physics step
  24454. * @param func The function to execute after physics step
  24455. */
  24456. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24457. /**
  24458. * register a function that will be executed when this impostor collides against a different body
  24459. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24460. * @param func Callback that is executed on collision
  24461. */
  24462. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24463. /**
  24464. * Unregisters the physics imposter on contact
  24465. * @param collideAgainst The physics object to collide against
  24466. * @param func Callback to execute on collision
  24467. */
  24468. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24469. private _tmpQuat;
  24470. private _tmpQuat2;
  24471. /**
  24472. * Get the parent rotation
  24473. * @returns The parent rotation
  24474. */
  24475. getParentsRotation(): Quaternion;
  24476. /**
  24477. * this function is executed by the physics engine.
  24478. */
  24479. beforeStep: () => void;
  24480. /**
  24481. * this function is executed by the physics engine
  24482. */
  24483. afterStep: () => void;
  24484. /**
  24485. * Legacy collision detection event support
  24486. */
  24487. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24488. /**
  24489. * event and body object due to cannon's event-based architecture.
  24490. */
  24491. onCollide: (e: {
  24492. body: any;
  24493. }) => void;
  24494. /**
  24495. * Apply a force
  24496. * @param force The force to apply
  24497. * @param contactPoint The contact point for the force
  24498. * @returns The physics imposter
  24499. */
  24500. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24501. /**
  24502. * Apply an impulse
  24503. * @param force The impulse force
  24504. * @param contactPoint The contact point for the impulse force
  24505. * @returns The physics imposter
  24506. */
  24507. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24508. /**
  24509. * A help function to create a joint
  24510. * @param otherImpostor A physics imposter used to create a joint
  24511. * @param jointType The type of joint
  24512. * @param jointData The data for the joint
  24513. * @returns The physics imposter
  24514. */
  24515. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24516. /**
  24517. * Add a joint to this impostor with a different impostor
  24518. * @param otherImpostor A physics imposter used to add a joint
  24519. * @param joint The joint to add
  24520. * @returns The physics imposter
  24521. */
  24522. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24523. /**
  24524. * Add an anchor to a cloth impostor
  24525. * @param otherImpostor rigid impostor to anchor to
  24526. * @param width ratio across width from 0 to 1
  24527. * @param height ratio up height from 0 to 1
  24528. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24529. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24530. * @returns impostor the soft imposter
  24531. */
  24532. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24533. /**
  24534. * Add a hook to a rope impostor
  24535. * @param otherImpostor rigid impostor to anchor to
  24536. * @param length ratio across rope from 0 to 1
  24537. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24538. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24539. * @returns impostor the rope imposter
  24540. */
  24541. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24542. /**
  24543. * Will keep this body still, in a sleep mode.
  24544. * @returns the physics imposter
  24545. */
  24546. sleep(): PhysicsImpostor;
  24547. /**
  24548. * Wake the body up.
  24549. * @returns The physics imposter
  24550. */
  24551. wakeUp(): PhysicsImpostor;
  24552. /**
  24553. * Clones the physics imposter
  24554. * @param newObject The physics imposter clones to this physics-enabled object
  24555. * @returns A nullable physics imposter
  24556. */
  24557. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24558. /**
  24559. * Disposes the physics imposter
  24560. */
  24561. dispose(): void;
  24562. /**
  24563. * Sets the delta position
  24564. * @param position The delta position amount
  24565. */
  24566. setDeltaPosition(position: Vector3): void;
  24567. /**
  24568. * Sets the delta rotation
  24569. * @param rotation The delta rotation amount
  24570. */
  24571. setDeltaRotation(rotation: Quaternion): void;
  24572. /**
  24573. * Gets the box size of the physics imposter and stores the result in the input parameter
  24574. * @param result Stores the box size
  24575. * @returns The physics imposter
  24576. */
  24577. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24578. /**
  24579. * Gets the radius of the physics imposter
  24580. * @returns Radius of the physics imposter
  24581. */
  24582. getRadius(): number;
  24583. /**
  24584. * Sync a bone with this impostor
  24585. * @param bone The bone to sync to the impostor.
  24586. * @param boneMesh The mesh that the bone is influencing.
  24587. * @param jointPivot The pivot of the joint / bone in local space.
  24588. * @param distToJoint Optional distance from the impostor to the joint.
  24589. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24590. */
  24591. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24592. /**
  24593. * Sync impostor to a bone
  24594. * @param bone The bone that the impostor will be synced to.
  24595. * @param boneMesh The mesh that the bone is influencing.
  24596. * @param jointPivot The pivot of the joint / bone in local space.
  24597. * @param distToJoint Optional distance from the impostor to the joint.
  24598. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24599. * @param boneAxis Optional vector3 axis the bone is aligned with
  24600. */
  24601. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24602. /**
  24603. * No-Imposter type
  24604. */
  24605. static NoImpostor: number;
  24606. /**
  24607. * Sphere-Imposter type
  24608. */
  24609. static SphereImpostor: number;
  24610. /**
  24611. * Box-Imposter type
  24612. */
  24613. static BoxImpostor: number;
  24614. /**
  24615. * Plane-Imposter type
  24616. */
  24617. static PlaneImpostor: number;
  24618. /**
  24619. * Mesh-imposter type
  24620. */
  24621. static MeshImpostor: number;
  24622. /**
  24623. * Capsule-Impostor type (Ammo.js plugin only)
  24624. */
  24625. static CapsuleImpostor: number;
  24626. /**
  24627. * Cylinder-Imposter type
  24628. */
  24629. static CylinderImpostor: number;
  24630. /**
  24631. * Particle-Imposter type
  24632. */
  24633. static ParticleImpostor: number;
  24634. /**
  24635. * Heightmap-Imposter type
  24636. */
  24637. static HeightmapImpostor: number;
  24638. /**
  24639. * ConvexHull-Impostor type (Ammo.js plugin only)
  24640. */
  24641. static ConvexHullImpostor: number;
  24642. /**
  24643. * Custom-Imposter type (Ammo.js plugin only)
  24644. */
  24645. static CustomImpostor: number;
  24646. /**
  24647. * Rope-Imposter type
  24648. */
  24649. static RopeImpostor: number;
  24650. /**
  24651. * Cloth-Imposter type
  24652. */
  24653. static ClothImpostor: number;
  24654. /**
  24655. * Softbody-Imposter type
  24656. */
  24657. static SoftbodyImpostor: number;
  24658. }
  24659. }
  24660. declare module "babylonjs/Meshes/mesh" {
  24661. import { Observable } from "babylonjs/Misc/observable";
  24662. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24663. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24664. import { Camera } from "babylonjs/Cameras/camera";
  24665. import { Scene } from "babylonjs/scene";
  24666. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24667. import { Color4 } from "babylonjs/Maths/math.color";
  24668. import { Engine } from "babylonjs/Engines/engine";
  24669. import { Node } from "babylonjs/node";
  24670. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24671. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24672. import { Buffer } from "babylonjs/Meshes/buffer";
  24673. import { Geometry } from "babylonjs/Meshes/geometry";
  24674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24675. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24676. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24677. import { Effect } from "babylonjs/Materials/effect";
  24678. import { Material } from "babylonjs/Materials/material";
  24679. import { Skeleton } from "babylonjs/Bones/skeleton";
  24680. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24681. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24682. import { Path3D } from "babylonjs/Maths/math.path";
  24683. import { Plane } from "babylonjs/Maths/math.plane";
  24684. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24685. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24686. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24687. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24688. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24689. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24690. /**
  24691. * @hidden
  24692. **/
  24693. export class _CreationDataStorage {
  24694. closePath?: boolean;
  24695. closeArray?: boolean;
  24696. idx: number[];
  24697. dashSize: number;
  24698. gapSize: number;
  24699. path3D: Path3D;
  24700. pathArray: Vector3[][];
  24701. arc: number;
  24702. radius: number;
  24703. cap: number;
  24704. tessellation: number;
  24705. }
  24706. /**
  24707. * @hidden
  24708. **/
  24709. class _InstanceDataStorage {
  24710. visibleInstances: any;
  24711. batchCache: _InstancesBatch;
  24712. instancesBufferSize: number;
  24713. instancesBuffer: Nullable<Buffer>;
  24714. instancesData: Float32Array;
  24715. overridenInstanceCount: number;
  24716. isFrozen: boolean;
  24717. previousBatch: Nullable<_InstancesBatch>;
  24718. hardwareInstancedRendering: boolean;
  24719. sideOrientation: number;
  24720. manualUpdate: boolean;
  24721. }
  24722. /**
  24723. * @hidden
  24724. **/
  24725. export class _InstancesBatch {
  24726. mustReturn: boolean;
  24727. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24728. renderSelf: boolean[];
  24729. hardwareInstancedRendering: boolean[];
  24730. }
  24731. /**
  24732. * Class used to represent renderable models
  24733. */
  24734. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24735. /**
  24736. * Mesh side orientation : usually the external or front surface
  24737. */
  24738. static readonly FRONTSIDE: number;
  24739. /**
  24740. * Mesh side orientation : usually the internal or back surface
  24741. */
  24742. static readonly BACKSIDE: number;
  24743. /**
  24744. * Mesh side orientation : both internal and external or front and back surfaces
  24745. */
  24746. static readonly DOUBLESIDE: number;
  24747. /**
  24748. * Mesh side orientation : by default, `FRONTSIDE`
  24749. */
  24750. static readonly DEFAULTSIDE: number;
  24751. /**
  24752. * Mesh cap setting : no cap
  24753. */
  24754. static readonly NO_CAP: number;
  24755. /**
  24756. * Mesh cap setting : one cap at the beginning of the mesh
  24757. */
  24758. static readonly CAP_START: number;
  24759. /**
  24760. * Mesh cap setting : one cap at the end of the mesh
  24761. */
  24762. static readonly CAP_END: number;
  24763. /**
  24764. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24765. */
  24766. static readonly CAP_ALL: number;
  24767. /**
  24768. * Mesh pattern setting : no flip or rotate
  24769. */
  24770. static readonly NO_FLIP: number;
  24771. /**
  24772. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24773. */
  24774. static readonly FLIP_TILE: number;
  24775. /**
  24776. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24777. */
  24778. static readonly ROTATE_TILE: number;
  24779. /**
  24780. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24781. */
  24782. static readonly FLIP_ROW: number;
  24783. /**
  24784. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24785. */
  24786. static readonly ROTATE_ROW: number;
  24787. /**
  24788. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24789. */
  24790. static readonly FLIP_N_ROTATE_TILE: number;
  24791. /**
  24792. * Mesh pattern setting : rotate pattern and rotate
  24793. */
  24794. static readonly FLIP_N_ROTATE_ROW: number;
  24795. /**
  24796. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24797. */
  24798. static readonly CENTER: number;
  24799. /**
  24800. * Mesh tile positioning : part tiles on left
  24801. */
  24802. static readonly LEFT: number;
  24803. /**
  24804. * Mesh tile positioning : part tiles on right
  24805. */
  24806. static readonly RIGHT: number;
  24807. /**
  24808. * Mesh tile positioning : part tiles on top
  24809. */
  24810. static readonly TOP: number;
  24811. /**
  24812. * Mesh tile positioning : part tiles on bottom
  24813. */
  24814. static readonly BOTTOM: number;
  24815. /**
  24816. * Gets the default side orientation.
  24817. * @param orientation the orientation to value to attempt to get
  24818. * @returns the default orientation
  24819. * @hidden
  24820. */
  24821. static _GetDefaultSideOrientation(orientation?: number): number;
  24822. private _internalMeshDataInfo;
  24823. /**
  24824. * An event triggered before rendering the mesh
  24825. */
  24826. get onBeforeRenderObservable(): Observable<Mesh>;
  24827. /**
  24828. * An event triggered before binding the mesh
  24829. */
  24830. get onBeforeBindObservable(): Observable<Mesh>;
  24831. /**
  24832. * An event triggered after rendering the mesh
  24833. */
  24834. get onAfterRenderObservable(): Observable<Mesh>;
  24835. /**
  24836. * An event triggered before drawing the mesh
  24837. */
  24838. get onBeforeDrawObservable(): Observable<Mesh>;
  24839. private _onBeforeDrawObserver;
  24840. /**
  24841. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24842. */
  24843. set onBeforeDraw(callback: () => void);
  24844. get hasInstances(): boolean;
  24845. /**
  24846. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24847. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24848. */
  24849. delayLoadState: number;
  24850. /**
  24851. * Gets the list of instances created from this mesh
  24852. * it is not supposed to be modified manually.
  24853. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24854. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24855. */
  24856. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24857. /**
  24858. * Gets the file containing delay loading data for this mesh
  24859. */
  24860. delayLoadingFile: string;
  24861. /** @hidden */
  24862. _binaryInfo: any;
  24863. /**
  24864. * User defined function used to change how LOD level selection is done
  24865. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24866. */
  24867. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24868. /**
  24869. * Gets or sets the morph target manager
  24870. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24871. */
  24872. get morphTargetManager(): Nullable<MorphTargetManager>;
  24873. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24874. /** @hidden */
  24875. _creationDataStorage: Nullable<_CreationDataStorage>;
  24876. /** @hidden */
  24877. _geometry: Nullable<Geometry>;
  24878. /** @hidden */
  24879. _delayInfo: Array<string>;
  24880. /** @hidden */
  24881. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24882. /** @hidden */
  24883. _instanceDataStorage: _InstanceDataStorage;
  24884. private _effectiveMaterial;
  24885. /** @hidden */
  24886. _shouldGenerateFlatShading: boolean;
  24887. /** @hidden */
  24888. _originalBuilderSideOrientation: number;
  24889. /**
  24890. * Use this property to change the original side orientation defined at construction time
  24891. */
  24892. overrideMaterialSideOrientation: Nullable<number>;
  24893. /**
  24894. * Gets the source mesh (the one used to clone this one from)
  24895. */
  24896. get source(): Nullable<Mesh>;
  24897. /**
  24898. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24899. */
  24900. get isUnIndexed(): boolean;
  24901. set isUnIndexed(value: boolean);
  24902. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24903. get worldMatrixInstancedBuffer(): Float32Array;
  24904. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24905. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24906. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24907. /**
  24908. * @constructor
  24909. * @param name The value used by scene.getMeshByName() to do a lookup.
  24910. * @param scene The scene to add this mesh to.
  24911. * @param parent The parent of this mesh, if it has one
  24912. * @param source An optional Mesh from which geometry is shared, cloned.
  24913. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24914. * When false, achieved by calling a clone(), also passing False.
  24915. * This will make creation of children, recursive.
  24916. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24917. */
  24918. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24919. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24920. doNotInstantiate: boolean;
  24921. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24922. /**
  24923. * Gets the class name
  24924. * @returns the string "Mesh".
  24925. */
  24926. getClassName(): string;
  24927. /** @hidden */
  24928. get _isMesh(): boolean;
  24929. /**
  24930. * Returns a description of this mesh
  24931. * @param fullDetails define if full details about this mesh must be used
  24932. * @returns a descriptive string representing this mesh
  24933. */
  24934. toString(fullDetails?: boolean): string;
  24935. /** @hidden */
  24936. _unBindEffect(): void;
  24937. /**
  24938. * Gets a boolean indicating if this mesh has LOD
  24939. */
  24940. get hasLODLevels(): boolean;
  24941. /**
  24942. * Gets the list of MeshLODLevel associated with the current mesh
  24943. * @returns an array of MeshLODLevel
  24944. */
  24945. getLODLevels(): MeshLODLevel[];
  24946. private _sortLODLevels;
  24947. /**
  24948. * Add a mesh as LOD level triggered at the given distance.
  24949. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24950. * @param distance The distance from the center of the object to show this level
  24951. * @param mesh The mesh to be added as LOD level (can be null)
  24952. * @return This mesh (for chaining)
  24953. */
  24954. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24955. /**
  24956. * Returns the LOD level mesh at the passed distance or null if not found.
  24957. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24958. * @param distance The distance from the center of the object to show this level
  24959. * @returns a Mesh or `null`
  24960. */
  24961. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24962. /**
  24963. * Remove a mesh from the LOD array
  24964. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24965. * @param mesh defines the mesh to be removed
  24966. * @return This mesh (for chaining)
  24967. */
  24968. removeLODLevel(mesh: Mesh): Mesh;
  24969. /**
  24970. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24971. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24972. * @param camera defines the camera to use to compute distance
  24973. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24974. * @return This mesh (for chaining)
  24975. */
  24976. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24977. /**
  24978. * Gets the mesh internal Geometry object
  24979. */
  24980. get geometry(): Nullable<Geometry>;
  24981. /**
  24982. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24983. * @returns the total number of vertices
  24984. */
  24985. getTotalVertices(): number;
  24986. /**
  24987. * Returns the content of an associated vertex buffer
  24988. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24989. * - VertexBuffer.PositionKind
  24990. * - VertexBuffer.UVKind
  24991. * - VertexBuffer.UV2Kind
  24992. * - VertexBuffer.UV3Kind
  24993. * - VertexBuffer.UV4Kind
  24994. * - VertexBuffer.UV5Kind
  24995. * - VertexBuffer.UV6Kind
  24996. * - VertexBuffer.ColorKind
  24997. * - VertexBuffer.MatricesIndicesKind
  24998. * - VertexBuffer.MatricesIndicesExtraKind
  24999. * - VertexBuffer.MatricesWeightsKind
  25000. * - VertexBuffer.MatricesWeightsExtraKind
  25001. * @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
  25002. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25003. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25004. */
  25005. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25006. /**
  25007. * Returns the mesh VertexBuffer object from the requested `kind`
  25008. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25009. * - VertexBuffer.PositionKind
  25010. * - VertexBuffer.NormalKind
  25011. * - VertexBuffer.UVKind
  25012. * - VertexBuffer.UV2Kind
  25013. * - VertexBuffer.UV3Kind
  25014. * - VertexBuffer.UV4Kind
  25015. * - VertexBuffer.UV5Kind
  25016. * - VertexBuffer.UV6Kind
  25017. * - VertexBuffer.ColorKind
  25018. * - VertexBuffer.MatricesIndicesKind
  25019. * - VertexBuffer.MatricesIndicesExtraKind
  25020. * - VertexBuffer.MatricesWeightsKind
  25021. * - VertexBuffer.MatricesWeightsExtraKind
  25022. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25023. */
  25024. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25025. /**
  25026. * Tests if a specific vertex buffer is associated with this mesh
  25027. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25028. * - VertexBuffer.PositionKind
  25029. * - VertexBuffer.NormalKind
  25030. * - VertexBuffer.UVKind
  25031. * - VertexBuffer.UV2Kind
  25032. * - VertexBuffer.UV3Kind
  25033. * - VertexBuffer.UV4Kind
  25034. * - VertexBuffer.UV5Kind
  25035. * - VertexBuffer.UV6Kind
  25036. * - VertexBuffer.ColorKind
  25037. * - VertexBuffer.MatricesIndicesKind
  25038. * - VertexBuffer.MatricesIndicesExtraKind
  25039. * - VertexBuffer.MatricesWeightsKind
  25040. * - VertexBuffer.MatricesWeightsExtraKind
  25041. * @returns a boolean
  25042. */
  25043. isVerticesDataPresent(kind: string): boolean;
  25044. /**
  25045. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25046. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25047. * - VertexBuffer.PositionKind
  25048. * - VertexBuffer.UVKind
  25049. * - VertexBuffer.UV2Kind
  25050. * - VertexBuffer.UV3Kind
  25051. * - VertexBuffer.UV4Kind
  25052. * - VertexBuffer.UV5Kind
  25053. * - VertexBuffer.UV6Kind
  25054. * - VertexBuffer.ColorKind
  25055. * - VertexBuffer.MatricesIndicesKind
  25056. * - VertexBuffer.MatricesIndicesExtraKind
  25057. * - VertexBuffer.MatricesWeightsKind
  25058. * - VertexBuffer.MatricesWeightsExtraKind
  25059. * @returns a boolean
  25060. */
  25061. isVertexBufferUpdatable(kind: string): boolean;
  25062. /**
  25063. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25064. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25065. * - VertexBuffer.PositionKind
  25066. * - VertexBuffer.NormalKind
  25067. * - VertexBuffer.UVKind
  25068. * - VertexBuffer.UV2Kind
  25069. * - VertexBuffer.UV3Kind
  25070. * - VertexBuffer.UV4Kind
  25071. * - VertexBuffer.UV5Kind
  25072. * - VertexBuffer.UV6Kind
  25073. * - VertexBuffer.ColorKind
  25074. * - VertexBuffer.MatricesIndicesKind
  25075. * - VertexBuffer.MatricesIndicesExtraKind
  25076. * - VertexBuffer.MatricesWeightsKind
  25077. * - VertexBuffer.MatricesWeightsExtraKind
  25078. * @returns an array of strings
  25079. */
  25080. getVerticesDataKinds(): string[];
  25081. /**
  25082. * Returns a positive integer : the total number of indices in this mesh geometry.
  25083. * @returns the numner of indices or zero if the mesh has no geometry.
  25084. */
  25085. getTotalIndices(): number;
  25086. /**
  25087. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25088. * @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.
  25089. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25090. * @returns the indices array or an empty array if the mesh has no geometry
  25091. */
  25092. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25093. get isBlocked(): boolean;
  25094. /**
  25095. * Determine if the current mesh is ready to be rendered
  25096. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25097. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25098. * @returns true if all associated assets are ready (material, textures, shaders)
  25099. */
  25100. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25101. /**
  25102. * 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.
  25103. */
  25104. get areNormalsFrozen(): boolean;
  25105. /**
  25106. * 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.
  25107. * @returns the current mesh
  25108. */
  25109. freezeNormals(): Mesh;
  25110. /**
  25111. * 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
  25112. * @returns the current mesh
  25113. */
  25114. unfreezeNormals(): Mesh;
  25115. /**
  25116. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25117. */
  25118. set overridenInstanceCount(count: number);
  25119. /** @hidden */
  25120. _preActivate(): Mesh;
  25121. /** @hidden */
  25122. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25123. /** @hidden */
  25124. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25125. /**
  25126. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25127. * This means the mesh underlying bounding box and sphere are recomputed.
  25128. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25129. * @returns the current mesh
  25130. */
  25131. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25132. /** @hidden */
  25133. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25134. /**
  25135. * This function will subdivide the mesh into multiple submeshes
  25136. * @param count defines the expected number of submeshes
  25137. */
  25138. subdivide(count: number): void;
  25139. /**
  25140. * Copy a FloatArray into a specific associated vertex buffer
  25141. * @param kind defines which buffer to write to (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. * @param data defines the data source
  25155. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25156. * @param stride defines the data stride size (can be null)
  25157. * @returns the current mesh
  25158. */
  25159. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25160. /**
  25161. * Delete a vertex buffer associated with this mesh
  25162. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25163. * - VertexBuffer.PositionKind
  25164. * - VertexBuffer.UVKind
  25165. * - VertexBuffer.UV2Kind
  25166. * - VertexBuffer.UV3Kind
  25167. * - VertexBuffer.UV4Kind
  25168. * - VertexBuffer.UV5Kind
  25169. * - VertexBuffer.UV6Kind
  25170. * - VertexBuffer.ColorKind
  25171. * - VertexBuffer.MatricesIndicesKind
  25172. * - VertexBuffer.MatricesIndicesExtraKind
  25173. * - VertexBuffer.MatricesWeightsKind
  25174. * - VertexBuffer.MatricesWeightsExtraKind
  25175. */
  25176. removeVerticesData(kind: string): void;
  25177. /**
  25178. * Flags an associated vertex buffer as updatable
  25179. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25180. * - VertexBuffer.PositionKind
  25181. * - VertexBuffer.UVKind
  25182. * - VertexBuffer.UV2Kind
  25183. * - VertexBuffer.UV3Kind
  25184. * - VertexBuffer.UV4Kind
  25185. * - VertexBuffer.UV5Kind
  25186. * - VertexBuffer.UV6Kind
  25187. * - VertexBuffer.ColorKind
  25188. * - VertexBuffer.MatricesIndicesKind
  25189. * - VertexBuffer.MatricesIndicesExtraKind
  25190. * - VertexBuffer.MatricesWeightsKind
  25191. * - VertexBuffer.MatricesWeightsExtraKind
  25192. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25193. */
  25194. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25195. /**
  25196. * Sets the mesh global Vertex Buffer
  25197. * @param buffer defines the buffer to use
  25198. * @returns the current mesh
  25199. */
  25200. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25201. /**
  25202. * Update a specific associated vertex buffer
  25203. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25204. * - VertexBuffer.PositionKind
  25205. * - VertexBuffer.UVKind
  25206. * - VertexBuffer.UV2Kind
  25207. * - VertexBuffer.UV3Kind
  25208. * - VertexBuffer.UV4Kind
  25209. * - VertexBuffer.UV5Kind
  25210. * - VertexBuffer.UV6Kind
  25211. * - VertexBuffer.ColorKind
  25212. * - VertexBuffer.MatricesIndicesKind
  25213. * - VertexBuffer.MatricesIndicesExtraKind
  25214. * - VertexBuffer.MatricesWeightsKind
  25215. * - VertexBuffer.MatricesWeightsExtraKind
  25216. * @param data defines the data source
  25217. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25218. * @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)
  25219. * @returns the current mesh
  25220. */
  25221. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25222. /**
  25223. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25224. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25225. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25226. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25227. * @returns the current mesh
  25228. */
  25229. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25230. /**
  25231. * Creates a un-shared specific occurence of the geometry for the mesh.
  25232. * @returns the current mesh
  25233. */
  25234. makeGeometryUnique(): Mesh;
  25235. /**
  25236. * Set the index buffer of this mesh
  25237. * @param indices defines the source data
  25238. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25239. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25240. * @returns the current mesh
  25241. */
  25242. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25243. /**
  25244. * Update the current index buffer
  25245. * @param indices defines the source data
  25246. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25247. * @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)
  25248. * @returns the current mesh
  25249. */
  25250. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25251. /**
  25252. * Invert the geometry to move from a right handed system to a left handed one.
  25253. * @returns the current mesh
  25254. */
  25255. toLeftHanded(): Mesh;
  25256. /** @hidden */
  25257. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25258. /** @hidden */
  25259. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25260. /**
  25261. * Registers for this mesh a javascript function called just before the rendering process
  25262. * @param func defines the function to call before rendering this mesh
  25263. * @returns the current mesh
  25264. */
  25265. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25266. /**
  25267. * Disposes a previously registered javascript function called before the rendering
  25268. * @param func defines the function to remove
  25269. * @returns the current mesh
  25270. */
  25271. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25272. /**
  25273. * Registers for this mesh a javascript function called just after the rendering is complete
  25274. * @param func defines the function to call after rendering this mesh
  25275. * @returns the current mesh
  25276. */
  25277. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25278. /**
  25279. * Disposes a previously registered javascript function called after the rendering.
  25280. * @param func defines the function to remove
  25281. * @returns the current mesh
  25282. */
  25283. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25284. /** @hidden */
  25285. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25286. /** @hidden */
  25287. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25288. /** @hidden */
  25289. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25290. /** @hidden */
  25291. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25292. /** @hidden */
  25293. _rebuild(): void;
  25294. /** @hidden */
  25295. _freeze(): void;
  25296. /** @hidden */
  25297. _unFreeze(): void;
  25298. /**
  25299. * 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
  25300. * @param subMesh defines the subMesh to render
  25301. * @param enableAlphaMode defines if alpha mode can be changed
  25302. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25303. * @returns the current mesh
  25304. */
  25305. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25306. private _onBeforeDraw;
  25307. /**
  25308. * Renormalize the mesh and patch it up if there are no weights
  25309. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25310. * However in the case of zero weights then we set just a single influence to 1.
  25311. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25312. */
  25313. cleanMatrixWeights(): void;
  25314. private normalizeSkinFourWeights;
  25315. private normalizeSkinWeightsAndExtra;
  25316. /**
  25317. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25318. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25319. * the user know there was an issue with importing the mesh
  25320. * @returns a validation object with skinned, valid and report string
  25321. */
  25322. validateSkinning(): {
  25323. skinned: boolean;
  25324. valid: boolean;
  25325. report: string;
  25326. };
  25327. /** @hidden */
  25328. _checkDelayState(): Mesh;
  25329. private _queueLoad;
  25330. /**
  25331. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25332. * A mesh is in the frustum if its bounding box intersects the frustum
  25333. * @param frustumPlanes defines the frustum to test
  25334. * @returns true if the mesh is in the frustum planes
  25335. */
  25336. isInFrustum(frustumPlanes: Plane[]): boolean;
  25337. /**
  25338. * Sets the mesh material by the material or multiMaterial `id` property
  25339. * @param id is a string identifying the material or the multiMaterial
  25340. * @returns the current mesh
  25341. */
  25342. setMaterialByID(id: string): Mesh;
  25343. /**
  25344. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25345. * @returns an array of IAnimatable
  25346. */
  25347. getAnimatables(): IAnimatable[];
  25348. /**
  25349. * Modifies the mesh geometry according to the passed transformation matrix.
  25350. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25351. * The mesh normals are modified using the same transformation.
  25352. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25353. * @param transform defines the transform matrix to use
  25354. * @see http://doc.babylonjs.com/resources/baking_transformations
  25355. * @returns the current mesh
  25356. */
  25357. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25358. /**
  25359. * Modifies the mesh geometry according to its own current World Matrix.
  25360. * The mesh World Matrix is then reset.
  25361. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25362. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25363. * @see http://doc.babylonjs.com/resources/baking_transformations
  25364. * @returns the current mesh
  25365. */
  25366. bakeCurrentTransformIntoVertices(): Mesh;
  25367. /** @hidden */
  25368. get _positions(): Nullable<Vector3[]>;
  25369. /** @hidden */
  25370. _resetPointsArrayCache(): Mesh;
  25371. /** @hidden */
  25372. _generatePointsArray(): boolean;
  25373. /**
  25374. * Returns a new Mesh object generated from the current mesh properties.
  25375. * This method must not get confused with createInstance()
  25376. * @param name is a string, the name given to the new mesh
  25377. * @param newParent can be any Node object (default `null`)
  25378. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25379. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25380. * @returns a new mesh
  25381. */
  25382. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25383. /**
  25384. * Releases resources associated with this mesh.
  25385. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25386. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25387. */
  25388. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25389. /** @hidden */
  25390. _disposeInstanceSpecificData(): void;
  25391. /**
  25392. * Modifies the mesh geometry according to a displacement map.
  25393. * 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.
  25394. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25395. * @param url is a string, the URL from the image file is to be downloaded.
  25396. * @param minHeight is the lower limit of the displacement.
  25397. * @param maxHeight is the upper limit of the displacement.
  25398. * @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.
  25399. * @param uvOffset is an optional vector2 used to offset UV.
  25400. * @param uvScale is an optional vector2 used to scale UV.
  25401. * @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.
  25402. * @returns the Mesh.
  25403. */
  25404. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25405. /**
  25406. * Modifies the mesh geometry according to a displacementMap buffer.
  25407. * 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.
  25408. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25409. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25410. * @param heightMapWidth is the width of the buffer image.
  25411. * @param heightMapHeight is the height of the buffer image.
  25412. * @param minHeight is the lower limit of the displacement.
  25413. * @param maxHeight is the upper limit of the displacement.
  25414. * @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.
  25415. * @param uvOffset is an optional vector2 used to offset UV.
  25416. * @param uvScale is an optional vector2 used to scale UV.
  25417. * @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.
  25418. * @returns the Mesh.
  25419. */
  25420. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25421. /**
  25422. * Modify the mesh to get a flat shading rendering.
  25423. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25424. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25425. * @returns current mesh
  25426. */
  25427. convertToFlatShadedMesh(): Mesh;
  25428. /**
  25429. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25430. * In other words, more vertices, no more indices and a single bigger VBO.
  25431. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25432. * @returns current mesh
  25433. */
  25434. convertToUnIndexedMesh(): Mesh;
  25435. /**
  25436. * Inverses facet orientations.
  25437. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25438. * @param flipNormals will also inverts the normals
  25439. * @returns current mesh
  25440. */
  25441. flipFaces(flipNormals?: boolean): Mesh;
  25442. /**
  25443. * Increase the number of facets and hence vertices in a mesh
  25444. * Vertex normals are interpolated from existing vertex normals
  25445. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25446. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25447. */
  25448. increaseVertices(numberPerEdge: number): void;
  25449. /**
  25450. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25451. * This will undo any application of covertToFlatShadedMesh
  25452. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25453. */
  25454. forceSharedVertices(): void;
  25455. /** @hidden */
  25456. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25457. /** @hidden */
  25458. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25459. /**
  25460. * Creates a new InstancedMesh object from the mesh model.
  25461. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25462. * @param name defines the name of the new instance
  25463. * @returns a new InstancedMesh
  25464. */
  25465. createInstance(name: string): InstancedMesh;
  25466. /**
  25467. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25468. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25469. * @returns the current mesh
  25470. */
  25471. synchronizeInstances(): Mesh;
  25472. /**
  25473. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25474. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25475. * This should be used together with the simplification to avoid disappearing triangles.
  25476. * @param successCallback an optional success callback to be called after the optimization finished.
  25477. * @returns the current mesh
  25478. */
  25479. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25480. /**
  25481. * Serialize current mesh
  25482. * @param serializationObject defines the object which will receive the serialization data
  25483. */
  25484. serialize(serializationObject: any): void;
  25485. /** @hidden */
  25486. _syncGeometryWithMorphTargetManager(): void;
  25487. /** @hidden */
  25488. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25489. /**
  25490. * Returns a new Mesh object parsed from the source provided.
  25491. * @param parsedMesh is the source
  25492. * @param scene defines the hosting scene
  25493. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25494. * @returns a new Mesh
  25495. */
  25496. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25497. /**
  25498. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25499. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25500. * @param name defines the name of the mesh to create
  25501. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25502. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25503. * @param closePath creates a seam between the first and the last points of each path of the path array
  25504. * @param offset is taken in account only if the `pathArray` is containing a single path
  25505. * @param scene defines the hosting scene
  25506. * @param updatable defines if the mesh must be flagged as updatable
  25507. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25508. * @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)
  25509. * @returns a new Mesh
  25510. */
  25511. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25512. /**
  25513. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25514. * @param name defines the name of the mesh to create
  25515. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25516. * @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
  25517. * @param scene defines the hosting scene
  25518. * @param updatable defines if the mesh must be flagged as updatable
  25519. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25520. * @returns a new Mesh
  25521. */
  25522. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25523. /**
  25524. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25525. * @param name defines the name of the mesh to create
  25526. * @param size sets the size (float) of each box side (default 1)
  25527. * @param scene defines the hosting scene
  25528. * @param updatable defines if the mesh must be flagged as updatable
  25529. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25530. * @returns a new Mesh
  25531. */
  25532. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25533. /**
  25534. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25535. * @param name defines the name of the mesh to create
  25536. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25537. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25538. * @param scene defines the hosting scene
  25539. * @param updatable defines if the mesh must be flagged as updatable
  25540. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25541. * @returns a new Mesh
  25542. */
  25543. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25544. /**
  25545. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25546. * @param name defines the name of the mesh to create
  25547. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25548. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25549. * @param scene defines the hosting scene
  25550. * @returns a new Mesh
  25551. */
  25552. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25553. /**
  25554. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25555. * @param name defines the name of the mesh to create
  25556. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25557. * @param diameterTop set the top cap diameter (floats, default 1)
  25558. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25559. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25560. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25561. * @param scene defines the hosting scene
  25562. * @param updatable defines if the mesh must be flagged as updatable
  25563. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25564. * @returns a new Mesh
  25565. */
  25566. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25567. /**
  25568. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25569. * @param name defines the name of the mesh to create
  25570. * @param diameter sets the diameter size (float) of the torus (default 1)
  25571. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25572. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25573. * @param scene defines the hosting scene
  25574. * @param updatable defines if the mesh must be flagged as updatable
  25575. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25576. * @returns a new Mesh
  25577. */
  25578. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25579. /**
  25580. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25581. * @param name defines the name of the mesh to create
  25582. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25583. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25584. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25585. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25586. * @param p the number of windings on X axis (positive integers, default 2)
  25587. * @param q the number of windings on Y axis (positive integers, default 3)
  25588. * @param scene defines the hosting scene
  25589. * @param updatable defines if the mesh must be flagged as updatable
  25590. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25591. * @returns a new Mesh
  25592. */
  25593. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25594. /**
  25595. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25596. * @param name defines the name of the mesh to create
  25597. * @param points is an array successive Vector3
  25598. * @param scene defines the hosting scene
  25599. * @param updatable defines if the mesh must be flagged as updatable
  25600. * @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).
  25601. * @returns a new Mesh
  25602. */
  25603. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25604. /**
  25605. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25606. * @param name defines the name of the mesh to create
  25607. * @param points is an array successive Vector3
  25608. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25609. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25610. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25611. * @param scene defines the hosting scene
  25612. * @param updatable defines if the mesh must be flagged as updatable
  25613. * @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)
  25614. * @returns a new Mesh
  25615. */
  25616. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25617. /**
  25618. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25619. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25620. * 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.
  25621. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25622. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25623. * Remember you can only change the shape positions, not their number when updating a polygon.
  25624. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25625. * @param name defines the name of the mesh to create
  25626. * @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
  25627. * @param scene defines the hosting scene
  25628. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25629. * @param updatable defines if the mesh must be flagged as updatable
  25630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25631. * @param earcutInjection can be used to inject your own earcut reference
  25632. * @returns a new Mesh
  25633. */
  25634. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25635. /**
  25636. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25637. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25638. * @param name defines the name of the mesh to create
  25639. * @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
  25640. * @param depth defines the height of extrusion
  25641. * @param scene defines the hosting scene
  25642. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25643. * @param updatable defines if the mesh must be flagged as updatable
  25644. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25645. * @param earcutInjection can be used to inject your own earcut reference
  25646. * @returns a new Mesh
  25647. */
  25648. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25649. /**
  25650. * Creates an extruded shape mesh.
  25651. * 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
  25652. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25653. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25654. * @param name defines the name of the mesh to create
  25655. * @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
  25656. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25657. * @param scale is the value to scale the shape
  25658. * @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
  25659. * @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
  25660. * @param scene defines the hosting scene
  25661. * @param updatable defines if the mesh must be flagged as updatable
  25662. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25663. * @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)
  25664. * @returns a new Mesh
  25665. */
  25666. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25667. /**
  25668. * Creates an custom extruded shape mesh.
  25669. * The custom extrusion is a parametric shape.
  25670. * It has no predefined shape. Its final shape will depend on the input parameters.
  25671. * Please consider using the same method from the MeshBuilder class instead
  25672. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25673. * @param name defines the name of the mesh to create
  25674. * @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
  25675. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25676. * @param scaleFunction is a custom Javascript function called on each path point
  25677. * @param rotationFunction is a custom Javascript function called on each path point
  25678. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25679. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25680. * @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
  25681. * @param scene defines the hosting scene
  25682. * @param updatable defines if the mesh must be flagged as updatable
  25683. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25684. * @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)
  25685. * @returns a new Mesh
  25686. */
  25687. 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;
  25688. /**
  25689. * Creates lathe mesh.
  25690. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25691. * Please consider using the same method from the MeshBuilder class instead
  25692. * @param name defines the name of the mesh to create
  25693. * @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
  25694. * @param radius is the radius value of the lathe
  25695. * @param tessellation is the side number of the lathe.
  25696. * @param scene defines the hosting scene
  25697. * @param updatable defines if the mesh must be flagged as updatable
  25698. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25699. * @returns a new Mesh
  25700. */
  25701. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25702. /**
  25703. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25704. * @param name defines the name of the mesh to create
  25705. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25706. * @param scene defines the hosting scene
  25707. * @param updatable defines if the mesh must be flagged as updatable
  25708. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25709. * @returns a new Mesh
  25710. */
  25711. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25712. /**
  25713. * Creates a ground mesh.
  25714. * Please consider using the same method from the MeshBuilder class instead
  25715. * @param name defines the name of the mesh to create
  25716. * @param width set the width of the ground
  25717. * @param height set the height of the ground
  25718. * @param subdivisions sets the number of subdivisions per side
  25719. * @param scene defines the hosting scene
  25720. * @param updatable defines if the mesh must be flagged as updatable
  25721. * @returns a new Mesh
  25722. */
  25723. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25724. /**
  25725. * Creates a tiled ground mesh.
  25726. * Please consider using the same method from the MeshBuilder class instead
  25727. * @param name defines the name of the mesh to create
  25728. * @param xmin set the ground minimum X coordinate
  25729. * @param zmin set the ground minimum Y coordinate
  25730. * @param xmax set the ground maximum X coordinate
  25731. * @param zmax set the ground maximum Z coordinate
  25732. * @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
  25733. * @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
  25734. * @param scene defines the hosting scene
  25735. * @param updatable defines if the mesh must be flagged as updatable
  25736. * @returns a new Mesh
  25737. */
  25738. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25739. w: number;
  25740. h: number;
  25741. }, precision: {
  25742. w: number;
  25743. h: number;
  25744. }, scene: Scene, updatable?: boolean): Mesh;
  25745. /**
  25746. * Creates a ground mesh from a height map.
  25747. * Please consider using the same method from the MeshBuilder class instead
  25748. * @see http://doc.babylonjs.com/babylon101/height_map
  25749. * @param name defines the name of the mesh to create
  25750. * @param url sets the URL of the height map image resource
  25751. * @param width set the ground width size
  25752. * @param height set the ground height size
  25753. * @param subdivisions sets the number of subdivision per side
  25754. * @param minHeight is the minimum altitude on the ground
  25755. * @param maxHeight is the maximum altitude on the ground
  25756. * @param scene defines the hosting scene
  25757. * @param updatable defines if the mesh must be flagged as updatable
  25758. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25759. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25760. * @returns a new Mesh
  25761. */
  25762. 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;
  25763. /**
  25764. * Creates a tube mesh.
  25765. * The tube is a parametric shape.
  25766. * It has no predefined shape. Its final shape will depend on the input parameters.
  25767. * Please consider using the same method from the MeshBuilder class instead
  25768. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25769. * @param name defines the name of the mesh to create
  25770. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25771. * @param radius sets the tube radius size
  25772. * @param tessellation is the number of sides on the tubular surface
  25773. * @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
  25774. * @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
  25775. * @param scene defines the hosting scene
  25776. * @param updatable defines if the mesh must be flagged as updatable
  25777. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25778. * @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)
  25779. * @returns a new Mesh
  25780. */
  25781. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25782. (i: number, distance: number): number;
  25783. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25784. /**
  25785. * Creates a polyhedron mesh.
  25786. * Please consider using the same method from the MeshBuilder class instead.
  25787. * * 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
  25788. * * The parameter `size` (positive float, default 1) sets the polygon size
  25789. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25790. * * 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`
  25791. * * 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
  25792. * * 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)`)
  25793. * * 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
  25794. * * 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
  25795. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25796. * * If you create a double-sided mesh, you can choose what parts of 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
  25797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25798. * @param name defines the name of the mesh to create
  25799. * @param options defines the options used to create the mesh
  25800. * @param scene defines the hosting scene
  25801. * @returns a new Mesh
  25802. */
  25803. static CreatePolyhedron(name: string, options: {
  25804. type?: number;
  25805. size?: number;
  25806. sizeX?: number;
  25807. sizeY?: number;
  25808. sizeZ?: number;
  25809. custom?: any;
  25810. faceUV?: Vector4[];
  25811. faceColors?: Color4[];
  25812. updatable?: boolean;
  25813. sideOrientation?: number;
  25814. }, scene: Scene): Mesh;
  25815. /**
  25816. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25817. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25818. * * 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`)
  25819. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25820. * * 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
  25821. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25822. * * If you create a double-sided mesh, you can choose what parts of 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
  25823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25824. * @param name defines the name of the mesh
  25825. * @param options defines the options used to create the mesh
  25826. * @param scene defines the hosting scene
  25827. * @returns a new Mesh
  25828. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25829. */
  25830. static CreateIcoSphere(name: string, options: {
  25831. radius?: number;
  25832. flat?: boolean;
  25833. subdivisions?: number;
  25834. sideOrientation?: number;
  25835. updatable?: boolean;
  25836. }, scene: Scene): Mesh;
  25837. /**
  25838. * Creates a decal mesh.
  25839. * Please consider using the same method from the MeshBuilder class instead.
  25840. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25841. * @param name defines the name of the mesh
  25842. * @param sourceMesh defines the mesh receiving the decal
  25843. * @param position sets the position of the decal in world coordinates
  25844. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25845. * @param size sets the decal scaling
  25846. * @param angle sets the angle to rotate the decal
  25847. * @returns a new Mesh
  25848. */
  25849. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25850. /**
  25851. * Prepare internal position array for software CPU skinning
  25852. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25853. */
  25854. setPositionsForCPUSkinning(): Float32Array;
  25855. /**
  25856. * Prepare internal normal array for software CPU skinning
  25857. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25858. */
  25859. setNormalsForCPUSkinning(): Float32Array;
  25860. /**
  25861. * Updates the vertex buffer by applying transformation from the bones
  25862. * @param skeleton defines the skeleton to apply to current mesh
  25863. * @returns the current mesh
  25864. */
  25865. applySkeleton(skeleton: Skeleton): Mesh;
  25866. /**
  25867. * 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
  25868. * @param meshes defines the list of meshes to scan
  25869. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25870. */
  25871. static MinMax(meshes: AbstractMesh[]): {
  25872. min: Vector3;
  25873. max: Vector3;
  25874. };
  25875. /**
  25876. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25877. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25878. * @returns a vector3
  25879. */
  25880. static Center(meshesOrMinMaxVector: {
  25881. min: Vector3;
  25882. max: Vector3;
  25883. } | AbstractMesh[]): Vector3;
  25884. /**
  25885. * Merge the array of meshes into a single mesh for performance reasons.
  25886. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25887. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25888. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25889. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25890. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25891. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25892. * @returns a new mesh
  25893. */
  25894. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25895. /** @hidden */
  25896. addInstance(instance: InstancedMesh): void;
  25897. /** @hidden */
  25898. removeInstance(instance: InstancedMesh): void;
  25899. }
  25900. }
  25901. declare module "babylonjs/Cameras/camera" {
  25902. import { SmartArray } from "babylonjs/Misc/smartArray";
  25903. import { Observable } from "babylonjs/Misc/observable";
  25904. import { Nullable } from "babylonjs/types";
  25905. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25906. import { Scene } from "babylonjs/scene";
  25907. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25908. import { Node } from "babylonjs/node";
  25909. import { Mesh } from "babylonjs/Meshes/mesh";
  25910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25911. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25912. import { Viewport } from "babylonjs/Maths/math.viewport";
  25913. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25914. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25915. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25916. import { Ray } from "babylonjs/Culling/ray";
  25917. /**
  25918. * This is the base class of all the camera used in the application.
  25919. * @see http://doc.babylonjs.com/features/cameras
  25920. */
  25921. export class Camera extends Node {
  25922. /** @hidden */
  25923. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25924. /**
  25925. * This is the default projection mode used by the cameras.
  25926. * It helps recreating a feeling of perspective and better appreciate depth.
  25927. * This is the best way to simulate real life cameras.
  25928. */
  25929. static readonly PERSPECTIVE_CAMERA: number;
  25930. /**
  25931. * This helps creating camera with an orthographic mode.
  25932. * 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.
  25933. */
  25934. static readonly ORTHOGRAPHIC_CAMERA: number;
  25935. /**
  25936. * This is the default FOV mode for perspective cameras.
  25937. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25938. */
  25939. static readonly FOVMODE_VERTICAL_FIXED: number;
  25940. /**
  25941. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25942. */
  25943. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25944. /**
  25945. * This specifies ther is no need for a camera rig.
  25946. * Basically only one eye is rendered corresponding to the camera.
  25947. */
  25948. static readonly RIG_MODE_NONE: number;
  25949. /**
  25950. * Simulates a camera Rig with one blue eye and one red eye.
  25951. * This can be use with 3d blue and red glasses.
  25952. */
  25953. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25954. /**
  25955. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25956. */
  25957. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25958. /**
  25959. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25960. */
  25961. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25962. /**
  25963. * Defines that both eyes of the camera will be rendered over under each other.
  25964. */
  25965. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25966. /**
  25967. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25968. */
  25969. static readonly RIG_MODE_VR: number;
  25970. /**
  25971. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25972. */
  25973. static readonly RIG_MODE_WEBVR: number;
  25974. /**
  25975. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25976. */
  25977. static readonly RIG_MODE_CUSTOM: number;
  25978. /**
  25979. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25980. */
  25981. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25982. /**
  25983. * Define the input manager associated with the camera.
  25984. */
  25985. inputs: CameraInputsManager<Camera>;
  25986. /** @hidden */
  25987. _position: Vector3;
  25988. /**
  25989. * Define the current local position of the camera in the scene
  25990. */
  25991. get position(): Vector3;
  25992. set position(newPosition: Vector3);
  25993. /**
  25994. * The vector the camera should consider as up.
  25995. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25996. */
  25997. upVector: Vector3;
  25998. /**
  25999. * Define the current limit on the left side for an orthographic camera
  26000. * In scene unit
  26001. */
  26002. orthoLeft: Nullable<number>;
  26003. /**
  26004. * Define the current limit on the right side for an orthographic camera
  26005. * In scene unit
  26006. */
  26007. orthoRight: Nullable<number>;
  26008. /**
  26009. * Define the current limit on the bottom side for an orthographic camera
  26010. * In scene unit
  26011. */
  26012. orthoBottom: Nullable<number>;
  26013. /**
  26014. * Define the current limit on the top side for an orthographic camera
  26015. * In scene unit
  26016. */
  26017. orthoTop: Nullable<number>;
  26018. /**
  26019. * Field Of View is set in Radians. (default is 0.8)
  26020. */
  26021. fov: number;
  26022. /**
  26023. * Define the minimum distance the camera can see from.
  26024. * This is important to note that the depth buffer are not infinite and the closer it starts
  26025. * the more your scene might encounter depth fighting issue.
  26026. */
  26027. minZ: number;
  26028. /**
  26029. * Define the maximum distance the camera can see to.
  26030. * This is important to note that the depth buffer are not infinite and the further it end
  26031. * the more your scene might encounter depth fighting issue.
  26032. */
  26033. maxZ: number;
  26034. /**
  26035. * Define the default inertia of the camera.
  26036. * This helps giving a smooth feeling to the camera movement.
  26037. */
  26038. inertia: number;
  26039. /**
  26040. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26041. */
  26042. mode: number;
  26043. /**
  26044. * Define wether the camera is intermediate.
  26045. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26046. */
  26047. isIntermediate: boolean;
  26048. /**
  26049. * Define the viewport of the camera.
  26050. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26051. */
  26052. viewport: Viewport;
  26053. /**
  26054. * Restricts the camera to viewing objects with the same layerMask.
  26055. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26056. */
  26057. layerMask: number;
  26058. /**
  26059. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26060. */
  26061. fovMode: number;
  26062. /**
  26063. * Rig mode of the camera.
  26064. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26065. * This is normally controlled byt the camera themselves as internal use.
  26066. */
  26067. cameraRigMode: number;
  26068. /**
  26069. * Defines the distance between both "eyes" in case of a RIG
  26070. */
  26071. interaxialDistance: number;
  26072. /**
  26073. * Defines if stereoscopic rendering is done side by side or over under.
  26074. */
  26075. isStereoscopicSideBySide: boolean;
  26076. /**
  26077. * 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
  26078. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26079. * else in the scene. (Eg. security camera)
  26080. *
  26081. * 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)
  26082. */
  26083. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26084. /**
  26085. * When set, the camera will render to this render target instead of the default canvas
  26086. *
  26087. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26088. */
  26089. outputRenderTarget: Nullable<RenderTargetTexture>;
  26090. /**
  26091. * Observable triggered when the camera view matrix has changed.
  26092. */
  26093. onViewMatrixChangedObservable: Observable<Camera>;
  26094. /**
  26095. * Observable triggered when the camera Projection matrix has changed.
  26096. */
  26097. onProjectionMatrixChangedObservable: Observable<Camera>;
  26098. /**
  26099. * Observable triggered when the inputs have been processed.
  26100. */
  26101. onAfterCheckInputsObservable: Observable<Camera>;
  26102. /**
  26103. * Observable triggered when reset has been called and applied to the camera.
  26104. */
  26105. onRestoreStateObservable: Observable<Camera>;
  26106. /** @hidden */
  26107. _cameraRigParams: any;
  26108. /** @hidden */
  26109. _rigCameras: Camera[];
  26110. /** @hidden */
  26111. _rigPostProcess: Nullable<PostProcess>;
  26112. protected _webvrViewMatrix: Matrix;
  26113. /** @hidden */
  26114. _skipRendering: boolean;
  26115. /** @hidden */
  26116. _projectionMatrix: Matrix;
  26117. /** @hidden */
  26118. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26119. /** @hidden */
  26120. _activeMeshes: SmartArray<AbstractMesh>;
  26121. protected _globalPosition: Vector3;
  26122. /** @hidden */
  26123. _computedViewMatrix: Matrix;
  26124. private _doNotComputeProjectionMatrix;
  26125. private _transformMatrix;
  26126. private _frustumPlanes;
  26127. private _refreshFrustumPlanes;
  26128. private _storedFov;
  26129. private _stateStored;
  26130. /**
  26131. * Instantiates a new camera object.
  26132. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26133. * @see http://doc.babylonjs.com/features/cameras
  26134. * @param name Defines the name of the camera in the scene
  26135. * @param position Defines the position of the camera
  26136. * @param scene Defines the scene the camera belongs too
  26137. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26138. */
  26139. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26140. /**
  26141. * Store current camera state (fov, position, etc..)
  26142. * @returns the camera
  26143. */
  26144. storeState(): Camera;
  26145. /**
  26146. * Restores the camera state values if it has been stored. You must call storeState() first
  26147. */
  26148. protected _restoreStateValues(): boolean;
  26149. /**
  26150. * Restored camera state. You must call storeState() first.
  26151. * @returns true if restored and false otherwise
  26152. */
  26153. restoreState(): boolean;
  26154. /**
  26155. * Gets the class name of the camera.
  26156. * @returns the class name
  26157. */
  26158. getClassName(): string;
  26159. /** @hidden */
  26160. readonly _isCamera: boolean;
  26161. /**
  26162. * Gets a string representation of the camera useful for debug purpose.
  26163. * @param fullDetails Defines that a more verboe level of logging is required
  26164. * @returns the string representation
  26165. */
  26166. toString(fullDetails?: boolean): string;
  26167. /**
  26168. * Gets the current world space position of the camera.
  26169. */
  26170. get globalPosition(): Vector3;
  26171. /**
  26172. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26173. * @returns the active meshe list
  26174. */
  26175. getActiveMeshes(): SmartArray<AbstractMesh>;
  26176. /**
  26177. * Check wether a mesh is part of the current active mesh list of the camera
  26178. * @param mesh Defines the mesh to check
  26179. * @returns true if active, false otherwise
  26180. */
  26181. isActiveMesh(mesh: Mesh): boolean;
  26182. /**
  26183. * Is this camera ready to be used/rendered
  26184. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26185. * @return true if the camera is ready
  26186. */
  26187. isReady(completeCheck?: boolean): boolean;
  26188. /** @hidden */
  26189. _initCache(): void;
  26190. /** @hidden */
  26191. _updateCache(ignoreParentClass?: boolean): void;
  26192. /** @hidden */
  26193. _isSynchronized(): boolean;
  26194. /** @hidden */
  26195. _isSynchronizedViewMatrix(): boolean;
  26196. /** @hidden */
  26197. _isSynchronizedProjectionMatrix(): boolean;
  26198. /**
  26199. * Attach the input controls to a specific dom element to get the input from.
  26200. * @param element Defines the element the controls should be listened from
  26201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26202. */
  26203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26204. /**
  26205. * Detach the current controls from the specified dom element.
  26206. * @param element Defines the element to stop listening the inputs from
  26207. */
  26208. detachControl(element: HTMLElement): void;
  26209. /**
  26210. * Update the camera state according to the different inputs gathered during the frame.
  26211. */
  26212. update(): void;
  26213. /** @hidden */
  26214. _checkInputs(): void;
  26215. /** @hidden */
  26216. get rigCameras(): Camera[];
  26217. /**
  26218. * Gets the post process used by the rig cameras
  26219. */
  26220. get rigPostProcess(): Nullable<PostProcess>;
  26221. /**
  26222. * Internal, gets the first post proces.
  26223. * @returns the first post process to be run on this camera.
  26224. */
  26225. _getFirstPostProcess(): Nullable<PostProcess>;
  26226. private _cascadePostProcessesToRigCams;
  26227. /**
  26228. * Attach a post process to the camera.
  26229. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26230. * @param postProcess The post process to attach to the camera
  26231. * @param insertAt The position of the post process in case several of them are in use in the scene
  26232. * @returns the position the post process has been inserted at
  26233. */
  26234. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26235. /**
  26236. * Detach a post process to the camera.
  26237. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26238. * @param postProcess The post process to detach from the camera
  26239. */
  26240. detachPostProcess(postProcess: PostProcess): void;
  26241. /**
  26242. * Gets the current world matrix of the camera
  26243. */
  26244. getWorldMatrix(): Matrix;
  26245. /** @hidden */
  26246. _getViewMatrix(): Matrix;
  26247. /**
  26248. * Gets the current view matrix of the camera.
  26249. * @param force forces the camera to recompute the matrix without looking at the cached state
  26250. * @returns the view matrix
  26251. */
  26252. getViewMatrix(force?: boolean): Matrix;
  26253. /**
  26254. * Freeze the projection matrix.
  26255. * It will prevent the cache check of the camera projection compute and can speed up perf
  26256. * if no parameter of the camera are meant to change
  26257. * @param projection Defines manually a projection if necessary
  26258. */
  26259. freezeProjectionMatrix(projection?: Matrix): void;
  26260. /**
  26261. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26262. */
  26263. unfreezeProjectionMatrix(): void;
  26264. /**
  26265. * Gets the current projection matrix of the camera.
  26266. * @param force forces the camera to recompute the matrix without looking at the cached state
  26267. * @returns the projection matrix
  26268. */
  26269. getProjectionMatrix(force?: boolean): Matrix;
  26270. /**
  26271. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26272. * @returns a Matrix
  26273. */
  26274. getTransformationMatrix(): Matrix;
  26275. private _updateFrustumPlanes;
  26276. /**
  26277. * Checks if a cullable object (mesh...) is in the camera frustum
  26278. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26279. * @param target The object to check
  26280. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26281. * @returns true if the object is in frustum otherwise false
  26282. */
  26283. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26284. /**
  26285. * Checks if a cullable object (mesh...) is in the camera frustum
  26286. * Unlike isInFrustum this cheks the full bounding box
  26287. * @param target The object to check
  26288. * @returns true if the object is in frustum otherwise false
  26289. */
  26290. isCompletelyInFrustum(target: ICullable): boolean;
  26291. /**
  26292. * Gets a ray in the forward direction from the camera.
  26293. * @param length Defines the length of the ray to create
  26294. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26295. * @param origin Defines the start point of the ray which defaults to the camera position
  26296. * @returns the forward ray
  26297. */
  26298. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26299. /**
  26300. * Releases resources associated with this node.
  26301. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26302. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26303. */
  26304. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26305. /** @hidden */
  26306. _isLeftCamera: boolean;
  26307. /**
  26308. * Gets the left camera of a rig setup in case of Rigged Camera
  26309. */
  26310. get isLeftCamera(): boolean;
  26311. /** @hidden */
  26312. _isRightCamera: boolean;
  26313. /**
  26314. * Gets the right camera of a rig setup in case of Rigged Camera
  26315. */
  26316. get isRightCamera(): boolean;
  26317. /**
  26318. * Gets the left camera of a rig setup in case of Rigged Camera
  26319. */
  26320. get leftCamera(): Nullable<FreeCamera>;
  26321. /**
  26322. * Gets the right camera of a rig setup in case of Rigged Camera
  26323. */
  26324. get rightCamera(): Nullable<FreeCamera>;
  26325. /**
  26326. * Gets the left camera target of a rig setup in case of Rigged Camera
  26327. * @returns the target position
  26328. */
  26329. getLeftTarget(): Nullable<Vector3>;
  26330. /**
  26331. * Gets the right camera target of a rig setup in case of Rigged Camera
  26332. * @returns the target position
  26333. */
  26334. getRightTarget(): Nullable<Vector3>;
  26335. /**
  26336. * @hidden
  26337. */
  26338. setCameraRigMode(mode: number, rigParams: any): void;
  26339. /** @hidden */
  26340. static _setStereoscopicRigMode(camera: Camera): void;
  26341. /** @hidden */
  26342. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26343. /** @hidden */
  26344. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26345. /** @hidden */
  26346. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26347. /** @hidden */
  26348. _getVRProjectionMatrix(): Matrix;
  26349. protected _updateCameraRotationMatrix(): void;
  26350. protected _updateWebVRCameraRotationMatrix(): void;
  26351. /**
  26352. * This function MUST be overwritten by the different WebVR cameras available.
  26353. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26354. * @hidden
  26355. */
  26356. _getWebVRProjectionMatrix(): Matrix;
  26357. /**
  26358. * This function MUST be overwritten by the different WebVR cameras available.
  26359. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26360. * @hidden
  26361. */
  26362. _getWebVRViewMatrix(): Matrix;
  26363. /** @hidden */
  26364. setCameraRigParameter(name: string, value: any): void;
  26365. /**
  26366. * needs to be overridden by children so sub has required properties to be copied
  26367. * @hidden
  26368. */
  26369. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26370. /**
  26371. * May need to be overridden by children
  26372. * @hidden
  26373. */
  26374. _updateRigCameras(): void;
  26375. /** @hidden */
  26376. _setupInputs(): void;
  26377. /**
  26378. * Serialiaze the camera setup to a json represention
  26379. * @returns the JSON representation
  26380. */
  26381. serialize(): any;
  26382. /**
  26383. * Clones the current camera.
  26384. * @param name The cloned camera name
  26385. * @returns the cloned camera
  26386. */
  26387. clone(name: string): Camera;
  26388. /**
  26389. * Gets the direction of the camera relative to a given local axis.
  26390. * @param localAxis Defines the reference axis to provide a relative direction.
  26391. * @return the direction
  26392. */
  26393. getDirection(localAxis: Vector3): Vector3;
  26394. /**
  26395. * Returns the current camera absolute rotation
  26396. */
  26397. get absoluteRotation(): Quaternion;
  26398. /**
  26399. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26400. * @param localAxis Defines the reference axis to provide a relative direction.
  26401. * @param result Defines the vector to store the result in
  26402. */
  26403. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26404. /**
  26405. * Gets a camera constructor for a given camera type
  26406. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26407. * @param name The name of the camera the result will be able to instantiate
  26408. * @param scene The scene the result will construct the camera in
  26409. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26410. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26411. * @returns a factory method to construc the camera
  26412. */
  26413. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26414. /**
  26415. * Compute the world matrix of the camera.
  26416. * @returns the camera world matrix
  26417. */
  26418. computeWorldMatrix(): Matrix;
  26419. /**
  26420. * Parse a JSON and creates the camera from the parsed information
  26421. * @param parsedCamera The JSON to parse
  26422. * @param scene The scene to instantiate the camera in
  26423. * @returns the newly constructed camera
  26424. */
  26425. static Parse(parsedCamera: any, scene: Scene): Camera;
  26426. }
  26427. }
  26428. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26429. import { Nullable } from "babylonjs/types";
  26430. import { Scene } from "babylonjs/scene";
  26431. import { Vector4 } from "babylonjs/Maths/math.vector";
  26432. import { Mesh } from "babylonjs/Meshes/mesh";
  26433. /**
  26434. * Class containing static functions to help procedurally build meshes
  26435. */
  26436. export class DiscBuilder {
  26437. /**
  26438. * Creates a plane polygonal mesh. By default, this is a disc
  26439. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26440. * * 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
  26441. * * 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
  26442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26445. * @param name defines the name of the mesh
  26446. * @param options defines the options used to create the mesh
  26447. * @param scene defines the hosting scene
  26448. * @returns the plane polygonal mesh
  26449. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26450. */
  26451. static CreateDisc(name: string, options: {
  26452. radius?: number;
  26453. tessellation?: number;
  26454. arc?: number;
  26455. updatable?: boolean;
  26456. sideOrientation?: number;
  26457. frontUVs?: Vector4;
  26458. backUVs?: Vector4;
  26459. }, scene?: Nullable<Scene>): Mesh;
  26460. }
  26461. }
  26462. declare module "babylonjs/Materials/fresnelParameters" {
  26463. import { Color3 } from "babylonjs/Maths/math.color";
  26464. /**
  26465. * This represents all the required information to add a fresnel effect on a material:
  26466. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26467. */
  26468. export class FresnelParameters {
  26469. private _isEnabled;
  26470. /**
  26471. * Define if the fresnel effect is enable or not.
  26472. */
  26473. get isEnabled(): boolean;
  26474. set isEnabled(value: boolean);
  26475. /**
  26476. * Define the color used on edges (grazing angle)
  26477. */
  26478. leftColor: Color3;
  26479. /**
  26480. * Define the color used on center
  26481. */
  26482. rightColor: Color3;
  26483. /**
  26484. * Define bias applied to computed fresnel term
  26485. */
  26486. bias: number;
  26487. /**
  26488. * Defined the power exponent applied to fresnel term
  26489. */
  26490. power: number;
  26491. /**
  26492. * Clones the current fresnel and its valuues
  26493. * @returns a clone fresnel configuration
  26494. */
  26495. clone(): FresnelParameters;
  26496. /**
  26497. * Serializes the current fresnel parameters to a JSON representation.
  26498. * @return the JSON serialization
  26499. */
  26500. serialize(): any;
  26501. /**
  26502. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26503. * @param parsedFresnelParameters Define the JSON representation
  26504. * @returns the parsed parameters
  26505. */
  26506. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26507. }
  26508. }
  26509. declare module "babylonjs/Materials/pushMaterial" {
  26510. import { Nullable } from "babylonjs/types";
  26511. import { Scene } from "babylonjs/scene";
  26512. import { Matrix } from "babylonjs/Maths/math.vector";
  26513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26514. import { Mesh } from "babylonjs/Meshes/mesh";
  26515. import { Material } from "babylonjs/Materials/material";
  26516. import { Effect } from "babylonjs/Materials/effect";
  26517. /**
  26518. * Base class of materials working in push mode in babylon JS
  26519. * @hidden
  26520. */
  26521. export class PushMaterial extends Material {
  26522. protected _activeEffect: Effect;
  26523. protected _normalMatrix: Matrix;
  26524. /**
  26525. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26526. * This means that the material can keep using a previous shader while a new one is being compiled.
  26527. * This is mostly used when shader parallel compilation is supported (true by default)
  26528. */
  26529. allowShaderHotSwapping: boolean;
  26530. constructor(name: string, scene: Scene);
  26531. getEffect(): Effect;
  26532. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26533. /**
  26534. * Binds the given world matrix to the active effect
  26535. *
  26536. * @param world the matrix to bind
  26537. */
  26538. bindOnlyWorldMatrix(world: Matrix): void;
  26539. /**
  26540. * Binds the given normal matrix to the active effect
  26541. *
  26542. * @param normalMatrix the matrix to bind
  26543. */
  26544. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26545. bind(world: Matrix, mesh?: Mesh): void;
  26546. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26547. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26548. }
  26549. }
  26550. declare module "babylonjs/Materials/materialFlags" {
  26551. /**
  26552. * This groups all the flags used to control the materials channel.
  26553. */
  26554. export class MaterialFlags {
  26555. private static _DiffuseTextureEnabled;
  26556. /**
  26557. * Are diffuse textures enabled in the application.
  26558. */
  26559. static get DiffuseTextureEnabled(): boolean;
  26560. static set DiffuseTextureEnabled(value: boolean);
  26561. private static _AmbientTextureEnabled;
  26562. /**
  26563. * Are ambient textures enabled in the application.
  26564. */
  26565. static get AmbientTextureEnabled(): boolean;
  26566. static set AmbientTextureEnabled(value: boolean);
  26567. private static _OpacityTextureEnabled;
  26568. /**
  26569. * Are opacity textures enabled in the application.
  26570. */
  26571. static get OpacityTextureEnabled(): boolean;
  26572. static set OpacityTextureEnabled(value: boolean);
  26573. private static _ReflectionTextureEnabled;
  26574. /**
  26575. * Are reflection textures enabled in the application.
  26576. */
  26577. static get ReflectionTextureEnabled(): boolean;
  26578. static set ReflectionTextureEnabled(value: boolean);
  26579. private static _EmissiveTextureEnabled;
  26580. /**
  26581. * Are emissive textures enabled in the application.
  26582. */
  26583. static get EmissiveTextureEnabled(): boolean;
  26584. static set EmissiveTextureEnabled(value: boolean);
  26585. private static _SpecularTextureEnabled;
  26586. /**
  26587. * Are specular textures enabled in the application.
  26588. */
  26589. static get SpecularTextureEnabled(): boolean;
  26590. static set SpecularTextureEnabled(value: boolean);
  26591. private static _BumpTextureEnabled;
  26592. /**
  26593. * Are bump textures enabled in the application.
  26594. */
  26595. static get BumpTextureEnabled(): boolean;
  26596. static set BumpTextureEnabled(value: boolean);
  26597. private static _LightmapTextureEnabled;
  26598. /**
  26599. * Are lightmap textures enabled in the application.
  26600. */
  26601. static get LightmapTextureEnabled(): boolean;
  26602. static set LightmapTextureEnabled(value: boolean);
  26603. private static _RefractionTextureEnabled;
  26604. /**
  26605. * Are refraction textures enabled in the application.
  26606. */
  26607. static get RefractionTextureEnabled(): boolean;
  26608. static set RefractionTextureEnabled(value: boolean);
  26609. private static _ColorGradingTextureEnabled;
  26610. /**
  26611. * Are color grading textures enabled in the application.
  26612. */
  26613. static get ColorGradingTextureEnabled(): boolean;
  26614. static set ColorGradingTextureEnabled(value: boolean);
  26615. private static _FresnelEnabled;
  26616. /**
  26617. * Are fresnels enabled in the application.
  26618. */
  26619. static get FresnelEnabled(): boolean;
  26620. static set FresnelEnabled(value: boolean);
  26621. private static _ClearCoatTextureEnabled;
  26622. /**
  26623. * Are clear coat textures enabled in the application.
  26624. */
  26625. static get ClearCoatTextureEnabled(): boolean;
  26626. static set ClearCoatTextureEnabled(value: boolean);
  26627. private static _ClearCoatBumpTextureEnabled;
  26628. /**
  26629. * Are clear coat bump textures enabled in the application.
  26630. */
  26631. static get ClearCoatBumpTextureEnabled(): boolean;
  26632. static set ClearCoatBumpTextureEnabled(value: boolean);
  26633. private static _ClearCoatTintTextureEnabled;
  26634. /**
  26635. * Are clear coat tint textures enabled in the application.
  26636. */
  26637. static get ClearCoatTintTextureEnabled(): boolean;
  26638. static set ClearCoatTintTextureEnabled(value: boolean);
  26639. private static _SheenTextureEnabled;
  26640. /**
  26641. * Are sheen textures enabled in the application.
  26642. */
  26643. static get SheenTextureEnabled(): boolean;
  26644. static set SheenTextureEnabled(value: boolean);
  26645. private static _AnisotropicTextureEnabled;
  26646. /**
  26647. * Are anisotropic textures enabled in the application.
  26648. */
  26649. static get AnisotropicTextureEnabled(): boolean;
  26650. static set AnisotropicTextureEnabled(value: boolean);
  26651. private static _ThicknessTextureEnabled;
  26652. /**
  26653. * Are thickness textures enabled in the application.
  26654. */
  26655. static get ThicknessTextureEnabled(): boolean;
  26656. static set ThicknessTextureEnabled(value: boolean);
  26657. }
  26658. }
  26659. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26660. /** @hidden */
  26661. export var defaultFragmentDeclaration: {
  26662. name: string;
  26663. shader: string;
  26664. };
  26665. }
  26666. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26667. /** @hidden */
  26668. export var defaultUboDeclaration: {
  26669. name: string;
  26670. shader: string;
  26671. };
  26672. }
  26673. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26674. /** @hidden */
  26675. export var lightFragmentDeclaration: {
  26676. name: string;
  26677. shader: string;
  26678. };
  26679. }
  26680. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26681. /** @hidden */
  26682. export var lightUboDeclaration: {
  26683. name: string;
  26684. shader: string;
  26685. };
  26686. }
  26687. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26688. /** @hidden */
  26689. export var lightsFragmentFunctions: {
  26690. name: string;
  26691. shader: string;
  26692. };
  26693. }
  26694. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26695. /** @hidden */
  26696. export var shadowsFragmentFunctions: {
  26697. name: string;
  26698. shader: string;
  26699. };
  26700. }
  26701. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26702. /** @hidden */
  26703. export var fresnelFunction: {
  26704. name: string;
  26705. shader: string;
  26706. };
  26707. }
  26708. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26709. /** @hidden */
  26710. export var reflectionFunction: {
  26711. name: string;
  26712. shader: string;
  26713. };
  26714. }
  26715. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26716. /** @hidden */
  26717. export var bumpFragmentFunctions: {
  26718. name: string;
  26719. shader: string;
  26720. };
  26721. }
  26722. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26723. /** @hidden */
  26724. export var logDepthDeclaration: {
  26725. name: string;
  26726. shader: string;
  26727. };
  26728. }
  26729. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26730. /** @hidden */
  26731. export var bumpFragment: {
  26732. name: string;
  26733. shader: string;
  26734. };
  26735. }
  26736. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26737. /** @hidden */
  26738. export var depthPrePass: {
  26739. name: string;
  26740. shader: string;
  26741. };
  26742. }
  26743. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26744. /** @hidden */
  26745. export var lightFragment: {
  26746. name: string;
  26747. shader: string;
  26748. };
  26749. }
  26750. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26751. /** @hidden */
  26752. export var logDepthFragment: {
  26753. name: string;
  26754. shader: string;
  26755. };
  26756. }
  26757. declare module "babylonjs/Shaders/default.fragment" {
  26758. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26759. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26760. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26761. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26762. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26763. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26764. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26765. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26766. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26767. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26768. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26769. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26770. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26771. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26772. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26773. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26774. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26775. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26776. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26777. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26778. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26779. /** @hidden */
  26780. export var defaultPixelShader: {
  26781. name: string;
  26782. shader: string;
  26783. };
  26784. }
  26785. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26786. /** @hidden */
  26787. export var defaultVertexDeclaration: {
  26788. name: string;
  26789. shader: string;
  26790. };
  26791. }
  26792. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26793. /** @hidden */
  26794. export var bumpVertexDeclaration: {
  26795. name: string;
  26796. shader: string;
  26797. };
  26798. }
  26799. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26800. /** @hidden */
  26801. export var bumpVertex: {
  26802. name: string;
  26803. shader: string;
  26804. };
  26805. }
  26806. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26807. /** @hidden */
  26808. export var fogVertex: {
  26809. name: string;
  26810. shader: string;
  26811. };
  26812. }
  26813. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26814. /** @hidden */
  26815. export var shadowsVertex: {
  26816. name: string;
  26817. shader: string;
  26818. };
  26819. }
  26820. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26821. /** @hidden */
  26822. export var pointCloudVertex: {
  26823. name: string;
  26824. shader: string;
  26825. };
  26826. }
  26827. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26828. /** @hidden */
  26829. export var logDepthVertex: {
  26830. name: string;
  26831. shader: string;
  26832. };
  26833. }
  26834. declare module "babylonjs/Shaders/default.vertex" {
  26835. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26836. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26837. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26838. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26839. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26840. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26841. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26842. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26843. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26844. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26846. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26847. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26848. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26849. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26850. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26851. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26852. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26853. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26854. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26855. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26856. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26857. /** @hidden */
  26858. export var defaultVertexShader: {
  26859. name: string;
  26860. shader: string;
  26861. };
  26862. }
  26863. declare module "babylonjs/Materials/standardMaterial" {
  26864. import { SmartArray } from "babylonjs/Misc/smartArray";
  26865. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26866. import { Nullable } from "babylonjs/types";
  26867. import { Scene } from "babylonjs/scene";
  26868. import { Matrix } from "babylonjs/Maths/math.vector";
  26869. import { Color3 } from "babylonjs/Maths/math.color";
  26870. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26872. import { Mesh } from "babylonjs/Meshes/mesh";
  26873. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26874. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26875. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26876. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26877. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26880. import "babylonjs/Shaders/default.fragment";
  26881. import "babylonjs/Shaders/default.vertex";
  26882. /** @hidden */
  26883. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26884. MAINUV1: boolean;
  26885. MAINUV2: boolean;
  26886. DIFFUSE: boolean;
  26887. DIFFUSEDIRECTUV: number;
  26888. AMBIENT: boolean;
  26889. AMBIENTDIRECTUV: number;
  26890. OPACITY: boolean;
  26891. OPACITYDIRECTUV: number;
  26892. OPACITYRGB: boolean;
  26893. REFLECTION: boolean;
  26894. EMISSIVE: boolean;
  26895. EMISSIVEDIRECTUV: number;
  26896. SPECULAR: boolean;
  26897. SPECULARDIRECTUV: number;
  26898. BUMP: boolean;
  26899. BUMPDIRECTUV: number;
  26900. PARALLAX: boolean;
  26901. PARALLAXOCCLUSION: boolean;
  26902. SPECULAROVERALPHA: boolean;
  26903. CLIPPLANE: boolean;
  26904. CLIPPLANE2: boolean;
  26905. CLIPPLANE3: boolean;
  26906. CLIPPLANE4: boolean;
  26907. CLIPPLANE5: boolean;
  26908. CLIPPLANE6: boolean;
  26909. ALPHATEST: boolean;
  26910. DEPTHPREPASS: boolean;
  26911. ALPHAFROMDIFFUSE: boolean;
  26912. POINTSIZE: boolean;
  26913. FOG: boolean;
  26914. SPECULARTERM: boolean;
  26915. DIFFUSEFRESNEL: boolean;
  26916. OPACITYFRESNEL: boolean;
  26917. REFLECTIONFRESNEL: boolean;
  26918. REFRACTIONFRESNEL: boolean;
  26919. EMISSIVEFRESNEL: boolean;
  26920. FRESNEL: boolean;
  26921. NORMAL: boolean;
  26922. UV1: boolean;
  26923. UV2: boolean;
  26924. VERTEXCOLOR: boolean;
  26925. VERTEXALPHA: boolean;
  26926. NUM_BONE_INFLUENCERS: number;
  26927. BonesPerMesh: number;
  26928. BONETEXTURE: boolean;
  26929. INSTANCES: boolean;
  26930. GLOSSINESS: boolean;
  26931. ROUGHNESS: boolean;
  26932. EMISSIVEASILLUMINATION: boolean;
  26933. LINKEMISSIVEWITHDIFFUSE: boolean;
  26934. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26935. LIGHTMAP: boolean;
  26936. LIGHTMAPDIRECTUV: number;
  26937. OBJECTSPACE_NORMALMAP: boolean;
  26938. USELIGHTMAPASSHADOWMAP: boolean;
  26939. REFLECTIONMAP_3D: boolean;
  26940. REFLECTIONMAP_SPHERICAL: boolean;
  26941. REFLECTIONMAP_PLANAR: boolean;
  26942. REFLECTIONMAP_CUBIC: boolean;
  26943. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26944. REFLECTIONMAP_PROJECTION: boolean;
  26945. REFLECTIONMAP_SKYBOX: boolean;
  26946. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26947. REFLECTIONMAP_EXPLICIT: boolean;
  26948. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26949. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26950. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26951. INVERTCUBICMAP: boolean;
  26952. LOGARITHMICDEPTH: boolean;
  26953. REFRACTION: boolean;
  26954. REFRACTIONMAP_3D: boolean;
  26955. REFLECTIONOVERALPHA: boolean;
  26956. TWOSIDEDLIGHTING: boolean;
  26957. SHADOWFLOAT: boolean;
  26958. MORPHTARGETS: boolean;
  26959. MORPHTARGETS_NORMAL: boolean;
  26960. MORPHTARGETS_TANGENT: boolean;
  26961. MORPHTARGETS_UV: boolean;
  26962. NUM_MORPH_INFLUENCERS: number;
  26963. NONUNIFORMSCALING: boolean;
  26964. PREMULTIPLYALPHA: boolean;
  26965. IMAGEPROCESSING: boolean;
  26966. VIGNETTE: boolean;
  26967. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26968. VIGNETTEBLENDMODEOPAQUE: boolean;
  26969. TONEMAPPING: boolean;
  26970. TONEMAPPING_ACES: boolean;
  26971. CONTRAST: boolean;
  26972. COLORCURVES: boolean;
  26973. COLORGRADING: boolean;
  26974. COLORGRADING3D: boolean;
  26975. SAMPLER3DGREENDEPTH: boolean;
  26976. SAMPLER3DBGRMAP: boolean;
  26977. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26978. MULTIVIEW: boolean;
  26979. /**
  26980. * If the reflection texture on this material is in linear color space
  26981. * @hidden
  26982. */
  26983. IS_REFLECTION_LINEAR: boolean;
  26984. /**
  26985. * If the refraction texture on this material is in linear color space
  26986. * @hidden
  26987. */
  26988. IS_REFRACTION_LINEAR: boolean;
  26989. EXPOSURE: boolean;
  26990. constructor();
  26991. setReflectionMode(modeToEnable: string): void;
  26992. }
  26993. /**
  26994. * This is the default material used in Babylon. It is the best trade off between quality
  26995. * and performances.
  26996. * @see http://doc.babylonjs.com/babylon101/materials
  26997. */
  26998. export class StandardMaterial extends PushMaterial {
  26999. private _diffuseTexture;
  27000. /**
  27001. * The basic texture of the material as viewed under a light.
  27002. */
  27003. diffuseTexture: Nullable<BaseTexture>;
  27004. private _ambientTexture;
  27005. /**
  27006. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27007. */
  27008. ambientTexture: Nullable<BaseTexture>;
  27009. private _opacityTexture;
  27010. /**
  27011. * Define the transparency of the material from a texture.
  27012. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27013. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27014. */
  27015. opacityTexture: Nullable<BaseTexture>;
  27016. private _reflectionTexture;
  27017. /**
  27018. * Define the texture used to display the reflection.
  27019. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27020. */
  27021. reflectionTexture: Nullable<BaseTexture>;
  27022. private _emissiveTexture;
  27023. /**
  27024. * Define texture of the material as if self lit.
  27025. * This will be mixed in the final result even in the absence of light.
  27026. */
  27027. emissiveTexture: Nullable<BaseTexture>;
  27028. private _specularTexture;
  27029. /**
  27030. * Define how the color and intensity of the highlight given by the light in the material.
  27031. */
  27032. specularTexture: Nullable<BaseTexture>;
  27033. private _bumpTexture;
  27034. /**
  27035. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27036. * 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.
  27037. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27038. */
  27039. bumpTexture: Nullable<BaseTexture>;
  27040. private _lightmapTexture;
  27041. /**
  27042. * Complex lighting can be computationally expensive to compute at runtime.
  27043. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27044. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27045. */
  27046. lightmapTexture: Nullable<BaseTexture>;
  27047. private _refractionTexture;
  27048. /**
  27049. * Define the texture used to display the refraction.
  27050. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27051. */
  27052. refractionTexture: Nullable<BaseTexture>;
  27053. /**
  27054. * The color of the material lit by the environmental background lighting.
  27055. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27056. */
  27057. ambientColor: Color3;
  27058. /**
  27059. * The basic color of the material as viewed under a light.
  27060. */
  27061. diffuseColor: Color3;
  27062. /**
  27063. * Define how the color and intensity of the highlight given by the light in the material.
  27064. */
  27065. specularColor: Color3;
  27066. /**
  27067. * Define the color of the material as if self lit.
  27068. * This will be mixed in the final result even in the absence of light.
  27069. */
  27070. emissiveColor: Color3;
  27071. /**
  27072. * Defines how sharp are the highlights in the material.
  27073. * The bigger the value the sharper giving a more glossy feeling to the result.
  27074. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27075. */
  27076. specularPower: number;
  27077. private _useAlphaFromDiffuseTexture;
  27078. /**
  27079. * Does the transparency come from the diffuse texture alpha channel.
  27080. */
  27081. useAlphaFromDiffuseTexture: boolean;
  27082. private _useEmissiveAsIllumination;
  27083. /**
  27084. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27085. */
  27086. useEmissiveAsIllumination: boolean;
  27087. private _linkEmissiveWithDiffuse;
  27088. /**
  27089. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27090. * the emissive level when the final color is close to one.
  27091. */
  27092. linkEmissiveWithDiffuse: boolean;
  27093. private _useSpecularOverAlpha;
  27094. /**
  27095. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27096. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27097. */
  27098. useSpecularOverAlpha: boolean;
  27099. private _useReflectionOverAlpha;
  27100. /**
  27101. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27102. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27103. */
  27104. useReflectionOverAlpha: boolean;
  27105. private _disableLighting;
  27106. /**
  27107. * Does lights from the scene impacts this material.
  27108. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27109. */
  27110. disableLighting: boolean;
  27111. private _useObjectSpaceNormalMap;
  27112. /**
  27113. * Allows using an object space normal map (instead of tangent space).
  27114. */
  27115. useObjectSpaceNormalMap: boolean;
  27116. private _useParallax;
  27117. /**
  27118. * Is parallax enabled or not.
  27119. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27120. */
  27121. useParallax: boolean;
  27122. private _useParallaxOcclusion;
  27123. /**
  27124. * Is parallax occlusion enabled or not.
  27125. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27126. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27127. */
  27128. useParallaxOcclusion: boolean;
  27129. /**
  27130. * 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.
  27131. */
  27132. parallaxScaleBias: number;
  27133. private _roughness;
  27134. /**
  27135. * Helps to define how blurry the reflections should appears in the material.
  27136. */
  27137. roughness: number;
  27138. /**
  27139. * In case of refraction, define the value of the index of refraction.
  27140. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27141. */
  27142. indexOfRefraction: number;
  27143. /**
  27144. * Invert the refraction texture alongside the y axis.
  27145. * It can be useful with procedural textures or probe for instance.
  27146. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27147. */
  27148. invertRefractionY: boolean;
  27149. /**
  27150. * Defines the alpha limits in alpha test mode.
  27151. */
  27152. alphaCutOff: number;
  27153. private _useLightmapAsShadowmap;
  27154. /**
  27155. * In case of light mapping, define whether the map contains light or shadow informations.
  27156. */
  27157. useLightmapAsShadowmap: boolean;
  27158. private _diffuseFresnelParameters;
  27159. /**
  27160. * Define the diffuse fresnel parameters of the material.
  27161. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27162. */
  27163. diffuseFresnelParameters: FresnelParameters;
  27164. private _opacityFresnelParameters;
  27165. /**
  27166. * Define the opacity fresnel parameters of the material.
  27167. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27168. */
  27169. opacityFresnelParameters: FresnelParameters;
  27170. private _reflectionFresnelParameters;
  27171. /**
  27172. * Define the reflection fresnel parameters of the material.
  27173. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27174. */
  27175. reflectionFresnelParameters: FresnelParameters;
  27176. private _refractionFresnelParameters;
  27177. /**
  27178. * Define the refraction fresnel parameters of the material.
  27179. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27180. */
  27181. refractionFresnelParameters: FresnelParameters;
  27182. private _emissiveFresnelParameters;
  27183. /**
  27184. * Define the emissive fresnel parameters of the material.
  27185. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27186. */
  27187. emissiveFresnelParameters: FresnelParameters;
  27188. private _useReflectionFresnelFromSpecular;
  27189. /**
  27190. * If true automatically deducts the fresnels values from the material specularity.
  27191. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27192. */
  27193. useReflectionFresnelFromSpecular: boolean;
  27194. private _useGlossinessFromSpecularMapAlpha;
  27195. /**
  27196. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27197. */
  27198. useGlossinessFromSpecularMapAlpha: boolean;
  27199. private _maxSimultaneousLights;
  27200. /**
  27201. * Defines the maximum number of lights that can be used in the material
  27202. */
  27203. maxSimultaneousLights: number;
  27204. private _invertNormalMapX;
  27205. /**
  27206. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27207. */
  27208. invertNormalMapX: boolean;
  27209. private _invertNormalMapY;
  27210. /**
  27211. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27212. */
  27213. invertNormalMapY: boolean;
  27214. private _twoSidedLighting;
  27215. /**
  27216. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27217. */
  27218. twoSidedLighting: boolean;
  27219. /**
  27220. * Default configuration related to image processing available in the standard Material.
  27221. */
  27222. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27223. /**
  27224. * Gets the image processing configuration used either in this material.
  27225. */
  27226. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27227. /**
  27228. * Sets the Default image processing configuration used either in the this material.
  27229. *
  27230. * If sets to null, the scene one is in use.
  27231. */
  27232. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27233. /**
  27234. * Keep track of the image processing observer to allow dispose and replace.
  27235. */
  27236. private _imageProcessingObserver;
  27237. /**
  27238. * Attaches a new image processing configuration to the Standard Material.
  27239. * @param configuration
  27240. */
  27241. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27242. /**
  27243. * Gets wether the color curves effect is enabled.
  27244. */
  27245. get cameraColorCurvesEnabled(): boolean;
  27246. /**
  27247. * Sets wether the color curves effect is enabled.
  27248. */
  27249. set cameraColorCurvesEnabled(value: boolean);
  27250. /**
  27251. * Gets wether the color grading effect is enabled.
  27252. */
  27253. get cameraColorGradingEnabled(): boolean;
  27254. /**
  27255. * Gets wether the color grading effect is enabled.
  27256. */
  27257. set cameraColorGradingEnabled(value: boolean);
  27258. /**
  27259. * Gets wether tonemapping is enabled or not.
  27260. */
  27261. get cameraToneMappingEnabled(): boolean;
  27262. /**
  27263. * Sets wether tonemapping is enabled or not
  27264. */
  27265. set cameraToneMappingEnabled(value: boolean);
  27266. /**
  27267. * The camera exposure used on this material.
  27268. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27269. * This corresponds to a photographic exposure.
  27270. */
  27271. get cameraExposure(): number;
  27272. /**
  27273. * The camera exposure used on this material.
  27274. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27275. * This corresponds to a photographic exposure.
  27276. */
  27277. set cameraExposure(value: number);
  27278. /**
  27279. * Gets The camera contrast used on this material.
  27280. */
  27281. get cameraContrast(): number;
  27282. /**
  27283. * Sets The camera contrast used on this material.
  27284. */
  27285. set cameraContrast(value: number);
  27286. /**
  27287. * Gets the Color Grading 2D Lookup Texture.
  27288. */
  27289. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27290. /**
  27291. * Sets the Color Grading 2D Lookup Texture.
  27292. */
  27293. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27294. /**
  27295. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27296. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27297. * 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;
  27298. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27299. */
  27300. get cameraColorCurves(): Nullable<ColorCurves>;
  27301. /**
  27302. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27303. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27304. * 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;
  27305. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27306. */
  27307. set cameraColorCurves(value: Nullable<ColorCurves>);
  27308. /**
  27309. * Custom callback helping to override the default shader used in the material.
  27310. */
  27311. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27312. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27313. protected _worldViewProjectionMatrix: Matrix;
  27314. protected _globalAmbientColor: Color3;
  27315. protected _useLogarithmicDepth: boolean;
  27316. protected _rebuildInParallel: boolean;
  27317. /**
  27318. * Instantiates a new standard material.
  27319. * This is the default material used in Babylon. It is the best trade off between quality
  27320. * and performances.
  27321. * @see http://doc.babylonjs.com/babylon101/materials
  27322. * @param name Define the name of the material in the scene
  27323. * @param scene Define the scene the material belong to
  27324. */
  27325. constructor(name: string, scene: Scene);
  27326. /**
  27327. * Gets a boolean indicating that current material needs to register RTT
  27328. */
  27329. get hasRenderTargetTextures(): boolean;
  27330. /**
  27331. * Gets the current class name of the material e.g. "StandardMaterial"
  27332. * Mainly use in serialization.
  27333. * @returns the class name
  27334. */
  27335. getClassName(): string;
  27336. /**
  27337. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27338. * You can try switching to logarithmic depth.
  27339. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27340. */
  27341. get useLogarithmicDepth(): boolean;
  27342. set useLogarithmicDepth(value: boolean);
  27343. /**
  27344. * Specifies if the material will require alpha blending
  27345. * @returns a boolean specifying if alpha blending is needed
  27346. */
  27347. needAlphaBlending(): boolean;
  27348. /**
  27349. * Specifies if this material should be rendered in alpha test mode
  27350. * @returns a boolean specifying if an alpha test is needed.
  27351. */
  27352. needAlphaTesting(): boolean;
  27353. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27354. /**
  27355. * Get the texture used for alpha test purpose.
  27356. * @returns the diffuse texture in case of the standard material.
  27357. */
  27358. getAlphaTestTexture(): Nullable<BaseTexture>;
  27359. /**
  27360. * Get if the submesh is ready to be used and all its information available.
  27361. * Child classes can use it to update shaders
  27362. * @param mesh defines the mesh to check
  27363. * @param subMesh defines which submesh to check
  27364. * @param useInstances specifies that instances should be used
  27365. * @returns a boolean indicating that the submesh is ready or not
  27366. */
  27367. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27368. /**
  27369. * Builds the material UBO layouts.
  27370. * Used internally during the effect preparation.
  27371. */
  27372. buildUniformLayout(): void;
  27373. /**
  27374. * Unbinds the material from the mesh
  27375. */
  27376. unbind(): void;
  27377. /**
  27378. * Binds the submesh to this material by preparing the effect and shader to draw
  27379. * @param world defines the world transformation matrix
  27380. * @param mesh defines the mesh containing the submesh
  27381. * @param subMesh defines the submesh to bind the material to
  27382. */
  27383. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27384. /**
  27385. * Get the list of animatables in the material.
  27386. * @returns the list of animatables object used in the material
  27387. */
  27388. getAnimatables(): IAnimatable[];
  27389. /**
  27390. * Gets the active textures from the material
  27391. * @returns an array of textures
  27392. */
  27393. getActiveTextures(): BaseTexture[];
  27394. /**
  27395. * Specifies if the material uses a texture
  27396. * @param texture defines the texture to check against the material
  27397. * @returns a boolean specifying if the material uses the texture
  27398. */
  27399. hasTexture(texture: BaseTexture): boolean;
  27400. /**
  27401. * Disposes the material
  27402. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27403. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27404. */
  27405. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27406. /**
  27407. * Makes a duplicate of the material, and gives it a new name
  27408. * @param name defines the new name for the duplicated material
  27409. * @returns the cloned material
  27410. */
  27411. clone(name: string): StandardMaterial;
  27412. /**
  27413. * Serializes this material in a JSON representation
  27414. * @returns the serialized material object
  27415. */
  27416. serialize(): any;
  27417. /**
  27418. * Creates a standard material from parsed material data
  27419. * @param source defines the JSON representation of the material
  27420. * @param scene defines the hosting scene
  27421. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27422. * @returns a new standard material
  27423. */
  27424. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27425. /**
  27426. * Are diffuse textures enabled in the application.
  27427. */
  27428. static get DiffuseTextureEnabled(): boolean;
  27429. static set DiffuseTextureEnabled(value: boolean);
  27430. /**
  27431. * Are ambient textures enabled in the application.
  27432. */
  27433. static get AmbientTextureEnabled(): boolean;
  27434. static set AmbientTextureEnabled(value: boolean);
  27435. /**
  27436. * Are opacity textures enabled in the application.
  27437. */
  27438. static get OpacityTextureEnabled(): boolean;
  27439. static set OpacityTextureEnabled(value: boolean);
  27440. /**
  27441. * Are reflection textures enabled in the application.
  27442. */
  27443. static get ReflectionTextureEnabled(): boolean;
  27444. static set ReflectionTextureEnabled(value: boolean);
  27445. /**
  27446. * Are emissive textures enabled in the application.
  27447. */
  27448. static get EmissiveTextureEnabled(): boolean;
  27449. static set EmissiveTextureEnabled(value: boolean);
  27450. /**
  27451. * Are specular textures enabled in the application.
  27452. */
  27453. static get SpecularTextureEnabled(): boolean;
  27454. static set SpecularTextureEnabled(value: boolean);
  27455. /**
  27456. * Are bump textures enabled in the application.
  27457. */
  27458. static get BumpTextureEnabled(): boolean;
  27459. static set BumpTextureEnabled(value: boolean);
  27460. /**
  27461. * Are lightmap textures enabled in the application.
  27462. */
  27463. static get LightmapTextureEnabled(): boolean;
  27464. static set LightmapTextureEnabled(value: boolean);
  27465. /**
  27466. * Are refraction textures enabled in the application.
  27467. */
  27468. static get RefractionTextureEnabled(): boolean;
  27469. static set RefractionTextureEnabled(value: boolean);
  27470. /**
  27471. * Are color grading textures enabled in the application.
  27472. */
  27473. static get ColorGradingTextureEnabled(): boolean;
  27474. static set ColorGradingTextureEnabled(value: boolean);
  27475. /**
  27476. * Are fresnels enabled in the application.
  27477. */
  27478. static get FresnelEnabled(): boolean;
  27479. static set FresnelEnabled(value: boolean);
  27480. }
  27481. }
  27482. declare module "babylonjs/Particles/solidParticleSystem" {
  27483. import { Nullable } from "babylonjs/types";
  27484. import { Vector3 } from "babylonjs/Maths/math.vector";
  27485. import { Mesh } from "babylonjs/Meshes/mesh";
  27486. import { Scene, IDisposable } from "babylonjs/scene";
  27487. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27488. import { Material } from "babylonjs/Materials/material";
  27489. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27490. /**
  27491. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27492. *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.
  27493. * The SPS is also a particle system. It provides some methods to manage the particles.
  27494. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27495. *
  27496. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27497. */
  27498. export class SolidParticleSystem implements IDisposable {
  27499. /**
  27500. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27501. * Example : var p = SPS.particles[i];
  27502. */
  27503. particles: SolidParticle[];
  27504. /**
  27505. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27506. */
  27507. nbParticles: number;
  27508. /**
  27509. * If the particles must ever face the camera (default false). Useful for planar particles.
  27510. */
  27511. billboard: boolean;
  27512. /**
  27513. * Recompute normals when adding a shape
  27514. */
  27515. recomputeNormals: boolean;
  27516. /**
  27517. * This a counter ofr your own usage. It's not set by any SPS functions.
  27518. */
  27519. counter: number;
  27520. /**
  27521. * The SPS name. This name is also given to the underlying mesh.
  27522. */
  27523. name: string;
  27524. /**
  27525. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27526. */
  27527. mesh: Mesh;
  27528. /**
  27529. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27530. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27531. */
  27532. vars: any;
  27533. /**
  27534. * This array is populated when the SPS is set as 'pickable'.
  27535. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27536. * Each element of this array is an object `{idx: int, faceId: int}`.
  27537. * `idx` is the picked particle index in the `SPS.particles` array
  27538. * `faceId` is the picked face index counted within this particle.
  27539. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27540. */
  27541. pickedParticles: {
  27542. idx: number;
  27543. faceId: number;
  27544. }[];
  27545. /**
  27546. * This array is populated when `enableDepthSort` is set to true.
  27547. * Each element of this array is an instance of the class DepthSortedParticle.
  27548. */
  27549. depthSortedParticles: DepthSortedParticle[];
  27550. /**
  27551. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27552. * @hidden
  27553. */
  27554. _bSphereOnly: boolean;
  27555. /**
  27556. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27557. * @hidden
  27558. */
  27559. _bSphereRadiusFactor: number;
  27560. private _scene;
  27561. private _positions;
  27562. private _indices;
  27563. private _normals;
  27564. private _colors;
  27565. private _uvs;
  27566. private _indices32;
  27567. private _positions32;
  27568. private _normals32;
  27569. private _fixedNormal32;
  27570. private _colors32;
  27571. private _uvs32;
  27572. private _index;
  27573. private _updatable;
  27574. private _pickable;
  27575. private _isVisibilityBoxLocked;
  27576. private _alwaysVisible;
  27577. private _depthSort;
  27578. private _expandable;
  27579. private _shapeCounter;
  27580. private _copy;
  27581. private _color;
  27582. private _computeParticleColor;
  27583. private _computeParticleTexture;
  27584. private _computeParticleRotation;
  27585. private _computeParticleVertex;
  27586. private _computeBoundingBox;
  27587. private _depthSortParticles;
  27588. private _camera;
  27589. private _mustUnrotateFixedNormals;
  27590. private _particlesIntersect;
  27591. private _needs32Bits;
  27592. private _isNotBuilt;
  27593. private _lastParticleId;
  27594. private _idxOfId;
  27595. private _multimaterialEnabled;
  27596. private _useModelMaterial;
  27597. private _indicesByMaterial;
  27598. private _materialIndexes;
  27599. private _depthSortFunction;
  27600. private _materialSortFunction;
  27601. private _materials;
  27602. private _multimaterial;
  27603. private _materialIndexesById;
  27604. private _defaultMaterial;
  27605. private _autoUpdateSubMeshes;
  27606. /**
  27607. * Creates a SPS (Solid Particle System) object.
  27608. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27609. * @param scene (Scene) is the scene in which the SPS is added.
  27610. * @param options defines the options of the sps e.g.
  27611. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27612. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27613. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27614. * * 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.
  27615. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27616. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27617. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27618. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27619. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27620. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27621. */
  27622. constructor(name: string, scene: Scene, options?: {
  27623. updatable?: boolean;
  27624. isPickable?: boolean;
  27625. enableDepthSort?: boolean;
  27626. particleIntersection?: boolean;
  27627. boundingSphereOnly?: boolean;
  27628. bSphereRadiusFactor?: number;
  27629. expandable?: boolean;
  27630. useModelMaterial?: boolean;
  27631. enableMultiMaterial?: boolean;
  27632. });
  27633. /**
  27634. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27635. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27636. * @returns the created mesh
  27637. */
  27638. buildMesh(): Mesh;
  27639. /**
  27640. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27641. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27642. * Thus the particles generated from `digest()` have their property `position` set yet.
  27643. * @param mesh ( Mesh ) is the mesh to be digested
  27644. * @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
  27645. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27646. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27647. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27648. * @returns the current SPS
  27649. */
  27650. digest(mesh: Mesh, options?: {
  27651. facetNb?: number;
  27652. number?: number;
  27653. delta?: number;
  27654. storage?: [];
  27655. }): SolidParticleSystem;
  27656. /**
  27657. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27658. * @hidden
  27659. */
  27660. private _unrotateFixedNormals;
  27661. /**
  27662. * Resets the temporary working copy particle
  27663. * @hidden
  27664. */
  27665. private _resetCopy;
  27666. /**
  27667. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27668. * @param p the current index in the positions array to be updated
  27669. * @param ind the current index in the indices array
  27670. * @param shape a Vector3 array, the shape geometry
  27671. * @param positions the positions array to be updated
  27672. * @param meshInd the shape indices array
  27673. * @param indices the indices array to be updated
  27674. * @param meshUV the shape uv array
  27675. * @param uvs the uv array to be updated
  27676. * @param meshCol the shape color array
  27677. * @param colors the color array to be updated
  27678. * @param meshNor the shape normals array
  27679. * @param normals the normals array to be updated
  27680. * @param idx the particle index
  27681. * @param idxInShape the particle index in its shape
  27682. * @param options the addShape() method passed options
  27683. * @model the particle model
  27684. * @hidden
  27685. */
  27686. private _meshBuilder;
  27687. /**
  27688. * Returns a shape Vector3 array from positions float array
  27689. * @param positions float array
  27690. * @returns a vector3 array
  27691. * @hidden
  27692. */
  27693. private _posToShape;
  27694. /**
  27695. * Returns a shapeUV array from a float uvs (array deep copy)
  27696. * @param uvs as a float array
  27697. * @returns a shapeUV array
  27698. * @hidden
  27699. */
  27700. private _uvsToShapeUV;
  27701. /**
  27702. * Adds a new particle object in the particles array
  27703. * @param idx particle index in particles array
  27704. * @param id particle id
  27705. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27706. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27707. * @param model particle ModelShape object
  27708. * @param shapeId model shape identifier
  27709. * @param idxInShape index of the particle in the current model
  27710. * @param bInfo model bounding info object
  27711. * @param storage target storage array, if any
  27712. * @hidden
  27713. */
  27714. private _addParticle;
  27715. /**
  27716. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27717. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27718. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27719. * @param nb (positive integer) the number of particles to be created from this model
  27720. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27721. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27722. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27723. * @returns the number of shapes in the system
  27724. */
  27725. addShape(mesh: Mesh, nb: number, options?: {
  27726. positionFunction?: any;
  27727. vertexFunction?: any;
  27728. storage?: [];
  27729. }): number;
  27730. /**
  27731. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27732. * @hidden
  27733. */
  27734. private _rebuildParticle;
  27735. /**
  27736. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27737. * @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.
  27738. * @returns the SPS.
  27739. */
  27740. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27741. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27742. * Returns an array with the removed particles.
  27743. * 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.
  27744. * The SPS can't be empty so at least one particle needs to remain in place.
  27745. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27746. * @param start index of the first particle to remove
  27747. * @param end index of the last particle to remove (included)
  27748. * @returns an array populated with the removed particles
  27749. */
  27750. removeParticles(start: number, end: number): SolidParticle[];
  27751. /**
  27752. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27753. * @param solidParticleArray an array populated with Solid Particles objects
  27754. * @returns the SPS
  27755. */
  27756. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27757. /**
  27758. * Creates a new particle and modifies the SPS mesh geometry :
  27759. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27760. * - calls _addParticle() to populate the particle array
  27761. * factorized code from addShape() and insertParticlesFromArray()
  27762. * @param idx particle index in the particles array
  27763. * @param i particle index in its shape
  27764. * @param modelShape particle ModelShape object
  27765. * @param shape shape vertex array
  27766. * @param meshInd shape indices array
  27767. * @param meshUV shape uv array
  27768. * @param meshCol shape color array
  27769. * @param meshNor shape normals array
  27770. * @param bbInfo shape bounding info
  27771. * @param storage target particle storage
  27772. * @options addShape() passed options
  27773. * @hidden
  27774. */
  27775. private _insertNewParticle;
  27776. /**
  27777. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27778. * This method calls `updateParticle()` for each particle of the SPS.
  27779. * For an animated SPS, it is usually called within the render loop.
  27780. * 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.
  27781. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27782. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27783. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27784. * @returns the SPS.
  27785. */
  27786. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27787. /**
  27788. * Disposes the SPS.
  27789. */
  27790. dispose(): void;
  27791. /**
  27792. * Returns a SolidParticle object from its identifier : particle.id
  27793. * @param id (integer) the particle Id
  27794. * @returns the searched particle or null if not found in the SPS.
  27795. */
  27796. getParticleById(id: number): Nullable<SolidParticle>;
  27797. /**
  27798. * Returns a new array populated with the particles having the passed shapeId.
  27799. * @param shapeId (integer) the shape identifier
  27800. * @returns a new solid particle array
  27801. */
  27802. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27803. /**
  27804. * Populates the passed array "ref" with the particles having the passed shapeId.
  27805. * @param shapeId the shape identifier
  27806. * @returns the SPS
  27807. * @param ref
  27808. */
  27809. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27810. /**
  27811. * Computes the required SubMeshes according the materials assigned to the particles.
  27812. * @returns the solid particle system.
  27813. * Does nothing if called before the SPS mesh is built.
  27814. */
  27815. computeSubMeshes(): SolidParticleSystem;
  27816. /**
  27817. * Sorts the solid particles by material when MultiMaterial is enabled.
  27818. * Updates the indices32 array.
  27819. * Updates the indicesByMaterial array.
  27820. * Updates the mesh indices array.
  27821. * @returns the SPS
  27822. * @hidden
  27823. */
  27824. private _sortParticlesByMaterial;
  27825. /**
  27826. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27827. * @hidden
  27828. */
  27829. private _setMaterialIndexesById;
  27830. /**
  27831. * Returns an array with unique values of Materials from the passed array
  27832. * @param array the material array to be checked and filtered
  27833. * @hidden
  27834. */
  27835. private _filterUniqueMaterialId;
  27836. /**
  27837. * Sets a new Standard Material as _defaultMaterial if not already set.
  27838. * @hidden
  27839. */
  27840. private _setDefaultMaterial;
  27841. /**
  27842. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27843. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27844. * @returns the SPS.
  27845. */
  27846. refreshVisibleSize(): SolidParticleSystem;
  27847. /**
  27848. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27849. * @param size the size (float) of the visibility box
  27850. * note : this doesn't lock the SPS mesh bounding box.
  27851. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27852. */
  27853. setVisibilityBox(size: number): void;
  27854. /**
  27855. * Gets whether the SPS as always visible or not
  27856. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27857. */
  27858. get isAlwaysVisible(): boolean;
  27859. /**
  27860. * Sets the SPS as always visible or not
  27861. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27862. */
  27863. set isAlwaysVisible(val: boolean);
  27864. /**
  27865. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27866. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27867. */
  27868. set isVisibilityBoxLocked(val: boolean);
  27869. /**
  27870. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27871. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27872. */
  27873. get isVisibilityBoxLocked(): boolean;
  27874. /**
  27875. * Tells to `setParticles()` to compute the particle rotations or not.
  27876. * Default value : true. The SPS is faster when it's set to false.
  27877. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27878. */
  27879. set computeParticleRotation(val: boolean);
  27880. /**
  27881. * Tells to `setParticles()` to compute the particle colors or not.
  27882. * Default value : true. The SPS is faster when it's set to false.
  27883. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27884. */
  27885. set computeParticleColor(val: boolean);
  27886. set computeParticleTexture(val: boolean);
  27887. /**
  27888. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27889. * Default value : false. The SPS is faster when it's set to false.
  27890. * Note : the particle custom vertex positions aren't stored values.
  27891. */
  27892. set computeParticleVertex(val: boolean);
  27893. /**
  27894. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27895. */
  27896. set computeBoundingBox(val: boolean);
  27897. /**
  27898. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27899. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27900. * Default : `true`
  27901. */
  27902. set depthSortParticles(val: boolean);
  27903. /**
  27904. * Gets if `setParticles()` computes the particle rotations or not.
  27905. * Default value : true. The SPS is faster when it's set to false.
  27906. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27907. */
  27908. get computeParticleRotation(): boolean;
  27909. /**
  27910. * Gets if `setParticles()` computes the particle colors or not.
  27911. * Default value : true. The SPS is faster when it's set to false.
  27912. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27913. */
  27914. get computeParticleColor(): boolean;
  27915. /**
  27916. * Gets if `setParticles()` computes the particle textures or not.
  27917. * Default value : true. The SPS is faster when it's set to false.
  27918. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27919. */
  27920. get computeParticleTexture(): boolean;
  27921. /**
  27922. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27923. * Default value : false. The SPS is faster when it's set to false.
  27924. * Note : the particle custom vertex positions aren't stored values.
  27925. */
  27926. get computeParticleVertex(): boolean;
  27927. /**
  27928. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27929. */
  27930. get computeBoundingBox(): boolean;
  27931. /**
  27932. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27933. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27934. * Default : `true`
  27935. */
  27936. get depthSortParticles(): boolean;
  27937. /**
  27938. * Gets if the SPS is created as expandable at construction time.
  27939. * Default : `false`
  27940. */
  27941. get expandable(): boolean;
  27942. /**
  27943. * Gets if the SPS supports the Multi Materials
  27944. */
  27945. get multimaterialEnabled(): boolean;
  27946. /**
  27947. * Gets if the SPS uses the model materials for its own multimaterial.
  27948. */
  27949. get useModelMaterial(): boolean;
  27950. /**
  27951. * The SPS used material array.
  27952. */
  27953. get materials(): Material[];
  27954. /**
  27955. * Sets the SPS MultiMaterial from the passed materials.
  27956. * Note : the passed array is internally copied and not used then by reference.
  27957. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27958. */
  27959. setMultiMaterial(materials: Material[]): void;
  27960. /**
  27961. * The SPS computed multimaterial object
  27962. */
  27963. get multimaterial(): MultiMaterial;
  27964. set multimaterial(mm: MultiMaterial);
  27965. /**
  27966. * If the subMeshes must be updated on the next call to setParticles()
  27967. */
  27968. get autoUpdateSubMeshes(): boolean;
  27969. set autoUpdateSubMeshes(val: boolean);
  27970. /**
  27971. * This function does nothing. It may be overwritten to set all the particle first values.
  27972. * The SPS doesn't call this function, you may have to call it by your own.
  27973. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27974. */
  27975. initParticles(): void;
  27976. /**
  27977. * This function does nothing. It may be overwritten to recycle a particle.
  27978. * The SPS doesn't call this function, you may have to call it by your own.
  27979. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27980. * @param particle The particle to recycle
  27981. * @returns the recycled particle
  27982. */
  27983. recycleParticle(particle: SolidParticle): SolidParticle;
  27984. /**
  27985. * Updates a particle : this function should be overwritten by the user.
  27986. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27987. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27988. * @example : just set a particle position or velocity and recycle conditions
  27989. * @param particle The particle to update
  27990. * @returns the updated particle
  27991. */
  27992. updateParticle(particle: SolidParticle): SolidParticle;
  27993. /**
  27994. * Updates a vertex of a particle : it can be overwritten by the user.
  27995. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27996. * @param particle the current particle
  27997. * @param vertex the current index of the current particle
  27998. * @param pt the index of the current vertex in the particle shape
  27999. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28000. * @example : just set a vertex particle position
  28001. * @returns the updated vertex
  28002. */
  28003. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28004. /**
  28005. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28006. * This does nothing and may be overwritten by the user.
  28007. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28008. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28009. * @param update the boolean update value actually passed to setParticles()
  28010. */
  28011. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28012. /**
  28013. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28014. * This will be passed three parameters.
  28015. * This does nothing and may be overwritten by the user.
  28016. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28017. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28018. * @param update the boolean update value actually passed to setParticles()
  28019. */
  28020. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28021. }
  28022. }
  28023. declare module "babylonjs/Particles/solidParticle" {
  28024. import { Nullable } from "babylonjs/types";
  28025. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28026. import { Color4 } from "babylonjs/Maths/math.color";
  28027. import { Mesh } from "babylonjs/Meshes/mesh";
  28028. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28029. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28030. import { Plane } from "babylonjs/Maths/math.plane";
  28031. import { Material } from "babylonjs/Materials/material";
  28032. /**
  28033. * Represents one particle of a solid particle system.
  28034. */
  28035. export class SolidParticle {
  28036. /**
  28037. * particle global index
  28038. */
  28039. idx: number;
  28040. /**
  28041. * particle identifier
  28042. */
  28043. id: number;
  28044. /**
  28045. * The color of the particle
  28046. */
  28047. color: Nullable<Color4>;
  28048. /**
  28049. * The world space position of the particle.
  28050. */
  28051. position: Vector3;
  28052. /**
  28053. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28054. */
  28055. rotation: Vector3;
  28056. /**
  28057. * The world space rotation quaternion of the particle.
  28058. */
  28059. rotationQuaternion: Nullable<Quaternion>;
  28060. /**
  28061. * The scaling of the particle.
  28062. */
  28063. scaling: Vector3;
  28064. /**
  28065. * The uvs of the particle.
  28066. */
  28067. uvs: Vector4;
  28068. /**
  28069. * The current speed of the particle.
  28070. */
  28071. velocity: Vector3;
  28072. /**
  28073. * The pivot point in the particle local space.
  28074. */
  28075. pivot: Vector3;
  28076. /**
  28077. * Must the particle be translated from its pivot point in its local space ?
  28078. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28079. * Default : false
  28080. */
  28081. translateFromPivot: boolean;
  28082. /**
  28083. * Is the particle active or not ?
  28084. */
  28085. alive: boolean;
  28086. /**
  28087. * Is the particle visible or not ?
  28088. */
  28089. isVisible: boolean;
  28090. /**
  28091. * Index of this particle in the global "positions" array (Internal use)
  28092. * @hidden
  28093. */
  28094. _pos: number;
  28095. /**
  28096. * @hidden Index of this particle in the global "indices" array (Internal use)
  28097. */
  28098. _ind: number;
  28099. /**
  28100. * @hidden ModelShape of this particle (Internal use)
  28101. */
  28102. _model: ModelShape;
  28103. /**
  28104. * ModelShape id of this particle
  28105. */
  28106. shapeId: number;
  28107. /**
  28108. * Index of the particle in its shape id
  28109. */
  28110. idxInShape: number;
  28111. /**
  28112. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28113. */
  28114. _modelBoundingInfo: BoundingInfo;
  28115. /**
  28116. * @hidden Particle BoundingInfo object (Internal use)
  28117. */
  28118. _boundingInfo: BoundingInfo;
  28119. /**
  28120. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28121. */
  28122. _sps: SolidParticleSystem;
  28123. /**
  28124. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28125. */
  28126. _stillInvisible: boolean;
  28127. /**
  28128. * @hidden Last computed particle rotation matrix
  28129. */
  28130. _rotationMatrix: number[];
  28131. /**
  28132. * Parent particle Id, if any.
  28133. * Default null.
  28134. */
  28135. parentId: Nullable<number>;
  28136. /**
  28137. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28138. */
  28139. materialIndex: Nullable<number>;
  28140. /**
  28141. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28142. * The possible values are :
  28143. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28144. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28145. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28146. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28147. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28148. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28149. * */
  28150. cullingStrategy: number;
  28151. /**
  28152. * @hidden Internal global position in the SPS.
  28153. */
  28154. _globalPosition: Vector3;
  28155. /**
  28156. * Creates a Solid Particle object.
  28157. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28158. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28159. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28160. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28161. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28162. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28163. * @param shapeId (integer) is the model shape identifier in the SPS.
  28164. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28165. * @param sps defines the sps it is associated to
  28166. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28167. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28168. */
  28169. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28170. /**
  28171. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28172. * @param target the particle target
  28173. * @returns the current particle
  28174. */
  28175. copyToRef(target: SolidParticle): SolidParticle;
  28176. /**
  28177. * Legacy support, changed scale to scaling
  28178. */
  28179. get scale(): Vector3;
  28180. /**
  28181. * Legacy support, changed scale to scaling
  28182. */
  28183. set scale(scale: Vector3);
  28184. /**
  28185. * Legacy support, changed quaternion to rotationQuaternion
  28186. */
  28187. get quaternion(): Nullable<Quaternion>;
  28188. /**
  28189. * Legacy support, changed quaternion to rotationQuaternion
  28190. */
  28191. set quaternion(q: Nullable<Quaternion>);
  28192. /**
  28193. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28194. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28195. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28196. * @returns true if it intersects
  28197. */
  28198. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28199. /**
  28200. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28201. * A particle is in the frustum if its bounding box intersects the frustum
  28202. * @param frustumPlanes defines the frustum to test
  28203. * @returns true if the particle is in the frustum planes
  28204. */
  28205. isInFrustum(frustumPlanes: Plane[]): boolean;
  28206. /**
  28207. * get the rotation matrix of the particle
  28208. * @hidden
  28209. */
  28210. getRotationMatrix(m: Matrix): void;
  28211. }
  28212. /**
  28213. * Represents the shape of the model used by one particle of a solid particle system.
  28214. * SPS internal tool, don't use it manually.
  28215. */
  28216. export class ModelShape {
  28217. /**
  28218. * The shape id
  28219. * @hidden
  28220. */
  28221. shapeID: number;
  28222. /**
  28223. * flat array of model positions (internal use)
  28224. * @hidden
  28225. */
  28226. _shape: Vector3[];
  28227. /**
  28228. * flat array of model UVs (internal use)
  28229. * @hidden
  28230. */
  28231. _shapeUV: number[];
  28232. /**
  28233. * color array of the model
  28234. * @hidden
  28235. */
  28236. _shapeColors: number[];
  28237. /**
  28238. * indices array of the model
  28239. * @hidden
  28240. */
  28241. _indices: number[];
  28242. /**
  28243. * normals array of the model
  28244. * @hidden
  28245. */
  28246. _normals: number[];
  28247. /**
  28248. * length of the shape in the model indices array (internal use)
  28249. * @hidden
  28250. */
  28251. _indicesLength: number;
  28252. /**
  28253. * Custom position function (internal use)
  28254. * @hidden
  28255. */
  28256. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28257. /**
  28258. * Custom vertex function (internal use)
  28259. * @hidden
  28260. */
  28261. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28262. /**
  28263. * Model material (internal use)
  28264. * @hidden
  28265. */
  28266. _material: Nullable<Material>;
  28267. /**
  28268. * 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.
  28269. * SPS internal tool, don't use it manually.
  28270. * @hidden
  28271. */
  28272. 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>);
  28273. }
  28274. /**
  28275. * Represents a Depth Sorted Particle in the solid particle system.
  28276. * @hidden
  28277. */
  28278. export class DepthSortedParticle {
  28279. /**
  28280. * Index of the particle in the "indices" array
  28281. */
  28282. ind: number;
  28283. /**
  28284. * Length of the particle shape in the "indices" array
  28285. */
  28286. indicesLength: number;
  28287. /**
  28288. * Squared distance from the particle to the camera
  28289. */
  28290. sqDistance: number;
  28291. /**
  28292. * Material index when used with MultiMaterials
  28293. */
  28294. materialIndex: number;
  28295. /**
  28296. * Creates a new sorted particle
  28297. * @param materialIndex
  28298. */
  28299. constructor(ind: number, indLength: number, materialIndex: number);
  28300. }
  28301. }
  28302. declare module "babylonjs/Collisions/meshCollisionData" {
  28303. import { Collider } from "babylonjs/Collisions/collider";
  28304. import { Vector3 } from "babylonjs/Maths/math.vector";
  28305. import { Nullable } from "babylonjs/types";
  28306. import { Observer } from "babylonjs/Misc/observable";
  28307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28308. /**
  28309. * @hidden
  28310. */
  28311. export class _MeshCollisionData {
  28312. _checkCollisions: boolean;
  28313. _collisionMask: number;
  28314. _collisionGroup: number;
  28315. _collider: Nullable<Collider>;
  28316. _oldPositionForCollisions: Vector3;
  28317. _diffPositionForCollisions: Vector3;
  28318. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28319. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28320. }
  28321. }
  28322. declare module "babylonjs/Meshes/abstractMesh" {
  28323. import { Observable } from "babylonjs/Misc/observable";
  28324. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28325. import { Camera } from "babylonjs/Cameras/camera";
  28326. import { Scene, IDisposable } from "babylonjs/scene";
  28327. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28328. import { Node } from "babylonjs/node";
  28329. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28330. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28332. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28333. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28334. import { Material } from "babylonjs/Materials/material";
  28335. import { Light } from "babylonjs/Lights/light";
  28336. import { Skeleton } from "babylonjs/Bones/skeleton";
  28337. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28338. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28339. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28340. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28341. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28342. import { Plane } from "babylonjs/Maths/math.plane";
  28343. import { Ray } from "babylonjs/Culling/ray";
  28344. import { Collider } from "babylonjs/Collisions/collider";
  28345. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28346. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28347. /** @hidden */
  28348. class _FacetDataStorage {
  28349. facetPositions: Vector3[];
  28350. facetNormals: Vector3[];
  28351. facetPartitioning: number[][];
  28352. facetNb: number;
  28353. partitioningSubdivisions: number;
  28354. partitioningBBoxRatio: number;
  28355. facetDataEnabled: boolean;
  28356. facetParameters: any;
  28357. bbSize: Vector3;
  28358. subDiv: {
  28359. max: number;
  28360. X: number;
  28361. Y: number;
  28362. Z: number;
  28363. };
  28364. facetDepthSort: boolean;
  28365. facetDepthSortEnabled: boolean;
  28366. depthSortedIndices: IndicesArray;
  28367. depthSortedFacets: {
  28368. ind: number;
  28369. sqDistance: number;
  28370. }[];
  28371. facetDepthSortFunction: (f1: {
  28372. ind: number;
  28373. sqDistance: number;
  28374. }, f2: {
  28375. ind: number;
  28376. sqDistance: number;
  28377. }) => number;
  28378. facetDepthSortFrom: Vector3;
  28379. facetDepthSortOrigin: Vector3;
  28380. invertedMatrix: Matrix;
  28381. }
  28382. /**
  28383. * @hidden
  28384. **/
  28385. class _InternalAbstractMeshDataInfo {
  28386. _hasVertexAlpha: boolean;
  28387. _useVertexColors: boolean;
  28388. _numBoneInfluencers: number;
  28389. _applyFog: boolean;
  28390. _receiveShadows: boolean;
  28391. _facetData: _FacetDataStorage;
  28392. _visibility: number;
  28393. _skeleton: Nullable<Skeleton>;
  28394. _layerMask: number;
  28395. _computeBonesUsingShaders: boolean;
  28396. _isActive: boolean;
  28397. _onlyForInstances: boolean;
  28398. _isActiveIntermediate: boolean;
  28399. _onlyForInstancesIntermediate: boolean;
  28400. _actAsRegularMesh: boolean;
  28401. }
  28402. /**
  28403. * Class used to store all common mesh properties
  28404. */
  28405. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28406. /** No occlusion */
  28407. static OCCLUSION_TYPE_NONE: number;
  28408. /** Occlusion set to optimisitic */
  28409. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28410. /** Occlusion set to strict */
  28411. static OCCLUSION_TYPE_STRICT: number;
  28412. /** Use an accurante occlusion algorithm */
  28413. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28414. /** Use a conservative occlusion algorithm */
  28415. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28416. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28417. * Test order :
  28418. * Is the bounding sphere outside the frustum ?
  28419. * If not, are the bounding box vertices outside the frustum ?
  28420. * It not, then the cullable object is in the frustum.
  28421. */
  28422. static readonly CULLINGSTRATEGY_STANDARD: number;
  28423. /** Culling strategy : Bounding Sphere Only.
  28424. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28425. * It's also less accurate than the standard because some not visible objects can still be selected.
  28426. * Test : is the bounding sphere outside the frustum ?
  28427. * If not, then the cullable object is in the frustum.
  28428. */
  28429. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28430. /** Culling strategy : Optimistic Inclusion.
  28431. * This in an inclusion test first, then the standard exclusion test.
  28432. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28433. * 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.
  28434. * Anyway, it's as accurate as the standard strategy.
  28435. * Test :
  28436. * Is the cullable object bounding sphere center in the frustum ?
  28437. * If not, apply the default culling strategy.
  28438. */
  28439. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28440. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28441. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28442. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28443. * 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.
  28444. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28445. * Test :
  28446. * Is the cullable object bounding sphere center in the frustum ?
  28447. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28448. */
  28449. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28450. /**
  28451. * No billboard
  28452. */
  28453. static get BILLBOARDMODE_NONE(): number;
  28454. /** Billboard on X axis */
  28455. static get BILLBOARDMODE_X(): number;
  28456. /** Billboard on Y axis */
  28457. static get BILLBOARDMODE_Y(): number;
  28458. /** Billboard on Z axis */
  28459. static get BILLBOARDMODE_Z(): number;
  28460. /** Billboard on all axes */
  28461. static get BILLBOARDMODE_ALL(): number;
  28462. /** Billboard on using position instead of orientation */
  28463. static get BILLBOARDMODE_USE_POSITION(): number;
  28464. /** @hidden */
  28465. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28466. /**
  28467. * The culling strategy to use to check whether the mesh must be rendered or not.
  28468. * This value can be changed at any time and will be used on the next render mesh selection.
  28469. * The possible values are :
  28470. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28471. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28472. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28473. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28474. * Please read each static variable documentation to get details about the culling process.
  28475. * */
  28476. cullingStrategy: number;
  28477. /**
  28478. * Gets the number of facets in the mesh
  28479. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28480. */
  28481. get facetNb(): number;
  28482. /**
  28483. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28485. */
  28486. get partitioningSubdivisions(): number;
  28487. set partitioningSubdivisions(nb: number);
  28488. /**
  28489. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28490. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28491. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28492. */
  28493. get partitioningBBoxRatio(): number;
  28494. set partitioningBBoxRatio(ratio: number);
  28495. /**
  28496. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28497. * Works only for updatable meshes.
  28498. * Doesn't work with multi-materials
  28499. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28500. */
  28501. get mustDepthSortFacets(): boolean;
  28502. set mustDepthSortFacets(sort: boolean);
  28503. /**
  28504. * The location (Vector3) where the facet depth sort must be computed from.
  28505. * By default, the active camera position.
  28506. * Used only when facet depth sort is enabled
  28507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28508. */
  28509. get facetDepthSortFrom(): Vector3;
  28510. set facetDepthSortFrom(location: Vector3);
  28511. /**
  28512. * gets a boolean indicating if facetData is enabled
  28513. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28514. */
  28515. get isFacetDataEnabled(): boolean;
  28516. /** @hidden */
  28517. _updateNonUniformScalingState(value: boolean): boolean;
  28518. /**
  28519. * An event triggered when this mesh collides with another one
  28520. */
  28521. onCollideObservable: Observable<AbstractMesh>;
  28522. /** Set a function to call when this mesh collides with another one */
  28523. set onCollide(callback: () => void);
  28524. /**
  28525. * An event triggered when the collision's position changes
  28526. */
  28527. onCollisionPositionChangeObservable: Observable<Vector3>;
  28528. /** Set a function to call when the collision's position changes */
  28529. set onCollisionPositionChange(callback: () => void);
  28530. /**
  28531. * An event triggered when material is changed
  28532. */
  28533. onMaterialChangedObservable: Observable<AbstractMesh>;
  28534. /**
  28535. * Gets or sets the orientation for POV movement & rotation
  28536. */
  28537. definedFacingForward: boolean;
  28538. /** @hidden */
  28539. _occlusionQuery: Nullable<WebGLQuery>;
  28540. /** @hidden */
  28541. _renderingGroup: Nullable<RenderingGroup>;
  28542. /**
  28543. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28544. */
  28545. get visibility(): number;
  28546. /**
  28547. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28548. */
  28549. set visibility(value: number);
  28550. /** Gets or sets the alpha index used to sort transparent meshes
  28551. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28552. */
  28553. alphaIndex: number;
  28554. /**
  28555. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28556. */
  28557. isVisible: boolean;
  28558. /**
  28559. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28560. */
  28561. isPickable: boolean;
  28562. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28563. showSubMeshesBoundingBox: boolean;
  28564. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28565. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28566. */
  28567. isBlocker: boolean;
  28568. /**
  28569. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28570. */
  28571. enablePointerMoveEvents: boolean;
  28572. /**
  28573. * Specifies the rendering group id for this mesh (0 by default)
  28574. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28575. */
  28576. renderingGroupId: number;
  28577. private _material;
  28578. /** Gets or sets current material */
  28579. get material(): Nullable<Material>;
  28580. set material(value: Nullable<Material>);
  28581. /**
  28582. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28583. * @see http://doc.babylonjs.com/babylon101/shadows
  28584. */
  28585. get receiveShadows(): boolean;
  28586. set receiveShadows(value: boolean);
  28587. /** Defines color to use when rendering outline */
  28588. outlineColor: Color3;
  28589. /** Define width to use when rendering outline */
  28590. outlineWidth: number;
  28591. /** Defines color to use when rendering overlay */
  28592. overlayColor: Color3;
  28593. /** Defines alpha to use when rendering overlay */
  28594. overlayAlpha: number;
  28595. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28596. get hasVertexAlpha(): boolean;
  28597. set hasVertexAlpha(value: boolean);
  28598. /** 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) */
  28599. get useVertexColors(): boolean;
  28600. set useVertexColors(value: boolean);
  28601. /**
  28602. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28603. */
  28604. get computeBonesUsingShaders(): boolean;
  28605. set computeBonesUsingShaders(value: boolean);
  28606. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28607. get numBoneInfluencers(): number;
  28608. set numBoneInfluencers(value: number);
  28609. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28610. get applyFog(): boolean;
  28611. set applyFog(value: boolean);
  28612. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28613. useOctreeForRenderingSelection: boolean;
  28614. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28615. useOctreeForPicking: boolean;
  28616. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28617. useOctreeForCollisions: boolean;
  28618. /**
  28619. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28620. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28621. */
  28622. get layerMask(): number;
  28623. set layerMask(value: number);
  28624. /**
  28625. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28626. */
  28627. alwaysSelectAsActiveMesh: boolean;
  28628. /**
  28629. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28630. */
  28631. doNotSyncBoundingInfo: boolean;
  28632. /**
  28633. * Gets or sets the current action manager
  28634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28635. */
  28636. actionManager: Nullable<AbstractActionManager>;
  28637. private _meshCollisionData;
  28638. /**
  28639. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28640. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28641. */
  28642. ellipsoid: Vector3;
  28643. /**
  28644. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28645. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28646. */
  28647. ellipsoidOffset: Vector3;
  28648. /**
  28649. * Gets or sets a collision mask used to mask collisions (default is -1).
  28650. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28651. */
  28652. get collisionMask(): number;
  28653. set collisionMask(mask: number);
  28654. /**
  28655. * Gets or sets the current collision group mask (-1 by default).
  28656. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28657. */
  28658. get collisionGroup(): number;
  28659. set collisionGroup(mask: number);
  28660. /**
  28661. * Defines edge width used when edgesRenderer is enabled
  28662. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28663. */
  28664. edgesWidth: number;
  28665. /**
  28666. * Defines edge color used when edgesRenderer is enabled
  28667. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28668. */
  28669. edgesColor: Color4;
  28670. /** @hidden */
  28671. _edgesRenderer: Nullable<IEdgesRenderer>;
  28672. /** @hidden */
  28673. _masterMesh: Nullable<AbstractMesh>;
  28674. /** @hidden */
  28675. _boundingInfo: Nullable<BoundingInfo>;
  28676. /** @hidden */
  28677. _renderId: number;
  28678. /**
  28679. * Gets or sets the list of subMeshes
  28680. * @see http://doc.babylonjs.com/how_to/multi_materials
  28681. */
  28682. subMeshes: SubMesh[];
  28683. /** @hidden */
  28684. _intersectionsInProgress: AbstractMesh[];
  28685. /** @hidden */
  28686. _unIndexed: boolean;
  28687. /** @hidden */
  28688. _lightSources: Light[];
  28689. /** Gets the list of lights affecting that mesh */
  28690. get lightSources(): Light[];
  28691. /** @hidden */
  28692. get _positions(): Nullable<Vector3[]>;
  28693. /** @hidden */
  28694. _waitingData: {
  28695. lods: Nullable<any>;
  28696. actions: Nullable<any>;
  28697. freezeWorldMatrix: Nullable<boolean>;
  28698. };
  28699. /** @hidden */
  28700. _bonesTransformMatrices: Nullable<Float32Array>;
  28701. /** @hidden */
  28702. _transformMatrixTexture: Nullable<RawTexture>;
  28703. /**
  28704. * Gets or sets a skeleton to apply skining transformations
  28705. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28706. */
  28707. set skeleton(value: Nullable<Skeleton>);
  28708. get skeleton(): Nullable<Skeleton>;
  28709. /**
  28710. * An event triggered when the mesh is rebuilt.
  28711. */
  28712. onRebuildObservable: Observable<AbstractMesh>;
  28713. /**
  28714. * Creates a new AbstractMesh
  28715. * @param name defines the name of the mesh
  28716. * @param scene defines the hosting scene
  28717. */
  28718. constructor(name: string, scene?: Nullable<Scene>);
  28719. /**
  28720. * Returns the string "AbstractMesh"
  28721. * @returns "AbstractMesh"
  28722. */
  28723. getClassName(): string;
  28724. /**
  28725. * Gets a string representation of the current mesh
  28726. * @param fullDetails defines a boolean indicating if full details must be included
  28727. * @returns a string representation of the current mesh
  28728. */
  28729. toString(fullDetails?: boolean): string;
  28730. /**
  28731. * @hidden
  28732. */
  28733. protected _getEffectiveParent(): Nullable<Node>;
  28734. /** @hidden */
  28735. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28736. /** @hidden */
  28737. _rebuild(): void;
  28738. /** @hidden */
  28739. _resyncLightSources(): void;
  28740. /** @hidden */
  28741. _resyncLightSource(light: Light): void;
  28742. /** @hidden */
  28743. _unBindEffect(): void;
  28744. /** @hidden */
  28745. _removeLightSource(light: Light, dispose: boolean): void;
  28746. private _markSubMeshesAsDirty;
  28747. /** @hidden */
  28748. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28749. /** @hidden */
  28750. _markSubMeshesAsAttributesDirty(): void;
  28751. /** @hidden */
  28752. _markSubMeshesAsMiscDirty(): void;
  28753. /**
  28754. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28755. */
  28756. get scaling(): Vector3;
  28757. set scaling(newScaling: Vector3);
  28758. /**
  28759. * Returns true if the mesh is blocked. Implemented by child classes
  28760. */
  28761. get isBlocked(): boolean;
  28762. /**
  28763. * Returns the mesh itself by default. Implemented by child classes
  28764. * @param camera defines the camera to use to pick the right LOD level
  28765. * @returns the currentAbstractMesh
  28766. */
  28767. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28768. /**
  28769. * Returns 0 by default. Implemented by child classes
  28770. * @returns an integer
  28771. */
  28772. getTotalVertices(): number;
  28773. /**
  28774. * Returns a positive integer : the total number of indices in this mesh geometry.
  28775. * @returns the numner of indices or zero if the mesh has no geometry.
  28776. */
  28777. getTotalIndices(): number;
  28778. /**
  28779. * Returns null by default. Implemented by child classes
  28780. * @returns null
  28781. */
  28782. getIndices(): Nullable<IndicesArray>;
  28783. /**
  28784. * Returns the array of the requested vertex data kind. Implemented by child classes
  28785. * @param kind defines the vertex data kind to use
  28786. * @returns null
  28787. */
  28788. getVerticesData(kind: string): Nullable<FloatArray>;
  28789. /**
  28790. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28791. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28792. * Note that a new underlying VertexBuffer object is created each call.
  28793. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28794. * @param kind defines vertex data kind:
  28795. * * VertexBuffer.PositionKind
  28796. * * VertexBuffer.UVKind
  28797. * * VertexBuffer.UV2Kind
  28798. * * VertexBuffer.UV3Kind
  28799. * * VertexBuffer.UV4Kind
  28800. * * VertexBuffer.UV5Kind
  28801. * * VertexBuffer.UV6Kind
  28802. * * VertexBuffer.ColorKind
  28803. * * VertexBuffer.MatricesIndicesKind
  28804. * * VertexBuffer.MatricesIndicesExtraKind
  28805. * * VertexBuffer.MatricesWeightsKind
  28806. * * VertexBuffer.MatricesWeightsExtraKind
  28807. * @param data defines the data source
  28808. * @param updatable defines if the data must be flagged as updatable (or static)
  28809. * @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
  28810. * @returns the current mesh
  28811. */
  28812. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28813. /**
  28814. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28815. * If the mesh has no geometry, it is simply returned as it is.
  28816. * @param kind defines vertex data kind:
  28817. * * VertexBuffer.PositionKind
  28818. * * VertexBuffer.UVKind
  28819. * * VertexBuffer.UV2Kind
  28820. * * VertexBuffer.UV3Kind
  28821. * * VertexBuffer.UV4Kind
  28822. * * VertexBuffer.UV5Kind
  28823. * * VertexBuffer.UV6Kind
  28824. * * VertexBuffer.ColorKind
  28825. * * VertexBuffer.MatricesIndicesKind
  28826. * * VertexBuffer.MatricesIndicesExtraKind
  28827. * * VertexBuffer.MatricesWeightsKind
  28828. * * VertexBuffer.MatricesWeightsExtraKind
  28829. * @param data defines the data source
  28830. * @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
  28831. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28832. * @returns the current mesh
  28833. */
  28834. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28835. /**
  28836. * Sets the mesh indices,
  28837. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28838. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28839. * @param totalVertices Defines the total number of vertices
  28840. * @returns the current mesh
  28841. */
  28842. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28843. /**
  28844. * Gets a boolean indicating if specific vertex data is present
  28845. * @param kind defines the vertex data kind to use
  28846. * @returns true is data kind is present
  28847. */
  28848. isVerticesDataPresent(kind: string): boolean;
  28849. /**
  28850. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28851. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28852. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28853. * @returns a BoundingInfo
  28854. */
  28855. getBoundingInfo(): BoundingInfo;
  28856. /**
  28857. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28858. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28859. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28860. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28861. * @returns the current mesh
  28862. */
  28863. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28864. /**
  28865. * Overwrite the current bounding info
  28866. * @param boundingInfo defines the new bounding info
  28867. * @returns the current mesh
  28868. */
  28869. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28870. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28871. get useBones(): boolean;
  28872. /** @hidden */
  28873. _preActivate(): void;
  28874. /** @hidden */
  28875. _preActivateForIntermediateRendering(renderId: number): void;
  28876. /** @hidden */
  28877. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28878. /** @hidden */
  28879. _postActivate(): void;
  28880. /** @hidden */
  28881. _freeze(): void;
  28882. /** @hidden */
  28883. _unFreeze(): void;
  28884. /**
  28885. * Gets the current world matrix
  28886. * @returns a Matrix
  28887. */
  28888. getWorldMatrix(): Matrix;
  28889. /** @hidden */
  28890. _getWorldMatrixDeterminant(): number;
  28891. /**
  28892. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28893. */
  28894. get isAnInstance(): boolean;
  28895. /**
  28896. * Gets a boolean indicating if this mesh has instances
  28897. */
  28898. get hasInstances(): boolean;
  28899. /**
  28900. * Perform relative position change from the point of view of behind the front of the mesh.
  28901. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28902. * Supports definition of mesh facing forward or backward
  28903. * @param amountRight defines the distance on the right axis
  28904. * @param amountUp defines the distance on the up axis
  28905. * @param amountForward defines the distance on the forward axis
  28906. * @returns the current mesh
  28907. */
  28908. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28909. /**
  28910. * Calculate relative position change from the point of view of behind the front of the mesh.
  28911. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28912. * Supports definition of mesh facing forward or backward
  28913. * @param amountRight defines the distance on the right axis
  28914. * @param amountUp defines the distance on the up axis
  28915. * @param amountForward defines the distance on the forward axis
  28916. * @returns the new displacement vector
  28917. */
  28918. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28919. /**
  28920. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28921. * Supports definition of mesh facing forward or backward
  28922. * @param flipBack defines the flip
  28923. * @param twirlClockwise defines the twirl
  28924. * @param tiltRight defines the tilt
  28925. * @returns the current mesh
  28926. */
  28927. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28928. /**
  28929. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28930. * Supports definition of mesh facing forward or backward.
  28931. * @param flipBack defines the flip
  28932. * @param twirlClockwise defines the twirl
  28933. * @param tiltRight defines the tilt
  28934. * @returns the new rotation vector
  28935. */
  28936. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28937. /**
  28938. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28939. * This means the mesh underlying bounding box and sphere are recomputed.
  28940. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28941. * @returns the current mesh
  28942. */
  28943. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28944. /** @hidden */
  28945. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28946. /** @hidden */
  28947. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28948. /** @hidden */
  28949. _updateBoundingInfo(): AbstractMesh;
  28950. /** @hidden */
  28951. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28952. /** @hidden */
  28953. protected _afterComputeWorldMatrix(): void;
  28954. /** @hidden */
  28955. get _effectiveMesh(): AbstractMesh;
  28956. /**
  28957. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28958. * A mesh is in the frustum if its bounding box intersects the frustum
  28959. * @param frustumPlanes defines the frustum to test
  28960. * @returns true if the mesh is in the frustum planes
  28961. */
  28962. isInFrustum(frustumPlanes: Plane[]): boolean;
  28963. /**
  28964. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28965. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28966. * @param frustumPlanes defines the frustum to test
  28967. * @returns true if the mesh is completely in the frustum planes
  28968. */
  28969. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28970. /**
  28971. * True if the mesh intersects another mesh or a SolidParticle object
  28972. * @param mesh defines a target mesh or SolidParticle to test
  28973. * @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)
  28974. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28975. * @returns true if there is an intersection
  28976. */
  28977. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28978. /**
  28979. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28980. * @param point defines the point to test
  28981. * @returns true if there is an intersection
  28982. */
  28983. intersectsPoint(point: Vector3): boolean;
  28984. /**
  28985. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28987. */
  28988. get checkCollisions(): boolean;
  28989. set checkCollisions(collisionEnabled: boolean);
  28990. /**
  28991. * Gets Collider object used to compute collisions (not physics)
  28992. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28993. */
  28994. get collider(): Nullable<Collider>;
  28995. /**
  28996. * Move the mesh using collision engine
  28997. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28998. * @param displacement defines the requested displacement vector
  28999. * @returns the current mesh
  29000. */
  29001. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29002. private _onCollisionPositionChange;
  29003. /** @hidden */
  29004. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29005. /** @hidden */
  29006. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29007. /** @hidden */
  29008. _checkCollision(collider: Collider): AbstractMesh;
  29009. /** @hidden */
  29010. _generatePointsArray(): boolean;
  29011. /**
  29012. * Checks if the passed Ray intersects with the mesh
  29013. * @param ray defines the ray to use
  29014. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29015. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29016. * @returns the picking info
  29017. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29018. */
  29019. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29020. /**
  29021. * Clones the current mesh
  29022. * @param name defines the mesh name
  29023. * @param newParent defines the new mesh parent
  29024. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29025. * @returns the new mesh
  29026. */
  29027. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29028. /**
  29029. * Disposes all the submeshes of the current meshnp
  29030. * @returns the current mesh
  29031. */
  29032. releaseSubMeshes(): AbstractMesh;
  29033. /**
  29034. * Releases resources associated with this abstract mesh.
  29035. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29036. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29037. */
  29038. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29039. /**
  29040. * Adds the passed mesh as a child to the current mesh
  29041. * @param mesh defines the child mesh
  29042. * @returns the current mesh
  29043. */
  29044. addChild(mesh: AbstractMesh): AbstractMesh;
  29045. /**
  29046. * Removes the passed mesh from the current mesh children list
  29047. * @param mesh defines the child mesh
  29048. * @returns the current mesh
  29049. */
  29050. removeChild(mesh: AbstractMesh): AbstractMesh;
  29051. /** @hidden */
  29052. private _initFacetData;
  29053. /**
  29054. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29055. * This method can be called within the render loop.
  29056. * 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
  29057. * @returns the current mesh
  29058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29059. */
  29060. updateFacetData(): AbstractMesh;
  29061. /**
  29062. * Returns the facetLocalNormals array.
  29063. * The normals are expressed in the mesh local spac
  29064. * @returns an array of Vector3
  29065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29066. */
  29067. getFacetLocalNormals(): Vector3[];
  29068. /**
  29069. * Returns the facetLocalPositions array.
  29070. * The facet positions are expressed in the mesh local space
  29071. * @returns an array of Vector3
  29072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29073. */
  29074. getFacetLocalPositions(): Vector3[];
  29075. /**
  29076. * Returns the facetLocalPartioning array
  29077. * @returns an array of array of numbers
  29078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29079. */
  29080. getFacetLocalPartitioning(): number[][];
  29081. /**
  29082. * Returns the i-th facet position in the world system.
  29083. * This method allocates a new Vector3 per call
  29084. * @param i defines the facet index
  29085. * @returns a new Vector3
  29086. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29087. */
  29088. getFacetPosition(i: number): Vector3;
  29089. /**
  29090. * Sets the reference Vector3 with the i-th facet position in the world system
  29091. * @param i defines the facet index
  29092. * @param ref defines the target vector
  29093. * @returns the current mesh
  29094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29095. */
  29096. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29097. /**
  29098. * Returns the i-th facet normal in the world system.
  29099. * This method allocates a new Vector3 per call
  29100. * @param i defines the facet index
  29101. * @returns a new Vector3
  29102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29103. */
  29104. getFacetNormal(i: number): Vector3;
  29105. /**
  29106. * Sets the reference Vector3 with the i-th facet normal in the world system
  29107. * @param i defines the facet index
  29108. * @param ref defines the target vector
  29109. * @returns the current mesh
  29110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29111. */
  29112. getFacetNormalToRef(i: number, ref: Vector3): this;
  29113. /**
  29114. * 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)
  29115. * @param x defines x coordinate
  29116. * @param y defines y coordinate
  29117. * @param z defines z coordinate
  29118. * @returns the array of facet indexes
  29119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29120. */
  29121. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29122. /**
  29123. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29124. * @param projected sets as the (x,y,z) world projection on the facet
  29125. * @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
  29126. * @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
  29127. * @param x defines x coordinate
  29128. * @param y defines y coordinate
  29129. * @param z defines z coordinate
  29130. * @returns the face index if found (or null instead)
  29131. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29132. */
  29133. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29134. /**
  29135. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29136. * @param projected sets as the (x,y,z) local projection on the facet
  29137. * @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
  29138. * @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
  29139. * @param x defines x coordinate
  29140. * @param y defines y coordinate
  29141. * @param z defines z coordinate
  29142. * @returns the face index if found (or null instead)
  29143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29144. */
  29145. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29146. /**
  29147. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29148. * @returns the parameters
  29149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29150. */
  29151. getFacetDataParameters(): any;
  29152. /**
  29153. * Disables the feature FacetData and frees the related memory
  29154. * @returns the current mesh
  29155. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29156. */
  29157. disableFacetData(): AbstractMesh;
  29158. /**
  29159. * Updates the AbstractMesh indices array
  29160. * @param indices defines the data source
  29161. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29162. * @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)
  29163. * @returns the current mesh
  29164. */
  29165. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29166. /**
  29167. * Creates new normals data for the mesh
  29168. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29169. * @returns the current mesh
  29170. */
  29171. createNormals(updatable: boolean): AbstractMesh;
  29172. /**
  29173. * Align the mesh with a normal
  29174. * @param normal defines the normal to use
  29175. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29176. * @returns the current mesh
  29177. */
  29178. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29179. /** @hidden */
  29180. _checkOcclusionQuery(): boolean;
  29181. /**
  29182. * Disables the mesh edge rendering mode
  29183. * @returns the currentAbstractMesh
  29184. */
  29185. disableEdgesRendering(): AbstractMesh;
  29186. /**
  29187. * Enables the edge rendering mode on the mesh.
  29188. * This mode makes the mesh edges visible
  29189. * @param epsilon defines the maximal distance between two angles to detect a face
  29190. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29191. * @returns the currentAbstractMesh
  29192. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29193. */
  29194. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29195. }
  29196. }
  29197. declare module "babylonjs/Actions/actionEvent" {
  29198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29199. import { Nullable } from "babylonjs/types";
  29200. import { Sprite } from "babylonjs/Sprites/sprite";
  29201. import { Scene } from "babylonjs/scene";
  29202. import { Vector2 } from "babylonjs/Maths/math.vector";
  29203. /**
  29204. * Interface used to define ActionEvent
  29205. */
  29206. export interface IActionEvent {
  29207. /** The mesh or sprite that triggered the action */
  29208. source: any;
  29209. /** The X mouse cursor position at the time of the event */
  29210. pointerX: number;
  29211. /** The Y mouse cursor position at the time of the event */
  29212. pointerY: number;
  29213. /** The mesh that is currently pointed at (can be null) */
  29214. meshUnderPointer: Nullable<AbstractMesh>;
  29215. /** the original (browser) event that triggered the ActionEvent */
  29216. sourceEvent?: any;
  29217. /** additional data for the event */
  29218. additionalData?: any;
  29219. }
  29220. /**
  29221. * ActionEvent is the event being sent when an action is triggered.
  29222. */
  29223. export class ActionEvent implements IActionEvent {
  29224. /** The mesh or sprite that triggered the action */
  29225. source: any;
  29226. /** The X mouse cursor position at the time of the event */
  29227. pointerX: number;
  29228. /** The Y mouse cursor position at the time of the event */
  29229. pointerY: number;
  29230. /** The mesh that is currently pointed at (can be null) */
  29231. meshUnderPointer: Nullable<AbstractMesh>;
  29232. /** the original (browser) event that triggered the ActionEvent */
  29233. sourceEvent?: any;
  29234. /** additional data for the event */
  29235. additionalData?: any;
  29236. /**
  29237. * Creates a new ActionEvent
  29238. * @param source The mesh or sprite that triggered the action
  29239. * @param pointerX The X mouse cursor position at the time of the event
  29240. * @param pointerY The Y mouse cursor position at the time of the event
  29241. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29242. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29243. * @param additionalData additional data for the event
  29244. */
  29245. constructor(
  29246. /** The mesh or sprite that triggered the action */
  29247. source: any,
  29248. /** The X mouse cursor position at the time of the event */
  29249. pointerX: number,
  29250. /** The Y mouse cursor position at the time of the event */
  29251. pointerY: number,
  29252. /** The mesh that is currently pointed at (can be null) */
  29253. meshUnderPointer: Nullable<AbstractMesh>,
  29254. /** the original (browser) event that triggered the ActionEvent */
  29255. sourceEvent?: any,
  29256. /** additional data for the event */
  29257. additionalData?: any);
  29258. /**
  29259. * Helper function to auto-create an ActionEvent from a source mesh.
  29260. * @param source The source mesh that triggered the event
  29261. * @param evt The original (browser) event
  29262. * @param additionalData additional data for the event
  29263. * @returns the new ActionEvent
  29264. */
  29265. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29266. /**
  29267. * Helper function to auto-create an ActionEvent from a source sprite
  29268. * @param source The source sprite that triggered the event
  29269. * @param scene Scene associated with the sprite
  29270. * @param evt The original (browser) event
  29271. * @param additionalData additional data for the event
  29272. * @returns the new ActionEvent
  29273. */
  29274. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29275. /**
  29276. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29277. * @param scene the scene where the event occurred
  29278. * @param evt The original (browser) event
  29279. * @returns the new ActionEvent
  29280. */
  29281. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29282. /**
  29283. * Helper function to auto-create an ActionEvent from a primitive
  29284. * @param prim defines the target primitive
  29285. * @param pointerPos defines the pointer position
  29286. * @param evt The original (browser) event
  29287. * @param additionalData additional data for the event
  29288. * @returns the new ActionEvent
  29289. */
  29290. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29291. }
  29292. }
  29293. declare module "babylonjs/Actions/abstractActionManager" {
  29294. import { IDisposable } from "babylonjs/scene";
  29295. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29296. import { IAction } from "babylonjs/Actions/action";
  29297. import { Nullable } from "babylonjs/types";
  29298. /**
  29299. * Abstract class used to decouple action Manager from scene and meshes.
  29300. * Do not instantiate.
  29301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29302. */
  29303. export abstract class AbstractActionManager implements IDisposable {
  29304. /** Gets the list of active triggers */
  29305. static Triggers: {
  29306. [key: string]: number;
  29307. };
  29308. /** Gets the cursor to use when hovering items */
  29309. hoverCursor: string;
  29310. /** Gets the list of actions */
  29311. actions: IAction[];
  29312. /**
  29313. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29314. */
  29315. isRecursive: boolean;
  29316. /**
  29317. * Releases all associated resources
  29318. */
  29319. abstract dispose(): void;
  29320. /**
  29321. * Does this action manager has pointer triggers
  29322. */
  29323. abstract get hasPointerTriggers(): boolean;
  29324. /**
  29325. * Does this action manager has pick triggers
  29326. */
  29327. abstract get hasPickTriggers(): boolean;
  29328. /**
  29329. * Process a specific trigger
  29330. * @param trigger defines the trigger to process
  29331. * @param evt defines the event details to be processed
  29332. */
  29333. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29334. /**
  29335. * Does this action manager handles actions of any of the given triggers
  29336. * @param triggers defines the triggers to be tested
  29337. * @return a boolean indicating whether one (or more) of the triggers is handled
  29338. */
  29339. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29340. /**
  29341. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29342. * speed.
  29343. * @param triggerA defines the trigger to be tested
  29344. * @param triggerB defines the trigger to be tested
  29345. * @return a boolean indicating whether one (or more) of the triggers is handled
  29346. */
  29347. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29348. /**
  29349. * Does this action manager handles actions of a given trigger
  29350. * @param trigger defines the trigger to be tested
  29351. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29352. * @return whether the trigger is handled
  29353. */
  29354. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29355. /**
  29356. * Serialize this manager to a JSON object
  29357. * @param name defines the property name to store this manager
  29358. * @returns a JSON representation of this manager
  29359. */
  29360. abstract serialize(name: string): any;
  29361. /**
  29362. * Registers an action to this action manager
  29363. * @param action defines the action to be registered
  29364. * @return the action amended (prepared) after registration
  29365. */
  29366. abstract registerAction(action: IAction): Nullable<IAction>;
  29367. /**
  29368. * Unregisters an action to this action manager
  29369. * @param action defines the action to be unregistered
  29370. * @return a boolean indicating whether the action has been unregistered
  29371. */
  29372. abstract unregisterAction(action: IAction): Boolean;
  29373. /**
  29374. * Does exist one action manager with at least one trigger
  29375. **/
  29376. static get HasTriggers(): boolean;
  29377. /**
  29378. * Does exist one action manager with at least one pick trigger
  29379. **/
  29380. static get HasPickTriggers(): boolean;
  29381. /**
  29382. * Does exist one action manager that handles actions of a given trigger
  29383. * @param trigger defines the trigger to be tested
  29384. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29385. **/
  29386. static HasSpecificTrigger(trigger: number): boolean;
  29387. }
  29388. }
  29389. declare module "babylonjs/node" {
  29390. import { Scene } from "babylonjs/scene";
  29391. import { Nullable } from "babylonjs/types";
  29392. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29393. import { Engine } from "babylonjs/Engines/engine";
  29394. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29395. import { Observable } from "babylonjs/Misc/observable";
  29396. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29397. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29398. import { Animatable } from "babylonjs/Animations/animatable";
  29399. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29400. import { Animation } from "babylonjs/Animations/animation";
  29401. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29403. /**
  29404. * Defines how a node can be built from a string name.
  29405. */
  29406. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29407. /**
  29408. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29409. */
  29410. export class Node implements IBehaviorAware<Node> {
  29411. /** @hidden */
  29412. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29413. private static _NodeConstructors;
  29414. /**
  29415. * Add a new node constructor
  29416. * @param type defines the type name of the node to construct
  29417. * @param constructorFunc defines the constructor function
  29418. */
  29419. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29420. /**
  29421. * Returns a node constructor based on type name
  29422. * @param type defines the type name
  29423. * @param name defines the new node name
  29424. * @param scene defines the hosting scene
  29425. * @param options defines optional options to transmit to constructors
  29426. * @returns the new constructor or null
  29427. */
  29428. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29429. /**
  29430. * Gets or sets the name of the node
  29431. */
  29432. name: string;
  29433. /**
  29434. * Gets or sets the id of the node
  29435. */
  29436. id: string;
  29437. /**
  29438. * Gets or sets the unique id of the node
  29439. */
  29440. uniqueId: number;
  29441. /**
  29442. * Gets or sets a string used to store user defined state for the node
  29443. */
  29444. state: string;
  29445. /**
  29446. * Gets or sets an object used to store user defined information for the node
  29447. */
  29448. metadata: any;
  29449. /**
  29450. * For internal use only. Please do not use.
  29451. */
  29452. reservedDataStore: any;
  29453. /**
  29454. * List of inspectable custom properties (used by the Inspector)
  29455. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29456. */
  29457. inspectableCustomProperties: IInspectable[];
  29458. private _doNotSerialize;
  29459. /**
  29460. * Gets or sets a boolean used to define if the node must be serialized
  29461. */
  29462. get doNotSerialize(): boolean;
  29463. set doNotSerialize(value: boolean);
  29464. /** @hidden */
  29465. _isDisposed: boolean;
  29466. /**
  29467. * Gets a list of Animations associated with the node
  29468. */
  29469. animations: import("babylonjs/Animations/animation").Animation[];
  29470. protected _ranges: {
  29471. [name: string]: Nullable<AnimationRange>;
  29472. };
  29473. /**
  29474. * Callback raised when the node is ready to be used
  29475. */
  29476. onReady: Nullable<(node: Node) => void>;
  29477. private _isEnabled;
  29478. private _isParentEnabled;
  29479. private _isReady;
  29480. /** @hidden */
  29481. _currentRenderId: number;
  29482. private _parentUpdateId;
  29483. /** @hidden */
  29484. _childUpdateId: number;
  29485. /** @hidden */
  29486. _waitingParentId: Nullable<string>;
  29487. /** @hidden */
  29488. _scene: Scene;
  29489. /** @hidden */
  29490. _cache: any;
  29491. private _parentNode;
  29492. private _children;
  29493. /** @hidden */
  29494. _worldMatrix: Matrix;
  29495. /** @hidden */
  29496. _worldMatrixDeterminant: number;
  29497. /** @hidden */
  29498. _worldMatrixDeterminantIsDirty: boolean;
  29499. /** @hidden */
  29500. private _sceneRootNodesIndex;
  29501. /**
  29502. * Gets a boolean indicating if the node has been disposed
  29503. * @returns true if the node was disposed
  29504. */
  29505. isDisposed(): boolean;
  29506. /**
  29507. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29508. * @see https://doc.babylonjs.com/how_to/parenting
  29509. */
  29510. set parent(parent: Nullable<Node>);
  29511. get parent(): Nullable<Node>;
  29512. /** @hidden */
  29513. _addToSceneRootNodes(): void;
  29514. /** @hidden */
  29515. _removeFromSceneRootNodes(): void;
  29516. private _animationPropertiesOverride;
  29517. /**
  29518. * Gets or sets the animation properties override
  29519. */
  29520. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29521. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29522. /**
  29523. * Gets a string idenfifying the name of the class
  29524. * @returns "Node" string
  29525. */
  29526. getClassName(): string;
  29527. /** @hidden */
  29528. readonly _isNode: boolean;
  29529. /**
  29530. * An event triggered when the mesh is disposed
  29531. */
  29532. onDisposeObservable: Observable<Node>;
  29533. private _onDisposeObserver;
  29534. /**
  29535. * Sets a callback that will be raised when the node will be disposed
  29536. */
  29537. set onDispose(callback: () => void);
  29538. /**
  29539. * Creates a new Node
  29540. * @param name the name and id to be given to this node
  29541. * @param scene the scene this node will be added to
  29542. */
  29543. constructor(name: string, scene?: Nullable<Scene>);
  29544. /**
  29545. * Gets the scene of the node
  29546. * @returns a scene
  29547. */
  29548. getScene(): Scene;
  29549. /**
  29550. * Gets the engine of the node
  29551. * @returns a Engine
  29552. */
  29553. getEngine(): Engine;
  29554. private _behaviors;
  29555. /**
  29556. * Attach a behavior to the node
  29557. * @see http://doc.babylonjs.com/features/behaviour
  29558. * @param behavior defines the behavior to attach
  29559. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29560. * @returns the current Node
  29561. */
  29562. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29563. /**
  29564. * Remove an attached behavior
  29565. * @see http://doc.babylonjs.com/features/behaviour
  29566. * @param behavior defines the behavior to attach
  29567. * @returns the current Node
  29568. */
  29569. removeBehavior(behavior: Behavior<Node>): Node;
  29570. /**
  29571. * Gets the list of attached behaviors
  29572. * @see http://doc.babylonjs.com/features/behaviour
  29573. */
  29574. get behaviors(): Behavior<Node>[];
  29575. /**
  29576. * Gets an attached behavior by name
  29577. * @param name defines the name of the behavior to look for
  29578. * @see http://doc.babylonjs.com/features/behaviour
  29579. * @returns null if behavior was not found else the requested behavior
  29580. */
  29581. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29582. /**
  29583. * Returns the latest update of the World matrix
  29584. * @returns a Matrix
  29585. */
  29586. getWorldMatrix(): Matrix;
  29587. /** @hidden */
  29588. _getWorldMatrixDeterminant(): number;
  29589. /**
  29590. * Returns directly the latest state of the mesh World matrix.
  29591. * A Matrix is returned.
  29592. */
  29593. get worldMatrixFromCache(): Matrix;
  29594. /** @hidden */
  29595. _initCache(): void;
  29596. /** @hidden */
  29597. updateCache(force?: boolean): void;
  29598. /** @hidden */
  29599. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29600. /** @hidden */
  29601. _updateCache(ignoreParentClass?: boolean): void;
  29602. /** @hidden */
  29603. _isSynchronized(): boolean;
  29604. /** @hidden */
  29605. _markSyncedWithParent(): void;
  29606. /** @hidden */
  29607. isSynchronizedWithParent(): boolean;
  29608. /** @hidden */
  29609. isSynchronized(): boolean;
  29610. /**
  29611. * Is this node ready to be used/rendered
  29612. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29613. * @return true if the node is ready
  29614. */
  29615. isReady(completeCheck?: boolean): boolean;
  29616. /**
  29617. * Is this node enabled?
  29618. * 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
  29619. * @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
  29620. * @return whether this node (and its parent) is enabled
  29621. */
  29622. isEnabled(checkAncestors?: boolean): boolean;
  29623. /** @hidden */
  29624. protected _syncParentEnabledState(): void;
  29625. /**
  29626. * Set the enabled state of this node
  29627. * @param value defines the new enabled state
  29628. */
  29629. setEnabled(value: boolean): void;
  29630. /**
  29631. * Is this node a descendant of the given node?
  29632. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29633. * @param ancestor defines the parent node to inspect
  29634. * @returns a boolean indicating if this node is a descendant of the given node
  29635. */
  29636. isDescendantOf(ancestor: Node): boolean;
  29637. /** @hidden */
  29638. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29639. /**
  29640. * Will return all nodes that have this node as ascendant
  29641. * @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
  29642. * @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
  29643. * @return all children nodes of all types
  29644. */
  29645. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29646. /**
  29647. * Get all child-meshes of this node
  29648. * @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)
  29649. * @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
  29650. * @returns an array of AbstractMesh
  29651. */
  29652. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29653. /**
  29654. * Get all direct children of this node
  29655. * @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
  29656. * @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)
  29657. * @returns an array of Node
  29658. */
  29659. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29660. /** @hidden */
  29661. _setReady(state: boolean): void;
  29662. /**
  29663. * Get an animation by name
  29664. * @param name defines the name of the animation to look for
  29665. * @returns null if not found else the requested animation
  29666. */
  29667. getAnimationByName(name: string): Nullable<Animation>;
  29668. /**
  29669. * Creates an animation range for this node
  29670. * @param name defines the name of the range
  29671. * @param from defines the starting key
  29672. * @param to defines the end key
  29673. */
  29674. createAnimationRange(name: string, from: number, to: number): void;
  29675. /**
  29676. * Delete a specific animation range
  29677. * @param name defines the name of the range to delete
  29678. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29679. */
  29680. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29681. /**
  29682. * Get an animation range by name
  29683. * @param name defines the name of the animation range to look for
  29684. * @returns null if not found else the requested animation range
  29685. */
  29686. getAnimationRange(name: string): Nullable<AnimationRange>;
  29687. /**
  29688. * Gets the list of all animation ranges defined on this node
  29689. * @returns an array
  29690. */
  29691. getAnimationRanges(): Nullable<AnimationRange>[];
  29692. /**
  29693. * Will start the animation sequence
  29694. * @param name defines the range frames for animation sequence
  29695. * @param loop defines if the animation should loop (false by default)
  29696. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29697. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29698. * @returns the object created for this animation. If range does not exist, it will return null
  29699. */
  29700. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29701. /**
  29702. * Serialize animation ranges into a JSON compatible object
  29703. * @returns serialization object
  29704. */
  29705. serializeAnimationRanges(): any;
  29706. /**
  29707. * Computes the world matrix of the node
  29708. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29709. * @returns the world matrix
  29710. */
  29711. computeWorldMatrix(force?: boolean): Matrix;
  29712. /**
  29713. * Releases resources associated with this node.
  29714. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29715. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29716. */
  29717. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29718. /**
  29719. * Parse animation range data from a serialization object and store them into a given node
  29720. * @param node defines where to store the animation ranges
  29721. * @param parsedNode defines the serialization object to read data from
  29722. * @param scene defines the hosting scene
  29723. */
  29724. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29725. /**
  29726. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29727. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29728. * @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
  29729. * @returns the new bounding vectors
  29730. */
  29731. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29732. min: Vector3;
  29733. max: Vector3;
  29734. };
  29735. }
  29736. }
  29737. declare module "babylonjs/Animations/animation" {
  29738. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29739. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29740. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29741. import { Nullable } from "babylonjs/types";
  29742. import { Scene } from "babylonjs/scene";
  29743. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29744. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29745. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29746. import { Node } from "babylonjs/node";
  29747. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29748. import { Size } from "babylonjs/Maths/math.size";
  29749. import { Animatable } from "babylonjs/Animations/animatable";
  29750. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29751. /**
  29752. * @hidden
  29753. */
  29754. export class _IAnimationState {
  29755. key: number;
  29756. repeatCount: number;
  29757. workValue?: any;
  29758. loopMode?: number;
  29759. offsetValue?: any;
  29760. highLimitValue?: any;
  29761. }
  29762. /**
  29763. * Class used to store any kind of animation
  29764. */
  29765. export class Animation {
  29766. /**Name of the animation */
  29767. name: string;
  29768. /**Property to animate */
  29769. targetProperty: string;
  29770. /**The frames per second of the animation */
  29771. framePerSecond: number;
  29772. /**The data type of the animation */
  29773. dataType: number;
  29774. /**The loop mode of the animation */
  29775. loopMode?: number | undefined;
  29776. /**Specifies if blending should be enabled */
  29777. enableBlending?: boolean | undefined;
  29778. /**
  29779. * Use matrix interpolation instead of using direct key value when animating matrices
  29780. */
  29781. static AllowMatricesInterpolation: boolean;
  29782. /**
  29783. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29784. */
  29785. static AllowMatrixDecomposeForInterpolation: boolean;
  29786. /**
  29787. * Stores the key frames of the animation
  29788. */
  29789. private _keys;
  29790. /**
  29791. * Stores the easing function of the animation
  29792. */
  29793. private _easingFunction;
  29794. /**
  29795. * @hidden Internal use only
  29796. */
  29797. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29798. /**
  29799. * The set of event that will be linked to this animation
  29800. */
  29801. private _events;
  29802. /**
  29803. * Stores an array of target property paths
  29804. */
  29805. targetPropertyPath: string[];
  29806. /**
  29807. * Stores the blending speed of the animation
  29808. */
  29809. blendingSpeed: number;
  29810. /**
  29811. * Stores the animation ranges for the animation
  29812. */
  29813. private _ranges;
  29814. /**
  29815. * @hidden Internal use
  29816. */
  29817. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29818. /**
  29819. * Sets up an animation
  29820. * @param property The property to animate
  29821. * @param animationType The animation type to apply
  29822. * @param framePerSecond The frames per second of the animation
  29823. * @param easingFunction The easing function used in the animation
  29824. * @returns The created animation
  29825. */
  29826. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29827. /**
  29828. * Create and start an animation on a node
  29829. * @param name defines the name of the global animation that will be run on all nodes
  29830. * @param node defines the root node where the animation will take place
  29831. * @param targetProperty defines property to animate
  29832. * @param framePerSecond defines the number of frame per second yo use
  29833. * @param totalFrame defines the number of frames in total
  29834. * @param from defines the initial value
  29835. * @param to defines the final value
  29836. * @param loopMode defines which loop mode you want to use (off by default)
  29837. * @param easingFunction defines the easing function to use (linear by default)
  29838. * @param onAnimationEnd defines the callback to call when animation end
  29839. * @returns the animatable created for this animation
  29840. */
  29841. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29842. /**
  29843. * Create and start an animation on a node and its descendants
  29844. * @param name defines the name of the global animation that will be run on all nodes
  29845. * @param node defines the root node where the animation will take place
  29846. * @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
  29847. * @param targetProperty defines property to animate
  29848. * @param framePerSecond defines the number of frame per second to use
  29849. * @param totalFrame defines the number of frames in total
  29850. * @param from defines the initial value
  29851. * @param to defines the final value
  29852. * @param loopMode defines which loop mode you want to use (off by default)
  29853. * @param easingFunction defines the easing function to use (linear by default)
  29854. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29855. * @returns the list of animatables created for all nodes
  29856. * @example https://www.babylonjs-playground.com/#MH0VLI
  29857. */
  29858. 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[]>;
  29859. /**
  29860. * Creates a new animation, merges it with the existing animations and starts it
  29861. * @param name Name of the animation
  29862. * @param node Node which contains the scene that begins the animations
  29863. * @param targetProperty Specifies which property to animate
  29864. * @param framePerSecond The frames per second of the animation
  29865. * @param totalFrame The total number of frames
  29866. * @param from The frame at the beginning of the animation
  29867. * @param to The frame at the end of the animation
  29868. * @param loopMode Specifies the loop mode of the animation
  29869. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29870. * @param onAnimationEnd Callback to run once the animation is complete
  29871. * @returns Nullable animation
  29872. */
  29873. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29874. /**
  29875. * Transition property of an host to the target Value
  29876. * @param property The property to transition
  29877. * @param targetValue The target Value of the property
  29878. * @param host The object where the property to animate belongs
  29879. * @param scene Scene used to run the animation
  29880. * @param frameRate Framerate (in frame/s) to use
  29881. * @param transition The transition type we want to use
  29882. * @param duration The duration of the animation, in milliseconds
  29883. * @param onAnimationEnd Callback trigger at the end of the animation
  29884. * @returns Nullable animation
  29885. */
  29886. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29887. /**
  29888. * Return the array of runtime animations currently using this animation
  29889. */
  29890. get runtimeAnimations(): RuntimeAnimation[];
  29891. /**
  29892. * Specifies if any of the runtime animations are currently running
  29893. */
  29894. get hasRunningRuntimeAnimations(): boolean;
  29895. /**
  29896. * Initializes the animation
  29897. * @param name Name of the animation
  29898. * @param targetProperty Property to animate
  29899. * @param framePerSecond The frames per second of the animation
  29900. * @param dataType The data type of the animation
  29901. * @param loopMode The loop mode of the animation
  29902. * @param enableBlending Specifies if blending should be enabled
  29903. */
  29904. constructor(
  29905. /**Name of the animation */
  29906. name: string,
  29907. /**Property to animate */
  29908. targetProperty: string,
  29909. /**The frames per second of the animation */
  29910. framePerSecond: number,
  29911. /**The data type of the animation */
  29912. dataType: number,
  29913. /**The loop mode of the animation */
  29914. loopMode?: number | undefined,
  29915. /**Specifies if blending should be enabled */
  29916. enableBlending?: boolean | undefined);
  29917. /**
  29918. * Converts the animation to a string
  29919. * @param fullDetails support for multiple levels of logging within scene loading
  29920. * @returns String form of the animation
  29921. */
  29922. toString(fullDetails?: boolean): string;
  29923. /**
  29924. * Add an event to this animation
  29925. * @param event Event to add
  29926. */
  29927. addEvent(event: AnimationEvent): void;
  29928. /**
  29929. * Remove all events found at the given frame
  29930. * @param frame The frame to remove events from
  29931. */
  29932. removeEvents(frame: number): void;
  29933. /**
  29934. * Retrieves all the events from the animation
  29935. * @returns Events from the animation
  29936. */
  29937. getEvents(): AnimationEvent[];
  29938. /**
  29939. * Creates an animation range
  29940. * @param name Name of the animation range
  29941. * @param from Starting frame of the animation range
  29942. * @param to Ending frame of the animation
  29943. */
  29944. createRange(name: string, from: number, to: number): void;
  29945. /**
  29946. * Deletes an animation range by name
  29947. * @param name Name of the animation range to delete
  29948. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29949. */
  29950. deleteRange(name: string, deleteFrames?: boolean): void;
  29951. /**
  29952. * Gets the animation range by name, or null if not defined
  29953. * @param name Name of the animation range
  29954. * @returns Nullable animation range
  29955. */
  29956. getRange(name: string): Nullable<AnimationRange>;
  29957. /**
  29958. * Gets the key frames from the animation
  29959. * @returns The key frames of the animation
  29960. */
  29961. getKeys(): Array<IAnimationKey>;
  29962. /**
  29963. * Gets the highest frame rate of the animation
  29964. * @returns Highest frame rate of the animation
  29965. */
  29966. getHighestFrame(): number;
  29967. /**
  29968. * Gets the easing function of the animation
  29969. * @returns Easing function of the animation
  29970. */
  29971. getEasingFunction(): IEasingFunction;
  29972. /**
  29973. * Sets the easing function of the animation
  29974. * @param easingFunction A custom mathematical formula for animation
  29975. */
  29976. setEasingFunction(easingFunction: EasingFunction): void;
  29977. /**
  29978. * Interpolates a scalar linearly
  29979. * @param startValue Start value of the animation curve
  29980. * @param endValue End value of the animation curve
  29981. * @param gradient Scalar amount to interpolate
  29982. * @returns Interpolated scalar value
  29983. */
  29984. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29985. /**
  29986. * Interpolates a scalar cubically
  29987. * @param startValue Start value of the animation curve
  29988. * @param outTangent End tangent of the animation
  29989. * @param endValue End value of the animation curve
  29990. * @param inTangent Start tangent of the animation curve
  29991. * @param gradient Scalar amount to interpolate
  29992. * @returns Interpolated scalar value
  29993. */
  29994. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29995. /**
  29996. * Interpolates a quaternion using a spherical linear interpolation
  29997. * @param startValue Start value of the animation curve
  29998. * @param endValue End value of the animation curve
  29999. * @param gradient Scalar amount to interpolate
  30000. * @returns Interpolated quaternion value
  30001. */
  30002. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30003. /**
  30004. * Interpolates a quaternion cubically
  30005. * @param startValue Start value of the animation curve
  30006. * @param outTangent End tangent of the animation curve
  30007. * @param endValue End value of the animation curve
  30008. * @param inTangent Start tangent of the animation curve
  30009. * @param gradient Scalar amount to interpolate
  30010. * @returns Interpolated quaternion value
  30011. */
  30012. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30013. /**
  30014. * Interpolates a Vector3 linearl
  30015. * @param startValue Start value of the animation curve
  30016. * @param endValue End value of the animation curve
  30017. * @param gradient Scalar amount to interpolate
  30018. * @returns Interpolated scalar value
  30019. */
  30020. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30021. /**
  30022. * Interpolates a Vector3 cubically
  30023. * @param startValue Start value of the animation curve
  30024. * @param outTangent End tangent of the animation
  30025. * @param endValue End value of the animation curve
  30026. * @param inTangent Start tangent of the animation curve
  30027. * @param gradient Scalar amount to interpolate
  30028. * @returns InterpolatedVector3 value
  30029. */
  30030. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30031. /**
  30032. * Interpolates a Vector2 linearly
  30033. * @param startValue Start value of the animation curve
  30034. * @param endValue End value of the animation curve
  30035. * @param gradient Scalar amount to interpolate
  30036. * @returns Interpolated Vector2 value
  30037. */
  30038. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30039. /**
  30040. * Interpolates a Vector2 cubically
  30041. * @param startValue Start value of the animation curve
  30042. * @param outTangent End tangent of the animation
  30043. * @param endValue End value of the animation curve
  30044. * @param inTangent Start tangent of the animation curve
  30045. * @param gradient Scalar amount to interpolate
  30046. * @returns Interpolated Vector2 value
  30047. */
  30048. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30049. /**
  30050. * Interpolates a size linearly
  30051. * @param startValue Start value of the animation curve
  30052. * @param endValue End value of the animation curve
  30053. * @param gradient Scalar amount to interpolate
  30054. * @returns Interpolated Size value
  30055. */
  30056. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30057. /**
  30058. * Interpolates a Color3 linearly
  30059. * @param startValue Start value of the animation curve
  30060. * @param endValue End value of the animation curve
  30061. * @param gradient Scalar amount to interpolate
  30062. * @returns Interpolated Color3 value
  30063. */
  30064. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30065. /**
  30066. * Interpolates a Color4 linearly
  30067. * @param startValue Start value of the animation curve
  30068. * @param endValue End value of the animation curve
  30069. * @param gradient Scalar amount to interpolate
  30070. * @returns Interpolated Color3 value
  30071. */
  30072. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30073. /**
  30074. * @hidden Internal use only
  30075. */
  30076. _getKeyValue(value: any): any;
  30077. /**
  30078. * @hidden Internal use only
  30079. */
  30080. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30081. /**
  30082. * Defines the function to use to interpolate matrices
  30083. * @param startValue defines the start matrix
  30084. * @param endValue defines the end matrix
  30085. * @param gradient defines the gradient between both matrices
  30086. * @param result defines an optional target matrix where to store the interpolation
  30087. * @returns the interpolated matrix
  30088. */
  30089. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30090. /**
  30091. * Makes a copy of the animation
  30092. * @returns Cloned animation
  30093. */
  30094. clone(): Animation;
  30095. /**
  30096. * Sets the key frames of the animation
  30097. * @param values The animation key frames to set
  30098. */
  30099. setKeys(values: Array<IAnimationKey>): void;
  30100. /**
  30101. * Serializes the animation to an object
  30102. * @returns Serialized object
  30103. */
  30104. serialize(): any;
  30105. /**
  30106. * Float animation type
  30107. */
  30108. static readonly ANIMATIONTYPE_FLOAT: number;
  30109. /**
  30110. * Vector3 animation type
  30111. */
  30112. static readonly ANIMATIONTYPE_VECTOR3: number;
  30113. /**
  30114. * Quaternion animation type
  30115. */
  30116. static readonly ANIMATIONTYPE_QUATERNION: number;
  30117. /**
  30118. * Matrix animation type
  30119. */
  30120. static readonly ANIMATIONTYPE_MATRIX: number;
  30121. /**
  30122. * Color3 animation type
  30123. */
  30124. static readonly ANIMATIONTYPE_COLOR3: number;
  30125. /**
  30126. * Color3 animation type
  30127. */
  30128. static readonly ANIMATIONTYPE_COLOR4: number;
  30129. /**
  30130. * Vector2 animation type
  30131. */
  30132. static readonly ANIMATIONTYPE_VECTOR2: number;
  30133. /**
  30134. * Size animation type
  30135. */
  30136. static readonly ANIMATIONTYPE_SIZE: number;
  30137. /**
  30138. * Relative Loop Mode
  30139. */
  30140. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30141. /**
  30142. * Cycle Loop Mode
  30143. */
  30144. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30145. /**
  30146. * Constant Loop Mode
  30147. */
  30148. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30149. /** @hidden */
  30150. static _UniversalLerp(left: any, right: any, amount: number): any;
  30151. /**
  30152. * Parses an animation object and creates an animation
  30153. * @param parsedAnimation Parsed animation object
  30154. * @returns Animation object
  30155. */
  30156. static Parse(parsedAnimation: any): Animation;
  30157. /**
  30158. * Appends the serialized animations from the source animations
  30159. * @param source Source containing the animations
  30160. * @param destination Target to store the animations
  30161. */
  30162. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30163. }
  30164. }
  30165. declare module "babylonjs/Animations/animatable.interface" {
  30166. import { Nullable } from "babylonjs/types";
  30167. import { Animation } from "babylonjs/Animations/animation";
  30168. /**
  30169. * Interface containing an array of animations
  30170. */
  30171. export interface IAnimatable {
  30172. /**
  30173. * Array of animations
  30174. */
  30175. animations: Nullable<Array<Animation>>;
  30176. }
  30177. }
  30178. declare module "babylonjs/Misc/decorators" {
  30179. import { Nullable } from "babylonjs/types";
  30180. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30181. import { Scene } from "babylonjs/scene";
  30182. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30183. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30184. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30185. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30186. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30187. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30188. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30189. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30190. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30191. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30192. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30193. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30194. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30195. /**
  30196. * Decorator used to define property that can be serialized as reference to a camera
  30197. * @param sourceName defines the name of the property to decorate
  30198. */
  30199. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30200. /**
  30201. * Class used to help serialization objects
  30202. */
  30203. export class SerializationHelper {
  30204. /** @hidden */
  30205. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30206. /** @hidden */
  30207. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30208. /** @hidden */
  30209. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30210. /** @hidden */
  30211. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30212. /**
  30213. * Appends the serialized animations from the source animations
  30214. * @param source Source containing the animations
  30215. * @param destination Target to store the animations
  30216. */
  30217. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30218. /**
  30219. * Static function used to serialized a specific entity
  30220. * @param entity defines the entity to serialize
  30221. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30222. * @returns a JSON compatible object representing the serialization of the entity
  30223. */
  30224. static Serialize<T>(entity: T, serializationObject?: any): any;
  30225. /**
  30226. * Creates a new entity from a serialization data object
  30227. * @param creationFunction defines a function used to instanciated the new entity
  30228. * @param source defines the source serialization data
  30229. * @param scene defines the hosting scene
  30230. * @param rootUrl defines the root url for resources
  30231. * @returns a new entity
  30232. */
  30233. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30234. /**
  30235. * Clones an object
  30236. * @param creationFunction defines the function used to instanciate the new object
  30237. * @param source defines the source object
  30238. * @returns the cloned object
  30239. */
  30240. static Clone<T>(creationFunction: () => T, source: T): T;
  30241. /**
  30242. * Instanciates a new object based on a source one (some data will be shared between both object)
  30243. * @param creationFunction defines the function used to instanciate the new object
  30244. * @param source defines the source object
  30245. * @returns the new object
  30246. */
  30247. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30248. }
  30249. }
  30250. declare module "babylonjs/Misc/guid" {
  30251. /**
  30252. * Class used to manipulate GUIDs
  30253. */
  30254. export class GUID {
  30255. /**
  30256. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30257. * Be aware Math.random() could cause collisions, but:
  30258. * "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"
  30259. * @returns a pseudo random id
  30260. */
  30261. static RandomId(): string;
  30262. }
  30263. }
  30264. declare module "babylonjs/Materials/Textures/baseTexture" {
  30265. import { Observable } from "babylonjs/Misc/observable";
  30266. import { Nullable } from "babylonjs/types";
  30267. import { Scene } from "babylonjs/scene";
  30268. import { Matrix } from "babylonjs/Maths/math.vector";
  30269. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30270. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30271. import { ISize } from "babylonjs/Maths/math.size";
  30272. import "babylonjs/Misc/fileTools";
  30273. /**
  30274. * Base class of all the textures in babylon.
  30275. * It groups all the common properties the materials, post process, lights... might need
  30276. * in order to make a correct use of the texture.
  30277. */
  30278. export class BaseTexture implements IAnimatable {
  30279. /**
  30280. * Default anisotropic filtering level for the application.
  30281. * It is set to 4 as a good tradeoff between perf and quality.
  30282. */
  30283. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30284. /**
  30285. * Gets or sets the unique id of the texture
  30286. */
  30287. uniqueId: number;
  30288. /**
  30289. * Define the name of the texture.
  30290. */
  30291. name: string;
  30292. /**
  30293. * Gets or sets an object used to store user defined information.
  30294. */
  30295. metadata: any;
  30296. /**
  30297. * For internal use only. Please do not use.
  30298. */
  30299. reservedDataStore: any;
  30300. private _hasAlpha;
  30301. /**
  30302. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30303. */
  30304. set hasAlpha(value: boolean);
  30305. get hasAlpha(): boolean;
  30306. /**
  30307. * Defines if the alpha value should be determined via the rgb values.
  30308. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30309. */
  30310. getAlphaFromRGB: boolean;
  30311. /**
  30312. * Intensity or strength of the texture.
  30313. * It is commonly used by materials to fine tune the intensity of the texture
  30314. */
  30315. level: number;
  30316. /**
  30317. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30318. * This is part of the texture as textures usually maps to one uv set.
  30319. */
  30320. coordinatesIndex: number;
  30321. private _coordinatesMode;
  30322. /**
  30323. * How a texture is mapped.
  30324. *
  30325. * | Value | Type | Description |
  30326. * | ----- | ----------------------------------- | ----------- |
  30327. * | 0 | EXPLICIT_MODE | |
  30328. * | 1 | SPHERICAL_MODE | |
  30329. * | 2 | PLANAR_MODE | |
  30330. * | 3 | CUBIC_MODE | |
  30331. * | 4 | PROJECTION_MODE | |
  30332. * | 5 | SKYBOX_MODE | |
  30333. * | 6 | INVCUBIC_MODE | |
  30334. * | 7 | EQUIRECTANGULAR_MODE | |
  30335. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30336. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30337. */
  30338. set coordinatesMode(value: number);
  30339. get coordinatesMode(): number;
  30340. /**
  30341. * | Value | Type | Description |
  30342. * | ----- | ------------------ | ----------- |
  30343. * | 0 | CLAMP_ADDRESSMODE | |
  30344. * | 1 | WRAP_ADDRESSMODE | |
  30345. * | 2 | MIRROR_ADDRESSMODE | |
  30346. */
  30347. wrapU: number;
  30348. /**
  30349. * | Value | Type | Description |
  30350. * | ----- | ------------------ | ----------- |
  30351. * | 0 | CLAMP_ADDRESSMODE | |
  30352. * | 1 | WRAP_ADDRESSMODE | |
  30353. * | 2 | MIRROR_ADDRESSMODE | |
  30354. */
  30355. wrapV: number;
  30356. /**
  30357. * | Value | Type | Description |
  30358. * | ----- | ------------------ | ----------- |
  30359. * | 0 | CLAMP_ADDRESSMODE | |
  30360. * | 1 | WRAP_ADDRESSMODE | |
  30361. * | 2 | MIRROR_ADDRESSMODE | |
  30362. */
  30363. wrapR: number;
  30364. /**
  30365. * With compliant hardware and browser (supporting anisotropic filtering)
  30366. * this defines the level of anisotropic filtering in the texture.
  30367. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30368. */
  30369. anisotropicFilteringLevel: number;
  30370. /**
  30371. * Define if the texture is a cube texture or if false a 2d texture.
  30372. */
  30373. get isCube(): boolean;
  30374. set isCube(value: boolean);
  30375. /**
  30376. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30377. */
  30378. get is3D(): boolean;
  30379. set is3D(value: boolean);
  30380. /**
  30381. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30382. */
  30383. get is2DArray(): boolean;
  30384. set is2DArray(value: boolean);
  30385. /**
  30386. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30387. * HDR texture are usually stored in linear space.
  30388. * This only impacts the PBR and Background materials
  30389. */
  30390. gammaSpace: boolean;
  30391. /**
  30392. * Gets or sets whether or not the texture contains RGBD data.
  30393. */
  30394. get isRGBD(): boolean;
  30395. set isRGBD(value: boolean);
  30396. /**
  30397. * Is Z inverted in the texture (useful in a cube texture).
  30398. */
  30399. invertZ: boolean;
  30400. /**
  30401. * Are mip maps generated for this texture or not.
  30402. */
  30403. get noMipmap(): boolean;
  30404. /**
  30405. * @hidden
  30406. */
  30407. lodLevelInAlpha: boolean;
  30408. /**
  30409. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30410. */
  30411. get lodGenerationOffset(): number;
  30412. set lodGenerationOffset(value: number);
  30413. /**
  30414. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30415. */
  30416. get lodGenerationScale(): number;
  30417. set lodGenerationScale(value: number);
  30418. /**
  30419. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30420. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30421. * average roughness values.
  30422. */
  30423. get linearSpecularLOD(): boolean;
  30424. set linearSpecularLOD(value: boolean);
  30425. /**
  30426. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30427. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30428. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30429. */
  30430. get irradianceTexture(): Nullable<BaseTexture>;
  30431. set irradianceTexture(value: Nullable<BaseTexture>);
  30432. /**
  30433. * Define if the texture is a render target.
  30434. */
  30435. isRenderTarget: boolean;
  30436. /**
  30437. * Define the unique id of the texture in the scene.
  30438. */
  30439. get uid(): string;
  30440. /**
  30441. * Return a string representation of the texture.
  30442. * @returns the texture as a string
  30443. */
  30444. toString(): string;
  30445. /**
  30446. * Get the class name of the texture.
  30447. * @returns "BaseTexture"
  30448. */
  30449. getClassName(): string;
  30450. /**
  30451. * Define the list of animation attached to the texture.
  30452. */
  30453. animations: import("babylonjs/Animations/animation").Animation[];
  30454. /**
  30455. * An event triggered when the texture is disposed.
  30456. */
  30457. onDisposeObservable: Observable<BaseTexture>;
  30458. private _onDisposeObserver;
  30459. /**
  30460. * Callback triggered when the texture has been disposed.
  30461. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30462. */
  30463. set onDispose(callback: () => void);
  30464. /**
  30465. * Define the current state of the loading sequence when in delayed load mode.
  30466. */
  30467. delayLoadState: number;
  30468. private _scene;
  30469. /** @hidden */
  30470. _texture: Nullable<InternalTexture>;
  30471. private _uid;
  30472. /**
  30473. * Define if the texture is preventinga material to render or not.
  30474. * If not and the texture is not ready, the engine will use a default black texture instead.
  30475. */
  30476. get isBlocking(): boolean;
  30477. /**
  30478. * Instantiates a new BaseTexture.
  30479. * Base class of all the textures in babylon.
  30480. * It groups all the common properties the materials, post process, lights... might need
  30481. * in order to make a correct use of the texture.
  30482. * @param scene Define the scene the texture blongs to
  30483. */
  30484. constructor(scene: Nullable<Scene>);
  30485. /**
  30486. * Get the scene the texture belongs to.
  30487. * @returns the scene or null if undefined
  30488. */
  30489. getScene(): Nullable<Scene>;
  30490. /**
  30491. * Get the texture transform matrix used to offset tile the texture for istance.
  30492. * @returns the transformation matrix
  30493. */
  30494. getTextureMatrix(): Matrix;
  30495. /**
  30496. * Get the texture reflection matrix used to rotate/transform the reflection.
  30497. * @returns the reflection matrix
  30498. */
  30499. getReflectionTextureMatrix(): Matrix;
  30500. /**
  30501. * Get the underlying lower level texture from Babylon.
  30502. * @returns the insternal texture
  30503. */
  30504. getInternalTexture(): Nullable<InternalTexture>;
  30505. /**
  30506. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30507. * @returns true if ready or not blocking
  30508. */
  30509. isReadyOrNotBlocking(): boolean;
  30510. /**
  30511. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30512. * @returns true if fully ready
  30513. */
  30514. isReady(): boolean;
  30515. private _cachedSize;
  30516. /**
  30517. * Get the size of the texture.
  30518. * @returns the texture size.
  30519. */
  30520. getSize(): ISize;
  30521. /**
  30522. * Get the base size of the texture.
  30523. * It can be different from the size if the texture has been resized for POT for instance
  30524. * @returns the base size
  30525. */
  30526. getBaseSize(): ISize;
  30527. /**
  30528. * Update the sampling mode of the texture.
  30529. * Default is Trilinear mode.
  30530. *
  30531. * | Value | Type | Description |
  30532. * | ----- | ------------------ | ----------- |
  30533. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30534. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30535. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30536. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30537. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30538. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30539. * | 7 | NEAREST_LINEAR | |
  30540. * | 8 | NEAREST_NEAREST | |
  30541. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30542. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30543. * | 11 | LINEAR_LINEAR | |
  30544. * | 12 | LINEAR_NEAREST | |
  30545. *
  30546. * > _mag_: magnification filter (close to the viewer)
  30547. * > _min_: minification filter (far from the viewer)
  30548. * > _mip_: filter used between mip map levels
  30549. *@param samplingMode Define the new sampling mode of the texture
  30550. */
  30551. updateSamplingMode(samplingMode: number): void;
  30552. /**
  30553. * Scales the texture if is `canRescale()`
  30554. * @param ratio the resize factor we want to use to rescale
  30555. */
  30556. scale(ratio: number): void;
  30557. /**
  30558. * Get if the texture can rescale.
  30559. */
  30560. get canRescale(): boolean;
  30561. /** @hidden */
  30562. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30563. /** @hidden */
  30564. _rebuild(): void;
  30565. /**
  30566. * Triggers the load sequence in delayed load mode.
  30567. */
  30568. delayLoad(): void;
  30569. /**
  30570. * Clones the texture.
  30571. * @returns the cloned texture
  30572. */
  30573. clone(): Nullable<BaseTexture>;
  30574. /**
  30575. * Get the texture underlying type (INT, FLOAT...)
  30576. */
  30577. get textureType(): number;
  30578. /**
  30579. * Get the texture underlying format (RGB, RGBA...)
  30580. */
  30581. get textureFormat(): number;
  30582. /**
  30583. * Indicates that textures need to be re-calculated for all materials
  30584. */
  30585. protected _markAllSubMeshesAsTexturesDirty(): void;
  30586. /**
  30587. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30588. * This will returns an RGBA array buffer containing either in values (0-255) or
  30589. * float values (0-1) depending of the underlying buffer type.
  30590. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30591. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30592. * @param buffer defines a user defined buffer to fill with data (can be null)
  30593. * @returns The Array buffer containing the pixels data.
  30594. */
  30595. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30596. /**
  30597. * Release and destroy the underlying lower level texture aka internalTexture.
  30598. */
  30599. releaseInternalTexture(): void;
  30600. /** @hidden */
  30601. get _lodTextureHigh(): Nullable<BaseTexture>;
  30602. /** @hidden */
  30603. get _lodTextureMid(): Nullable<BaseTexture>;
  30604. /** @hidden */
  30605. get _lodTextureLow(): Nullable<BaseTexture>;
  30606. /**
  30607. * Dispose the texture and release its associated resources.
  30608. */
  30609. dispose(): void;
  30610. /**
  30611. * Serialize the texture into a JSON representation that can be parsed later on.
  30612. * @returns the JSON representation of the texture
  30613. */
  30614. serialize(): any;
  30615. /**
  30616. * Helper function to be called back once a list of texture contains only ready textures.
  30617. * @param textures Define the list of textures to wait for
  30618. * @param callback Define the callback triggered once the entire list will be ready
  30619. */
  30620. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30621. }
  30622. }
  30623. declare module "babylonjs/Materials/effect" {
  30624. import { Observable } from "babylonjs/Misc/observable";
  30625. import { Nullable } from "babylonjs/types";
  30626. import { IDisposable } from "babylonjs/scene";
  30627. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30628. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30629. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30630. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30631. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30632. import { Engine } from "babylonjs/Engines/engine";
  30633. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30634. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30635. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30636. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30637. /**
  30638. * Options to be used when creating an effect.
  30639. */
  30640. export interface IEffectCreationOptions {
  30641. /**
  30642. * Atrributes that will be used in the shader.
  30643. */
  30644. attributes: string[];
  30645. /**
  30646. * Uniform varible names that will be set in the shader.
  30647. */
  30648. uniformsNames: string[];
  30649. /**
  30650. * Uniform buffer variable names that will be set in the shader.
  30651. */
  30652. uniformBuffersNames: string[];
  30653. /**
  30654. * Sampler texture variable names that will be set in the shader.
  30655. */
  30656. samplers: string[];
  30657. /**
  30658. * Define statements that will be set in the shader.
  30659. */
  30660. defines: any;
  30661. /**
  30662. * Possible fallbacks for this effect to improve performance when needed.
  30663. */
  30664. fallbacks: Nullable<IEffectFallbacks>;
  30665. /**
  30666. * Callback that will be called when the shader is compiled.
  30667. */
  30668. onCompiled: Nullable<(effect: Effect) => void>;
  30669. /**
  30670. * Callback that will be called if an error occurs during shader compilation.
  30671. */
  30672. onError: Nullable<(effect: Effect, errors: string) => void>;
  30673. /**
  30674. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30675. */
  30676. indexParameters?: any;
  30677. /**
  30678. * Max number of lights that can be used in the shader.
  30679. */
  30680. maxSimultaneousLights?: number;
  30681. /**
  30682. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30683. */
  30684. transformFeedbackVaryings?: Nullable<string[]>;
  30685. }
  30686. /**
  30687. * Effect containing vertex and fragment shader that can be executed on an object.
  30688. */
  30689. export class Effect implements IDisposable {
  30690. /**
  30691. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30692. */
  30693. static ShadersRepository: string;
  30694. /**
  30695. * Name of the effect.
  30696. */
  30697. name: any;
  30698. /**
  30699. * String container all the define statements that should be set on the shader.
  30700. */
  30701. defines: string;
  30702. /**
  30703. * Callback that will be called when the shader is compiled.
  30704. */
  30705. onCompiled: Nullable<(effect: Effect) => void>;
  30706. /**
  30707. * Callback that will be called if an error occurs during shader compilation.
  30708. */
  30709. onError: Nullable<(effect: Effect, errors: string) => void>;
  30710. /**
  30711. * Callback that will be called when effect is bound.
  30712. */
  30713. onBind: Nullable<(effect: Effect) => void>;
  30714. /**
  30715. * Unique ID of the effect.
  30716. */
  30717. uniqueId: number;
  30718. /**
  30719. * Observable that will be called when the shader is compiled.
  30720. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30721. */
  30722. onCompileObservable: Observable<Effect>;
  30723. /**
  30724. * Observable that will be called if an error occurs during shader compilation.
  30725. */
  30726. onErrorObservable: Observable<Effect>;
  30727. /** @hidden */
  30728. _onBindObservable: Nullable<Observable<Effect>>;
  30729. /**
  30730. * @hidden
  30731. * Specifies if the effect was previously ready
  30732. */
  30733. _wasPreviouslyReady: boolean;
  30734. /**
  30735. * Observable that will be called when effect is bound.
  30736. */
  30737. get onBindObservable(): Observable<Effect>;
  30738. /** @hidden */
  30739. _bonesComputationForcedToCPU: boolean;
  30740. private static _uniqueIdSeed;
  30741. private _engine;
  30742. private _uniformBuffersNames;
  30743. private _uniformsNames;
  30744. private _samplerList;
  30745. private _samplers;
  30746. private _isReady;
  30747. private _compilationError;
  30748. private _allFallbacksProcessed;
  30749. private _attributesNames;
  30750. private _attributes;
  30751. private _attributeLocationByName;
  30752. private _uniforms;
  30753. /**
  30754. * Key for the effect.
  30755. * @hidden
  30756. */
  30757. _key: string;
  30758. private _indexParameters;
  30759. private _fallbacks;
  30760. private _vertexSourceCode;
  30761. private _fragmentSourceCode;
  30762. private _vertexSourceCodeOverride;
  30763. private _fragmentSourceCodeOverride;
  30764. private _transformFeedbackVaryings;
  30765. /**
  30766. * Compiled shader to webGL program.
  30767. * @hidden
  30768. */
  30769. _pipelineContext: Nullable<IPipelineContext>;
  30770. private _valueCache;
  30771. private static _baseCache;
  30772. /**
  30773. * Instantiates an effect.
  30774. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30775. * @param baseName Name of the effect.
  30776. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30777. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30778. * @param samplers List of sampler variables that will be passed to the shader.
  30779. * @param engine Engine to be used to render the effect
  30780. * @param defines Define statements to be added to the shader.
  30781. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30782. * @param onCompiled Callback that will be called when the shader is compiled.
  30783. * @param onError Callback that will be called if an error occurs during shader compilation.
  30784. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30785. */
  30786. 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);
  30787. private _useFinalCode;
  30788. /**
  30789. * Unique key for this effect
  30790. */
  30791. get key(): string;
  30792. /**
  30793. * If the effect has been compiled and prepared.
  30794. * @returns if the effect is compiled and prepared.
  30795. */
  30796. isReady(): boolean;
  30797. private _isReadyInternal;
  30798. /**
  30799. * The engine the effect was initialized with.
  30800. * @returns the engine.
  30801. */
  30802. getEngine(): Engine;
  30803. /**
  30804. * The pipeline context for this effect
  30805. * @returns the associated pipeline context
  30806. */
  30807. getPipelineContext(): Nullable<IPipelineContext>;
  30808. /**
  30809. * The set of names of attribute variables for the shader.
  30810. * @returns An array of attribute names.
  30811. */
  30812. getAttributesNames(): string[];
  30813. /**
  30814. * Returns the attribute at the given index.
  30815. * @param index The index of the attribute.
  30816. * @returns The location of the attribute.
  30817. */
  30818. getAttributeLocation(index: number): number;
  30819. /**
  30820. * Returns the attribute based on the name of the variable.
  30821. * @param name of the attribute to look up.
  30822. * @returns the attribute location.
  30823. */
  30824. getAttributeLocationByName(name: string): number;
  30825. /**
  30826. * The number of attributes.
  30827. * @returns the numnber of attributes.
  30828. */
  30829. getAttributesCount(): number;
  30830. /**
  30831. * Gets the index of a uniform variable.
  30832. * @param uniformName of the uniform to look up.
  30833. * @returns the index.
  30834. */
  30835. getUniformIndex(uniformName: string): number;
  30836. /**
  30837. * Returns the attribute based on the name of the variable.
  30838. * @param uniformName of the uniform to look up.
  30839. * @returns the location of the uniform.
  30840. */
  30841. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30842. /**
  30843. * Returns an array of sampler variable names
  30844. * @returns The array of sampler variable neames.
  30845. */
  30846. getSamplers(): string[];
  30847. /**
  30848. * The error from the last compilation.
  30849. * @returns the error string.
  30850. */
  30851. getCompilationError(): string;
  30852. /**
  30853. * Gets a boolean indicating that all fallbacks were used during compilation
  30854. * @returns true if all fallbacks were used
  30855. */
  30856. allFallbacksProcessed(): boolean;
  30857. /**
  30858. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30859. * @param func The callback to be used.
  30860. */
  30861. executeWhenCompiled(func: (effect: Effect) => void): void;
  30862. private _checkIsReady;
  30863. private _loadShader;
  30864. /**
  30865. * Recompiles the webGL program
  30866. * @param vertexSourceCode The source code for the vertex shader.
  30867. * @param fragmentSourceCode The source code for the fragment shader.
  30868. * @param onCompiled Callback called when completed.
  30869. * @param onError Callback called on error.
  30870. * @hidden
  30871. */
  30872. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30873. /**
  30874. * Prepares the effect
  30875. * @hidden
  30876. */
  30877. _prepareEffect(): void;
  30878. private _processCompilationErrors;
  30879. /**
  30880. * Checks if the effect is supported. (Must be called after compilation)
  30881. */
  30882. get isSupported(): boolean;
  30883. /**
  30884. * Binds a texture to the engine to be used as output of the shader.
  30885. * @param channel Name of the output variable.
  30886. * @param texture Texture to bind.
  30887. * @hidden
  30888. */
  30889. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30890. /**
  30891. * Sets a texture on the engine to be used in the shader.
  30892. * @param channel Name of the sampler variable.
  30893. * @param texture Texture to set.
  30894. */
  30895. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30896. /**
  30897. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30898. * @param channel Name of the sampler variable.
  30899. * @param texture Texture to set.
  30900. */
  30901. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30902. /**
  30903. * Sets an array of textures on the engine to be used in the shader.
  30904. * @param channel Name of the variable.
  30905. * @param textures Textures to set.
  30906. */
  30907. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30908. /**
  30909. * 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)
  30910. * @param channel Name of the sampler variable.
  30911. * @param postProcess Post process to get the input texture from.
  30912. */
  30913. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30914. /**
  30915. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30916. * 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)
  30917. * @param channel Name of the sampler variable.
  30918. * @param postProcess Post process to get the output texture from.
  30919. */
  30920. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30921. /** @hidden */
  30922. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30923. /** @hidden */
  30924. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30925. /** @hidden */
  30926. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30927. /** @hidden */
  30928. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30929. /**
  30930. * Binds a buffer to a uniform.
  30931. * @param buffer Buffer to bind.
  30932. * @param name Name of the uniform variable to bind to.
  30933. */
  30934. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30935. /**
  30936. * Binds block to a uniform.
  30937. * @param blockName Name of the block to bind.
  30938. * @param index Index to bind.
  30939. */
  30940. bindUniformBlock(blockName: string, index: number): void;
  30941. /**
  30942. * Sets an interger value on a uniform variable.
  30943. * @param uniformName Name of the variable.
  30944. * @param value Value to be set.
  30945. * @returns this effect.
  30946. */
  30947. setInt(uniformName: string, value: number): Effect;
  30948. /**
  30949. * Sets an int array on a uniform variable.
  30950. * @param uniformName Name of the variable.
  30951. * @param array array to be set.
  30952. * @returns this effect.
  30953. */
  30954. setIntArray(uniformName: string, array: Int32Array): Effect;
  30955. /**
  30956. * 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)
  30957. * @param uniformName Name of the variable.
  30958. * @param array array to be set.
  30959. * @returns this effect.
  30960. */
  30961. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30962. /**
  30963. * 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)
  30964. * @param uniformName Name of the variable.
  30965. * @param array array to be set.
  30966. * @returns this effect.
  30967. */
  30968. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30969. /**
  30970. * 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)
  30971. * @param uniformName Name of the variable.
  30972. * @param array array to be set.
  30973. * @returns this effect.
  30974. */
  30975. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30976. /**
  30977. * Sets an float array on a uniform variable.
  30978. * @param uniformName Name of the variable.
  30979. * @param array array to be set.
  30980. * @returns this effect.
  30981. */
  30982. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30983. /**
  30984. * 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)
  30985. * @param uniformName Name of the variable.
  30986. * @param array array to be set.
  30987. * @returns this effect.
  30988. */
  30989. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30990. /**
  30991. * 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)
  30992. * @param uniformName Name of the variable.
  30993. * @param array array to be set.
  30994. * @returns this effect.
  30995. */
  30996. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30997. /**
  30998. * 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)
  30999. * @param uniformName Name of the variable.
  31000. * @param array array to be set.
  31001. * @returns this effect.
  31002. */
  31003. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31004. /**
  31005. * Sets an array on a uniform variable.
  31006. * @param uniformName Name of the variable.
  31007. * @param array array to be set.
  31008. * @returns this effect.
  31009. */
  31010. setArray(uniformName: string, array: number[]): Effect;
  31011. /**
  31012. * 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)
  31013. * @param uniformName Name of the variable.
  31014. * @param array array to be set.
  31015. * @returns this effect.
  31016. */
  31017. setArray2(uniformName: string, array: number[]): Effect;
  31018. /**
  31019. * 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)
  31020. * @param uniformName Name of the variable.
  31021. * @param array array to be set.
  31022. * @returns this effect.
  31023. */
  31024. setArray3(uniformName: string, array: number[]): Effect;
  31025. /**
  31026. * 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)
  31027. * @param uniformName Name of the variable.
  31028. * @param array array to be set.
  31029. * @returns this effect.
  31030. */
  31031. setArray4(uniformName: string, array: number[]): Effect;
  31032. /**
  31033. * Sets matrices on a uniform variable.
  31034. * @param uniformName Name of the variable.
  31035. * @param matrices matrices to be set.
  31036. * @returns this effect.
  31037. */
  31038. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31039. /**
  31040. * Sets matrix on a uniform variable.
  31041. * @param uniformName Name of the variable.
  31042. * @param matrix matrix to be set.
  31043. * @returns this effect.
  31044. */
  31045. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31046. /**
  31047. * 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)
  31048. * @param uniformName Name of the variable.
  31049. * @param matrix matrix to be set.
  31050. * @returns this effect.
  31051. */
  31052. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31053. /**
  31054. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31055. * @param uniformName Name of the variable.
  31056. * @param matrix matrix to be set.
  31057. * @returns this effect.
  31058. */
  31059. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31060. /**
  31061. * Sets a float on a uniform variable.
  31062. * @param uniformName Name of the variable.
  31063. * @param value value to be set.
  31064. * @returns this effect.
  31065. */
  31066. setFloat(uniformName: string, value: number): Effect;
  31067. /**
  31068. * Sets a boolean on a uniform variable.
  31069. * @param uniformName Name of the variable.
  31070. * @param bool value to be set.
  31071. * @returns this effect.
  31072. */
  31073. setBool(uniformName: string, bool: boolean): Effect;
  31074. /**
  31075. * Sets a Vector2 on a uniform variable.
  31076. * @param uniformName Name of the variable.
  31077. * @param vector2 vector2 to be set.
  31078. * @returns this effect.
  31079. */
  31080. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31081. /**
  31082. * Sets a float2 on a uniform variable.
  31083. * @param uniformName Name of the variable.
  31084. * @param x First float in float2.
  31085. * @param y Second float in float2.
  31086. * @returns this effect.
  31087. */
  31088. setFloat2(uniformName: string, x: number, y: number): Effect;
  31089. /**
  31090. * Sets a Vector3 on a uniform variable.
  31091. * @param uniformName Name of the variable.
  31092. * @param vector3 Value to be set.
  31093. * @returns this effect.
  31094. */
  31095. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31096. /**
  31097. * Sets a float3 on a uniform variable.
  31098. * @param uniformName Name of the variable.
  31099. * @param x First float in float3.
  31100. * @param y Second float in float3.
  31101. * @param z Third float in float3.
  31102. * @returns this effect.
  31103. */
  31104. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31105. /**
  31106. * Sets a Vector4 on a uniform variable.
  31107. * @param uniformName Name of the variable.
  31108. * @param vector4 Value to be set.
  31109. * @returns this effect.
  31110. */
  31111. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31112. /**
  31113. * Sets a float4 on a uniform variable.
  31114. * @param uniformName Name of the variable.
  31115. * @param x First float in float4.
  31116. * @param y Second float in float4.
  31117. * @param z Third float in float4.
  31118. * @param w Fourth float in float4.
  31119. * @returns this effect.
  31120. */
  31121. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31122. /**
  31123. * Sets a Color3 on a uniform variable.
  31124. * @param uniformName Name of the variable.
  31125. * @param color3 Value to be set.
  31126. * @returns this effect.
  31127. */
  31128. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31129. /**
  31130. * Sets a Color4 on a uniform variable.
  31131. * @param uniformName Name of the variable.
  31132. * @param color3 Value to be set.
  31133. * @param alpha Alpha value to be set.
  31134. * @returns this effect.
  31135. */
  31136. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31137. /**
  31138. * Sets a Color4 on a uniform variable
  31139. * @param uniformName defines the name of the variable
  31140. * @param color4 defines the value to be set
  31141. * @returns this effect.
  31142. */
  31143. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31144. /** Release all associated resources */
  31145. dispose(): void;
  31146. /**
  31147. * This function will add a new shader to the shader store
  31148. * @param name the name of the shader
  31149. * @param pixelShader optional pixel shader content
  31150. * @param vertexShader optional vertex shader content
  31151. */
  31152. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31153. /**
  31154. * Store of each shader (The can be looked up using effect.key)
  31155. */
  31156. static ShadersStore: {
  31157. [key: string]: string;
  31158. };
  31159. /**
  31160. * Store of each included file for a shader (The can be looked up using effect.key)
  31161. */
  31162. static IncludesShadersStore: {
  31163. [key: string]: string;
  31164. };
  31165. /**
  31166. * Resets the cache of effects.
  31167. */
  31168. static ResetCache(): void;
  31169. }
  31170. }
  31171. declare module "babylonjs/Engines/engineCapabilities" {
  31172. /**
  31173. * Interface used to describe the capabilities of the engine relatively to the current browser
  31174. */
  31175. export interface EngineCapabilities {
  31176. /** Maximum textures units per fragment shader */
  31177. maxTexturesImageUnits: number;
  31178. /** Maximum texture units per vertex shader */
  31179. maxVertexTextureImageUnits: number;
  31180. /** Maximum textures units in the entire pipeline */
  31181. maxCombinedTexturesImageUnits: number;
  31182. /** Maximum texture size */
  31183. maxTextureSize: number;
  31184. /** Maximum texture samples */
  31185. maxSamples?: number;
  31186. /** Maximum cube texture size */
  31187. maxCubemapTextureSize: number;
  31188. /** Maximum render texture size */
  31189. maxRenderTextureSize: number;
  31190. /** Maximum number of vertex attributes */
  31191. maxVertexAttribs: number;
  31192. /** Maximum number of varyings */
  31193. maxVaryingVectors: number;
  31194. /** Maximum number of uniforms per vertex shader */
  31195. maxVertexUniformVectors: number;
  31196. /** Maximum number of uniforms per fragment shader */
  31197. maxFragmentUniformVectors: number;
  31198. /** Defines if standard derivates (dx/dy) are supported */
  31199. standardDerivatives: boolean;
  31200. /** Defines if s3tc texture compression is supported */
  31201. s3tc?: WEBGL_compressed_texture_s3tc;
  31202. /** Defines if pvrtc texture compression is supported */
  31203. pvrtc: any;
  31204. /** Defines if etc1 texture compression is supported */
  31205. etc1: any;
  31206. /** Defines if etc2 texture compression is supported */
  31207. etc2: any;
  31208. /** Defines if astc texture compression is supported */
  31209. astc: any;
  31210. /** Defines if float textures are supported */
  31211. textureFloat: boolean;
  31212. /** Defines if vertex array objects are supported */
  31213. vertexArrayObject: boolean;
  31214. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31215. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31216. /** Gets the maximum level of anisotropy supported */
  31217. maxAnisotropy: number;
  31218. /** Defines if instancing is supported */
  31219. instancedArrays: boolean;
  31220. /** Defines if 32 bits indices are supported */
  31221. uintIndices: boolean;
  31222. /** Defines if high precision shaders are supported */
  31223. highPrecisionShaderSupported: boolean;
  31224. /** Defines if depth reading in the fragment shader is supported */
  31225. fragmentDepthSupported: boolean;
  31226. /** Defines if float texture linear filtering is supported*/
  31227. textureFloatLinearFiltering: boolean;
  31228. /** Defines if rendering to float textures is supported */
  31229. textureFloatRender: boolean;
  31230. /** Defines if half float textures are supported*/
  31231. textureHalfFloat: boolean;
  31232. /** Defines if half float texture linear filtering is supported*/
  31233. textureHalfFloatLinearFiltering: boolean;
  31234. /** Defines if rendering to half float textures is supported */
  31235. textureHalfFloatRender: boolean;
  31236. /** Defines if textureLOD shader command is supported */
  31237. textureLOD: boolean;
  31238. /** Defines if draw buffers extension is supported */
  31239. drawBuffersExtension: boolean;
  31240. /** Defines if depth textures are supported */
  31241. depthTextureExtension: boolean;
  31242. /** Defines if float color buffer are supported */
  31243. colorBufferFloat: boolean;
  31244. /** Gets disjoint timer query extension (null if not supported) */
  31245. timerQuery?: EXT_disjoint_timer_query;
  31246. /** Defines if timestamp can be used with timer query */
  31247. canUseTimestampForTimerQuery: boolean;
  31248. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31249. multiview?: any;
  31250. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31251. oculusMultiview?: any;
  31252. /** Function used to let the system compiles shaders in background */
  31253. parallelShaderCompile?: {
  31254. COMPLETION_STATUS_KHR: number;
  31255. };
  31256. /** Max number of texture samples for MSAA */
  31257. maxMSAASamples: number;
  31258. /** Defines if the blend min max extension is supported */
  31259. blendMinMax: boolean;
  31260. }
  31261. }
  31262. declare module "babylonjs/States/depthCullingState" {
  31263. import { Nullable } from "babylonjs/types";
  31264. /**
  31265. * @hidden
  31266. **/
  31267. export class DepthCullingState {
  31268. private _isDepthTestDirty;
  31269. private _isDepthMaskDirty;
  31270. private _isDepthFuncDirty;
  31271. private _isCullFaceDirty;
  31272. private _isCullDirty;
  31273. private _isZOffsetDirty;
  31274. private _isFrontFaceDirty;
  31275. private _depthTest;
  31276. private _depthMask;
  31277. private _depthFunc;
  31278. private _cull;
  31279. private _cullFace;
  31280. private _zOffset;
  31281. private _frontFace;
  31282. /**
  31283. * Initializes the state.
  31284. */
  31285. constructor();
  31286. get isDirty(): boolean;
  31287. get zOffset(): number;
  31288. set zOffset(value: number);
  31289. get cullFace(): Nullable<number>;
  31290. set cullFace(value: Nullable<number>);
  31291. get cull(): Nullable<boolean>;
  31292. set cull(value: Nullable<boolean>);
  31293. get depthFunc(): Nullable<number>;
  31294. set depthFunc(value: Nullable<number>);
  31295. get depthMask(): boolean;
  31296. set depthMask(value: boolean);
  31297. get depthTest(): boolean;
  31298. set depthTest(value: boolean);
  31299. get frontFace(): Nullable<number>;
  31300. set frontFace(value: Nullable<number>);
  31301. reset(): void;
  31302. apply(gl: WebGLRenderingContext): void;
  31303. }
  31304. }
  31305. declare module "babylonjs/States/stencilState" {
  31306. /**
  31307. * @hidden
  31308. **/
  31309. export class StencilState {
  31310. /** 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 */
  31311. static readonly ALWAYS: number;
  31312. /** Passed to stencilOperation to specify that stencil value must be kept */
  31313. static readonly KEEP: number;
  31314. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31315. static readonly REPLACE: number;
  31316. private _isStencilTestDirty;
  31317. private _isStencilMaskDirty;
  31318. private _isStencilFuncDirty;
  31319. private _isStencilOpDirty;
  31320. private _stencilTest;
  31321. private _stencilMask;
  31322. private _stencilFunc;
  31323. private _stencilFuncRef;
  31324. private _stencilFuncMask;
  31325. private _stencilOpStencilFail;
  31326. private _stencilOpDepthFail;
  31327. private _stencilOpStencilDepthPass;
  31328. get isDirty(): boolean;
  31329. get stencilFunc(): number;
  31330. set stencilFunc(value: number);
  31331. get stencilFuncRef(): number;
  31332. set stencilFuncRef(value: number);
  31333. get stencilFuncMask(): number;
  31334. set stencilFuncMask(value: number);
  31335. get stencilOpStencilFail(): number;
  31336. set stencilOpStencilFail(value: number);
  31337. get stencilOpDepthFail(): number;
  31338. set stencilOpDepthFail(value: number);
  31339. get stencilOpStencilDepthPass(): number;
  31340. set stencilOpStencilDepthPass(value: number);
  31341. get stencilMask(): number;
  31342. set stencilMask(value: number);
  31343. get stencilTest(): boolean;
  31344. set stencilTest(value: boolean);
  31345. constructor();
  31346. reset(): void;
  31347. apply(gl: WebGLRenderingContext): void;
  31348. }
  31349. }
  31350. declare module "babylonjs/States/alphaCullingState" {
  31351. /**
  31352. * @hidden
  31353. **/
  31354. export class AlphaState {
  31355. private _isAlphaBlendDirty;
  31356. private _isBlendFunctionParametersDirty;
  31357. private _isBlendEquationParametersDirty;
  31358. private _isBlendConstantsDirty;
  31359. private _alphaBlend;
  31360. private _blendFunctionParameters;
  31361. private _blendEquationParameters;
  31362. private _blendConstants;
  31363. /**
  31364. * Initializes the state.
  31365. */
  31366. constructor();
  31367. get isDirty(): boolean;
  31368. get alphaBlend(): boolean;
  31369. set alphaBlend(value: boolean);
  31370. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31371. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31372. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31373. reset(): void;
  31374. apply(gl: WebGLRenderingContext): void;
  31375. }
  31376. }
  31377. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31378. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31379. /** @hidden */
  31380. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31381. attributeProcessor(attribute: string): string;
  31382. varyingProcessor(varying: string, isFragment: boolean): string;
  31383. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31384. }
  31385. }
  31386. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31387. /**
  31388. * Interface for attribute information associated with buffer instanciation
  31389. */
  31390. export interface InstancingAttributeInfo {
  31391. /**
  31392. * Name of the GLSL attribute
  31393. * if attribute index is not specified, this is used to retrieve the index from the effect
  31394. */
  31395. attributeName: string;
  31396. /**
  31397. * Index/offset of the attribute in the vertex shader
  31398. * if not specified, this will be computes from the name.
  31399. */
  31400. index?: number;
  31401. /**
  31402. * size of the attribute, 1, 2, 3 or 4
  31403. */
  31404. attributeSize: number;
  31405. /**
  31406. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31407. */
  31408. offset: number;
  31409. /**
  31410. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31411. * default to 1
  31412. */
  31413. divisor?: number;
  31414. /**
  31415. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31416. * default is FLOAT
  31417. */
  31418. attributeType?: number;
  31419. /**
  31420. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31421. */
  31422. normalized?: boolean;
  31423. }
  31424. }
  31425. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31426. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31427. import { Nullable } from "babylonjs/types";
  31428. module "babylonjs/Engines/thinEngine" {
  31429. interface ThinEngine {
  31430. /**
  31431. * Update a video texture
  31432. * @param texture defines the texture to update
  31433. * @param video defines the video element to use
  31434. * @param invertY defines if data must be stored with Y axis inverted
  31435. */
  31436. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31437. }
  31438. }
  31439. }
  31440. declare module "babylonjs/Materials/Textures/videoTexture" {
  31441. import { Observable } from "babylonjs/Misc/observable";
  31442. import { Nullable } from "babylonjs/types";
  31443. import { Scene } from "babylonjs/scene";
  31444. import { Texture } from "babylonjs/Materials/Textures/texture";
  31445. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31446. /**
  31447. * Settings for finer control over video usage
  31448. */
  31449. export interface VideoTextureSettings {
  31450. /**
  31451. * Applies `autoplay` to video, if specified
  31452. */
  31453. autoPlay?: boolean;
  31454. /**
  31455. * Applies `loop` to video, if specified
  31456. */
  31457. loop?: boolean;
  31458. /**
  31459. * Automatically updates internal texture from video at every frame in the render loop
  31460. */
  31461. autoUpdateTexture: boolean;
  31462. /**
  31463. * Image src displayed during the video loading or until the user interacts with the video.
  31464. */
  31465. poster?: string;
  31466. }
  31467. /**
  31468. * If you want to display a video in your scene, this is the special texture for that.
  31469. * This special texture works similar to other textures, with the exception of a few parameters.
  31470. * @see https://doc.babylonjs.com/how_to/video_texture
  31471. */
  31472. export class VideoTexture extends Texture {
  31473. /**
  31474. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31475. */
  31476. readonly autoUpdateTexture: boolean;
  31477. /**
  31478. * The video instance used by the texture internally
  31479. */
  31480. readonly video: HTMLVideoElement;
  31481. private _onUserActionRequestedObservable;
  31482. /**
  31483. * Event triggerd when a dom action is required by the user to play the video.
  31484. * This happens due to recent changes in browser policies preventing video to auto start.
  31485. */
  31486. get onUserActionRequestedObservable(): Observable<Texture>;
  31487. private _generateMipMaps;
  31488. private _engine;
  31489. private _stillImageCaptured;
  31490. private _displayingPosterTexture;
  31491. private _settings;
  31492. private _createInternalTextureOnEvent;
  31493. private _frameId;
  31494. /**
  31495. * Creates a video texture.
  31496. * If you want to display a video in your scene, this is the special texture for that.
  31497. * This special texture works similar to other textures, with the exception of a few parameters.
  31498. * @see https://doc.babylonjs.com/how_to/video_texture
  31499. * @param name optional name, will detect from video source, if not defined
  31500. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31501. * @param scene is obviously the current scene.
  31502. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31503. * @param invertY is false by default but can be used to invert video on Y axis
  31504. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31505. * @param settings allows finer control over video usage
  31506. */
  31507. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31508. private _getName;
  31509. private _getVideo;
  31510. private _createInternalTexture;
  31511. private reset;
  31512. /**
  31513. * @hidden Internal method to initiate `update`.
  31514. */
  31515. _rebuild(): void;
  31516. /**
  31517. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31518. */
  31519. update(): void;
  31520. /**
  31521. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31522. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31523. */
  31524. updateTexture(isVisible: boolean): void;
  31525. protected _updateInternalTexture: () => void;
  31526. /**
  31527. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31528. * @param url New url.
  31529. */
  31530. updateURL(url: string): void;
  31531. /**
  31532. * Dispose the texture and release its associated resources.
  31533. */
  31534. dispose(): void;
  31535. /**
  31536. * Creates a video texture straight from a stream.
  31537. * @param scene Define the scene the texture should be created in
  31538. * @param stream Define the stream the texture should be created from
  31539. * @returns The created video texture as a promise
  31540. */
  31541. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31542. /**
  31543. * Creates a video texture straight from your WebCam video feed.
  31544. * @param scene Define the scene the texture should be created in
  31545. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31546. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31547. * @returns The created video texture as a promise
  31548. */
  31549. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31550. minWidth: number;
  31551. maxWidth: number;
  31552. minHeight: number;
  31553. maxHeight: number;
  31554. deviceId: string;
  31555. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31556. /**
  31557. * Creates a video texture straight from your WebCam video feed.
  31558. * @param scene Define the scene the texture should be created in
  31559. * @param onReady Define a callback to triggered once the texture will be ready
  31560. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31561. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31562. */
  31563. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31564. minWidth: number;
  31565. maxWidth: number;
  31566. minHeight: number;
  31567. maxHeight: number;
  31568. deviceId: string;
  31569. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31570. }
  31571. }
  31572. declare module "babylonjs/Engines/thinEngine" {
  31573. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31574. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31575. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31576. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31577. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31578. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31579. import { Observable } from "babylonjs/Misc/observable";
  31580. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31581. import { StencilState } from "babylonjs/States/stencilState";
  31582. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31583. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31584. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31585. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31586. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31587. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31588. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31589. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31590. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31591. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31592. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31593. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31594. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31595. import { WebRequest } from "babylonjs/Misc/webRequest";
  31596. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31597. /**
  31598. * Defines the interface used by objects working like Scene
  31599. * @hidden
  31600. */
  31601. interface ISceneLike {
  31602. _addPendingData(data: any): void;
  31603. _removePendingData(data: any): void;
  31604. offlineProvider: IOfflineProvider;
  31605. }
  31606. /** Interface defining initialization parameters for Engine class */
  31607. export interface EngineOptions extends WebGLContextAttributes {
  31608. /**
  31609. * Defines if the engine should no exceed a specified device ratio
  31610. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31611. */
  31612. limitDeviceRatio?: number;
  31613. /**
  31614. * Defines if webvr should be enabled automatically
  31615. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31616. */
  31617. autoEnableWebVR?: boolean;
  31618. /**
  31619. * Defines if webgl2 should be turned off even if supported
  31620. * @see http://doc.babylonjs.com/features/webgl2
  31621. */
  31622. disableWebGL2Support?: boolean;
  31623. /**
  31624. * Defines if webaudio should be initialized as well
  31625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31626. */
  31627. audioEngine?: boolean;
  31628. /**
  31629. * Defines if animations should run using a deterministic lock step
  31630. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31631. */
  31632. deterministicLockstep?: boolean;
  31633. /** Defines the maximum steps to use with deterministic lock step mode */
  31634. lockstepMaxSteps?: number;
  31635. /** Defines the seconds between each deterministic lock step */
  31636. timeStep?: number;
  31637. /**
  31638. * Defines that engine should ignore context lost events
  31639. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31640. */
  31641. doNotHandleContextLost?: boolean;
  31642. /**
  31643. * Defines that engine should ignore modifying touch action attribute and style
  31644. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31645. */
  31646. doNotHandleTouchAction?: boolean;
  31647. /**
  31648. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31649. */
  31650. useHighPrecisionFloats?: boolean;
  31651. }
  31652. /**
  31653. * The base engine class (root of all engines)
  31654. */
  31655. export class ThinEngine {
  31656. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31657. static ExceptionList: ({
  31658. key: string;
  31659. capture: string;
  31660. captureConstraint: number;
  31661. targets: string[];
  31662. } | {
  31663. key: string;
  31664. capture: null;
  31665. captureConstraint: null;
  31666. targets: string[];
  31667. })[];
  31668. /** @hidden */
  31669. static _TextureLoaders: IInternalTextureLoader[];
  31670. /**
  31671. * Returns the current npm package of the sdk
  31672. */
  31673. static get NpmPackage(): string;
  31674. /**
  31675. * Returns the current version of the framework
  31676. */
  31677. static get Version(): string;
  31678. /**
  31679. * Returns a string describing the current engine
  31680. */
  31681. get description(): string;
  31682. /**
  31683. * Gets or sets the epsilon value used by collision engine
  31684. */
  31685. static CollisionsEpsilon: number;
  31686. /**
  31687. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31688. */
  31689. static get ShadersRepository(): string;
  31690. static set ShadersRepository(value: string);
  31691. /**
  31692. * Gets or sets the textures that the engine should not attempt to load as compressed
  31693. */
  31694. protected _excludedCompressedTextures: string[];
  31695. /**
  31696. * Filters the compressed texture formats to only include
  31697. * files that are not included in the skippable list
  31698. *
  31699. * @param url the current extension
  31700. * @param textureFormatInUse the current compressed texture format
  31701. * @returns "format" string
  31702. */
  31703. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31704. /** @hidden */
  31705. _shaderProcessor: IShaderProcessor;
  31706. /**
  31707. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31708. */
  31709. forcePOTTextures: boolean;
  31710. /**
  31711. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31712. */
  31713. isFullscreen: boolean;
  31714. /**
  31715. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31716. */
  31717. cullBackFaces: boolean;
  31718. /**
  31719. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31720. */
  31721. renderEvenInBackground: boolean;
  31722. /**
  31723. * Gets or sets a boolean indicating that cache can be kept between frames
  31724. */
  31725. preventCacheWipeBetweenFrames: boolean;
  31726. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31727. validateShaderPrograms: boolean;
  31728. /**
  31729. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31730. * This can provide greater z depth for distant objects.
  31731. */
  31732. useReverseDepthBuffer: boolean;
  31733. /**
  31734. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31735. */
  31736. disableUniformBuffers: boolean;
  31737. /** @hidden */
  31738. _uniformBuffers: UniformBuffer[];
  31739. /**
  31740. * Gets a boolean indicating that the engine supports uniform buffers
  31741. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31742. */
  31743. get supportsUniformBuffers(): boolean;
  31744. /** @hidden */
  31745. _gl: WebGLRenderingContext;
  31746. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31747. protected _windowIsBackground: boolean;
  31748. protected _webGLVersion: number;
  31749. protected _creationOptions: EngineOptions;
  31750. protected _highPrecisionShadersAllowed: boolean;
  31751. /** @hidden */
  31752. get _shouldUseHighPrecisionShader(): boolean;
  31753. /**
  31754. * Gets a boolean indicating that only power of 2 textures are supported
  31755. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31756. */
  31757. get needPOTTextures(): boolean;
  31758. /** @hidden */
  31759. _badOS: boolean;
  31760. /** @hidden */
  31761. _badDesktopOS: boolean;
  31762. private _hardwareScalingLevel;
  31763. /** @hidden */
  31764. _caps: EngineCapabilities;
  31765. private _isStencilEnable;
  31766. private _glVersion;
  31767. private _glRenderer;
  31768. private _glVendor;
  31769. /** @hidden */
  31770. _videoTextureSupported: boolean;
  31771. protected _renderingQueueLaunched: boolean;
  31772. protected _activeRenderLoops: (() => void)[];
  31773. /**
  31774. * Observable signaled when a context lost event is raised
  31775. */
  31776. onContextLostObservable: Observable<ThinEngine>;
  31777. /**
  31778. * Observable signaled when a context restored event is raised
  31779. */
  31780. onContextRestoredObservable: Observable<ThinEngine>;
  31781. private _onContextLost;
  31782. private _onContextRestored;
  31783. protected _contextWasLost: boolean;
  31784. /** @hidden */
  31785. _doNotHandleContextLost: boolean;
  31786. /**
  31787. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31788. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31789. */
  31790. get doNotHandleContextLost(): boolean;
  31791. set doNotHandleContextLost(value: boolean);
  31792. /**
  31793. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31794. */
  31795. disableVertexArrayObjects: boolean;
  31796. /** @hidden */
  31797. protected _colorWrite: boolean;
  31798. /** @hidden */
  31799. protected _colorWriteChanged: boolean;
  31800. /** @hidden */
  31801. protected _depthCullingState: DepthCullingState;
  31802. /** @hidden */
  31803. protected _stencilState: StencilState;
  31804. /** @hidden */
  31805. _alphaState: AlphaState;
  31806. /** @hidden */
  31807. _alphaMode: number;
  31808. /** @hidden */
  31809. _alphaEquation: number;
  31810. /** @hidden */
  31811. _internalTexturesCache: InternalTexture[];
  31812. /** @hidden */
  31813. protected _activeChannel: number;
  31814. private _currentTextureChannel;
  31815. /** @hidden */
  31816. protected _boundTexturesCache: {
  31817. [key: string]: Nullable<InternalTexture>;
  31818. };
  31819. /** @hidden */
  31820. protected _currentEffect: Nullable<Effect>;
  31821. /** @hidden */
  31822. protected _currentProgram: Nullable<WebGLProgram>;
  31823. private _compiledEffects;
  31824. private _vertexAttribArraysEnabled;
  31825. /** @hidden */
  31826. protected _cachedViewport: Nullable<IViewportLike>;
  31827. private _cachedVertexArrayObject;
  31828. /** @hidden */
  31829. protected _cachedVertexBuffers: any;
  31830. /** @hidden */
  31831. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31832. /** @hidden */
  31833. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31834. /** @hidden */
  31835. _currentRenderTarget: Nullable<InternalTexture>;
  31836. private _uintIndicesCurrentlySet;
  31837. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31838. /** @hidden */
  31839. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31840. private _currentBufferPointers;
  31841. private _currentInstanceLocations;
  31842. private _currentInstanceBuffers;
  31843. private _textureUnits;
  31844. /** @hidden */
  31845. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31846. /** @hidden */
  31847. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31848. /** @hidden */
  31849. _boundRenderFunction: any;
  31850. private _vaoRecordInProgress;
  31851. private _mustWipeVertexAttributes;
  31852. private _emptyTexture;
  31853. private _emptyCubeTexture;
  31854. private _emptyTexture3D;
  31855. private _emptyTexture2DArray;
  31856. /** @hidden */
  31857. _frameHandler: number;
  31858. private _nextFreeTextureSlots;
  31859. private _maxSimultaneousTextures;
  31860. private _activeRequests;
  31861. protected _texturesSupported: string[];
  31862. /** @hidden */
  31863. _textureFormatInUse: Nullable<string>;
  31864. protected get _supportsHardwareTextureRescaling(): boolean;
  31865. /**
  31866. * Gets the list of texture formats supported
  31867. */
  31868. get texturesSupported(): Array<string>;
  31869. /**
  31870. * Gets the list of texture formats in use
  31871. */
  31872. get textureFormatInUse(): Nullable<string>;
  31873. /**
  31874. * Gets the current viewport
  31875. */
  31876. get currentViewport(): Nullable<IViewportLike>;
  31877. /**
  31878. * Gets the default empty texture
  31879. */
  31880. get emptyTexture(): InternalTexture;
  31881. /**
  31882. * Gets the default empty 3D texture
  31883. */
  31884. get emptyTexture3D(): InternalTexture;
  31885. /**
  31886. * Gets the default empty 2D array texture
  31887. */
  31888. get emptyTexture2DArray(): InternalTexture;
  31889. /**
  31890. * Gets the default empty cube texture
  31891. */
  31892. get emptyCubeTexture(): InternalTexture;
  31893. /**
  31894. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31895. */
  31896. readonly premultipliedAlpha: boolean;
  31897. /**
  31898. * Observable event triggered before each texture is initialized
  31899. */
  31900. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31901. /**
  31902. * Creates a new engine
  31903. * @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
  31904. * @param antialias defines enable antialiasing (default: false)
  31905. * @param options defines further options to be sent to the getContext() function
  31906. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31907. */
  31908. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31909. private _rebuildInternalTextures;
  31910. private _rebuildEffects;
  31911. /**
  31912. * Gets a boolean indicating if all created effects are ready
  31913. * @returns true if all effects are ready
  31914. */
  31915. areAllEffectsReady(): boolean;
  31916. protected _rebuildBuffers(): void;
  31917. private _initGLContext;
  31918. /**
  31919. * Gets version of the current webGL context
  31920. */
  31921. get webGLVersion(): number;
  31922. /**
  31923. * Gets a string idenfifying the name of the class
  31924. * @returns "Engine" string
  31925. */
  31926. getClassName(): string;
  31927. /**
  31928. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31929. */
  31930. get isStencilEnable(): boolean;
  31931. /** @hidden */
  31932. _prepareWorkingCanvas(): void;
  31933. /**
  31934. * Reset the texture cache to empty state
  31935. */
  31936. resetTextureCache(): void;
  31937. /**
  31938. * Gets an object containing information about the current webGL context
  31939. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31940. */
  31941. getGlInfo(): {
  31942. vendor: string;
  31943. renderer: string;
  31944. version: string;
  31945. };
  31946. /**
  31947. * Defines the hardware scaling level.
  31948. * By default the hardware scaling level is computed from the window device ratio.
  31949. * 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.
  31950. * @param level defines the level to use
  31951. */
  31952. setHardwareScalingLevel(level: number): void;
  31953. /**
  31954. * Gets the current hardware scaling level.
  31955. * By default the hardware scaling level is computed from the window device ratio.
  31956. * 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.
  31957. * @returns a number indicating the current hardware scaling level
  31958. */
  31959. getHardwareScalingLevel(): number;
  31960. /**
  31961. * Gets the list of loaded textures
  31962. * @returns an array containing all loaded textures
  31963. */
  31964. getLoadedTexturesCache(): InternalTexture[];
  31965. /**
  31966. * Gets the object containing all engine capabilities
  31967. * @returns the EngineCapabilities object
  31968. */
  31969. getCaps(): EngineCapabilities;
  31970. /**
  31971. * stop executing a render loop function and remove it from the execution array
  31972. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31973. */
  31974. stopRenderLoop(renderFunction?: () => void): void;
  31975. /** @hidden */
  31976. _renderLoop(): void;
  31977. /**
  31978. * Gets the HTML canvas attached with the current webGL context
  31979. * @returns a HTML canvas
  31980. */
  31981. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31982. /**
  31983. * Gets host window
  31984. * @returns the host window object
  31985. */
  31986. getHostWindow(): Nullable<Window>;
  31987. /**
  31988. * Gets the current render width
  31989. * @param useScreen defines if screen size must be used (or the current render target if any)
  31990. * @returns a number defining the current render width
  31991. */
  31992. getRenderWidth(useScreen?: boolean): number;
  31993. /**
  31994. * Gets the current render height
  31995. * @param useScreen defines if screen size must be used (or the current render target if any)
  31996. * @returns a number defining the current render height
  31997. */
  31998. getRenderHeight(useScreen?: boolean): number;
  31999. /**
  32000. * Can be used to override the current requestAnimationFrame requester.
  32001. * @hidden
  32002. */
  32003. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32004. /**
  32005. * Register and execute a render loop. The engine can have more than one render function
  32006. * @param renderFunction defines the function to continuously execute
  32007. */
  32008. runRenderLoop(renderFunction: () => void): void;
  32009. /**
  32010. * Clear the current render buffer or the current render target (if any is set up)
  32011. * @param color defines the color to use
  32012. * @param backBuffer defines if the back buffer must be cleared
  32013. * @param depth defines if the depth buffer must be cleared
  32014. * @param stencil defines if the stencil buffer must be cleared
  32015. */
  32016. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32017. private _viewportCached;
  32018. /** @hidden */
  32019. _viewport(x: number, y: number, width: number, height: number): void;
  32020. /**
  32021. * Set the WebGL's viewport
  32022. * @param viewport defines the viewport element to be used
  32023. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32024. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32025. */
  32026. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32027. /**
  32028. * Begin a new frame
  32029. */
  32030. beginFrame(): void;
  32031. /**
  32032. * Enf the current frame
  32033. */
  32034. endFrame(): void;
  32035. /**
  32036. * Resize the view according to the canvas' size
  32037. */
  32038. resize(): void;
  32039. /**
  32040. * Force a specific size of the canvas
  32041. * @param width defines the new canvas' width
  32042. * @param height defines the new canvas' height
  32043. */
  32044. setSize(width: number, height: number): void;
  32045. /**
  32046. * Binds the frame buffer to the specified texture.
  32047. * @param texture The texture to render to or null for the default canvas
  32048. * @param faceIndex The face of the texture to render to in case of cube texture
  32049. * @param requiredWidth The width of the target to render to
  32050. * @param requiredHeight The height of the target to render to
  32051. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32052. * @param depthStencilTexture The depth stencil texture to use to render
  32053. * @param lodLevel defines le lod level to bind to the frame buffer
  32054. */
  32055. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  32056. /** @hidden */
  32057. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32058. /**
  32059. * Unbind the current render target texture from the webGL context
  32060. * @param texture defines the render target texture to unbind
  32061. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32062. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32063. */
  32064. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32065. /**
  32066. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32067. */
  32068. flushFramebuffer(): void;
  32069. /**
  32070. * Unbind the current render target and bind the default framebuffer
  32071. */
  32072. restoreDefaultFramebuffer(): void;
  32073. /** @hidden */
  32074. protected _resetVertexBufferBinding(): void;
  32075. /**
  32076. * Creates a vertex buffer
  32077. * @param data the data for the vertex buffer
  32078. * @returns the new WebGL static buffer
  32079. */
  32080. createVertexBuffer(data: DataArray): DataBuffer;
  32081. private _createVertexBuffer;
  32082. /**
  32083. * Creates a dynamic vertex buffer
  32084. * @param data the data for the dynamic vertex buffer
  32085. * @returns the new WebGL dynamic buffer
  32086. */
  32087. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32088. protected _resetIndexBufferBinding(): void;
  32089. /**
  32090. * Creates a new index buffer
  32091. * @param indices defines the content of the index buffer
  32092. * @param updatable defines if the index buffer must be updatable
  32093. * @returns a new webGL buffer
  32094. */
  32095. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32096. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32097. /**
  32098. * Bind a webGL buffer to the webGL context
  32099. * @param buffer defines the buffer to bind
  32100. */
  32101. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32102. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32103. private bindBuffer;
  32104. /**
  32105. * update the bound buffer with the given data
  32106. * @param data defines the data to update
  32107. */
  32108. updateArrayBuffer(data: Float32Array): void;
  32109. private _vertexAttribPointer;
  32110. private _bindIndexBufferWithCache;
  32111. private _bindVertexBuffersAttributes;
  32112. /**
  32113. * Records a vertex array object
  32114. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32115. * @param vertexBuffers defines the list of vertex buffers to store
  32116. * @param indexBuffer defines the index buffer to store
  32117. * @param effect defines the effect to store
  32118. * @returns the new vertex array object
  32119. */
  32120. recordVertexArrayObject(vertexBuffers: {
  32121. [key: string]: VertexBuffer;
  32122. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32123. /**
  32124. * Bind a specific vertex array object
  32125. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32126. * @param vertexArrayObject defines the vertex array object to bind
  32127. * @param indexBuffer defines the index buffer to bind
  32128. */
  32129. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32130. /**
  32131. * Bind webGl buffers directly to the webGL context
  32132. * @param vertexBuffer defines the vertex buffer to bind
  32133. * @param indexBuffer defines the index buffer to bind
  32134. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32135. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32136. * @param effect defines the effect associated with the vertex buffer
  32137. */
  32138. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32139. private _unbindVertexArrayObject;
  32140. /**
  32141. * Bind a list of vertex buffers to the webGL context
  32142. * @param vertexBuffers defines the list of vertex buffers to bind
  32143. * @param indexBuffer defines the index buffer to bind
  32144. * @param effect defines the effect associated with the vertex buffers
  32145. */
  32146. bindBuffers(vertexBuffers: {
  32147. [key: string]: Nullable<VertexBuffer>;
  32148. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32149. /**
  32150. * Unbind all instance attributes
  32151. */
  32152. unbindInstanceAttributes(): void;
  32153. /**
  32154. * Release and free the memory of a vertex array object
  32155. * @param vao defines the vertex array object to delete
  32156. */
  32157. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32158. /** @hidden */
  32159. _releaseBuffer(buffer: DataBuffer): boolean;
  32160. protected _deleteBuffer(buffer: DataBuffer): void;
  32161. /**
  32162. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32163. * @param instancesBuffer defines the webGL buffer to update and bind
  32164. * @param data defines the data to store in the buffer
  32165. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32166. */
  32167. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32168. /**
  32169. * Bind the content of a webGL buffer used with instanciation
  32170. * @param instancesBuffer defines the webGL buffer to bind
  32171. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32172. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32173. */
  32174. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32175. /**
  32176. * Disable the instance attribute corresponding to the name in parameter
  32177. * @param name defines the name of the attribute to disable
  32178. */
  32179. disableInstanceAttributeByName(name: string): void;
  32180. /**
  32181. * Disable the instance attribute corresponding to the location in parameter
  32182. * @param attributeLocation defines the attribute location of the attribute to disable
  32183. */
  32184. disableInstanceAttribute(attributeLocation: number): void;
  32185. /**
  32186. * Disable the attribute corresponding to the location in parameter
  32187. * @param attributeLocation defines the attribute location of the attribute to disable
  32188. */
  32189. disableAttributeByIndex(attributeLocation: number): void;
  32190. /**
  32191. * Send a draw order
  32192. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32193. * @param indexStart defines the starting index
  32194. * @param indexCount defines the number of index to draw
  32195. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32196. */
  32197. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32198. /**
  32199. * Draw a list of points
  32200. * @param verticesStart defines the index of first vertex to draw
  32201. * @param verticesCount defines the count of vertices to draw
  32202. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32203. */
  32204. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32205. /**
  32206. * Draw a list of unindexed primitives
  32207. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32208. * @param verticesStart defines the index of first vertex to draw
  32209. * @param verticesCount defines the count of vertices to draw
  32210. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32211. */
  32212. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32213. /**
  32214. * Draw a list of indexed primitives
  32215. * @param fillMode defines the primitive to use
  32216. * @param indexStart defines the starting index
  32217. * @param indexCount defines the number of index to draw
  32218. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32219. */
  32220. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32221. /**
  32222. * Draw a list of unindexed primitives
  32223. * @param fillMode defines the primitive to use
  32224. * @param verticesStart defines the index of first vertex to draw
  32225. * @param verticesCount defines the count of vertices to draw
  32226. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32227. */
  32228. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32229. private _drawMode;
  32230. /** @hidden */
  32231. protected _reportDrawCall(): void;
  32232. /** @hidden */
  32233. _releaseEffect(effect: Effect): void;
  32234. /** @hidden */
  32235. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32236. /**
  32237. * Create a new effect (used to store vertex/fragment shaders)
  32238. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32239. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32240. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32241. * @param samplers defines an array of string used to represent textures
  32242. * @param defines defines the string containing the defines to use to compile the shaders
  32243. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32244. * @param onCompiled defines a function to call when the effect creation is successful
  32245. * @param onError defines a function to call when the effect creation has failed
  32246. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32247. * @returns the new Effect
  32248. */
  32249. 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;
  32250. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32251. private _compileShader;
  32252. private _compileRawShader;
  32253. /**
  32254. * Directly creates a webGL program
  32255. * @param pipelineContext defines the pipeline context to attach to
  32256. * @param vertexCode defines the vertex shader code to use
  32257. * @param fragmentCode defines the fragment shader code to use
  32258. * @param context defines the webGL context to use (if not set, the current one will be used)
  32259. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32260. * @returns the new webGL program
  32261. */
  32262. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32263. /**
  32264. * Creates a webGL program
  32265. * @param pipelineContext defines the pipeline context to attach to
  32266. * @param vertexCode defines the vertex shader code to use
  32267. * @param fragmentCode defines the fragment shader code to use
  32268. * @param defines defines the string containing the defines to use to compile the shaders
  32269. * @param context defines the webGL context to use (if not set, the current one will be used)
  32270. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32271. * @returns the new webGL program
  32272. */
  32273. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32274. /**
  32275. * Creates a new pipeline context
  32276. * @returns the new pipeline
  32277. */
  32278. createPipelineContext(): IPipelineContext;
  32279. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32280. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32281. /** @hidden */
  32282. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32283. /** @hidden */
  32284. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32285. /** @hidden */
  32286. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32287. /**
  32288. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32289. * @param pipelineContext defines the pipeline context to use
  32290. * @param uniformsNames defines the list of uniform names
  32291. * @returns an array of webGL uniform locations
  32292. */
  32293. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32294. /**
  32295. * Gets the lsit of active attributes for a given webGL program
  32296. * @param pipelineContext defines the pipeline context to use
  32297. * @param attributesNames defines the list of attribute names to get
  32298. * @returns an array of indices indicating the offset of each attribute
  32299. */
  32300. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32301. /**
  32302. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32303. * @param effect defines the effect to activate
  32304. */
  32305. enableEffect(effect: Nullable<Effect>): void;
  32306. /**
  32307. * Set the value of an uniform to a number (int)
  32308. * @param uniform defines the webGL uniform location where to store the value
  32309. * @param value defines the int number to store
  32310. */
  32311. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32312. /**
  32313. * Set the value of an uniform to an array of int32
  32314. * @param uniform defines the webGL uniform location where to store the value
  32315. * @param array defines the array of int32 to store
  32316. */
  32317. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32318. /**
  32319. * Set the value of an uniform to an array of int32 (stored as vec2)
  32320. * @param uniform defines the webGL uniform location where to store the value
  32321. * @param array defines the array of int32 to store
  32322. */
  32323. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32324. /**
  32325. * Set the value of an uniform to an array of int32 (stored as vec3)
  32326. * @param uniform defines the webGL uniform location where to store the value
  32327. * @param array defines the array of int32 to store
  32328. */
  32329. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32330. /**
  32331. * Set the value of an uniform to an array of int32 (stored as vec4)
  32332. * @param uniform defines the webGL uniform location where to store the value
  32333. * @param array defines the array of int32 to store
  32334. */
  32335. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32336. /**
  32337. * Set the value of an uniform to an array of number
  32338. * @param uniform defines the webGL uniform location where to store the value
  32339. * @param array defines the array of number to store
  32340. */
  32341. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32342. /**
  32343. * Set the value of an uniform to an array of number (stored as vec2)
  32344. * @param uniform defines the webGL uniform location where to store the value
  32345. * @param array defines the array of number to store
  32346. */
  32347. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32348. /**
  32349. * Set the value of an uniform to an array of number (stored as vec3)
  32350. * @param uniform defines the webGL uniform location where to store the value
  32351. * @param array defines the array of number to store
  32352. */
  32353. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32354. /**
  32355. * Set the value of an uniform to an array of number (stored as vec4)
  32356. * @param uniform defines the webGL uniform location where to store the value
  32357. * @param array defines the array of number to store
  32358. */
  32359. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32360. /**
  32361. * Set the value of an uniform to an array of float32 (stored as matrices)
  32362. * @param uniform defines the webGL uniform location where to store the value
  32363. * @param matrices defines the array of float32 to store
  32364. */
  32365. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32366. /**
  32367. * Set the value of an uniform to a matrix (3x3)
  32368. * @param uniform defines the webGL uniform location where to store the value
  32369. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32370. */
  32371. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32372. /**
  32373. * Set the value of an uniform to a matrix (2x2)
  32374. * @param uniform defines the webGL uniform location where to store the value
  32375. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32376. */
  32377. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32378. /**
  32379. * Set the value of an uniform to a number (float)
  32380. * @param uniform defines the webGL uniform location where to store the value
  32381. * @param value defines the float number to store
  32382. */
  32383. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32384. /**
  32385. * Set the value of an uniform to a vec2
  32386. * @param uniform defines the webGL uniform location where to store the value
  32387. * @param x defines the 1st component of the value
  32388. * @param y defines the 2nd component of the value
  32389. */
  32390. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32391. /**
  32392. * Set the value of an uniform to a vec3
  32393. * @param uniform defines the webGL uniform location where to store the value
  32394. * @param x defines the 1st component of the value
  32395. * @param y defines the 2nd component of the value
  32396. * @param z defines the 3rd component of the value
  32397. */
  32398. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32399. /**
  32400. * Set the value of an uniform to a vec4
  32401. * @param uniform defines the webGL uniform location where to store the value
  32402. * @param x defines the 1st component of the value
  32403. * @param y defines the 2nd component of the value
  32404. * @param z defines the 3rd component of the value
  32405. * @param w defines the 4th component of the value
  32406. */
  32407. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32408. /**
  32409. * Apply all cached states (depth, culling, stencil and alpha)
  32410. */
  32411. applyStates(): void;
  32412. /**
  32413. * Enable or disable color writing
  32414. * @param enable defines the state to set
  32415. */
  32416. setColorWrite(enable: boolean): void;
  32417. /**
  32418. * Gets a boolean indicating if color writing is enabled
  32419. * @returns the current color writing state
  32420. */
  32421. getColorWrite(): boolean;
  32422. /**
  32423. * Gets the depth culling state manager
  32424. */
  32425. get depthCullingState(): DepthCullingState;
  32426. /**
  32427. * Gets the alpha state manager
  32428. */
  32429. get alphaState(): AlphaState;
  32430. /**
  32431. * Gets the stencil state manager
  32432. */
  32433. get stencilState(): StencilState;
  32434. /**
  32435. * Clears the list of texture accessible through engine.
  32436. * This can help preventing texture load conflict due to name collision.
  32437. */
  32438. clearInternalTexturesCache(): void;
  32439. /**
  32440. * Force the entire cache to be cleared
  32441. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32442. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32443. */
  32444. wipeCaches(bruteForce?: boolean): void;
  32445. /** @hidden */
  32446. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32447. min: number;
  32448. mag: number;
  32449. };
  32450. /** @hidden */
  32451. _createTexture(): WebGLTexture;
  32452. /**
  32453. * Usually called from Texture.ts.
  32454. * Passed information to create a WebGLTexture
  32455. * @param urlArg defines a value which contains one of the following:
  32456. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32457. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32458. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32459. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32460. * @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)
  32461. * @param scene needed for loading to the correct scene
  32462. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32463. * @param onLoad optional callback to be called upon successful completion
  32464. * @param onError optional callback to be called upon failure
  32465. * @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
  32466. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32467. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32468. * @param forcedExtension defines the extension to use to pick the right loader
  32469. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32470. * @param mimeType defines an optional mime type
  32471. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32472. */
  32473. 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;
  32474. /**
  32475. * Loads an image as an HTMLImageElement.
  32476. * @param input url string, ArrayBuffer, or Blob to load
  32477. * @param onLoad callback called when the image successfully loads
  32478. * @param onError callback called when the image fails to load
  32479. * @param offlineProvider offline provider for caching
  32480. * @param mimeType optional mime type
  32481. * @returns the HTMLImageElement of the loaded image
  32482. * @hidden
  32483. */
  32484. 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>;
  32485. /**
  32486. * @hidden
  32487. */
  32488. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32489. /**
  32490. * Creates a raw texture
  32491. * @param data defines the data to store in the texture
  32492. * @param width defines the width of the texture
  32493. * @param height defines the height of the texture
  32494. * @param format defines the format of the data
  32495. * @param generateMipMaps defines if the engine should generate the mip levels
  32496. * @param invertY defines if data must be stored with Y axis inverted
  32497. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32498. * @param compression defines the compression used (null by default)
  32499. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32500. * @returns the raw texture inside an InternalTexture
  32501. */
  32502. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32503. /**
  32504. * Creates a new raw cube texture
  32505. * @param data defines the array of data to use to create each face
  32506. * @param size defines the size of the textures
  32507. * @param format defines the format of the data
  32508. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32509. * @param generateMipMaps defines if the engine should generate the mip levels
  32510. * @param invertY defines if data must be stored with Y axis inverted
  32511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32512. * @param compression defines the compression used (null by default)
  32513. * @returns the cube texture as an InternalTexture
  32514. */
  32515. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32516. /**
  32517. * Creates a new raw 3D texture
  32518. * @param data defines the data used to create the texture
  32519. * @param width defines the width of the texture
  32520. * @param height defines the height of the texture
  32521. * @param depth defines the depth of the texture
  32522. * @param format defines the format of the texture
  32523. * @param generateMipMaps defines if the engine must generate mip levels
  32524. * @param invertY defines if data must be stored with Y axis inverted
  32525. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32526. * @param compression defines the compressed used (can be null)
  32527. * @param textureType defines the compressed used (can be null)
  32528. * @returns a new raw 3D texture (stored in an InternalTexture)
  32529. */
  32530. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32531. /**
  32532. * Creates a new raw 2D array texture
  32533. * @param data defines the data used to create the texture
  32534. * @param width defines the width of the texture
  32535. * @param height defines the height of the texture
  32536. * @param depth defines the number of layers of the texture
  32537. * @param format defines the format of the texture
  32538. * @param generateMipMaps defines if the engine must generate mip levels
  32539. * @param invertY defines if data must be stored with Y axis inverted
  32540. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32541. * @param compression defines the compressed used (can be null)
  32542. * @param textureType defines the compressed used (can be null)
  32543. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32544. */
  32545. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32546. private _unpackFlipYCached;
  32547. /**
  32548. * In case you are sharing the context with other applications, it might
  32549. * be interested to not cache the unpack flip y state to ensure a consistent
  32550. * value would be set.
  32551. */
  32552. enableUnpackFlipYCached: boolean;
  32553. /** @hidden */
  32554. _unpackFlipY(value: boolean): void;
  32555. /** @hidden */
  32556. _getUnpackAlignement(): number;
  32557. private _getTextureTarget;
  32558. /**
  32559. * Update the sampling mode of a given texture
  32560. * @param samplingMode defines the required sampling mode
  32561. * @param texture defines the texture to update
  32562. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32563. */
  32564. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32565. /**
  32566. * Update the sampling mode of a given texture
  32567. * @param texture defines the texture to update
  32568. * @param wrapU defines the texture wrap mode of the u coordinates
  32569. * @param wrapV defines the texture wrap mode of the v coordinates
  32570. * @param wrapR defines the texture wrap mode of the r coordinates
  32571. */
  32572. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32573. /** @hidden */
  32574. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32575. width: number;
  32576. height: number;
  32577. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32578. /** @hidden */
  32579. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32580. /** @hidden */
  32581. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32582. /** @hidden */
  32583. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32584. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32585. private _prepareWebGLTexture;
  32586. /** @hidden */
  32587. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32588. private _getDepthStencilBuffer;
  32589. /** @hidden */
  32590. _releaseFramebufferObjects(texture: InternalTexture): void;
  32591. /** @hidden */
  32592. _releaseTexture(texture: InternalTexture): void;
  32593. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32594. protected _setProgram(program: WebGLProgram): void;
  32595. protected _boundUniforms: {
  32596. [key: number]: WebGLUniformLocation;
  32597. };
  32598. /**
  32599. * Binds an effect to the webGL context
  32600. * @param effect defines the effect to bind
  32601. */
  32602. bindSamplers(effect: Effect): void;
  32603. private _activateCurrentTexture;
  32604. /** @hidden */
  32605. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32606. /** @hidden */
  32607. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32608. /**
  32609. * Unbind all textures from the webGL context
  32610. */
  32611. unbindAllTextures(): void;
  32612. /**
  32613. * Sets a texture to the according uniform.
  32614. * @param channel The texture channel
  32615. * @param uniform The uniform to set
  32616. * @param texture The texture to apply
  32617. */
  32618. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32619. private _bindSamplerUniformToChannel;
  32620. private _getTextureWrapMode;
  32621. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32622. /**
  32623. * Sets an array of texture to the webGL context
  32624. * @param channel defines the channel where the texture array must be set
  32625. * @param uniform defines the associated uniform location
  32626. * @param textures defines the array of textures to bind
  32627. */
  32628. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32629. /** @hidden */
  32630. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32631. private _setTextureParameterFloat;
  32632. private _setTextureParameterInteger;
  32633. /**
  32634. * Unbind all vertex attributes from the webGL context
  32635. */
  32636. unbindAllAttributes(): void;
  32637. /**
  32638. * 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
  32639. */
  32640. releaseEffects(): void;
  32641. /**
  32642. * Dispose and release all associated resources
  32643. */
  32644. dispose(): void;
  32645. /**
  32646. * Attach a new callback raised when context lost event is fired
  32647. * @param callback defines the callback to call
  32648. */
  32649. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32650. /**
  32651. * Attach a new callback raised when context restored event is fired
  32652. * @param callback defines the callback to call
  32653. */
  32654. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32655. /**
  32656. * Get the current error code of the webGL context
  32657. * @returns the error code
  32658. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32659. */
  32660. getError(): number;
  32661. private _canRenderToFloatFramebuffer;
  32662. private _canRenderToHalfFloatFramebuffer;
  32663. private _canRenderToFramebuffer;
  32664. /** @hidden */
  32665. _getWebGLTextureType(type: number): number;
  32666. /** @hidden */
  32667. _getInternalFormat(format: number): number;
  32668. /** @hidden */
  32669. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32670. /** @hidden */
  32671. _getRGBAMultiSampleBufferFormat(type: number): number;
  32672. /** @hidden */
  32673. _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;
  32674. /**
  32675. * Loads a file from a url
  32676. * @param url url to load
  32677. * @param onSuccess callback called when the file successfully loads
  32678. * @param onProgress callback called while file is loading (if the server supports this mode)
  32679. * @param offlineProvider defines the offline provider for caching
  32680. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32681. * @param onError callback called when the file fails to load
  32682. * @returns a file request object
  32683. * @hidden
  32684. */
  32685. 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;
  32686. /**
  32687. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32688. * @param x defines the x coordinate of the rectangle where pixels must be read
  32689. * @param y defines the y coordinate of the rectangle where pixels must be read
  32690. * @param width defines the width of the rectangle where pixels must be read
  32691. * @param height defines the height of the rectangle where pixels must be read
  32692. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32693. * @returns a Uint8Array containing RGBA colors
  32694. */
  32695. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32696. private static _isSupported;
  32697. /**
  32698. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32699. * @returns true if the engine can be created
  32700. * @ignorenaming
  32701. */
  32702. static isSupported(): boolean;
  32703. /**
  32704. * Find the next highest power of two.
  32705. * @param x Number to start search from.
  32706. * @return Next highest power of two.
  32707. */
  32708. static CeilingPOT(x: number): number;
  32709. /**
  32710. * Find the next lowest power of two.
  32711. * @param x Number to start search from.
  32712. * @return Next lowest power of two.
  32713. */
  32714. static FloorPOT(x: number): number;
  32715. /**
  32716. * Find the nearest power of two.
  32717. * @param x Number to start search from.
  32718. * @return Next nearest power of two.
  32719. */
  32720. static NearestPOT(x: number): number;
  32721. /**
  32722. * Get the closest exponent of two
  32723. * @param value defines the value to approximate
  32724. * @param max defines the maximum value to return
  32725. * @param mode defines how to define the closest value
  32726. * @returns closest exponent of two of the given value
  32727. */
  32728. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32729. /**
  32730. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32731. * @param func - the function to be called
  32732. * @param requester - the object that will request the next frame. Falls back to window.
  32733. * @returns frame number
  32734. */
  32735. static QueueNewFrame(func: () => void, requester?: any): number;
  32736. /**
  32737. * Gets host document
  32738. * @returns the host document object
  32739. */
  32740. getHostDocument(): Nullable<Document>;
  32741. }
  32742. }
  32743. declare module "babylonjs/Maths/sphericalPolynomial" {
  32744. import { Vector3 } from "babylonjs/Maths/math.vector";
  32745. import { Color3 } from "babylonjs/Maths/math.color";
  32746. /**
  32747. * Class representing spherical harmonics coefficients to the 3rd degree
  32748. */
  32749. export class SphericalHarmonics {
  32750. /**
  32751. * Defines whether or not the harmonics have been prescaled for rendering.
  32752. */
  32753. preScaled: boolean;
  32754. /**
  32755. * The l0,0 coefficients of the spherical harmonics
  32756. */
  32757. l00: Vector3;
  32758. /**
  32759. * The l1,-1 coefficients of the spherical harmonics
  32760. */
  32761. l1_1: Vector3;
  32762. /**
  32763. * The l1,0 coefficients of the spherical harmonics
  32764. */
  32765. l10: Vector3;
  32766. /**
  32767. * The l1,1 coefficients of the spherical harmonics
  32768. */
  32769. l11: Vector3;
  32770. /**
  32771. * The l2,-2 coefficients of the spherical harmonics
  32772. */
  32773. l2_2: Vector3;
  32774. /**
  32775. * The l2,-1 coefficients of the spherical harmonics
  32776. */
  32777. l2_1: Vector3;
  32778. /**
  32779. * The l2,0 coefficients of the spherical harmonics
  32780. */
  32781. l20: Vector3;
  32782. /**
  32783. * The l2,1 coefficients of the spherical harmonics
  32784. */
  32785. l21: Vector3;
  32786. /**
  32787. * The l2,2 coefficients of the spherical harmonics
  32788. */
  32789. l22: Vector3;
  32790. /**
  32791. * Adds a light to the spherical harmonics
  32792. * @param direction the direction of the light
  32793. * @param color the color of the light
  32794. * @param deltaSolidAngle the delta solid angle of the light
  32795. */
  32796. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32797. /**
  32798. * Scales the spherical harmonics by the given amount
  32799. * @param scale the amount to scale
  32800. */
  32801. scaleInPlace(scale: number): void;
  32802. /**
  32803. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32804. *
  32805. * ```
  32806. * E_lm = A_l * L_lm
  32807. * ```
  32808. *
  32809. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32810. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32811. * the scaling factors are given in equation 9.
  32812. */
  32813. convertIncidentRadianceToIrradiance(): void;
  32814. /**
  32815. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32816. *
  32817. * ```
  32818. * L = (1/pi) * E * rho
  32819. * ```
  32820. *
  32821. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32822. */
  32823. convertIrradianceToLambertianRadiance(): void;
  32824. /**
  32825. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32826. * required operations at run time.
  32827. *
  32828. * This is simply done by scaling back the SH with Ylm constants parameter.
  32829. * The trigonometric part being applied by the shader at run time.
  32830. */
  32831. preScaleForRendering(): void;
  32832. /**
  32833. * Constructs a spherical harmonics from an array.
  32834. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32835. * @returns the spherical harmonics
  32836. */
  32837. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32838. /**
  32839. * Gets the spherical harmonics from polynomial
  32840. * @param polynomial the spherical polynomial
  32841. * @returns the spherical harmonics
  32842. */
  32843. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32844. }
  32845. /**
  32846. * Class representing spherical polynomial coefficients to the 3rd degree
  32847. */
  32848. export class SphericalPolynomial {
  32849. private _harmonics;
  32850. /**
  32851. * The spherical harmonics used to create the polynomials.
  32852. */
  32853. get preScaledHarmonics(): SphericalHarmonics;
  32854. /**
  32855. * The x coefficients of the spherical polynomial
  32856. */
  32857. x: Vector3;
  32858. /**
  32859. * The y coefficients of the spherical polynomial
  32860. */
  32861. y: Vector3;
  32862. /**
  32863. * The z coefficients of the spherical polynomial
  32864. */
  32865. z: Vector3;
  32866. /**
  32867. * The xx coefficients of the spherical polynomial
  32868. */
  32869. xx: Vector3;
  32870. /**
  32871. * The yy coefficients of the spherical polynomial
  32872. */
  32873. yy: Vector3;
  32874. /**
  32875. * The zz coefficients of the spherical polynomial
  32876. */
  32877. zz: Vector3;
  32878. /**
  32879. * The xy coefficients of the spherical polynomial
  32880. */
  32881. xy: Vector3;
  32882. /**
  32883. * The yz coefficients of the spherical polynomial
  32884. */
  32885. yz: Vector3;
  32886. /**
  32887. * The zx coefficients of the spherical polynomial
  32888. */
  32889. zx: Vector3;
  32890. /**
  32891. * Adds an ambient color to the spherical polynomial
  32892. * @param color the color to add
  32893. */
  32894. addAmbient(color: Color3): void;
  32895. /**
  32896. * Scales the spherical polynomial by the given amount
  32897. * @param scale the amount to scale
  32898. */
  32899. scaleInPlace(scale: number): void;
  32900. /**
  32901. * Gets the spherical polynomial from harmonics
  32902. * @param harmonics the spherical harmonics
  32903. * @returns the spherical polynomial
  32904. */
  32905. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32906. /**
  32907. * Constructs a spherical polynomial from an array.
  32908. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32909. * @returns the spherical polynomial
  32910. */
  32911. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32912. }
  32913. }
  32914. declare module "babylonjs/Materials/Textures/internalTexture" {
  32915. import { Observable } from "babylonjs/Misc/observable";
  32916. import { Nullable, int } from "babylonjs/types";
  32917. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32919. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32920. /**
  32921. * Defines the source of the internal texture
  32922. */
  32923. export enum InternalTextureSource {
  32924. /**
  32925. * The source of the texture data is unknown
  32926. */
  32927. Unknown = 0,
  32928. /**
  32929. * Texture data comes from an URL
  32930. */
  32931. Url = 1,
  32932. /**
  32933. * Texture data is only used for temporary storage
  32934. */
  32935. Temp = 2,
  32936. /**
  32937. * Texture data comes from raw data (ArrayBuffer)
  32938. */
  32939. Raw = 3,
  32940. /**
  32941. * Texture content is dynamic (video or dynamic texture)
  32942. */
  32943. Dynamic = 4,
  32944. /**
  32945. * Texture content is generated by rendering to it
  32946. */
  32947. RenderTarget = 5,
  32948. /**
  32949. * Texture content is part of a multi render target process
  32950. */
  32951. MultiRenderTarget = 6,
  32952. /**
  32953. * Texture data comes from a cube data file
  32954. */
  32955. Cube = 7,
  32956. /**
  32957. * Texture data comes from a raw cube data
  32958. */
  32959. CubeRaw = 8,
  32960. /**
  32961. * Texture data come from a prefiltered cube data file
  32962. */
  32963. CubePrefiltered = 9,
  32964. /**
  32965. * Texture content is raw 3D data
  32966. */
  32967. Raw3D = 10,
  32968. /**
  32969. * Texture content is raw 2D array data
  32970. */
  32971. Raw2DArray = 11,
  32972. /**
  32973. * Texture content is a depth texture
  32974. */
  32975. Depth = 12,
  32976. /**
  32977. * Texture data comes from a raw cube data encoded with RGBD
  32978. */
  32979. CubeRawRGBD = 13
  32980. }
  32981. /**
  32982. * Class used to store data associated with WebGL texture data for the engine
  32983. * This class should not be used directly
  32984. */
  32985. export class InternalTexture {
  32986. /** @hidden */
  32987. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32988. /**
  32989. * Defines if the texture is ready
  32990. */
  32991. isReady: boolean;
  32992. /**
  32993. * Defines if the texture is a cube texture
  32994. */
  32995. isCube: boolean;
  32996. /**
  32997. * Defines if the texture contains 3D data
  32998. */
  32999. is3D: boolean;
  33000. /**
  33001. * Defines if the texture contains 2D array data
  33002. */
  33003. is2DArray: boolean;
  33004. /**
  33005. * Defines if the texture contains multiview data
  33006. */
  33007. isMultiview: boolean;
  33008. /**
  33009. * Gets the URL used to load this texture
  33010. */
  33011. url: string;
  33012. /**
  33013. * Gets the sampling mode of the texture
  33014. */
  33015. samplingMode: number;
  33016. /**
  33017. * Gets a boolean indicating if the texture needs mipmaps generation
  33018. */
  33019. generateMipMaps: boolean;
  33020. /**
  33021. * Gets the number of samples used by the texture (WebGL2+ only)
  33022. */
  33023. samples: number;
  33024. /**
  33025. * Gets the type of the texture (int, float...)
  33026. */
  33027. type: number;
  33028. /**
  33029. * Gets the format of the texture (RGB, RGBA...)
  33030. */
  33031. format: number;
  33032. /**
  33033. * Observable called when the texture is loaded
  33034. */
  33035. onLoadedObservable: Observable<InternalTexture>;
  33036. /**
  33037. * Gets the width of the texture
  33038. */
  33039. width: number;
  33040. /**
  33041. * Gets the height of the texture
  33042. */
  33043. height: number;
  33044. /**
  33045. * Gets the depth of the texture
  33046. */
  33047. depth: number;
  33048. /**
  33049. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33050. */
  33051. baseWidth: number;
  33052. /**
  33053. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33054. */
  33055. baseHeight: number;
  33056. /**
  33057. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33058. */
  33059. baseDepth: number;
  33060. /**
  33061. * Gets a boolean indicating if the texture is inverted on Y axis
  33062. */
  33063. invertY: boolean;
  33064. /** @hidden */
  33065. _invertVScale: boolean;
  33066. /** @hidden */
  33067. _associatedChannel: number;
  33068. /** @hidden */
  33069. _source: InternalTextureSource;
  33070. /** @hidden */
  33071. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33072. /** @hidden */
  33073. _bufferView: Nullable<ArrayBufferView>;
  33074. /** @hidden */
  33075. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33076. /** @hidden */
  33077. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33078. /** @hidden */
  33079. _size: number;
  33080. /** @hidden */
  33081. _extension: string;
  33082. /** @hidden */
  33083. _files: Nullable<string[]>;
  33084. /** @hidden */
  33085. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33086. /** @hidden */
  33087. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33088. /** @hidden */
  33089. _framebuffer: Nullable<WebGLFramebuffer>;
  33090. /** @hidden */
  33091. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33092. /** @hidden */
  33093. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33094. /** @hidden */
  33095. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33096. /** @hidden */
  33097. _attachments: Nullable<number[]>;
  33098. /** @hidden */
  33099. _cachedCoordinatesMode: Nullable<number>;
  33100. /** @hidden */
  33101. _cachedWrapU: Nullable<number>;
  33102. /** @hidden */
  33103. _cachedWrapV: Nullable<number>;
  33104. /** @hidden */
  33105. _cachedWrapR: Nullable<number>;
  33106. /** @hidden */
  33107. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33108. /** @hidden */
  33109. _isDisabled: boolean;
  33110. /** @hidden */
  33111. _compression: Nullable<string>;
  33112. /** @hidden */
  33113. _generateStencilBuffer: boolean;
  33114. /** @hidden */
  33115. _generateDepthBuffer: boolean;
  33116. /** @hidden */
  33117. _comparisonFunction: number;
  33118. /** @hidden */
  33119. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33120. /** @hidden */
  33121. _lodGenerationScale: number;
  33122. /** @hidden */
  33123. _lodGenerationOffset: number;
  33124. /** @hidden */
  33125. _colorTextureArray: Nullable<WebGLTexture>;
  33126. /** @hidden */
  33127. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33128. /** @hidden */
  33129. _lodTextureHigh: Nullable<BaseTexture>;
  33130. /** @hidden */
  33131. _lodTextureMid: Nullable<BaseTexture>;
  33132. /** @hidden */
  33133. _lodTextureLow: Nullable<BaseTexture>;
  33134. /** @hidden */
  33135. _isRGBD: boolean;
  33136. /** @hidden */
  33137. _linearSpecularLOD: boolean;
  33138. /** @hidden */
  33139. _irradianceTexture: Nullable<BaseTexture>;
  33140. /** @hidden */
  33141. _webGLTexture: Nullable<WebGLTexture>;
  33142. /** @hidden */
  33143. _references: number;
  33144. private _engine;
  33145. /**
  33146. * Gets the Engine the texture belongs to.
  33147. * @returns The babylon engine
  33148. */
  33149. getEngine(): ThinEngine;
  33150. /**
  33151. * Gets the data source type of the texture
  33152. */
  33153. get source(): InternalTextureSource;
  33154. /**
  33155. * Creates a new InternalTexture
  33156. * @param engine defines the engine to use
  33157. * @param source defines the type of data that will be used
  33158. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33159. */
  33160. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33161. /**
  33162. * Increments the number of references (ie. the number of Texture that point to it)
  33163. */
  33164. incrementReferences(): void;
  33165. /**
  33166. * Change the size of the texture (not the size of the content)
  33167. * @param width defines the new width
  33168. * @param height defines the new height
  33169. * @param depth defines the new depth (1 by default)
  33170. */
  33171. updateSize(width: int, height: int, depth?: int): void;
  33172. /** @hidden */
  33173. _rebuild(): void;
  33174. /** @hidden */
  33175. _swapAndDie(target: InternalTexture): void;
  33176. /**
  33177. * Dispose the current allocated resources
  33178. */
  33179. dispose(): void;
  33180. }
  33181. }
  33182. declare module "babylonjs/Audio/analyser" {
  33183. import { Scene } from "babylonjs/scene";
  33184. /**
  33185. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33187. */
  33188. export class Analyser {
  33189. /**
  33190. * Gets or sets the smoothing
  33191. * @ignorenaming
  33192. */
  33193. SMOOTHING: number;
  33194. /**
  33195. * Gets or sets the FFT table size
  33196. * @ignorenaming
  33197. */
  33198. FFT_SIZE: number;
  33199. /**
  33200. * Gets or sets the bar graph amplitude
  33201. * @ignorenaming
  33202. */
  33203. BARGRAPHAMPLITUDE: number;
  33204. /**
  33205. * Gets or sets the position of the debug canvas
  33206. * @ignorenaming
  33207. */
  33208. DEBUGCANVASPOS: {
  33209. x: number;
  33210. y: number;
  33211. };
  33212. /**
  33213. * Gets or sets the debug canvas size
  33214. * @ignorenaming
  33215. */
  33216. DEBUGCANVASSIZE: {
  33217. width: number;
  33218. height: number;
  33219. };
  33220. private _byteFreqs;
  33221. private _byteTime;
  33222. private _floatFreqs;
  33223. private _webAudioAnalyser;
  33224. private _debugCanvas;
  33225. private _debugCanvasContext;
  33226. private _scene;
  33227. private _registerFunc;
  33228. private _audioEngine;
  33229. /**
  33230. * Creates a new analyser
  33231. * @param scene defines hosting scene
  33232. */
  33233. constructor(scene: Scene);
  33234. /**
  33235. * Get the number of data values you will have to play with for the visualization
  33236. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33237. * @returns a number
  33238. */
  33239. getFrequencyBinCount(): number;
  33240. /**
  33241. * Gets the current frequency data as a byte array
  33242. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33243. * @returns a Uint8Array
  33244. */
  33245. getByteFrequencyData(): Uint8Array;
  33246. /**
  33247. * Gets the current waveform as a byte array
  33248. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33249. * @returns a Uint8Array
  33250. */
  33251. getByteTimeDomainData(): Uint8Array;
  33252. /**
  33253. * Gets the current frequency data as a float array
  33254. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33255. * @returns a Float32Array
  33256. */
  33257. getFloatFrequencyData(): Float32Array;
  33258. /**
  33259. * Renders the debug canvas
  33260. */
  33261. drawDebugCanvas(): void;
  33262. /**
  33263. * Stops rendering the debug canvas and removes it
  33264. */
  33265. stopDebugCanvas(): void;
  33266. /**
  33267. * Connects two audio nodes
  33268. * @param inputAudioNode defines first node to connect
  33269. * @param outputAudioNode defines second node to connect
  33270. */
  33271. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33272. /**
  33273. * Releases all associated resources
  33274. */
  33275. dispose(): void;
  33276. }
  33277. }
  33278. declare module "babylonjs/Audio/audioEngine" {
  33279. import { IDisposable } from "babylonjs/scene";
  33280. import { Analyser } from "babylonjs/Audio/analyser";
  33281. import { Nullable } from "babylonjs/types";
  33282. import { Observable } from "babylonjs/Misc/observable";
  33283. /**
  33284. * This represents an audio engine and it is responsible
  33285. * to play, synchronize and analyse sounds throughout the application.
  33286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33287. */
  33288. export interface IAudioEngine extends IDisposable {
  33289. /**
  33290. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33291. */
  33292. readonly canUseWebAudio: boolean;
  33293. /**
  33294. * Gets the current AudioContext if available.
  33295. */
  33296. readonly audioContext: Nullable<AudioContext>;
  33297. /**
  33298. * The master gain node defines the global audio volume of your audio engine.
  33299. */
  33300. readonly masterGain: GainNode;
  33301. /**
  33302. * Gets whether or not mp3 are supported by your browser.
  33303. */
  33304. readonly isMP3supported: boolean;
  33305. /**
  33306. * Gets whether or not ogg are supported by your browser.
  33307. */
  33308. readonly isOGGsupported: boolean;
  33309. /**
  33310. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33311. * @ignoreNaming
  33312. */
  33313. WarnedWebAudioUnsupported: boolean;
  33314. /**
  33315. * Defines if the audio engine relies on a custom unlocked button.
  33316. * In this case, the embedded button will not be displayed.
  33317. */
  33318. useCustomUnlockedButton: boolean;
  33319. /**
  33320. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33321. */
  33322. readonly unlocked: boolean;
  33323. /**
  33324. * Event raised when audio has been unlocked on the browser.
  33325. */
  33326. onAudioUnlockedObservable: Observable<AudioEngine>;
  33327. /**
  33328. * Event raised when audio has been locked on the browser.
  33329. */
  33330. onAudioLockedObservable: Observable<AudioEngine>;
  33331. /**
  33332. * Flags the audio engine in Locked state.
  33333. * This happens due to new browser policies preventing audio to autoplay.
  33334. */
  33335. lock(): void;
  33336. /**
  33337. * Unlocks the audio engine once a user action has been done on the dom.
  33338. * This is helpful to resume play once browser policies have been satisfied.
  33339. */
  33340. unlock(): void;
  33341. }
  33342. /**
  33343. * This represents the default audio engine used in babylon.
  33344. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33346. */
  33347. export class AudioEngine implements IAudioEngine {
  33348. private _audioContext;
  33349. private _audioContextInitialized;
  33350. private _muteButton;
  33351. private _hostElement;
  33352. /**
  33353. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33354. */
  33355. canUseWebAudio: boolean;
  33356. /**
  33357. * The master gain node defines the global audio volume of your audio engine.
  33358. */
  33359. masterGain: GainNode;
  33360. /**
  33361. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33362. * @ignoreNaming
  33363. */
  33364. WarnedWebAudioUnsupported: boolean;
  33365. /**
  33366. * Gets whether or not mp3 are supported by your browser.
  33367. */
  33368. isMP3supported: boolean;
  33369. /**
  33370. * Gets whether or not ogg are supported by your browser.
  33371. */
  33372. isOGGsupported: boolean;
  33373. /**
  33374. * Gets whether audio has been unlocked on the device.
  33375. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33376. * a user interaction has happened.
  33377. */
  33378. unlocked: boolean;
  33379. /**
  33380. * Defines if the audio engine relies on a custom unlocked button.
  33381. * In this case, the embedded button will not be displayed.
  33382. */
  33383. useCustomUnlockedButton: boolean;
  33384. /**
  33385. * Event raised when audio has been unlocked on the browser.
  33386. */
  33387. onAudioUnlockedObservable: Observable<AudioEngine>;
  33388. /**
  33389. * Event raised when audio has been locked on the browser.
  33390. */
  33391. onAudioLockedObservable: Observable<AudioEngine>;
  33392. /**
  33393. * Gets the current AudioContext if available.
  33394. */
  33395. get audioContext(): Nullable<AudioContext>;
  33396. private _connectedAnalyser;
  33397. /**
  33398. * Instantiates a new audio engine.
  33399. *
  33400. * There should be only one per page as some browsers restrict the number
  33401. * of audio contexts you can create.
  33402. * @param hostElement defines the host element where to display the mute icon if necessary
  33403. */
  33404. constructor(hostElement?: Nullable<HTMLElement>);
  33405. /**
  33406. * Flags the audio engine in Locked state.
  33407. * This happens due to new browser policies preventing audio to autoplay.
  33408. */
  33409. lock(): void;
  33410. /**
  33411. * Unlocks the audio engine once a user action has been done on the dom.
  33412. * This is helpful to resume play once browser policies have been satisfied.
  33413. */
  33414. unlock(): void;
  33415. private _resumeAudioContext;
  33416. private _initializeAudioContext;
  33417. private _tryToRun;
  33418. private _triggerRunningState;
  33419. private _triggerSuspendedState;
  33420. private _displayMuteButton;
  33421. private _moveButtonToTopLeft;
  33422. private _onResize;
  33423. private _hideMuteButton;
  33424. /**
  33425. * Destroy and release the resources associated with the audio ccontext.
  33426. */
  33427. dispose(): void;
  33428. /**
  33429. * Gets the global volume sets on the master gain.
  33430. * @returns the global volume if set or -1 otherwise
  33431. */
  33432. getGlobalVolume(): number;
  33433. /**
  33434. * Sets the global volume of your experience (sets on the master gain).
  33435. * @param newVolume Defines the new global volume of the application
  33436. */
  33437. setGlobalVolume(newVolume: number): void;
  33438. /**
  33439. * Connect the audio engine to an audio analyser allowing some amazing
  33440. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33442. * @param analyser The analyser to connect to the engine
  33443. */
  33444. connectToAnalyser(analyser: Analyser): void;
  33445. }
  33446. }
  33447. declare module "babylonjs/Loading/loadingScreen" {
  33448. /**
  33449. * Interface used to present a loading screen while loading a scene
  33450. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33451. */
  33452. export interface ILoadingScreen {
  33453. /**
  33454. * Function called to display the loading screen
  33455. */
  33456. displayLoadingUI: () => void;
  33457. /**
  33458. * Function called to hide the loading screen
  33459. */
  33460. hideLoadingUI: () => void;
  33461. /**
  33462. * Gets or sets the color to use for the background
  33463. */
  33464. loadingUIBackgroundColor: string;
  33465. /**
  33466. * Gets or sets the text to display while loading
  33467. */
  33468. loadingUIText: string;
  33469. }
  33470. /**
  33471. * Class used for the default loading screen
  33472. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33473. */
  33474. export class DefaultLoadingScreen implements ILoadingScreen {
  33475. private _renderingCanvas;
  33476. private _loadingText;
  33477. private _loadingDivBackgroundColor;
  33478. private _loadingDiv;
  33479. private _loadingTextDiv;
  33480. /** Gets or sets the logo url to use for the default loading screen */
  33481. static DefaultLogoUrl: string;
  33482. /** Gets or sets the spinner url to use for the default loading screen */
  33483. static DefaultSpinnerUrl: string;
  33484. /**
  33485. * Creates a new default loading screen
  33486. * @param _renderingCanvas defines the canvas used to render the scene
  33487. * @param _loadingText defines the default text to display
  33488. * @param _loadingDivBackgroundColor defines the default background color
  33489. */
  33490. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33491. /**
  33492. * Function called to display the loading screen
  33493. */
  33494. displayLoadingUI(): void;
  33495. /**
  33496. * Function called to hide the loading screen
  33497. */
  33498. hideLoadingUI(): void;
  33499. /**
  33500. * Gets or sets the text to display while loading
  33501. */
  33502. set loadingUIText(text: string);
  33503. get loadingUIText(): string;
  33504. /**
  33505. * Gets or sets the color to use for the background
  33506. */
  33507. get loadingUIBackgroundColor(): string;
  33508. set loadingUIBackgroundColor(color: string);
  33509. private _resizeLoadingUI;
  33510. }
  33511. }
  33512. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33513. /**
  33514. * Interface for any object that can request an animation frame
  33515. */
  33516. export interface ICustomAnimationFrameRequester {
  33517. /**
  33518. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33519. */
  33520. renderFunction?: Function;
  33521. /**
  33522. * Called to request the next frame to render to
  33523. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33524. */
  33525. requestAnimationFrame: Function;
  33526. /**
  33527. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33528. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33529. */
  33530. requestID?: number;
  33531. }
  33532. }
  33533. declare module "babylonjs/Misc/performanceMonitor" {
  33534. /**
  33535. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33536. */
  33537. export class PerformanceMonitor {
  33538. private _enabled;
  33539. private _rollingFrameTime;
  33540. private _lastFrameTimeMs;
  33541. /**
  33542. * constructor
  33543. * @param frameSampleSize The number of samples required to saturate the sliding window
  33544. */
  33545. constructor(frameSampleSize?: number);
  33546. /**
  33547. * Samples current frame
  33548. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33549. */
  33550. sampleFrame(timeMs?: number): void;
  33551. /**
  33552. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33553. */
  33554. get averageFrameTime(): number;
  33555. /**
  33556. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33557. */
  33558. get averageFrameTimeVariance(): number;
  33559. /**
  33560. * Returns the frame time of the most recent frame
  33561. */
  33562. get instantaneousFrameTime(): number;
  33563. /**
  33564. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33565. */
  33566. get averageFPS(): number;
  33567. /**
  33568. * Returns the average framerate in frames per second using the most recent frame time
  33569. */
  33570. get instantaneousFPS(): number;
  33571. /**
  33572. * Returns true if enough samples have been taken to completely fill the sliding window
  33573. */
  33574. get isSaturated(): boolean;
  33575. /**
  33576. * Enables contributions to the sliding window sample set
  33577. */
  33578. enable(): void;
  33579. /**
  33580. * Disables contributions to the sliding window sample set
  33581. * Samples will not be interpolated over the disabled period
  33582. */
  33583. disable(): void;
  33584. /**
  33585. * Returns true if sampling is enabled
  33586. */
  33587. get isEnabled(): boolean;
  33588. /**
  33589. * Resets performance monitor
  33590. */
  33591. reset(): void;
  33592. }
  33593. /**
  33594. * RollingAverage
  33595. *
  33596. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33597. */
  33598. export class RollingAverage {
  33599. /**
  33600. * Current average
  33601. */
  33602. average: number;
  33603. /**
  33604. * Current variance
  33605. */
  33606. variance: number;
  33607. protected _samples: Array<number>;
  33608. protected _sampleCount: number;
  33609. protected _pos: number;
  33610. protected _m2: number;
  33611. /**
  33612. * constructor
  33613. * @param length The number of samples required to saturate the sliding window
  33614. */
  33615. constructor(length: number);
  33616. /**
  33617. * Adds a sample to the sample set
  33618. * @param v The sample value
  33619. */
  33620. add(v: number): void;
  33621. /**
  33622. * Returns previously added values or null if outside of history or outside the sliding window domain
  33623. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33624. * @return Value previously recorded with add() or null if outside of range
  33625. */
  33626. history(i: number): number;
  33627. /**
  33628. * Returns true if enough samples have been taken to completely fill the sliding window
  33629. * @return true if sample-set saturated
  33630. */
  33631. isSaturated(): boolean;
  33632. /**
  33633. * Resets the rolling average (equivalent to 0 samples taken so far)
  33634. */
  33635. reset(): void;
  33636. /**
  33637. * Wraps a value around the sample range boundaries
  33638. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33639. * @return Wrapped position in sample range
  33640. */
  33641. protected _wrapPosition(i: number): number;
  33642. }
  33643. }
  33644. declare module "babylonjs/Misc/perfCounter" {
  33645. /**
  33646. * This class is used to track a performance counter which is number based.
  33647. * The user has access to many properties which give statistics of different nature.
  33648. *
  33649. * The implementer can track two kinds of Performance Counter: time and count.
  33650. * 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.
  33651. * 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.
  33652. */
  33653. export class PerfCounter {
  33654. /**
  33655. * Gets or sets a global boolean to turn on and off all the counters
  33656. */
  33657. static Enabled: boolean;
  33658. /**
  33659. * Returns the smallest value ever
  33660. */
  33661. get min(): number;
  33662. /**
  33663. * Returns the biggest value ever
  33664. */
  33665. get max(): number;
  33666. /**
  33667. * Returns the average value since the performance counter is running
  33668. */
  33669. get average(): number;
  33670. /**
  33671. * Returns the average value of the last second the counter was monitored
  33672. */
  33673. get lastSecAverage(): number;
  33674. /**
  33675. * Returns the current value
  33676. */
  33677. get current(): number;
  33678. /**
  33679. * Gets the accumulated total
  33680. */
  33681. get total(): number;
  33682. /**
  33683. * Gets the total value count
  33684. */
  33685. get count(): number;
  33686. /**
  33687. * Creates a new counter
  33688. */
  33689. constructor();
  33690. /**
  33691. * Call this method to start monitoring a new frame.
  33692. * 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.
  33693. */
  33694. fetchNewFrame(): void;
  33695. /**
  33696. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33697. * @param newCount the count value to add to the monitored count
  33698. * @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.
  33699. */
  33700. addCount(newCount: number, fetchResult: boolean): void;
  33701. /**
  33702. * Start monitoring this performance counter
  33703. */
  33704. beginMonitoring(): void;
  33705. /**
  33706. * Compute the time lapsed since the previous beginMonitoring() call.
  33707. * @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
  33708. */
  33709. endMonitoring(newFrame?: boolean): void;
  33710. private _fetchResult;
  33711. private _startMonitoringTime;
  33712. private _min;
  33713. private _max;
  33714. private _average;
  33715. private _current;
  33716. private _totalValueCount;
  33717. private _totalAccumulated;
  33718. private _lastSecAverage;
  33719. private _lastSecAccumulated;
  33720. private _lastSecTime;
  33721. private _lastSecValueCount;
  33722. }
  33723. }
  33724. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33725. module "babylonjs/Engines/thinEngine" {
  33726. interface ThinEngine {
  33727. /**
  33728. * Sets alpha constants used by some alpha blending modes
  33729. * @param r defines the red component
  33730. * @param g defines the green component
  33731. * @param b defines the blue component
  33732. * @param a defines the alpha component
  33733. */
  33734. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33735. /**
  33736. * Sets the current alpha mode
  33737. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33738. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33739. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33740. */
  33741. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33742. /**
  33743. * Gets the current alpha mode
  33744. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33745. * @returns the current alpha mode
  33746. */
  33747. getAlphaMode(): number;
  33748. /**
  33749. * Sets the current alpha equation
  33750. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33751. */
  33752. setAlphaEquation(equation: number): void;
  33753. /**
  33754. * Gets the current alpha equation.
  33755. * @returns the current alpha equation
  33756. */
  33757. getAlphaEquation(): number;
  33758. }
  33759. }
  33760. }
  33761. declare module "babylonjs/Engines/engine" {
  33762. import { Observable } from "babylonjs/Misc/observable";
  33763. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33764. import { Scene } from "babylonjs/scene";
  33765. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33766. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33767. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33768. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33769. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33770. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33771. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33772. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33773. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33774. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33775. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33776. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33777. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33778. import "babylonjs/Engines/Extensions/engine.alpha";
  33779. import { Material } from "babylonjs/Materials/material";
  33780. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33781. /**
  33782. * Defines the interface used by display changed events
  33783. */
  33784. export interface IDisplayChangedEventArgs {
  33785. /** Gets the vrDisplay object (if any) */
  33786. vrDisplay: Nullable<any>;
  33787. /** Gets a boolean indicating if webVR is supported */
  33788. vrSupported: boolean;
  33789. }
  33790. /**
  33791. * Defines the interface used by objects containing a viewport (like a camera)
  33792. */
  33793. interface IViewportOwnerLike {
  33794. /**
  33795. * Gets or sets the viewport
  33796. */
  33797. viewport: IViewportLike;
  33798. }
  33799. /**
  33800. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33801. */
  33802. export class Engine extends ThinEngine {
  33803. /** Defines that alpha blending is disabled */
  33804. static readonly ALPHA_DISABLE: number;
  33805. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33806. static readonly ALPHA_ADD: number;
  33807. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33808. static readonly ALPHA_COMBINE: number;
  33809. /** Defines that alpha blending to DEST - SRC * DEST */
  33810. static readonly ALPHA_SUBTRACT: number;
  33811. /** Defines that alpha blending to SRC * DEST */
  33812. static readonly ALPHA_MULTIPLY: number;
  33813. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33814. static readonly ALPHA_MAXIMIZED: number;
  33815. /** Defines that alpha blending to SRC + DEST */
  33816. static readonly ALPHA_ONEONE: number;
  33817. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33818. static readonly ALPHA_PREMULTIPLIED: number;
  33819. /**
  33820. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33821. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33822. */
  33823. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33824. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33825. static readonly ALPHA_INTERPOLATE: number;
  33826. /**
  33827. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33828. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33829. */
  33830. static readonly ALPHA_SCREENMODE: number;
  33831. /** Defines that the ressource is not delayed*/
  33832. static readonly DELAYLOADSTATE_NONE: number;
  33833. /** Defines that the ressource was successfully delay loaded */
  33834. static readonly DELAYLOADSTATE_LOADED: number;
  33835. /** Defines that the ressource is currently delay loading */
  33836. static readonly DELAYLOADSTATE_LOADING: number;
  33837. /** Defines that the ressource is delayed and has not started loading */
  33838. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33839. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33840. static readonly NEVER: number;
  33841. /** 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 */
  33842. static readonly ALWAYS: number;
  33843. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33844. static readonly LESS: number;
  33845. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33846. static readonly EQUAL: number;
  33847. /** 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 */
  33848. static readonly LEQUAL: number;
  33849. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33850. static readonly GREATER: number;
  33851. /** 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 */
  33852. static readonly GEQUAL: number;
  33853. /** 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 */
  33854. static readonly NOTEQUAL: number;
  33855. /** Passed to stencilOperation to specify that stencil value must be kept */
  33856. static readonly KEEP: number;
  33857. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33858. static readonly REPLACE: number;
  33859. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33860. static readonly INCR: number;
  33861. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33862. static readonly DECR: number;
  33863. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33864. static readonly INVERT: number;
  33865. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33866. static readonly INCR_WRAP: number;
  33867. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33868. static readonly DECR_WRAP: number;
  33869. /** Texture is not repeating outside of 0..1 UVs */
  33870. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33871. /** Texture is repeating outside of 0..1 UVs */
  33872. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33873. /** Texture is repeating and mirrored */
  33874. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33875. /** ALPHA */
  33876. static readonly TEXTUREFORMAT_ALPHA: number;
  33877. /** LUMINANCE */
  33878. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33879. /** LUMINANCE_ALPHA */
  33880. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33881. /** RGB */
  33882. static readonly TEXTUREFORMAT_RGB: number;
  33883. /** RGBA */
  33884. static readonly TEXTUREFORMAT_RGBA: number;
  33885. /** RED */
  33886. static readonly TEXTUREFORMAT_RED: number;
  33887. /** RED (2nd reference) */
  33888. static readonly TEXTUREFORMAT_R: number;
  33889. /** RG */
  33890. static readonly TEXTUREFORMAT_RG: number;
  33891. /** RED_INTEGER */
  33892. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33893. /** RED_INTEGER (2nd reference) */
  33894. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33895. /** RG_INTEGER */
  33896. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33897. /** RGB_INTEGER */
  33898. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33899. /** RGBA_INTEGER */
  33900. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33901. /** UNSIGNED_BYTE */
  33902. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33903. /** UNSIGNED_BYTE (2nd reference) */
  33904. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33905. /** FLOAT */
  33906. static readonly TEXTURETYPE_FLOAT: number;
  33907. /** HALF_FLOAT */
  33908. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33909. /** BYTE */
  33910. static readonly TEXTURETYPE_BYTE: number;
  33911. /** SHORT */
  33912. static readonly TEXTURETYPE_SHORT: number;
  33913. /** UNSIGNED_SHORT */
  33914. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33915. /** INT */
  33916. static readonly TEXTURETYPE_INT: number;
  33917. /** UNSIGNED_INT */
  33918. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33919. /** UNSIGNED_SHORT_4_4_4_4 */
  33920. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33921. /** UNSIGNED_SHORT_5_5_5_1 */
  33922. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33923. /** UNSIGNED_SHORT_5_6_5 */
  33924. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33925. /** UNSIGNED_INT_2_10_10_10_REV */
  33926. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33927. /** UNSIGNED_INT_24_8 */
  33928. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33929. /** UNSIGNED_INT_10F_11F_11F_REV */
  33930. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33931. /** UNSIGNED_INT_5_9_9_9_REV */
  33932. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33933. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33934. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33935. /** nearest is mag = nearest and min = nearest and mip = linear */
  33936. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33937. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33938. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33939. /** Trilinear is mag = linear and min = linear and mip = linear */
  33940. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33941. /** nearest is mag = nearest and min = nearest and mip = linear */
  33942. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33943. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33944. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33945. /** Trilinear is mag = linear and min = linear and mip = linear */
  33946. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33947. /** mag = nearest and min = nearest and mip = nearest */
  33948. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33949. /** mag = nearest and min = linear and mip = nearest */
  33950. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33951. /** mag = nearest and min = linear and mip = linear */
  33952. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33953. /** mag = nearest and min = linear and mip = none */
  33954. static readonly TEXTURE_NEAREST_LINEAR: number;
  33955. /** mag = nearest and min = nearest and mip = none */
  33956. static readonly TEXTURE_NEAREST_NEAREST: number;
  33957. /** mag = linear and min = nearest and mip = nearest */
  33958. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33959. /** mag = linear and min = nearest and mip = linear */
  33960. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33961. /** mag = linear and min = linear and mip = none */
  33962. static readonly TEXTURE_LINEAR_LINEAR: number;
  33963. /** mag = linear and min = nearest and mip = none */
  33964. static readonly TEXTURE_LINEAR_NEAREST: number;
  33965. /** Explicit coordinates mode */
  33966. static readonly TEXTURE_EXPLICIT_MODE: number;
  33967. /** Spherical coordinates mode */
  33968. static readonly TEXTURE_SPHERICAL_MODE: number;
  33969. /** Planar coordinates mode */
  33970. static readonly TEXTURE_PLANAR_MODE: number;
  33971. /** Cubic coordinates mode */
  33972. static readonly TEXTURE_CUBIC_MODE: number;
  33973. /** Projection coordinates mode */
  33974. static readonly TEXTURE_PROJECTION_MODE: number;
  33975. /** Skybox coordinates mode */
  33976. static readonly TEXTURE_SKYBOX_MODE: number;
  33977. /** Inverse Cubic coordinates mode */
  33978. static readonly TEXTURE_INVCUBIC_MODE: number;
  33979. /** Equirectangular coordinates mode */
  33980. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33981. /** Equirectangular Fixed coordinates mode */
  33982. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33983. /** Equirectangular Fixed Mirrored coordinates mode */
  33984. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33985. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33986. static readonly SCALEMODE_FLOOR: number;
  33987. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33988. static readonly SCALEMODE_NEAREST: number;
  33989. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33990. static readonly SCALEMODE_CEILING: number;
  33991. /**
  33992. * Returns the current npm package of the sdk
  33993. */
  33994. static get NpmPackage(): string;
  33995. /**
  33996. * Returns the current version of the framework
  33997. */
  33998. static get Version(): string;
  33999. /** Gets the list of created engines */
  34000. static get Instances(): Engine[];
  34001. /**
  34002. * Gets the latest created engine
  34003. */
  34004. static get LastCreatedEngine(): Nullable<Engine>;
  34005. /**
  34006. * Gets the latest created scene
  34007. */
  34008. static get LastCreatedScene(): Nullable<Scene>;
  34009. /**
  34010. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34011. * @param flag defines which part of the materials must be marked as dirty
  34012. * @param predicate defines a predicate used to filter which materials should be affected
  34013. */
  34014. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34015. /**
  34016. * Method called to create the default loading screen.
  34017. * This can be overriden in your own app.
  34018. * @param canvas The rendering canvas element
  34019. * @returns The loading screen
  34020. */
  34021. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34022. /**
  34023. * Method called to create the default rescale post process on each engine.
  34024. */
  34025. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34026. /**
  34027. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34028. **/
  34029. enableOfflineSupport: boolean;
  34030. /**
  34031. * 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)
  34032. **/
  34033. disableManifestCheck: boolean;
  34034. /**
  34035. * Gets the list of created scenes
  34036. */
  34037. scenes: Scene[];
  34038. /**
  34039. * Event raised when a new scene is created
  34040. */
  34041. onNewSceneAddedObservable: Observable<Scene>;
  34042. /**
  34043. * Gets the list of created postprocesses
  34044. */
  34045. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34046. /**
  34047. * Gets a boolean indicating if the pointer is currently locked
  34048. */
  34049. isPointerLock: boolean;
  34050. /**
  34051. * Observable event triggered each time the rendering canvas is resized
  34052. */
  34053. onResizeObservable: Observable<Engine>;
  34054. /**
  34055. * Observable event triggered each time the canvas loses focus
  34056. */
  34057. onCanvasBlurObservable: Observable<Engine>;
  34058. /**
  34059. * Observable event triggered each time the canvas gains focus
  34060. */
  34061. onCanvasFocusObservable: Observable<Engine>;
  34062. /**
  34063. * Observable event triggered each time the canvas receives pointerout event
  34064. */
  34065. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34066. /**
  34067. * Observable raised when the engine begins a new frame
  34068. */
  34069. onBeginFrameObservable: Observable<Engine>;
  34070. /**
  34071. * If set, will be used to request the next animation frame for the render loop
  34072. */
  34073. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34074. /**
  34075. * Observable raised when the engine ends the current frame
  34076. */
  34077. onEndFrameObservable: Observable<Engine>;
  34078. /**
  34079. * Observable raised when the engine is about to compile a shader
  34080. */
  34081. onBeforeShaderCompilationObservable: Observable<Engine>;
  34082. /**
  34083. * Observable raised when the engine has jsut compiled a shader
  34084. */
  34085. onAfterShaderCompilationObservable: Observable<Engine>;
  34086. /**
  34087. * Gets the audio engine
  34088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34089. * @ignorenaming
  34090. */
  34091. static audioEngine: IAudioEngine;
  34092. /**
  34093. * Default AudioEngine factory responsible of creating the Audio Engine.
  34094. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34095. */
  34096. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34097. /**
  34098. * Default offline support factory responsible of creating a tool used to store data locally.
  34099. * By default, this will create a Database object if the workload has been embedded.
  34100. */
  34101. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34102. private _loadingScreen;
  34103. private _pointerLockRequested;
  34104. private _dummyFramebuffer;
  34105. private _rescalePostProcess;
  34106. private _deterministicLockstep;
  34107. private _lockstepMaxSteps;
  34108. private _timeStep;
  34109. protected get _supportsHardwareTextureRescaling(): boolean;
  34110. private _fps;
  34111. private _deltaTime;
  34112. /** @hidden */
  34113. _drawCalls: PerfCounter;
  34114. /**
  34115. * Turn this value on if you want to pause FPS computation when in background
  34116. */
  34117. disablePerformanceMonitorInBackground: boolean;
  34118. private _performanceMonitor;
  34119. /**
  34120. * Gets the performance monitor attached to this engine
  34121. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34122. */
  34123. get performanceMonitor(): PerformanceMonitor;
  34124. private _onFocus;
  34125. private _onBlur;
  34126. private _onCanvasPointerOut;
  34127. private _onCanvasBlur;
  34128. private _onCanvasFocus;
  34129. private _onFullscreenChange;
  34130. private _onPointerLockChange;
  34131. /**
  34132. * Gets the HTML element used to attach event listeners
  34133. * @returns a HTML element
  34134. */
  34135. getInputElement(): Nullable<HTMLElement>;
  34136. /**
  34137. * Creates a new engine
  34138. * @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
  34139. * @param antialias defines enable antialiasing (default: false)
  34140. * @param options defines further options to be sent to the getContext() function
  34141. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34142. */
  34143. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34144. /**
  34145. * Gets current aspect ratio
  34146. * @param viewportOwner defines the camera to use to get the aspect ratio
  34147. * @param useScreen defines if screen size must be used (or the current render target if any)
  34148. * @returns a number defining the aspect ratio
  34149. */
  34150. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34151. /**
  34152. * Gets current screen aspect ratio
  34153. * @returns a number defining the aspect ratio
  34154. */
  34155. getScreenAspectRatio(): number;
  34156. /**
  34157. * Gets the client rect of the HTML canvas attached with the current webGL context
  34158. * @returns a client rectanglee
  34159. */
  34160. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34161. /**
  34162. * Gets the client rect of the HTML element used for events
  34163. * @returns a client rectanglee
  34164. */
  34165. getInputElementClientRect(): Nullable<ClientRect>;
  34166. /**
  34167. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34168. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34169. * @returns true if engine is in deterministic lock step mode
  34170. */
  34171. isDeterministicLockStep(): boolean;
  34172. /**
  34173. * Gets the max steps when engine is running in deterministic lock step
  34174. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34175. * @returns the max steps
  34176. */
  34177. getLockstepMaxSteps(): number;
  34178. /**
  34179. * Returns the time in ms between steps when using deterministic lock step.
  34180. * @returns time step in (ms)
  34181. */
  34182. getTimeStep(): number;
  34183. /**
  34184. * Force the mipmap generation for the given render target texture
  34185. * @param texture defines the render target texture to use
  34186. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34187. */
  34188. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34189. /** States */
  34190. /**
  34191. * Set various states to the webGL context
  34192. * @param culling defines backface culling state
  34193. * @param zOffset defines the value to apply to zOffset (0 by default)
  34194. * @param force defines if states must be applied even if cache is up to date
  34195. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34196. */
  34197. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34198. /**
  34199. * Set the z offset to apply to current rendering
  34200. * @param value defines the offset to apply
  34201. */
  34202. setZOffset(value: number): void;
  34203. /**
  34204. * Gets the current value of the zOffset
  34205. * @returns the current zOffset state
  34206. */
  34207. getZOffset(): number;
  34208. /**
  34209. * Enable or disable depth buffering
  34210. * @param enable defines the state to set
  34211. */
  34212. setDepthBuffer(enable: boolean): void;
  34213. /**
  34214. * Gets a boolean indicating if depth writing is enabled
  34215. * @returns the current depth writing state
  34216. */
  34217. getDepthWrite(): boolean;
  34218. /**
  34219. * Enable or disable depth writing
  34220. * @param enable defines the state to set
  34221. */
  34222. setDepthWrite(enable: boolean): void;
  34223. /**
  34224. * Gets a boolean indicating if stencil buffer is enabled
  34225. * @returns the current stencil buffer state
  34226. */
  34227. getStencilBuffer(): boolean;
  34228. /**
  34229. * Enable or disable the stencil buffer
  34230. * @param enable defines if the stencil buffer must be enabled or disabled
  34231. */
  34232. setStencilBuffer(enable: boolean): void;
  34233. /**
  34234. * Gets the current stencil mask
  34235. * @returns a number defining the new stencil mask to use
  34236. */
  34237. getStencilMask(): number;
  34238. /**
  34239. * Sets the current stencil mask
  34240. * @param mask defines the new stencil mask to use
  34241. */
  34242. setStencilMask(mask: number): void;
  34243. /**
  34244. * Gets the current stencil function
  34245. * @returns a number defining the stencil function to use
  34246. */
  34247. getStencilFunction(): number;
  34248. /**
  34249. * Gets the current stencil reference value
  34250. * @returns a number defining the stencil reference value to use
  34251. */
  34252. getStencilFunctionReference(): number;
  34253. /**
  34254. * Gets the current stencil mask
  34255. * @returns a number defining the stencil mask to use
  34256. */
  34257. getStencilFunctionMask(): number;
  34258. /**
  34259. * Sets the current stencil function
  34260. * @param stencilFunc defines the new stencil function to use
  34261. */
  34262. setStencilFunction(stencilFunc: number): void;
  34263. /**
  34264. * Sets the current stencil reference
  34265. * @param reference defines the new stencil reference to use
  34266. */
  34267. setStencilFunctionReference(reference: number): void;
  34268. /**
  34269. * Sets the current stencil mask
  34270. * @param mask defines the new stencil mask to use
  34271. */
  34272. setStencilFunctionMask(mask: number): void;
  34273. /**
  34274. * Gets the current stencil operation when stencil fails
  34275. * @returns a number defining stencil operation to use when stencil fails
  34276. */
  34277. getStencilOperationFail(): number;
  34278. /**
  34279. * Gets the current stencil operation when depth fails
  34280. * @returns a number defining stencil operation to use when depth fails
  34281. */
  34282. getStencilOperationDepthFail(): number;
  34283. /**
  34284. * Gets the current stencil operation when stencil passes
  34285. * @returns a number defining stencil operation to use when stencil passes
  34286. */
  34287. getStencilOperationPass(): number;
  34288. /**
  34289. * Sets the stencil operation to use when stencil fails
  34290. * @param operation defines the stencil operation to use when stencil fails
  34291. */
  34292. setStencilOperationFail(operation: number): void;
  34293. /**
  34294. * Sets the stencil operation to use when depth fails
  34295. * @param operation defines the stencil operation to use when depth fails
  34296. */
  34297. setStencilOperationDepthFail(operation: number): void;
  34298. /**
  34299. * Sets the stencil operation to use when stencil passes
  34300. * @param operation defines the stencil operation to use when stencil passes
  34301. */
  34302. setStencilOperationPass(operation: number): void;
  34303. /**
  34304. * Sets a boolean indicating if the dithering state is enabled or disabled
  34305. * @param value defines the dithering state
  34306. */
  34307. setDitheringState(value: boolean): void;
  34308. /**
  34309. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34310. * @param value defines the rasterizer state
  34311. */
  34312. setRasterizerState(value: boolean): void;
  34313. /**
  34314. * Gets the current depth function
  34315. * @returns a number defining the depth function
  34316. */
  34317. getDepthFunction(): Nullable<number>;
  34318. /**
  34319. * Sets the current depth function
  34320. * @param depthFunc defines the function to use
  34321. */
  34322. setDepthFunction(depthFunc: number): void;
  34323. /**
  34324. * Sets the current depth function to GREATER
  34325. */
  34326. setDepthFunctionToGreater(): void;
  34327. /**
  34328. * Sets the current depth function to GEQUAL
  34329. */
  34330. setDepthFunctionToGreaterOrEqual(): void;
  34331. /**
  34332. * Sets the current depth function to LESS
  34333. */
  34334. setDepthFunctionToLess(): void;
  34335. /**
  34336. * Sets the current depth function to LEQUAL
  34337. */
  34338. setDepthFunctionToLessOrEqual(): void;
  34339. private _cachedStencilBuffer;
  34340. private _cachedStencilFunction;
  34341. private _cachedStencilMask;
  34342. private _cachedStencilOperationPass;
  34343. private _cachedStencilOperationFail;
  34344. private _cachedStencilOperationDepthFail;
  34345. private _cachedStencilReference;
  34346. /**
  34347. * Caches the the state of the stencil buffer
  34348. */
  34349. cacheStencilState(): void;
  34350. /**
  34351. * Restores the state of the stencil buffer
  34352. */
  34353. restoreStencilState(): void;
  34354. /**
  34355. * Directly set the WebGL Viewport
  34356. * @param x defines the x coordinate of the viewport (in screen space)
  34357. * @param y defines the y coordinate of the viewport (in screen space)
  34358. * @param width defines the width of the viewport (in screen space)
  34359. * @param height defines the height of the viewport (in screen space)
  34360. * @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
  34361. */
  34362. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34363. /**
  34364. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34365. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34366. * @param y defines the y-coordinate of the corner of the clear rectangle
  34367. * @param width defines the width of the clear rectangle
  34368. * @param height defines the height of the clear rectangle
  34369. * @param clearColor defines the clear color
  34370. */
  34371. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34372. /**
  34373. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34374. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34375. * @param y defines the y-coordinate of the corner of the clear rectangle
  34376. * @param width defines the width of the clear rectangle
  34377. * @param height defines the height of the clear rectangle
  34378. */
  34379. enableScissor(x: number, y: number, width: number, height: number): void;
  34380. /**
  34381. * Disable previously set scissor test rectangle
  34382. */
  34383. disableScissor(): void;
  34384. protected _reportDrawCall(): void;
  34385. /**
  34386. * Initializes a webVR display and starts listening to display change events
  34387. * The onVRDisplayChangedObservable will be notified upon these changes
  34388. * @returns The onVRDisplayChangedObservable
  34389. */
  34390. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34391. /** @hidden */
  34392. _prepareVRComponent(): void;
  34393. /** @hidden */
  34394. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34395. /** @hidden */
  34396. _submitVRFrame(): void;
  34397. /**
  34398. * Call this function to leave webVR mode
  34399. * Will do nothing if webVR is not supported or if there is no webVR device
  34400. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34401. */
  34402. disableVR(): void;
  34403. /**
  34404. * Gets a boolean indicating that the system is in VR mode and is presenting
  34405. * @returns true if VR mode is engaged
  34406. */
  34407. isVRPresenting(): boolean;
  34408. /** @hidden */
  34409. _requestVRFrame(): void;
  34410. /** @hidden */
  34411. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34412. /**
  34413. * Gets the source code of the vertex shader associated with a specific webGL program
  34414. * @param program defines the program to use
  34415. * @returns a string containing the source code of the vertex shader associated with the program
  34416. */
  34417. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34418. /**
  34419. * Gets the source code of the fragment shader associated with a specific webGL program
  34420. * @param program defines the program to use
  34421. * @returns a string containing the source code of the fragment shader associated with the program
  34422. */
  34423. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34424. /**
  34425. * Sets a depth stencil texture from a render target to the according uniform.
  34426. * @param channel The texture channel
  34427. * @param uniform The uniform to set
  34428. * @param texture The render target texture containing the depth stencil texture to apply
  34429. */
  34430. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34431. /**
  34432. * Sets a texture to the webGL context from a postprocess
  34433. * @param channel defines the channel to use
  34434. * @param postProcess defines the source postprocess
  34435. */
  34436. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34437. /**
  34438. * Binds the output of the passed in post process to the texture channel specified
  34439. * @param channel The channel the texture should be bound to
  34440. * @param postProcess The post process which's output should be bound
  34441. */
  34442. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34443. /** @hidden */
  34444. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34445. protected _rebuildBuffers(): void;
  34446. /** @hidden */
  34447. _renderFrame(): void;
  34448. _renderLoop(): void;
  34449. /** @hidden */
  34450. _renderViews(): boolean;
  34451. /**
  34452. * Toggle full screen mode
  34453. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34454. */
  34455. switchFullscreen(requestPointerLock: boolean): void;
  34456. /**
  34457. * Enters full screen mode
  34458. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34459. */
  34460. enterFullscreen(requestPointerLock: boolean): void;
  34461. /**
  34462. * Exits full screen mode
  34463. */
  34464. exitFullscreen(): void;
  34465. /**
  34466. * Enters Pointerlock mode
  34467. */
  34468. enterPointerlock(): void;
  34469. /**
  34470. * Exits Pointerlock mode
  34471. */
  34472. exitPointerlock(): void;
  34473. /**
  34474. * Begin a new frame
  34475. */
  34476. beginFrame(): void;
  34477. /**
  34478. * Enf the current frame
  34479. */
  34480. endFrame(): void;
  34481. resize(): void;
  34482. /**
  34483. * Set the compressed texture format to use, based on the formats you have, and the formats
  34484. * supported by the hardware / browser.
  34485. *
  34486. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34487. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34488. * to API arguments needed to compressed textures. This puts the burden on the container
  34489. * generator to house the arcane code for determining these for current & future formats.
  34490. *
  34491. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34492. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34493. *
  34494. * Note: The result of this call is not taken into account when a texture is base64.
  34495. *
  34496. * @param formatsAvailable defines the list of those format families you have created
  34497. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34498. *
  34499. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34500. * @returns The extension selected.
  34501. */
  34502. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34503. /**
  34504. * Set the compressed texture extensions or file names to skip.
  34505. *
  34506. * @param skippedFiles defines the list of those texture files you want to skip
  34507. * Example: [".dds", ".env", "myfile.png"]
  34508. */
  34509. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34510. /**
  34511. * Force a specific size of the canvas
  34512. * @param width defines the new canvas' width
  34513. * @param height defines the new canvas' height
  34514. */
  34515. setSize(width: number, height: number): void;
  34516. /**
  34517. * Updates a dynamic vertex buffer.
  34518. * @param vertexBuffer the vertex buffer to update
  34519. * @param data the data used to update the vertex buffer
  34520. * @param byteOffset the byte offset of the data
  34521. * @param byteLength the byte length of the data
  34522. */
  34523. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34524. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34525. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34526. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34527. _releaseTexture(texture: InternalTexture): void;
  34528. /**
  34529. * @hidden
  34530. * Rescales a texture
  34531. * @param source input texutre
  34532. * @param destination destination texture
  34533. * @param scene scene to use to render the resize
  34534. * @param internalFormat format to use when resizing
  34535. * @param onComplete callback to be called when resize has completed
  34536. */
  34537. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34538. /**
  34539. * Gets the current framerate
  34540. * @returns a number representing the framerate
  34541. */
  34542. getFps(): number;
  34543. /**
  34544. * Gets the time spent between current and previous frame
  34545. * @returns a number representing the delta time in ms
  34546. */
  34547. getDeltaTime(): number;
  34548. private _measureFps;
  34549. /** @hidden */
  34550. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34551. /**
  34552. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34553. * @param renderTarget The render target to set the frame buffer for
  34554. */
  34555. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34556. /**
  34557. * Update a dynamic index buffer
  34558. * @param indexBuffer defines the target index buffer
  34559. * @param indices defines the data to update
  34560. * @param offset defines the offset in the target index buffer where update should start
  34561. */
  34562. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34563. /**
  34564. * Updates the sample count of a render target texture
  34565. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34566. * @param texture defines the texture to update
  34567. * @param samples defines the sample count to set
  34568. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34569. */
  34570. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34571. /**
  34572. * Updates a depth texture Comparison Mode and Function.
  34573. * If the comparison Function is equal to 0, the mode will be set to none.
  34574. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34575. * @param texture The texture to set the comparison function for
  34576. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34577. */
  34578. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34579. /**
  34580. * Creates a webGL buffer to use with instanciation
  34581. * @param capacity defines the size of the buffer
  34582. * @returns the webGL buffer
  34583. */
  34584. createInstancesBuffer(capacity: number): DataBuffer;
  34585. /**
  34586. * Delete a webGL buffer used with instanciation
  34587. * @param buffer defines the webGL buffer to delete
  34588. */
  34589. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34590. /** @hidden */
  34591. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34592. dispose(): void;
  34593. private _disableTouchAction;
  34594. /**
  34595. * Display the loading screen
  34596. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34597. */
  34598. displayLoadingUI(): void;
  34599. /**
  34600. * Hide the loading screen
  34601. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34602. */
  34603. hideLoadingUI(): void;
  34604. /**
  34605. * Gets the current loading screen object
  34606. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34607. */
  34608. get loadingScreen(): ILoadingScreen;
  34609. /**
  34610. * Sets the current loading screen object
  34611. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34612. */
  34613. set loadingScreen(loadingScreen: ILoadingScreen);
  34614. /**
  34615. * Sets the current loading screen text
  34616. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34617. */
  34618. set loadingUIText(text: string);
  34619. /**
  34620. * Sets the current loading screen background color
  34621. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34622. */
  34623. set loadingUIBackgroundColor(color: string);
  34624. /** Pointerlock and fullscreen */
  34625. /**
  34626. * Ask the browser to promote the current element to pointerlock mode
  34627. * @param element defines the DOM element to promote
  34628. */
  34629. static _RequestPointerlock(element: HTMLElement): void;
  34630. /**
  34631. * Asks the browser to exit pointerlock mode
  34632. */
  34633. static _ExitPointerlock(): void;
  34634. /**
  34635. * Ask the browser to promote the current element to fullscreen rendering mode
  34636. * @param element defines the DOM element to promote
  34637. */
  34638. static _RequestFullscreen(element: HTMLElement): void;
  34639. /**
  34640. * Asks the browser to exit fullscreen mode
  34641. */
  34642. static _ExitFullscreen(): void;
  34643. }
  34644. }
  34645. declare module "babylonjs/Engines/engineStore" {
  34646. import { Nullable } from "babylonjs/types";
  34647. import { Engine } from "babylonjs/Engines/engine";
  34648. import { Scene } from "babylonjs/scene";
  34649. /**
  34650. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34651. * during the life time of the application.
  34652. */
  34653. export class EngineStore {
  34654. /** Gets the list of created engines */
  34655. static Instances: import("babylonjs/Engines/engine").Engine[];
  34656. /** @hidden */
  34657. static _LastCreatedScene: Nullable<Scene>;
  34658. /**
  34659. * Gets the latest created engine
  34660. */
  34661. static get LastCreatedEngine(): Nullable<Engine>;
  34662. /**
  34663. * Gets the latest created scene
  34664. */
  34665. static get LastCreatedScene(): Nullable<Scene>;
  34666. /**
  34667. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34668. * @ignorenaming
  34669. */
  34670. static UseFallbackTexture: boolean;
  34671. /**
  34672. * Texture content used if a texture cannot loaded
  34673. * @ignorenaming
  34674. */
  34675. static FallbackTexture: string;
  34676. }
  34677. }
  34678. declare module "babylonjs/Misc/promise" {
  34679. /**
  34680. * Helper class that provides a small promise polyfill
  34681. */
  34682. export class PromisePolyfill {
  34683. /**
  34684. * Static function used to check if the polyfill is required
  34685. * If this is the case then the function will inject the polyfill to window.Promise
  34686. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34687. */
  34688. static Apply(force?: boolean): void;
  34689. }
  34690. }
  34691. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34692. /**
  34693. * Interface for screenshot methods with describe argument called `size` as object with options
  34694. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34695. */
  34696. export interface IScreenshotSize {
  34697. /**
  34698. * number in pixels for canvas height
  34699. */
  34700. height?: number;
  34701. /**
  34702. * multiplier allowing render at a higher or lower resolution
  34703. * If value is defined then height and width will be ignored and taken from camera
  34704. */
  34705. precision?: number;
  34706. /**
  34707. * number in pixels for canvas width
  34708. */
  34709. width?: number;
  34710. }
  34711. }
  34712. declare module "babylonjs/Misc/tools" {
  34713. import { Nullable, float } from "babylonjs/types";
  34714. import { DomManagement } from "babylonjs/Misc/domManagement";
  34715. import { WebRequest } from "babylonjs/Misc/webRequest";
  34716. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34717. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34718. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34719. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34720. import { Camera } from "babylonjs/Cameras/camera";
  34721. import { Engine } from "babylonjs/Engines/engine";
  34722. interface IColor4Like {
  34723. r: float;
  34724. g: float;
  34725. b: float;
  34726. a: float;
  34727. }
  34728. /**
  34729. * Class containing a set of static utilities functions
  34730. */
  34731. export class Tools {
  34732. /**
  34733. * Gets or sets the base URL to use to load assets
  34734. */
  34735. static get BaseUrl(): string;
  34736. static set BaseUrl(value: string);
  34737. /**
  34738. * Enable/Disable Custom HTTP Request Headers globally.
  34739. * default = false
  34740. * @see CustomRequestHeaders
  34741. */
  34742. static UseCustomRequestHeaders: boolean;
  34743. /**
  34744. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34745. * i.e. when loading files, where the server/service expects an Authorization header
  34746. */
  34747. static CustomRequestHeaders: {
  34748. [key: string]: string;
  34749. };
  34750. /**
  34751. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34752. */
  34753. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34754. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34755. /**
  34756. * Default behaviour for cors in the application.
  34757. * It can be a string if the expected behavior is identical in the entire app.
  34758. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34759. */
  34760. static CorsBehavior: string | ((url: string | string[]) => string);
  34761. /**
  34762. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34763. * @ignorenaming
  34764. */
  34765. static get UseFallbackTexture(): boolean;
  34766. static set UseFallbackTexture(value: boolean);
  34767. /**
  34768. * Use this object to register external classes like custom textures or material
  34769. * to allow the laoders to instantiate them
  34770. */
  34771. static get RegisteredExternalClasses(): {
  34772. [key: string]: Object;
  34773. };
  34774. static set RegisteredExternalClasses(classes: {
  34775. [key: string]: Object;
  34776. });
  34777. /**
  34778. * Texture content used if a texture cannot loaded
  34779. * @ignorenaming
  34780. */
  34781. static get fallbackTexture(): string;
  34782. static set fallbackTexture(value: string);
  34783. /**
  34784. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34785. * @param u defines the coordinate on X axis
  34786. * @param v defines the coordinate on Y axis
  34787. * @param width defines the width of the source data
  34788. * @param height defines the height of the source data
  34789. * @param pixels defines the source byte array
  34790. * @param color defines the output color
  34791. */
  34792. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34793. /**
  34794. * Interpolates between a and b via alpha
  34795. * @param a The lower value (returned when alpha = 0)
  34796. * @param b The upper value (returned when alpha = 1)
  34797. * @param alpha The interpolation-factor
  34798. * @return The mixed value
  34799. */
  34800. static Mix(a: number, b: number, alpha: number): number;
  34801. /**
  34802. * Tries to instantiate a new object from a given class name
  34803. * @param className defines the class name to instantiate
  34804. * @returns the new object or null if the system was not able to do the instantiation
  34805. */
  34806. static Instantiate(className: string): any;
  34807. /**
  34808. * Provides a slice function that will work even on IE
  34809. * @param data defines the array to slice
  34810. * @param start defines the start of the data (optional)
  34811. * @param end defines the end of the data (optional)
  34812. * @returns the new sliced array
  34813. */
  34814. static Slice<T>(data: T, start?: number, end?: number): T;
  34815. /**
  34816. * Polyfill for setImmediate
  34817. * @param action defines the action to execute after the current execution block
  34818. */
  34819. static SetImmediate(action: () => void): void;
  34820. /**
  34821. * Function indicating if a number is an exponent of 2
  34822. * @param value defines the value to test
  34823. * @returns true if the value is an exponent of 2
  34824. */
  34825. static IsExponentOfTwo(value: number): boolean;
  34826. private static _tmpFloatArray;
  34827. /**
  34828. * Returns the nearest 32-bit single precision float representation of a Number
  34829. * @param value A Number. If the parameter is of a different type, it will get converted
  34830. * to a number or to NaN if it cannot be converted
  34831. * @returns number
  34832. */
  34833. static FloatRound(value: number): number;
  34834. /**
  34835. * Extracts the filename from a path
  34836. * @param path defines the path to use
  34837. * @returns the filename
  34838. */
  34839. static GetFilename(path: string): string;
  34840. /**
  34841. * Extracts the "folder" part of a path (everything before the filename).
  34842. * @param uri The URI to extract the info from
  34843. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34844. * @returns The "folder" part of the path
  34845. */
  34846. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34847. /**
  34848. * Extracts text content from a DOM element hierarchy
  34849. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34850. */
  34851. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34852. /**
  34853. * Convert an angle in radians to degrees
  34854. * @param angle defines the angle to convert
  34855. * @returns the angle in degrees
  34856. */
  34857. static ToDegrees(angle: number): number;
  34858. /**
  34859. * Convert an angle in degrees to radians
  34860. * @param angle defines the angle to convert
  34861. * @returns the angle in radians
  34862. */
  34863. static ToRadians(angle: number): number;
  34864. /**
  34865. * Returns an array if obj is not an array
  34866. * @param obj defines the object to evaluate as an array
  34867. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34868. * @returns either obj directly if obj is an array or a new array containing obj
  34869. */
  34870. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34871. /**
  34872. * Gets the pointer prefix to use
  34873. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34874. */
  34875. static GetPointerPrefix(): string;
  34876. /**
  34877. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34878. * @param url define the url we are trying
  34879. * @param element define the dom element where to configure the cors policy
  34880. */
  34881. static SetCorsBehavior(url: string | string[], element: {
  34882. crossOrigin: string | null;
  34883. }): void;
  34884. /**
  34885. * Removes unwanted characters from an url
  34886. * @param url defines the url to clean
  34887. * @returns the cleaned url
  34888. */
  34889. static CleanUrl(url: string): string;
  34890. /**
  34891. * Gets or sets a function used to pre-process url before using them to load assets
  34892. */
  34893. static get PreprocessUrl(): (url: string) => string;
  34894. static set PreprocessUrl(processor: (url: string) => string);
  34895. /**
  34896. * Loads an image as an HTMLImageElement.
  34897. * @param input url string, ArrayBuffer, or Blob to load
  34898. * @param onLoad callback called when the image successfully loads
  34899. * @param onError callback called when the image fails to load
  34900. * @param offlineProvider offline provider for caching
  34901. * @param mimeType optional mime type
  34902. * @returns the HTMLImageElement of the loaded image
  34903. */
  34904. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34905. /**
  34906. * Loads a file from a url
  34907. * @param url url string, ArrayBuffer, or Blob to load
  34908. * @param onSuccess callback called when the file successfully loads
  34909. * @param onProgress callback called while file is loading (if the server supports this mode)
  34910. * @param offlineProvider defines the offline provider for caching
  34911. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34912. * @param onError callback called when the file fails to load
  34913. * @returns a file request object
  34914. */
  34915. 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;
  34916. /**
  34917. * Loads a file from a url
  34918. * @param url the file url to load
  34919. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34920. */
  34921. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34922. /**
  34923. * Load a script (identified by an url). When the url returns, the
  34924. * content of this file is added into a new script element, attached to the DOM (body element)
  34925. * @param scriptUrl defines the url of the script to laod
  34926. * @param onSuccess defines the callback called when the script is loaded
  34927. * @param onError defines the callback to call if an error occurs
  34928. * @param scriptId defines the id of the script element
  34929. */
  34930. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34931. /**
  34932. * Load an asynchronous script (identified by an url). When the url returns, the
  34933. * content of this file is added into a new script element, attached to the DOM (body element)
  34934. * @param scriptUrl defines the url of the script to laod
  34935. * @param scriptId defines the id of the script element
  34936. * @returns a promise request object
  34937. */
  34938. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34939. /**
  34940. * Loads a file from a blob
  34941. * @param fileToLoad defines the blob to use
  34942. * @param callback defines the callback to call when data is loaded
  34943. * @param progressCallback defines the callback to call during loading process
  34944. * @returns a file request object
  34945. */
  34946. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34947. /**
  34948. * Reads a file from a File object
  34949. * @param file defines the file to load
  34950. * @param onSuccess defines the callback to call when data is loaded
  34951. * @param onProgress defines the callback to call during loading process
  34952. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34953. * @param onError defines the callback to call when an error occurs
  34954. * @returns a file request object
  34955. */
  34956. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34957. /**
  34958. * Creates a data url from a given string content
  34959. * @param content defines the content to convert
  34960. * @returns the new data url link
  34961. */
  34962. static FileAsURL(content: string): string;
  34963. /**
  34964. * Format the given number to a specific decimal format
  34965. * @param value defines the number to format
  34966. * @param decimals defines the number of decimals to use
  34967. * @returns the formatted string
  34968. */
  34969. static Format(value: number, decimals?: number): string;
  34970. /**
  34971. * Tries to copy an object by duplicating every property
  34972. * @param source defines the source object
  34973. * @param destination defines the target object
  34974. * @param doNotCopyList defines a list of properties to avoid
  34975. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34976. */
  34977. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34978. /**
  34979. * Gets a boolean indicating if the given object has no own property
  34980. * @param obj defines the object to test
  34981. * @returns true if object has no own property
  34982. */
  34983. static IsEmpty(obj: any): boolean;
  34984. /**
  34985. * Function used to register events at window level
  34986. * @param windowElement defines the Window object to use
  34987. * @param events defines the events to register
  34988. */
  34989. static RegisterTopRootEvents(windowElement: Window, events: {
  34990. name: string;
  34991. handler: Nullable<(e: FocusEvent) => any>;
  34992. }[]): void;
  34993. /**
  34994. * Function used to unregister events from window level
  34995. * @param windowElement defines the Window object to use
  34996. * @param events defines the events to unregister
  34997. */
  34998. static UnregisterTopRootEvents(windowElement: Window, events: {
  34999. name: string;
  35000. handler: Nullable<(e: FocusEvent) => any>;
  35001. }[]): void;
  35002. /**
  35003. * @ignore
  35004. */
  35005. static _ScreenshotCanvas: HTMLCanvasElement;
  35006. /**
  35007. * Dumps the current bound framebuffer
  35008. * @param width defines the rendering width
  35009. * @param height defines the rendering height
  35010. * @param engine defines the hosting engine
  35011. * @param successCallback defines the callback triggered once the data are available
  35012. * @param mimeType defines the mime type of the result
  35013. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35014. */
  35015. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35016. /**
  35017. * Converts the canvas data to blob.
  35018. * This acts as a polyfill for browsers not supporting the to blob function.
  35019. * @param canvas Defines the canvas to extract the data from
  35020. * @param successCallback Defines the callback triggered once the data are available
  35021. * @param mimeType Defines the mime type of the result
  35022. */
  35023. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35024. /**
  35025. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35026. * @param successCallback defines the callback triggered once the data are available
  35027. * @param mimeType defines the mime type of the result
  35028. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35029. */
  35030. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35031. /**
  35032. * Downloads a blob in the browser
  35033. * @param blob defines the blob to download
  35034. * @param fileName defines the name of the downloaded file
  35035. */
  35036. static Download(blob: Blob, fileName: string): void;
  35037. /**
  35038. * Captures a screenshot of the current rendering
  35039. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35040. * @param engine defines the rendering engine
  35041. * @param camera defines the source camera
  35042. * @param size This parameter can be set to a single number or to an object with the
  35043. * following (optional) properties: precision, width, height. If a single number is passed,
  35044. * it will be used for both width and height. If an object is passed, the screenshot size
  35045. * will be derived from the parameters. The precision property is a multiplier allowing
  35046. * rendering at a higher or lower resolution
  35047. * @param successCallback defines the callback receives a single parameter which contains the
  35048. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35049. * src parameter of an <img> to display it
  35050. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35051. * Check your browser for supported MIME types
  35052. */
  35053. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35054. /**
  35055. * Captures a screenshot of the current rendering
  35056. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35057. * @param engine defines the rendering engine
  35058. * @param camera defines the source camera
  35059. * @param size This parameter can be set to a single number or to an object with the
  35060. * following (optional) properties: precision, width, height. If a single number is passed,
  35061. * it will be used for both width and height. If an object is passed, the screenshot size
  35062. * will be derived from the parameters. The precision property is a multiplier allowing
  35063. * rendering at a higher or lower resolution
  35064. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35065. * Check your browser for supported MIME types
  35066. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35067. * to the src parameter of an <img> to display it
  35068. */
  35069. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35070. /**
  35071. * Generates an image screenshot from the specified camera.
  35072. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35073. * @param engine The engine to use for rendering
  35074. * @param camera The camera to use for rendering
  35075. * @param size This parameter can be set to a single number or to an object with the
  35076. * following (optional) properties: precision, width, height. If a single number is passed,
  35077. * it will be used for both width and height. If an object is passed, the screenshot size
  35078. * will be derived from the parameters. The precision property is a multiplier allowing
  35079. * rendering at a higher or lower resolution
  35080. * @param successCallback The callback receives a single parameter which contains the
  35081. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35082. * src parameter of an <img> to display it
  35083. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35084. * Check your browser for supported MIME types
  35085. * @param samples Texture samples (default: 1)
  35086. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35087. * @param fileName A name for for the downloaded file.
  35088. */
  35089. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35090. /**
  35091. * Generates an image screenshot from the specified camera.
  35092. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35093. * @param engine The engine to use for rendering
  35094. * @param camera The camera to use for rendering
  35095. * @param size This parameter can be set to a single number or to an object with the
  35096. * following (optional) properties: precision, width, height. If a single number is passed,
  35097. * it will be used for both width and height. If an object is passed, the screenshot size
  35098. * will be derived from the parameters. The precision property is a multiplier allowing
  35099. * rendering at a higher or lower resolution
  35100. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35101. * Check your browser for supported MIME types
  35102. * @param samples Texture samples (default: 1)
  35103. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35104. * @param fileName A name for for the downloaded file.
  35105. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35106. * to the src parameter of an <img> to display it
  35107. */
  35108. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35109. /**
  35110. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35111. * Be aware Math.random() could cause collisions, but:
  35112. * "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"
  35113. * @returns a pseudo random id
  35114. */
  35115. static RandomId(): string;
  35116. /**
  35117. * Test if the given uri is a base64 string
  35118. * @param uri The uri to test
  35119. * @return True if the uri is a base64 string or false otherwise
  35120. */
  35121. static IsBase64(uri: string): boolean;
  35122. /**
  35123. * Decode the given base64 uri.
  35124. * @param uri The uri to decode
  35125. * @return The decoded base64 data.
  35126. */
  35127. static DecodeBase64(uri: string): ArrayBuffer;
  35128. /**
  35129. * Gets the absolute url.
  35130. * @param url the input url
  35131. * @return the absolute url
  35132. */
  35133. static GetAbsoluteUrl(url: string): string;
  35134. /**
  35135. * No log
  35136. */
  35137. static readonly NoneLogLevel: number;
  35138. /**
  35139. * Only message logs
  35140. */
  35141. static readonly MessageLogLevel: number;
  35142. /**
  35143. * Only warning logs
  35144. */
  35145. static readonly WarningLogLevel: number;
  35146. /**
  35147. * Only error logs
  35148. */
  35149. static readonly ErrorLogLevel: number;
  35150. /**
  35151. * All logs
  35152. */
  35153. static readonly AllLogLevel: number;
  35154. /**
  35155. * Gets a value indicating the number of loading errors
  35156. * @ignorenaming
  35157. */
  35158. static get errorsCount(): number;
  35159. /**
  35160. * Callback called when a new log is added
  35161. */
  35162. static OnNewCacheEntry: (entry: string) => void;
  35163. /**
  35164. * Log a message to the console
  35165. * @param message defines the message to log
  35166. */
  35167. static Log(message: string): void;
  35168. /**
  35169. * Write a warning message to the console
  35170. * @param message defines the message to log
  35171. */
  35172. static Warn(message: string): void;
  35173. /**
  35174. * Write an error message to the console
  35175. * @param message defines the message to log
  35176. */
  35177. static Error(message: string): void;
  35178. /**
  35179. * Gets current log cache (list of logs)
  35180. */
  35181. static get LogCache(): string;
  35182. /**
  35183. * Clears the log cache
  35184. */
  35185. static ClearLogCache(): void;
  35186. /**
  35187. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35188. */
  35189. static set LogLevels(level: number);
  35190. /**
  35191. * Checks if the window object exists
  35192. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35193. */
  35194. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35195. /**
  35196. * No performance log
  35197. */
  35198. static readonly PerformanceNoneLogLevel: number;
  35199. /**
  35200. * Use user marks to log performance
  35201. */
  35202. static readonly PerformanceUserMarkLogLevel: number;
  35203. /**
  35204. * Log performance to the console
  35205. */
  35206. static readonly PerformanceConsoleLogLevel: number;
  35207. private static _performance;
  35208. /**
  35209. * Sets the current performance log level
  35210. */
  35211. static set PerformanceLogLevel(level: number);
  35212. private static _StartPerformanceCounterDisabled;
  35213. private static _EndPerformanceCounterDisabled;
  35214. private static _StartUserMark;
  35215. private static _EndUserMark;
  35216. private static _StartPerformanceConsole;
  35217. private static _EndPerformanceConsole;
  35218. /**
  35219. * Starts a performance counter
  35220. */
  35221. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35222. /**
  35223. * Ends a specific performance coutner
  35224. */
  35225. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35226. /**
  35227. * Gets either window.performance.now() if supported or Date.now() else
  35228. */
  35229. static get Now(): number;
  35230. /**
  35231. * This method will return the name of the class used to create the instance of the given object.
  35232. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35233. * @param object the object to get the class name from
  35234. * @param isType defines if the object is actually a type
  35235. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35236. */
  35237. static GetClassName(object: any, isType?: boolean): string;
  35238. /**
  35239. * Gets the first element of an array satisfying a given predicate
  35240. * @param array defines the array to browse
  35241. * @param predicate defines the predicate to use
  35242. * @returns null if not found or the element
  35243. */
  35244. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35245. /**
  35246. * This method will return the name of the full name of the class, including its owning module (if any).
  35247. * 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).
  35248. * @param object the object to get the class name from
  35249. * @param isType defines if the object is actually a type
  35250. * @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.
  35251. * @ignorenaming
  35252. */
  35253. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35254. /**
  35255. * Returns a promise that resolves after the given amount of time.
  35256. * @param delay Number of milliseconds to delay
  35257. * @returns Promise that resolves after the given amount of time
  35258. */
  35259. static DelayAsync(delay: number): Promise<void>;
  35260. }
  35261. /**
  35262. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35263. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35264. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35265. * @param name The name of the class, case should be preserved
  35266. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35267. */
  35268. export function className(name: string, module?: string): (target: Object) => void;
  35269. /**
  35270. * An implementation of a loop for asynchronous functions.
  35271. */
  35272. export class AsyncLoop {
  35273. /**
  35274. * Defines the number of iterations for the loop
  35275. */
  35276. iterations: number;
  35277. /**
  35278. * Defines the current index of the loop.
  35279. */
  35280. index: number;
  35281. private _done;
  35282. private _fn;
  35283. private _successCallback;
  35284. /**
  35285. * Constructor.
  35286. * @param iterations the number of iterations.
  35287. * @param func the function to run each iteration
  35288. * @param successCallback the callback that will be called upon succesful execution
  35289. * @param offset starting offset.
  35290. */
  35291. constructor(
  35292. /**
  35293. * Defines the number of iterations for the loop
  35294. */
  35295. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35296. /**
  35297. * Execute the next iteration. Must be called after the last iteration was finished.
  35298. */
  35299. executeNext(): void;
  35300. /**
  35301. * Break the loop and run the success callback.
  35302. */
  35303. breakLoop(): void;
  35304. /**
  35305. * Create and run an async loop.
  35306. * @param iterations the number of iterations.
  35307. * @param fn the function to run each iteration
  35308. * @param successCallback the callback that will be called upon succesful execution
  35309. * @param offset starting offset.
  35310. * @returns the created async loop object
  35311. */
  35312. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35313. /**
  35314. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35315. * @param iterations total number of iterations
  35316. * @param syncedIterations number of synchronous iterations in each async iteration.
  35317. * @param fn the function to call each iteration.
  35318. * @param callback a success call back that will be called when iterating stops.
  35319. * @param breakFunction a break condition (optional)
  35320. * @param timeout timeout settings for the setTimeout function. default - 0.
  35321. * @returns the created async loop object
  35322. */
  35323. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35324. }
  35325. }
  35326. declare module "babylonjs/Misc/stringDictionary" {
  35327. import { Nullable } from "babylonjs/types";
  35328. /**
  35329. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35330. * The underlying implementation relies on an associative array to ensure the best performances.
  35331. * The value can be anything including 'null' but except 'undefined'
  35332. */
  35333. export class StringDictionary<T> {
  35334. /**
  35335. * This will clear this dictionary and copy the content from the 'source' one.
  35336. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35337. * @param source the dictionary to take the content from and copy to this dictionary
  35338. */
  35339. copyFrom(source: StringDictionary<T>): void;
  35340. /**
  35341. * Get a value based from its key
  35342. * @param key the given key to get the matching value from
  35343. * @return the value if found, otherwise undefined is returned
  35344. */
  35345. get(key: string): T | undefined;
  35346. /**
  35347. * Get a value from its key or add it if it doesn't exist.
  35348. * This method will ensure you that a given key/data will be present in the dictionary.
  35349. * @param key the given key to get the matching value from
  35350. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35351. * The factory will only be invoked if there's no data for the given key.
  35352. * @return the value corresponding to the key.
  35353. */
  35354. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35355. /**
  35356. * Get a value from its key if present in the dictionary otherwise add it
  35357. * @param key the key to get the value from
  35358. * @param val if there's no such key/value pair in the dictionary add it with this value
  35359. * @return the value corresponding to the key
  35360. */
  35361. getOrAdd(key: string, val: T): T;
  35362. /**
  35363. * Check if there's a given key in the dictionary
  35364. * @param key the key to check for
  35365. * @return true if the key is present, false otherwise
  35366. */
  35367. contains(key: string): boolean;
  35368. /**
  35369. * Add a new key and its corresponding value
  35370. * @param key the key to add
  35371. * @param value the value corresponding to the key
  35372. * @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
  35373. */
  35374. add(key: string, value: T): boolean;
  35375. /**
  35376. * Update a specific value associated to a key
  35377. * @param key defines the key to use
  35378. * @param value defines the value to store
  35379. * @returns true if the value was updated (or false if the key was not found)
  35380. */
  35381. set(key: string, value: T): boolean;
  35382. /**
  35383. * Get the element of the given key and remove it from the dictionary
  35384. * @param key defines the key to search
  35385. * @returns the value associated with the key or null if not found
  35386. */
  35387. getAndRemove(key: string): Nullable<T>;
  35388. /**
  35389. * Remove a key/value from the dictionary.
  35390. * @param key the key to remove
  35391. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35392. */
  35393. remove(key: string): boolean;
  35394. /**
  35395. * Clear the whole content of the dictionary
  35396. */
  35397. clear(): void;
  35398. /**
  35399. * Gets the current count
  35400. */
  35401. get count(): number;
  35402. /**
  35403. * Execute a callback on each key/val of the dictionary.
  35404. * Note that you can remove any element in this dictionary in the callback implementation
  35405. * @param callback the callback to execute on a given key/value pair
  35406. */
  35407. forEach(callback: (key: string, val: T) => void): void;
  35408. /**
  35409. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35410. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35411. * Note that you can remove any element in this dictionary in the callback implementation
  35412. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35413. * @returns the first item
  35414. */
  35415. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35416. private _count;
  35417. private _data;
  35418. }
  35419. }
  35420. declare module "babylonjs/Collisions/collisionCoordinator" {
  35421. import { Nullable } from "babylonjs/types";
  35422. import { Scene } from "babylonjs/scene";
  35423. import { Vector3 } from "babylonjs/Maths/math.vector";
  35424. import { Collider } from "babylonjs/Collisions/collider";
  35425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35426. /** @hidden */
  35427. export interface ICollisionCoordinator {
  35428. createCollider(): Collider;
  35429. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35430. init(scene: Scene): void;
  35431. }
  35432. /** @hidden */
  35433. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35434. private _scene;
  35435. private _scaledPosition;
  35436. private _scaledVelocity;
  35437. private _finalPosition;
  35438. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35439. createCollider(): Collider;
  35440. init(scene: Scene): void;
  35441. private _collideWithWorld;
  35442. }
  35443. }
  35444. declare module "babylonjs/Inputs/scene.inputManager" {
  35445. import { Nullable } from "babylonjs/types";
  35446. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35447. import { Vector2 } from "babylonjs/Maths/math.vector";
  35448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35449. import { Scene } from "babylonjs/scene";
  35450. /**
  35451. * Class used to manage all inputs for the scene.
  35452. */
  35453. export class InputManager {
  35454. /** The distance in pixel that you have to move to prevent some events */
  35455. static DragMovementThreshold: number;
  35456. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35457. static LongPressDelay: number;
  35458. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35459. static DoubleClickDelay: number;
  35460. /** If you need to check double click without raising a single click at first click, enable this flag */
  35461. static ExclusiveDoubleClickMode: boolean;
  35462. private _wheelEventName;
  35463. private _onPointerMove;
  35464. private _onPointerDown;
  35465. private _onPointerUp;
  35466. private _initClickEvent;
  35467. private _initActionManager;
  35468. private _delayedSimpleClick;
  35469. private _delayedSimpleClickTimeout;
  35470. private _previousDelayedSimpleClickTimeout;
  35471. private _meshPickProceed;
  35472. private _previousButtonPressed;
  35473. private _currentPickResult;
  35474. private _previousPickResult;
  35475. private _totalPointersPressed;
  35476. private _doubleClickOccured;
  35477. private _pointerOverMesh;
  35478. private _pickedDownMesh;
  35479. private _pickedUpMesh;
  35480. private _pointerX;
  35481. private _pointerY;
  35482. private _unTranslatedPointerX;
  35483. private _unTranslatedPointerY;
  35484. private _startingPointerPosition;
  35485. private _previousStartingPointerPosition;
  35486. private _startingPointerTime;
  35487. private _previousStartingPointerTime;
  35488. private _pointerCaptures;
  35489. private _onKeyDown;
  35490. private _onKeyUp;
  35491. private _onCanvasFocusObserver;
  35492. private _onCanvasBlurObserver;
  35493. private _scene;
  35494. /**
  35495. * Creates a new InputManager
  35496. * @param scene defines the hosting scene
  35497. */
  35498. constructor(scene: Scene);
  35499. /**
  35500. * Gets the mesh that is currently under the pointer
  35501. */
  35502. get meshUnderPointer(): Nullable<AbstractMesh>;
  35503. /**
  35504. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35505. */
  35506. get unTranslatedPointer(): Vector2;
  35507. /**
  35508. * Gets or sets the current on-screen X position of the pointer
  35509. */
  35510. get pointerX(): number;
  35511. set pointerX(value: number);
  35512. /**
  35513. * Gets or sets the current on-screen Y position of the pointer
  35514. */
  35515. get pointerY(): number;
  35516. set pointerY(value: number);
  35517. private _updatePointerPosition;
  35518. private _processPointerMove;
  35519. private _setRayOnPointerInfo;
  35520. private _checkPrePointerObservable;
  35521. /**
  35522. * Use this method to simulate a pointer move on a mesh
  35523. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35524. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35525. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35526. */
  35527. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35528. /**
  35529. * Use this method to simulate a pointer down on a mesh
  35530. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35531. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35532. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35533. */
  35534. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35535. private _processPointerDown;
  35536. /** @hidden */
  35537. _isPointerSwiping(): boolean;
  35538. /**
  35539. * Use this method to simulate a pointer up on a mesh
  35540. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35541. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35542. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35543. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35544. */
  35545. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35546. private _processPointerUp;
  35547. /**
  35548. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35549. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35550. * @returns true if the pointer was captured
  35551. */
  35552. isPointerCaptured(pointerId?: number): boolean;
  35553. /**
  35554. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35555. * @param attachUp defines if you want to attach events to pointerup
  35556. * @param attachDown defines if you want to attach events to pointerdown
  35557. * @param attachMove defines if you want to attach events to pointermove
  35558. */
  35559. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35560. /**
  35561. * Detaches all event handlers
  35562. */
  35563. detachControl(): void;
  35564. /**
  35565. * Force the value of meshUnderPointer
  35566. * @param mesh defines the mesh to use
  35567. */
  35568. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35569. /**
  35570. * Gets the mesh under the pointer
  35571. * @returns a Mesh or null if no mesh is under the pointer
  35572. */
  35573. getPointerOverMesh(): Nullable<AbstractMesh>;
  35574. }
  35575. }
  35576. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35577. /**
  35578. * Helper class used to generate session unique ID
  35579. */
  35580. export class UniqueIdGenerator {
  35581. private static _UniqueIdCounter;
  35582. /**
  35583. * Gets an unique (relatively to the current scene) Id
  35584. */
  35585. static get UniqueId(): number;
  35586. }
  35587. }
  35588. declare module "babylonjs/Animations/animationGroup" {
  35589. import { Animatable } from "babylonjs/Animations/animatable";
  35590. import { Animation } from "babylonjs/Animations/animation";
  35591. import { Scene, IDisposable } from "babylonjs/scene";
  35592. import { Observable } from "babylonjs/Misc/observable";
  35593. import { Nullable } from "babylonjs/types";
  35594. import "babylonjs/Animations/animatable";
  35595. /**
  35596. * This class defines the direct association between an animation and a target
  35597. */
  35598. export class TargetedAnimation {
  35599. /**
  35600. * Animation to perform
  35601. */
  35602. animation: Animation;
  35603. /**
  35604. * Target to animate
  35605. */
  35606. target: any;
  35607. /**
  35608. * Serialize the object
  35609. * @returns the JSON object representing the current entity
  35610. */
  35611. serialize(): any;
  35612. }
  35613. /**
  35614. * Use this class to create coordinated animations on multiple targets
  35615. */
  35616. export class AnimationGroup implements IDisposable {
  35617. /** The name of the animation group */
  35618. name: string;
  35619. private _scene;
  35620. private _targetedAnimations;
  35621. private _animatables;
  35622. private _from;
  35623. private _to;
  35624. private _isStarted;
  35625. private _isPaused;
  35626. private _speedRatio;
  35627. private _loopAnimation;
  35628. /**
  35629. * Gets or sets the unique id of the node
  35630. */
  35631. uniqueId: number;
  35632. /**
  35633. * This observable will notify when one animation have ended
  35634. */
  35635. onAnimationEndObservable: Observable<TargetedAnimation>;
  35636. /**
  35637. * Observer raised when one animation loops
  35638. */
  35639. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35640. /**
  35641. * Observer raised when all animations have looped
  35642. */
  35643. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35644. /**
  35645. * This observable will notify when all animations have ended.
  35646. */
  35647. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35648. /**
  35649. * This observable will notify when all animations have paused.
  35650. */
  35651. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35652. /**
  35653. * This observable will notify when all animations are playing.
  35654. */
  35655. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35656. /**
  35657. * Gets the first frame
  35658. */
  35659. get from(): number;
  35660. /**
  35661. * Gets the last frame
  35662. */
  35663. get to(): number;
  35664. /**
  35665. * Define if the animations are started
  35666. */
  35667. get isStarted(): boolean;
  35668. /**
  35669. * Gets a value indicating that the current group is playing
  35670. */
  35671. get isPlaying(): boolean;
  35672. /**
  35673. * Gets or sets the speed ratio to use for all animations
  35674. */
  35675. get speedRatio(): number;
  35676. /**
  35677. * Gets or sets the speed ratio to use for all animations
  35678. */
  35679. set speedRatio(value: number);
  35680. /**
  35681. * Gets or sets if all animations should loop or not
  35682. */
  35683. get loopAnimation(): boolean;
  35684. set loopAnimation(value: boolean);
  35685. /**
  35686. * Gets the targeted animations for this animation group
  35687. */
  35688. get targetedAnimations(): Array<TargetedAnimation>;
  35689. /**
  35690. * returning the list of animatables controlled by this animation group.
  35691. */
  35692. get animatables(): Array<Animatable>;
  35693. /**
  35694. * Instantiates a new Animation Group.
  35695. * This helps managing several animations at once.
  35696. * @see http://doc.babylonjs.com/how_to/group
  35697. * @param name Defines the name of the group
  35698. * @param scene Defines the scene the group belongs to
  35699. */
  35700. constructor(
  35701. /** The name of the animation group */
  35702. name: string, scene?: Nullable<Scene>);
  35703. /**
  35704. * Add an animation (with its target) in the group
  35705. * @param animation defines the animation we want to add
  35706. * @param target defines the target of the animation
  35707. * @returns the TargetedAnimation object
  35708. */
  35709. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35710. /**
  35711. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35712. * It can add constant keys at begin or end
  35713. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35714. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35715. * @returns the animation group
  35716. */
  35717. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35718. private _animationLoopCount;
  35719. private _animationLoopFlags;
  35720. private _processLoop;
  35721. /**
  35722. * Start all animations on given targets
  35723. * @param loop defines if animations must loop
  35724. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35725. * @param from defines the from key (optional)
  35726. * @param to defines the to key (optional)
  35727. * @returns the current animation group
  35728. */
  35729. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35730. /**
  35731. * Pause all animations
  35732. * @returns the animation group
  35733. */
  35734. pause(): AnimationGroup;
  35735. /**
  35736. * Play all animations to initial state
  35737. * This function will start() the animations if they were not started or will restart() them if they were paused
  35738. * @param loop defines if animations must loop
  35739. * @returns the animation group
  35740. */
  35741. play(loop?: boolean): AnimationGroup;
  35742. /**
  35743. * Reset all animations to initial state
  35744. * @returns the animation group
  35745. */
  35746. reset(): AnimationGroup;
  35747. /**
  35748. * Restart animations from key 0
  35749. * @returns the animation group
  35750. */
  35751. restart(): AnimationGroup;
  35752. /**
  35753. * Stop all animations
  35754. * @returns the animation group
  35755. */
  35756. stop(): AnimationGroup;
  35757. /**
  35758. * Set animation weight for all animatables
  35759. * @param weight defines the weight to use
  35760. * @return the animationGroup
  35761. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35762. */
  35763. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35764. /**
  35765. * Synchronize and normalize all animatables with a source animatable
  35766. * @param root defines the root animatable to synchronize with
  35767. * @return the animationGroup
  35768. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35769. */
  35770. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35771. /**
  35772. * Goes to a specific frame in this animation group
  35773. * @param frame the frame number to go to
  35774. * @return the animationGroup
  35775. */
  35776. goToFrame(frame: number): AnimationGroup;
  35777. /**
  35778. * Dispose all associated resources
  35779. */
  35780. dispose(): void;
  35781. private _checkAnimationGroupEnded;
  35782. /**
  35783. * Clone the current animation group and returns a copy
  35784. * @param newName defines the name of the new group
  35785. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35786. * @returns the new aniamtion group
  35787. */
  35788. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35789. /**
  35790. * Serializes the animationGroup to an object
  35791. * @returns Serialized object
  35792. */
  35793. serialize(): any;
  35794. /**
  35795. * Returns a new AnimationGroup object parsed from the source provided.
  35796. * @param parsedAnimationGroup defines the source
  35797. * @param scene defines the scene that will receive the animationGroup
  35798. * @returns a new AnimationGroup
  35799. */
  35800. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35801. /**
  35802. * Returns the string "AnimationGroup"
  35803. * @returns "AnimationGroup"
  35804. */
  35805. getClassName(): string;
  35806. /**
  35807. * Creates a detailled string about the object
  35808. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35809. * @returns a string representing the object
  35810. */
  35811. toString(fullDetails?: boolean): string;
  35812. }
  35813. }
  35814. declare module "babylonjs/scene" {
  35815. import { Nullable } from "babylonjs/types";
  35816. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35817. import { Observable } from "babylonjs/Misc/observable";
  35818. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35819. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35820. import { Geometry } from "babylonjs/Meshes/geometry";
  35821. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35822. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35824. import { Mesh } from "babylonjs/Meshes/mesh";
  35825. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35826. import { Bone } from "babylonjs/Bones/bone";
  35827. import { Skeleton } from "babylonjs/Bones/skeleton";
  35828. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35829. import { Camera } from "babylonjs/Cameras/camera";
  35830. import { AbstractScene } from "babylonjs/abstractScene";
  35831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35832. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35833. import { Material } from "babylonjs/Materials/material";
  35834. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35835. import { Effect } from "babylonjs/Materials/effect";
  35836. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35837. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35838. import { Light } from "babylonjs/Lights/light";
  35839. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35840. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35841. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35842. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35843. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35844. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35845. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35846. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35847. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35848. import { Engine } from "babylonjs/Engines/engine";
  35849. import { Node } from "babylonjs/node";
  35850. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35851. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35852. import { WebRequest } from "babylonjs/Misc/webRequest";
  35853. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35854. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35855. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35856. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35857. import { Plane } from "babylonjs/Maths/math.plane";
  35858. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35859. import { Ray } from "babylonjs/Culling/ray";
  35860. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35861. import { Animation } from "babylonjs/Animations/animation";
  35862. import { Animatable } from "babylonjs/Animations/animatable";
  35863. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35864. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35865. import { Collider } from "babylonjs/Collisions/collider";
  35866. /**
  35867. * Define an interface for all classes that will hold resources
  35868. */
  35869. export interface IDisposable {
  35870. /**
  35871. * Releases all held resources
  35872. */
  35873. dispose(): void;
  35874. }
  35875. /** Interface defining initialization parameters for Scene class */
  35876. export interface SceneOptions {
  35877. /**
  35878. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35879. * It will improve performance when the number of geometries becomes important.
  35880. */
  35881. useGeometryUniqueIdsMap?: boolean;
  35882. /**
  35883. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35884. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35885. */
  35886. useMaterialMeshMap?: boolean;
  35887. /**
  35888. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35889. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35890. */
  35891. useClonedMeshMap?: boolean;
  35892. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35893. virtual?: boolean;
  35894. }
  35895. /**
  35896. * Represents a scene to be rendered by the engine.
  35897. * @see http://doc.babylonjs.com/features/scene
  35898. */
  35899. export class Scene extends AbstractScene implements IAnimatable {
  35900. /** The fog is deactivated */
  35901. static readonly FOGMODE_NONE: number;
  35902. /** The fog density is following an exponential function */
  35903. static readonly FOGMODE_EXP: number;
  35904. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35905. static readonly FOGMODE_EXP2: number;
  35906. /** The fog density is following a linear function. */
  35907. static readonly FOGMODE_LINEAR: number;
  35908. /**
  35909. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35910. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35911. */
  35912. static MinDeltaTime: number;
  35913. /**
  35914. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35915. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35916. */
  35917. static MaxDeltaTime: number;
  35918. /**
  35919. * Factory used to create the default material.
  35920. * @param name The name of the material to create
  35921. * @param scene The scene to create the material for
  35922. * @returns The default material
  35923. */
  35924. static DefaultMaterialFactory(scene: Scene): Material;
  35925. /**
  35926. * Factory used to create the a collision coordinator.
  35927. * @returns The collision coordinator
  35928. */
  35929. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35930. /** @hidden */
  35931. _inputManager: InputManager;
  35932. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35933. cameraToUseForPointers: Nullable<Camera>;
  35934. /** @hidden */
  35935. readonly _isScene: boolean;
  35936. /**
  35937. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35938. */
  35939. autoClear: boolean;
  35940. /**
  35941. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35942. */
  35943. autoClearDepthAndStencil: boolean;
  35944. /**
  35945. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35946. */
  35947. clearColor: Color4;
  35948. /**
  35949. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35950. */
  35951. ambientColor: Color3;
  35952. /**
  35953. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35954. * It should only be one of the following (if not the default embedded one):
  35955. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35956. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35957. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35958. * The material properties need to be setup according to the type of texture in use.
  35959. */
  35960. environmentBRDFTexture: BaseTexture;
  35961. /** @hidden */
  35962. protected _environmentTexture: Nullable<BaseTexture>;
  35963. /**
  35964. * Texture used in all pbr material as the reflection texture.
  35965. * As in the majority of the scene they are the same (exception for multi room and so on),
  35966. * this is easier to reference from here than from all the materials.
  35967. */
  35968. get environmentTexture(): Nullable<BaseTexture>;
  35969. /**
  35970. * Texture used in all pbr material as the reflection texture.
  35971. * As in the majority of the scene they are the same (exception for multi room and so on),
  35972. * this is easier to set here than in all the materials.
  35973. */
  35974. set environmentTexture(value: Nullable<BaseTexture>);
  35975. /** @hidden */
  35976. protected _environmentIntensity: number;
  35977. /**
  35978. * Intensity of the environment in all pbr material.
  35979. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35980. * As in the majority of the scene they are the same (exception for multi room and so on),
  35981. * this is easier to reference from here than from all the materials.
  35982. */
  35983. get environmentIntensity(): number;
  35984. /**
  35985. * Intensity of the environment in all pbr material.
  35986. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35987. * As in the majority of the scene they are the same (exception for multi room and so on),
  35988. * this is easier to set here than in all the materials.
  35989. */
  35990. set environmentIntensity(value: number);
  35991. /** @hidden */
  35992. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35993. /**
  35994. * Default image processing configuration used either in the rendering
  35995. * Forward main pass or through the imageProcessingPostProcess if present.
  35996. * As in the majority of the scene they are the same (exception for multi camera),
  35997. * this is easier to reference from here than from all the materials and post process.
  35998. *
  35999. * No setter as we it is a shared configuration, you can set the values instead.
  36000. */
  36001. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36002. private _forceWireframe;
  36003. /**
  36004. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36005. */
  36006. set forceWireframe(value: boolean);
  36007. get forceWireframe(): boolean;
  36008. private _skipFrustumClipping;
  36009. /**
  36010. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36011. */
  36012. set skipFrustumClipping(value: boolean);
  36013. get skipFrustumClipping(): boolean;
  36014. private _forcePointsCloud;
  36015. /**
  36016. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36017. */
  36018. set forcePointsCloud(value: boolean);
  36019. get forcePointsCloud(): boolean;
  36020. /**
  36021. * Gets or sets the active clipplane 1
  36022. */
  36023. clipPlane: Nullable<Plane>;
  36024. /**
  36025. * Gets or sets the active clipplane 2
  36026. */
  36027. clipPlane2: Nullable<Plane>;
  36028. /**
  36029. * Gets or sets the active clipplane 3
  36030. */
  36031. clipPlane3: Nullable<Plane>;
  36032. /**
  36033. * Gets or sets the active clipplane 4
  36034. */
  36035. clipPlane4: Nullable<Plane>;
  36036. /**
  36037. * Gets or sets the active clipplane 5
  36038. */
  36039. clipPlane5: Nullable<Plane>;
  36040. /**
  36041. * Gets or sets the active clipplane 6
  36042. */
  36043. clipPlane6: Nullable<Plane>;
  36044. /**
  36045. * Gets or sets a boolean indicating if animations are enabled
  36046. */
  36047. animationsEnabled: boolean;
  36048. private _animationPropertiesOverride;
  36049. /**
  36050. * Gets or sets the animation properties override
  36051. */
  36052. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36053. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36054. /**
  36055. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36056. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36057. */
  36058. useConstantAnimationDeltaTime: boolean;
  36059. /**
  36060. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36061. * Please note that it requires to run a ray cast through the scene on every frame
  36062. */
  36063. constantlyUpdateMeshUnderPointer: boolean;
  36064. /**
  36065. * Defines the HTML cursor to use when hovering over interactive elements
  36066. */
  36067. hoverCursor: string;
  36068. /**
  36069. * Defines the HTML default cursor to use (empty by default)
  36070. */
  36071. defaultCursor: string;
  36072. /**
  36073. * Defines wether cursors are handled by the scene.
  36074. */
  36075. doNotHandleCursors: boolean;
  36076. /**
  36077. * This is used to call preventDefault() on pointer down
  36078. * in order to block unwanted artifacts like system double clicks
  36079. */
  36080. preventDefaultOnPointerDown: boolean;
  36081. /**
  36082. * This is used to call preventDefault() on pointer up
  36083. * in order to block unwanted artifacts like system double clicks
  36084. */
  36085. preventDefaultOnPointerUp: boolean;
  36086. /**
  36087. * Gets or sets user defined metadata
  36088. */
  36089. metadata: any;
  36090. /**
  36091. * For internal use only. Please do not use.
  36092. */
  36093. reservedDataStore: any;
  36094. /**
  36095. * Gets the name of the plugin used to load this scene (null by default)
  36096. */
  36097. loadingPluginName: string;
  36098. /**
  36099. * Use this array to add regular expressions used to disable offline support for specific urls
  36100. */
  36101. disableOfflineSupportExceptionRules: RegExp[];
  36102. /**
  36103. * An event triggered when the scene is disposed.
  36104. */
  36105. onDisposeObservable: Observable<Scene>;
  36106. private _onDisposeObserver;
  36107. /** Sets a function to be executed when this scene is disposed. */
  36108. set onDispose(callback: () => void);
  36109. /**
  36110. * An event triggered before rendering the scene (right after animations and physics)
  36111. */
  36112. onBeforeRenderObservable: Observable<Scene>;
  36113. private _onBeforeRenderObserver;
  36114. /** Sets a function to be executed before rendering this scene */
  36115. set beforeRender(callback: Nullable<() => void>);
  36116. /**
  36117. * An event triggered after rendering the scene
  36118. */
  36119. onAfterRenderObservable: Observable<Scene>;
  36120. /**
  36121. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36122. */
  36123. onAfterRenderCameraObservable: Observable<Camera>;
  36124. private _onAfterRenderObserver;
  36125. /** Sets a function to be executed after rendering this scene */
  36126. set afterRender(callback: Nullable<() => void>);
  36127. /**
  36128. * An event triggered before animating the scene
  36129. */
  36130. onBeforeAnimationsObservable: Observable<Scene>;
  36131. /**
  36132. * An event triggered after animations processing
  36133. */
  36134. onAfterAnimationsObservable: Observable<Scene>;
  36135. /**
  36136. * An event triggered before draw calls are ready to be sent
  36137. */
  36138. onBeforeDrawPhaseObservable: Observable<Scene>;
  36139. /**
  36140. * An event triggered after draw calls have been sent
  36141. */
  36142. onAfterDrawPhaseObservable: Observable<Scene>;
  36143. /**
  36144. * An event triggered when the scene is ready
  36145. */
  36146. onReadyObservable: Observable<Scene>;
  36147. /**
  36148. * An event triggered before rendering a camera
  36149. */
  36150. onBeforeCameraRenderObservable: Observable<Camera>;
  36151. private _onBeforeCameraRenderObserver;
  36152. /** Sets a function to be executed before rendering a camera*/
  36153. set beforeCameraRender(callback: () => void);
  36154. /**
  36155. * An event triggered after rendering a camera
  36156. */
  36157. onAfterCameraRenderObservable: Observable<Camera>;
  36158. private _onAfterCameraRenderObserver;
  36159. /** Sets a function to be executed after rendering a camera*/
  36160. set afterCameraRender(callback: () => void);
  36161. /**
  36162. * An event triggered when active meshes evaluation is about to start
  36163. */
  36164. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36165. /**
  36166. * An event triggered when active meshes evaluation is done
  36167. */
  36168. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36169. /**
  36170. * An event triggered when particles rendering is about to start
  36171. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36172. */
  36173. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36174. /**
  36175. * An event triggered when particles rendering is done
  36176. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36177. */
  36178. onAfterParticlesRenderingObservable: Observable<Scene>;
  36179. /**
  36180. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36181. */
  36182. onDataLoadedObservable: Observable<Scene>;
  36183. /**
  36184. * An event triggered when a camera is created
  36185. */
  36186. onNewCameraAddedObservable: Observable<Camera>;
  36187. /**
  36188. * An event triggered when a camera is removed
  36189. */
  36190. onCameraRemovedObservable: Observable<Camera>;
  36191. /**
  36192. * An event triggered when a light is created
  36193. */
  36194. onNewLightAddedObservable: Observable<Light>;
  36195. /**
  36196. * An event triggered when a light is removed
  36197. */
  36198. onLightRemovedObservable: Observable<Light>;
  36199. /**
  36200. * An event triggered when a geometry is created
  36201. */
  36202. onNewGeometryAddedObservable: Observable<Geometry>;
  36203. /**
  36204. * An event triggered when a geometry is removed
  36205. */
  36206. onGeometryRemovedObservable: Observable<Geometry>;
  36207. /**
  36208. * An event triggered when a transform node is created
  36209. */
  36210. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36211. /**
  36212. * An event triggered when a transform node is removed
  36213. */
  36214. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36215. /**
  36216. * An event triggered when a mesh is created
  36217. */
  36218. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36219. /**
  36220. * An event triggered when a mesh is removed
  36221. */
  36222. onMeshRemovedObservable: Observable<AbstractMesh>;
  36223. /**
  36224. * An event triggered when a skeleton is created
  36225. */
  36226. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36227. /**
  36228. * An event triggered when a skeleton is removed
  36229. */
  36230. onSkeletonRemovedObservable: Observable<Skeleton>;
  36231. /**
  36232. * An event triggered when a material is created
  36233. */
  36234. onNewMaterialAddedObservable: Observable<Material>;
  36235. /**
  36236. * An event triggered when a material is removed
  36237. */
  36238. onMaterialRemovedObservable: Observable<Material>;
  36239. /**
  36240. * An event triggered when a texture is created
  36241. */
  36242. onNewTextureAddedObservable: Observable<BaseTexture>;
  36243. /**
  36244. * An event triggered when a texture is removed
  36245. */
  36246. onTextureRemovedObservable: Observable<BaseTexture>;
  36247. /**
  36248. * An event triggered when render targets are about to be rendered
  36249. * Can happen multiple times per frame.
  36250. */
  36251. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36252. /**
  36253. * An event triggered when render targets were rendered.
  36254. * Can happen multiple times per frame.
  36255. */
  36256. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36257. /**
  36258. * An event triggered before calculating deterministic simulation step
  36259. */
  36260. onBeforeStepObservable: Observable<Scene>;
  36261. /**
  36262. * An event triggered after calculating deterministic simulation step
  36263. */
  36264. onAfterStepObservable: Observable<Scene>;
  36265. /**
  36266. * An event triggered when the activeCamera property is updated
  36267. */
  36268. onActiveCameraChanged: Observable<Scene>;
  36269. /**
  36270. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36271. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36272. * 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)
  36273. */
  36274. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36275. /**
  36276. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36277. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36278. * 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)
  36279. */
  36280. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36281. /**
  36282. * This Observable will when a mesh has been imported into the scene.
  36283. */
  36284. onMeshImportedObservable: Observable<AbstractMesh>;
  36285. /**
  36286. * This Observable will when an animation file has been imported into the scene.
  36287. */
  36288. onAnimationFileImportedObservable: Observable<Scene>;
  36289. /**
  36290. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36291. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36292. */
  36293. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36294. /** @hidden */
  36295. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36296. /**
  36297. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36298. */
  36299. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36300. /**
  36301. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36302. */
  36303. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36304. /**
  36305. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36306. */
  36307. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36308. /** Callback called when a pointer move is detected */
  36309. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36310. /** Callback called when a pointer down is detected */
  36311. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36312. /** Callback called when a pointer up is detected */
  36313. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36314. /** Callback called when a pointer pick is detected */
  36315. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36316. /**
  36317. * 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).
  36318. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36319. */
  36320. onPrePointerObservable: Observable<PointerInfoPre>;
  36321. /**
  36322. * Observable event triggered each time an input event is received from the rendering canvas
  36323. */
  36324. onPointerObservable: Observable<PointerInfo>;
  36325. /**
  36326. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36327. */
  36328. get unTranslatedPointer(): Vector2;
  36329. /**
  36330. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36331. */
  36332. static get DragMovementThreshold(): number;
  36333. static set DragMovementThreshold(value: number);
  36334. /**
  36335. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36336. */
  36337. static get LongPressDelay(): number;
  36338. static set LongPressDelay(value: number);
  36339. /**
  36340. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36341. */
  36342. static get DoubleClickDelay(): number;
  36343. static set DoubleClickDelay(value: number);
  36344. /** If you need to check double click without raising a single click at first click, enable this flag */
  36345. static get ExclusiveDoubleClickMode(): boolean;
  36346. static set ExclusiveDoubleClickMode(value: boolean);
  36347. /** @hidden */
  36348. _mirroredCameraPosition: Nullable<Vector3>;
  36349. /**
  36350. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36351. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36352. */
  36353. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36354. /**
  36355. * Observable event triggered each time an keyboard event is received from the hosting window
  36356. */
  36357. onKeyboardObservable: Observable<KeyboardInfo>;
  36358. private _useRightHandedSystem;
  36359. /**
  36360. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36361. */
  36362. set useRightHandedSystem(value: boolean);
  36363. get useRightHandedSystem(): boolean;
  36364. private _timeAccumulator;
  36365. private _currentStepId;
  36366. private _currentInternalStep;
  36367. /**
  36368. * Sets the step Id used by deterministic lock step
  36369. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36370. * @param newStepId defines the step Id
  36371. */
  36372. setStepId(newStepId: number): void;
  36373. /**
  36374. * Gets the step Id used by deterministic lock step
  36375. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36376. * @returns the step Id
  36377. */
  36378. getStepId(): number;
  36379. /**
  36380. * Gets the internal step used by deterministic lock step
  36381. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36382. * @returns the internal step
  36383. */
  36384. getInternalStep(): number;
  36385. private _fogEnabled;
  36386. /**
  36387. * Gets or sets a boolean indicating if fog is enabled on this scene
  36388. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36389. * (Default is true)
  36390. */
  36391. set fogEnabled(value: boolean);
  36392. get fogEnabled(): boolean;
  36393. private _fogMode;
  36394. /**
  36395. * Gets or sets the fog mode to use
  36396. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36397. * | mode | value |
  36398. * | --- | --- |
  36399. * | FOGMODE_NONE | 0 |
  36400. * | FOGMODE_EXP | 1 |
  36401. * | FOGMODE_EXP2 | 2 |
  36402. * | FOGMODE_LINEAR | 3 |
  36403. */
  36404. set fogMode(value: number);
  36405. get fogMode(): number;
  36406. /**
  36407. * Gets or sets the fog color to use
  36408. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36409. * (Default is Color3(0.2, 0.2, 0.3))
  36410. */
  36411. fogColor: Color3;
  36412. /**
  36413. * Gets or sets the fog density to use
  36414. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36415. * (Default is 0.1)
  36416. */
  36417. fogDensity: number;
  36418. /**
  36419. * Gets or sets the fog start distance to use
  36420. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36421. * (Default is 0)
  36422. */
  36423. fogStart: number;
  36424. /**
  36425. * Gets or sets the fog end distance to use
  36426. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36427. * (Default is 1000)
  36428. */
  36429. fogEnd: number;
  36430. private _shadowsEnabled;
  36431. /**
  36432. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36433. */
  36434. set shadowsEnabled(value: boolean);
  36435. get shadowsEnabled(): boolean;
  36436. private _lightsEnabled;
  36437. /**
  36438. * Gets or sets a boolean indicating if lights are enabled on this scene
  36439. */
  36440. set lightsEnabled(value: boolean);
  36441. get lightsEnabled(): boolean;
  36442. /** All of the active cameras added to this scene. */
  36443. activeCameras: Camera[];
  36444. /** @hidden */
  36445. _activeCamera: Nullable<Camera>;
  36446. /** Gets or sets the current active camera */
  36447. get activeCamera(): Nullable<Camera>;
  36448. set activeCamera(value: Nullable<Camera>);
  36449. private _defaultMaterial;
  36450. /** The default material used on meshes when no material is affected */
  36451. get defaultMaterial(): Material;
  36452. /** The default material used on meshes when no material is affected */
  36453. set defaultMaterial(value: Material);
  36454. private _texturesEnabled;
  36455. /**
  36456. * Gets or sets a boolean indicating if textures are enabled on this scene
  36457. */
  36458. set texturesEnabled(value: boolean);
  36459. get texturesEnabled(): boolean;
  36460. /**
  36461. * Gets or sets a boolean indicating if particles are enabled on this scene
  36462. */
  36463. particlesEnabled: boolean;
  36464. /**
  36465. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36466. */
  36467. spritesEnabled: boolean;
  36468. private _skeletonsEnabled;
  36469. /**
  36470. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36471. */
  36472. set skeletonsEnabled(value: boolean);
  36473. get skeletonsEnabled(): boolean;
  36474. /**
  36475. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36476. */
  36477. lensFlaresEnabled: boolean;
  36478. /**
  36479. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36480. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36481. */
  36482. collisionsEnabled: boolean;
  36483. private _collisionCoordinator;
  36484. /** @hidden */
  36485. get collisionCoordinator(): ICollisionCoordinator;
  36486. /**
  36487. * Defines the gravity applied to this scene (used only for collisions)
  36488. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36489. */
  36490. gravity: Vector3;
  36491. /**
  36492. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36493. */
  36494. postProcessesEnabled: boolean;
  36495. /**
  36496. * The list of postprocesses added to the scene
  36497. */
  36498. postProcesses: PostProcess[];
  36499. /**
  36500. * Gets the current postprocess manager
  36501. */
  36502. postProcessManager: PostProcessManager;
  36503. /**
  36504. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36505. */
  36506. renderTargetsEnabled: boolean;
  36507. /**
  36508. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36509. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36510. */
  36511. dumpNextRenderTargets: boolean;
  36512. /**
  36513. * The list of user defined render targets added to the scene
  36514. */
  36515. customRenderTargets: RenderTargetTexture[];
  36516. /**
  36517. * Defines if texture loading must be delayed
  36518. * If true, textures will only be loaded when they need to be rendered
  36519. */
  36520. useDelayedTextureLoading: boolean;
  36521. /**
  36522. * Gets the list of meshes imported to the scene through SceneLoader
  36523. */
  36524. importedMeshesFiles: String[];
  36525. /**
  36526. * Gets or sets a boolean indicating if probes are enabled on this scene
  36527. */
  36528. probesEnabled: boolean;
  36529. /**
  36530. * Gets or sets the current offline provider to use to store scene data
  36531. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36532. */
  36533. offlineProvider: IOfflineProvider;
  36534. /**
  36535. * Gets or sets the action manager associated with the scene
  36536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36537. */
  36538. actionManager: AbstractActionManager;
  36539. private _meshesForIntersections;
  36540. /**
  36541. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36542. */
  36543. proceduralTexturesEnabled: boolean;
  36544. private _engine;
  36545. private _totalVertices;
  36546. /** @hidden */
  36547. _activeIndices: PerfCounter;
  36548. /** @hidden */
  36549. _activeParticles: PerfCounter;
  36550. /** @hidden */
  36551. _activeBones: PerfCounter;
  36552. private _animationRatio;
  36553. /** @hidden */
  36554. _animationTimeLast: number;
  36555. /** @hidden */
  36556. _animationTime: number;
  36557. /**
  36558. * Gets or sets a general scale for animation speed
  36559. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36560. */
  36561. animationTimeScale: number;
  36562. /** @hidden */
  36563. _cachedMaterial: Nullable<Material>;
  36564. /** @hidden */
  36565. _cachedEffect: Nullable<Effect>;
  36566. /** @hidden */
  36567. _cachedVisibility: Nullable<number>;
  36568. private _renderId;
  36569. private _frameId;
  36570. private _executeWhenReadyTimeoutId;
  36571. private _intermediateRendering;
  36572. private _viewUpdateFlag;
  36573. private _projectionUpdateFlag;
  36574. /** @hidden */
  36575. _toBeDisposed: Nullable<IDisposable>[];
  36576. private _activeRequests;
  36577. /** @hidden */
  36578. _pendingData: any[];
  36579. private _isDisposed;
  36580. /**
  36581. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36582. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36583. */
  36584. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36585. private _activeMeshes;
  36586. private _processedMaterials;
  36587. private _renderTargets;
  36588. /** @hidden */
  36589. _activeParticleSystems: SmartArray<IParticleSystem>;
  36590. private _activeSkeletons;
  36591. private _softwareSkinnedMeshes;
  36592. private _renderingManager;
  36593. /** @hidden */
  36594. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36595. private _transformMatrix;
  36596. private _sceneUbo;
  36597. /** @hidden */
  36598. _viewMatrix: Matrix;
  36599. private _projectionMatrix;
  36600. /** @hidden */
  36601. _forcedViewPosition: Nullable<Vector3>;
  36602. /** @hidden */
  36603. _frustumPlanes: Plane[];
  36604. /**
  36605. * Gets the list of frustum planes (built from the active camera)
  36606. */
  36607. get frustumPlanes(): Plane[];
  36608. /**
  36609. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36610. * This is useful if there are more lights that the maximum simulteanous authorized
  36611. */
  36612. requireLightSorting: boolean;
  36613. /** @hidden */
  36614. readonly useMaterialMeshMap: boolean;
  36615. /** @hidden */
  36616. readonly useClonedMeshMap: boolean;
  36617. private _externalData;
  36618. private _uid;
  36619. /**
  36620. * @hidden
  36621. * Backing store of defined scene components.
  36622. */
  36623. _components: ISceneComponent[];
  36624. /**
  36625. * @hidden
  36626. * Backing store of defined scene components.
  36627. */
  36628. _serializableComponents: ISceneSerializableComponent[];
  36629. /**
  36630. * List of components to register on the next registration step.
  36631. */
  36632. private _transientComponents;
  36633. /**
  36634. * Registers the transient components if needed.
  36635. */
  36636. private _registerTransientComponents;
  36637. /**
  36638. * @hidden
  36639. * Add a component to the scene.
  36640. * Note that the ccomponent could be registered on th next frame if this is called after
  36641. * the register component stage.
  36642. * @param component Defines the component to add to the scene
  36643. */
  36644. _addComponent(component: ISceneComponent): void;
  36645. /**
  36646. * @hidden
  36647. * Gets a component from the scene.
  36648. * @param name defines the name of the component to retrieve
  36649. * @returns the component or null if not present
  36650. */
  36651. _getComponent(name: string): Nullable<ISceneComponent>;
  36652. /**
  36653. * @hidden
  36654. * Defines the actions happening before camera updates.
  36655. */
  36656. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36657. /**
  36658. * @hidden
  36659. * Defines the actions happening before clear the canvas.
  36660. */
  36661. _beforeClearStage: Stage<SimpleStageAction>;
  36662. /**
  36663. * @hidden
  36664. * Defines the actions when collecting render targets for the frame.
  36665. */
  36666. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36667. /**
  36668. * @hidden
  36669. * Defines the actions happening for one camera in the frame.
  36670. */
  36671. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36672. /**
  36673. * @hidden
  36674. * Defines the actions happening during the per mesh ready checks.
  36675. */
  36676. _isReadyForMeshStage: Stage<MeshStageAction>;
  36677. /**
  36678. * @hidden
  36679. * Defines the actions happening before evaluate active mesh checks.
  36680. */
  36681. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36682. /**
  36683. * @hidden
  36684. * Defines the actions happening during the evaluate sub mesh checks.
  36685. */
  36686. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36687. /**
  36688. * @hidden
  36689. * Defines the actions happening during the active mesh stage.
  36690. */
  36691. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36692. /**
  36693. * @hidden
  36694. * Defines the actions happening during the per camera render target step.
  36695. */
  36696. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36697. /**
  36698. * @hidden
  36699. * Defines the actions happening just before the active camera is drawing.
  36700. */
  36701. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36702. /**
  36703. * @hidden
  36704. * Defines the actions happening just before a render target is drawing.
  36705. */
  36706. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36707. /**
  36708. * @hidden
  36709. * Defines the actions happening just before a rendering group is drawing.
  36710. */
  36711. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36712. /**
  36713. * @hidden
  36714. * Defines the actions happening just before a mesh is drawing.
  36715. */
  36716. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36717. /**
  36718. * @hidden
  36719. * Defines the actions happening just after a mesh has been drawn.
  36720. */
  36721. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36722. /**
  36723. * @hidden
  36724. * Defines the actions happening just after a rendering group has been drawn.
  36725. */
  36726. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36727. /**
  36728. * @hidden
  36729. * Defines the actions happening just after the active camera has been drawn.
  36730. */
  36731. _afterCameraDrawStage: Stage<CameraStageAction>;
  36732. /**
  36733. * @hidden
  36734. * Defines the actions happening just after a render target has been drawn.
  36735. */
  36736. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36737. /**
  36738. * @hidden
  36739. * Defines the actions happening just after rendering all cameras and computing intersections.
  36740. */
  36741. _afterRenderStage: Stage<SimpleStageAction>;
  36742. /**
  36743. * @hidden
  36744. * Defines the actions happening when a pointer move event happens.
  36745. */
  36746. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36747. /**
  36748. * @hidden
  36749. * Defines the actions happening when a pointer down event happens.
  36750. */
  36751. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36752. /**
  36753. * @hidden
  36754. * Defines the actions happening when a pointer up event happens.
  36755. */
  36756. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36757. /**
  36758. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36759. */
  36760. private geometriesByUniqueId;
  36761. /**
  36762. * Creates a new Scene
  36763. * @param engine defines the engine to use to render this scene
  36764. * @param options defines the scene options
  36765. */
  36766. constructor(engine: Engine, options?: SceneOptions);
  36767. /**
  36768. * Gets a string idenfifying the name of the class
  36769. * @returns "Scene" string
  36770. */
  36771. getClassName(): string;
  36772. private _defaultMeshCandidates;
  36773. /**
  36774. * @hidden
  36775. */
  36776. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36777. private _defaultSubMeshCandidates;
  36778. /**
  36779. * @hidden
  36780. */
  36781. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36782. /**
  36783. * Sets the default candidate providers for the scene.
  36784. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36785. * and getCollidingSubMeshCandidates to their default function
  36786. */
  36787. setDefaultCandidateProviders(): void;
  36788. /**
  36789. * Gets the mesh that is currently under the pointer
  36790. */
  36791. get meshUnderPointer(): Nullable<AbstractMesh>;
  36792. /**
  36793. * Gets or sets the current on-screen X position of the pointer
  36794. */
  36795. get pointerX(): number;
  36796. set pointerX(value: number);
  36797. /**
  36798. * Gets or sets the current on-screen Y position of the pointer
  36799. */
  36800. get pointerY(): number;
  36801. set pointerY(value: number);
  36802. /**
  36803. * Gets the cached material (ie. the latest rendered one)
  36804. * @returns the cached material
  36805. */
  36806. getCachedMaterial(): Nullable<Material>;
  36807. /**
  36808. * Gets the cached effect (ie. the latest rendered one)
  36809. * @returns the cached effect
  36810. */
  36811. getCachedEffect(): Nullable<Effect>;
  36812. /**
  36813. * Gets the cached visibility state (ie. the latest rendered one)
  36814. * @returns the cached visibility state
  36815. */
  36816. getCachedVisibility(): Nullable<number>;
  36817. /**
  36818. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36819. * @param material defines the current material
  36820. * @param effect defines the current effect
  36821. * @param visibility defines the current visibility state
  36822. * @returns true if one parameter is not cached
  36823. */
  36824. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36825. /**
  36826. * Gets the engine associated with the scene
  36827. * @returns an Engine
  36828. */
  36829. getEngine(): Engine;
  36830. /**
  36831. * Gets the total number of vertices rendered per frame
  36832. * @returns the total number of vertices rendered per frame
  36833. */
  36834. getTotalVertices(): number;
  36835. /**
  36836. * Gets the performance counter for total vertices
  36837. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36838. */
  36839. get totalVerticesPerfCounter(): PerfCounter;
  36840. /**
  36841. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36842. * @returns the total number of active indices rendered per frame
  36843. */
  36844. getActiveIndices(): number;
  36845. /**
  36846. * Gets the performance counter for active indices
  36847. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36848. */
  36849. get totalActiveIndicesPerfCounter(): PerfCounter;
  36850. /**
  36851. * Gets the total number of active particles rendered per frame
  36852. * @returns the total number of active particles rendered per frame
  36853. */
  36854. getActiveParticles(): number;
  36855. /**
  36856. * Gets the performance counter for active particles
  36857. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36858. */
  36859. get activeParticlesPerfCounter(): PerfCounter;
  36860. /**
  36861. * Gets the total number of active bones rendered per frame
  36862. * @returns the total number of active bones rendered per frame
  36863. */
  36864. getActiveBones(): number;
  36865. /**
  36866. * Gets the performance counter for active bones
  36867. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36868. */
  36869. get activeBonesPerfCounter(): PerfCounter;
  36870. /**
  36871. * Gets the array of active meshes
  36872. * @returns an array of AbstractMesh
  36873. */
  36874. getActiveMeshes(): SmartArray<AbstractMesh>;
  36875. /**
  36876. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36877. * @returns a number
  36878. */
  36879. getAnimationRatio(): number;
  36880. /**
  36881. * Gets an unique Id for the current render phase
  36882. * @returns a number
  36883. */
  36884. getRenderId(): number;
  36885. /**
  36886. * Gets an unique Id for the current frame
  36887. * @returns a number
  36888. */
  36889. getFrameId(): number;
  36890. /** Call this function if you want to manually increment the render Id*/
  36891. incrementRenderId(): void;
  36892. private _createUbo;
  36893. /**
  36894. * Use this method to simulate a pointer move on a mesh
  36895. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36896. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36897. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36898. * @returns the current scene
  36899. */
  36900. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36901. /**
  36902. * Use this method to simulate a pointer down on a mesh
  36903. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36904. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36905. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36906. * @returns the current scene
  36907. */
  36908. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36909. /**
  36910. * Use this method to simulate a pointer up on a mesh
  36911. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36912. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36913. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36914. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36915. * @returns the current scene
  36916. */
  36917. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36918. /**
  36919. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36920. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36921. * @returns true if the pointer was captured
  36922. */
  36923. isPointerCaptured(pointerId?: number): boolean;
  36924. /**
  36925. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36926. * @param attachUp defines if you want to attach events to pointerup
  36927. * @param attachDown defines if you want to attach events to pointerdown
  36928. * @param attachMove defines if you want to attach events to pointermove
  36929. */
  36930. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36931. /** Detaches all event handlers*/
  36932. detachControl(): void;
  36933. /**
  36934. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36935. * Delay loaded resources are not taking in account
  36936. * @return true if all required resources are ready
  36937. */
  36938. isReady(): boolean;
  36939. /** Resets all cached information relative to material (including effect and visibility) */
  36940. resetCachedMaterial(): void;
  36941. /**
  36942. * Registers a function to be called before every frame render
  36943. * @param func defines the function to register
  36944. */
  36945. registerBeforeRender(func: () => void): void;
  36946. /**
  36947. * Unregisters a function called before every frame render
  36948. * @param func defines the function to unregister
  36949. */
  36950. unregisterBeforeRender(func: () => void): void;
  36951. /**
  36952. * Registers a function to be called after every frame render
  36953. * @param func defines the function to register
  36954. */
  36955. registerAfterRender(func: () => void): void;
  36956. /**
  36957. * Unregisters a function called after every frame render
  36958. * @param func defines the function to unregister
  36959. */
  36960. unregisterAfterRender(func: () => void): void;
  36961. private _executeOnceBeforeRender;
  36962. /**
  36963. * The provided function will run before render once and will be disposed afterwards.
  36964. * A timeout delay can be provided so that the function will be executed in N ms.
  36965. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36966. * @param func The function to be executed.
  36967. * @param timeout optional delay in ms
  36968. */
  36969. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36970. /** @hidden */
  36971. _addPendingData(data: any): void;
  36972. /** @hidden */
  36973. _removePendingData(data: any): void;
  36974. /**
  36975. * Returns the number of items waiting to be loaded
  36976. * @returns the number of items waiting to be loaded
  36977. */
  36978. getWaitingItemsCount(): number;
  36979. /**
  36980. * Returns a boolean indicating if the scene is still loading data
  36981. */
  36982. get isLoading(): boolean;
  36983. /**
  36984. * Registers a function to be executed when the scene is ready
  36985. * @param {Function} func - the function to be executed
  36986. */
  36987. executeWhenReady(func: () => void): void;
  36988. /**
  36989. * Returns a promise that resolves when the scene is ready
  36990. * @returns A promise that resolves when the scene is ready
  36991. */
  36992. whenReadyAsync(): Promise<void>;
  36993. /** @hidden */
  36994. _checkIsReady(): void;
  36995. /**
  36996. * Gets all animatable attached to the scene
  36997. */
  36998. get animatables(): Animatable[];
  36999. /**
  37000. * Resets the last animation time frame.
  37001. * Useful to override when animations start running when loading a scene for the first time.
  37002. */
  37003. resetLastAnimationTimeFrame(): void;
  37004. /**
  37005. * Gets the current view matrix
  37006. * @returns a Matrix
  37007. */
  37008. getViewMatrix(): Matrix;
  37009. /**
  37010. * Gets the current projection matrix
  37011. * @returns a Matrix
  37012. */
  37013. getProjectionMatrix(): Matrix;
  37014. /**
  37015. * Gets the current transform matrix
  37016. * @returns a Matrix made of View * Projection
  37017. */
  37018. getTransformMatrix(): Matrix;
  37019. /**
  37020. * Sets the current transform matrix
  37021. * @param viewL defines the View matrix to use
  37022. * @param projectionL defines the Projection matrix to use
  37023. * @param viewR defines the right View matrix to use (if provided)
  37024. * @param projectionR defines the right Projection matrix to use (if provided)
  37025. */
  37026. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37027. /**
  37028. * Gets the uniform buffer used to store scene data
  37029. * @returns a UniformBuffer
  37030. */
  37031. getSceneUniformBuffer(): UniformBuffer;
  37032. /**
  37033. * Gets an unique (relatively to the current scene) Id
  37034. * @returns an unique number for the scene
  37035. */
  37036. getUniqueId(): number;
  37037. /**
  37038. * Add a mesh to the list of scene's meshes
  37039. * @param newMesh defines the mesh to add
  37040. * @param recursive if all child meshes should also be added to the scene
  37041. */
  37042. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37043. /**
  37044. * Remove a mesh for the list of scene's meshes
  37045. * @param toRemove defines the mesh to remove
  37046. * @param recursive if all child meshes should also be removed from the scene
  37047. * @returns the index where the mesh was in the mesh list
  37048. */
  37049. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37050. /**
  37051. * Add a transform node to the list of scene's transform nodes
  37052. * @param newTransformNode defines the transform node to add
  37053. */
  37054. addTransformNode(newTransformNode: TransformNode): void;
  37055. /**
  37056. * Remove a transform node for the list of scene's transform nodes
  37057. * @param toRemove defines the transform node to remove
  37058. * @returns the index where the transform node was in the transform node list
  37059. */
  37060. removeTransformNode(toRemove: TransformNode): number;
  37061. /**
  37062. * Remove a skeleton for the list of scene's skeletons
  37063. * @param toRemove defines the skeleton to remove
  37064. * @returns the index where the skeleton was in the skeleton list
  37065. */
  37066. removeSkeleton(toRemove: Skeleton): number;
  37067. /**
  37068. * Remove a morph target for the list of scene's morph targets
  37069. * @param toRemove defines the morph target to remove
  37070. * @returns the index where the morph target was in the morph target list
  37071. */
  37072. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37073. /**
  37074. * Remove a light for the list of scene's lights
  37075. * @param toRemove defines the light to remove
  37076. * @returns the index where the light was in the light list
  37077. */
  37078. removeLight(toRemove: Light): number;
  37079. /**
  37080. * Remove a camera for the list of scene's cameras
  37081. * @param toRemove defines the camera to remove
  37082. * @returns the index where the camera was in the camera list
  37083. */
  37084. removeCamera(toRemove: Camera): number;
  37085. /**
  37086. * Remove a particle system for the list of scene's particle systems
  37087. * @param toRemove defines the particle system to remove
  37088. * @returns the index where the particle system was in the particle system list
  37089. */
  37090. removeParticleSystem(toRemove: IParticleSystem): number;
  37091. /**
  37092. * Remove a animation for the list of scene's animations
  37093. * @param toRemove defines the animation to remove
  37094. * @returns the index where the animation was in the animation list
  37095. */
  37096. removeAnimation(toRemove: Animation): number;
  37097. /**
  37098. * Will stop the animation of the given target
  37099. * @param target - the target
  37100. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37101. * @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)
  37102. */
  37103. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37104. /**
  37105. * Removes the given animation group from this scene.
  37106. * @param toRemove The animation group to remove
  37107. * @returns The index of the removed animation group
  37108. */
  37109. removeAnimationGroup(toRemove: AnimationGroup): number;
  37110. /**
  37111. * Removes the given multi-material from this scene.
  37112. * @param toRemove The multi-material to remove
  37113. * @returns The index of the removed multi-material
  37114. */
  37115. removeMultiMaterial(toRemove: MultiMaterial): number;
  37116. /**
  37117. * Removes the given material from this scene.
  37118. * @param toRemove The material to remove
  37119. * @returns The index of the removed material
  37120. */
  37121. removeMaterial(toRemove: Material): number;
  37122. /**
  37123. * Removes the given action manager from this scene.
  37124. * @param toRemove The action manager to remove
  37125. * @returns The index of the removed action manager
  37126. */
  37127. removeActionManager(toRemove: AbstractActionManager): number;
  37128. /**
  37129. * Removes the given texture from this scene.
  37130. * @param toRemove The texture to remove
  37131. * @returns The index of the removed texture
  37132. */
  37133. removeTexture(toRemove: BaseTexture): number;
  37134. /**
  37135. * Adds the given light to this scene
  37136. * @param newLight The light to add
  37137. */
  37138. addLight(newLight: Light): void;
  37139. /**
  37140. * Sorts the list list based on light priorities
  37141. */
  37142. sortLightsByPriority(): void;
  37143. /**
  37144. * Adds the given camera to this scene
  37145. * @param newCamera The camera to add
  37146. */
  37147. addCamera(newCamera: Camera): void;
  37148. /**
  37149. * Adds the given skeleton to this scene
  37150. * @param newSkeleton The skeleton to add
  37151. */
  37152. addSkeleton(newSkeleton: Skeleton): void;
  37153. /**
  37154. * Adds the given particle system to this scene
  37155. * @param newParticleSystem The particle system to add
  37156. */
  37157. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37158. /**
  37159. * Adds the given animation to this scene
  37160. * @param newAnimation The animation to add
  37161. */
  37162. addAnimation(newAnimation: Animation): void;
  37163. /**
  37164. * Adds the given animation group to this scene.
  37165. * @param newAnimationGroup The animation group to add
  37166. */
  37167. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37168. /**
  37169. * Adds the given multi-material to this scene
  37170. * @param newMultiMaterial The multi-material to add
  37171. */
  37172. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37173. /**
  37174. * Adds the given material to this scene
  37175. * @param newMaterial The material to add
  37176. */
  37177. addMaterial(newMaterial: Material): void;
  37178. /**
  37179. * Adds the given morph target to this scene
  37180. * @param newMorphTargetManager The morph target to add
  37181. */
  37182. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37183. /**
  37184. * Adds the given geometry to this scene
  37185. * @param newGeometry The geometry to add
  37186. */
  37187. addGeometry(newGeometry: Geometry): void;
  37188. /**
  37189. * Adds the given action manager to this scene
  37190. * @param newActionManager The action manager to add
  37191. */
  37192. addActionManager(newActionManager: AbstractActionManager): void;
  37193. /**
  37194. * Adds the given texture to this scene.
  37195. * @param newTexture The texture to add
  37196. */
  37197. addTexture(newTexture: BaseTexture): void;
  37198. /**
  37199. * Switch active camera
  37200. * @param newCamera defines the new active camera
  37201. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37202. */
  37203. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37204. /**
  37205. * sets the active camera of the scene using its ID
  37206. * @param id defines the camera's ID
  37207. * @return the new active camera or null if none found.
  37208. */
  37209. setActiveCameraByID(id: string): Nullable<Camera>;
  37210. /**
  37211. * sets the active camera of the scene using its name
  37212. * @param name defines the camera's name
  37213. * @returns the new active camera or null if none found.
  37214. */
  37215. setActiveCameraByName(name: string): Nullable<Camera>;
  37216. /**
  37217. * get an animation group using its name
  37218. * @param name defines the material's name
  37219. * @return the animation group or null if none found.
  37220. */
  37221. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37222. /**
  37223. * Get a material using its unique id
  37224. * @param uniqueId defines the material's unique id
  37225. * @return the material or null if none found.
  37226. */
  37227. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37228. /**
  37229. * get a material using its id
  37230. * @param id defines the material's ID
  37231. * @return the material or null if none found.
  37232. */
  37233. getMaterialByID(id: string): Nullable<Material>;
  37234. /**
  37235. * Gets a the last added material using a given id
  37236. * @param id defines the material's ID
  37237. * @return the last material with the given id or null if none found.
  37238. */
  37239. getLastMaterialByID(id: string): Nullable<Material>;
  37240. /**
  37241. * Gets a material using its name
  37242. * @param name defines the material's name
  37243. * @return the material or null if none found.
  37244. */
  37245. getMaterialByName(name: string): Nullable<Material>;
  37246. /**
  37247. * Get a texture using its unique id
  37248. * @param uniqueId defines the texture's unique id
  37249. * @return the texture or null if none found.
  37250. */
  37251. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37252. /**
  37253. * Gets a camera using its id
  37254. * @param id defines the id to look for
  37255. * @returns the camera or null if not found
  37256. */
  37257. getCameraByID(id: string): Nullable<Camera>;
  37258. /**
  37259. * Gets a camera using its unique id
  37260. * @param uniqueId defines the unique id to look for
  37261. * @returns the camera or null if not found
  37262. */
  37263. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37264. /**
  37265. * Gets a camera using its name
  37266. * @param name defines the camera's name
  37267. * @return the camera or null if none found.
  37268. */
  37269. getCameraByName(name: string): Nullable<Camera>;
  37270. /**
  37271. * Gets a bone using its id
  37272. * @param id defines the bone's id
  37273. * @return the bone or null if not found
  37274. */
  37275. getBoneByID(id: string): Nullable<Bone>;
  37276. /**
  37277. * Gets a bone using its id
  37278. * @param name defines the bone's name
  37279. * @return the bone or null if not found
  37280. */
  37281. getBoneByName(name: string): Nullable<Bone>;
  37282. /**
  37283. * Gets a light node using its name
  37284. * @param name defines the the light's name
  37285. * @return the light or null if none found.
  37286. */
  37287. getLightByName(name: string): Nullable<Light>;
  37288. /**
  37289. * Gets a light node using its id
  37290. * @param id defines the light's id
  37291. * @return the light or null if none found.
  37292. */
  37293. getLightByID(id: string): Nullable<Light>;
  37294. /**
  37295. * Gets a light node using its scene-generated unique ID
  37296. * @param uniqueId defines the light's unique id
  37297. * @return the light or null if none found.
  37298. */
  37299. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37300. /**
  37301. * Gets a particle system by id
  37302. * @param id defines the particle system id
  37303. * @return the corresponding system or null if none found
  37304. */
  37305. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37306. /**
  37307. * Gets a geometry using its ID
  37308. * @param id defines the geometry's id
  37309. * @return the geometry or null if none found.
  37310. */
  37311. getGeometryByID(id: string): Nullable<Geometry>;
  37312. private _getGeometryByUniqueID;
  37313. /**
  37314. * Add a new geometry to this scene
  37315. * @param geometry defines the geometry to be added to the scene.
  37316. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37317. * @return a boolean defining if the geometry was added or not
  37318. */
  37319. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37320. /**
  37321. * Removes an existing geometry
  37322. * @param geometry defines the geometry to be removed from the scene
  37323. * @return a boolean defining if the geometry was removed or not
  37324. */
  37325. removeGeometry(geometry: Geometry): boolean;
  37326. /**
  37327. * Gets the list of geometries attached to the scene
  37328. * @returns an array of Geometry
  37329. */
  37330. getGeometries(): Geometry[];
  37331. /**
  37332. * Gets the first added mesh found of a given ID
  37333. * @param id defines the id to search for
  37334. * @return the mesh found or null if not found at all
  37335. */
  37336. getMeshByID(id: string): Nullable<AbstractMesh>;
  37337. /**
  37338. * Gets a list of meshes using their id
  37339. * @param id defines the id to search for
  37340. * @returns a list of meshes
  37341. */
  37342. getMeshesByID(id: string): Array<AbstractMesh>;
  37343. /**
  37344. * Gets the first added transform node found of a given ID
  37345. * @param id defines the id to search for
  37346. * @return the found transform node or null if not found at all.
  37347. */
  37348. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37349. /**
  37350. * Gets a transform node with its auto-generated unique id
  37351. * @param uniqueId efines the unique id to search for
  37352. * @return the found transform node or null if not found at all.
  37353. */
  37354. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37355. /**
  37356. * Gets a list of transform nodes using their id
  37357. * @param id defines the id to search for
  37358. * @returns a list of transform nodes
  37359. */
  37360. getTransformNodesByID(id: string): Array<TransformNode>;
  37361. /**
  37362. * Gets a mesh with its auto-generated unique id
  37363. * @param uniqueId defines the unique id to search for
  37364. * @return the found mesh or null if not found at all.
  37365. */
  37366. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37367. /**
  37368. * Gets a the last added mesh using a given id
  37369. * @param id defines the id to search for
  37370. * @return the found mesh or null if not found at all.
  37371. */
  37372. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37373. /**
  37374. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37375. * @param id defines the id to search for
  37376. * @return the found node or null if not found at all
  37377. */
  37378. getLastEntryByID(id: string): Nullable<Node>;
  37379. /**
  37380. * Gets a node (Mesh, Camera, Light) using a given id
  37381. * @param id defines the id to search for
  37382. * @return the found node or null if not found at all
  37383. */
  37384. getNodeByID(id: string): Nullable<Node>;
  37385. /**
  37386. * Gets a node (Mesh, Camera, Light) using a given name
  37387. * @param name defines the name to search for
  37388. * @return the found node or null if not found at all.
  37389. */
  37390. getNodeByName(name: string): Nullable<Node>;
  37391. /**
  37392. * Gets a mesh using a given name
  37393. * @param name defines the name to search for
  37394. * @return the found mesh or null if not found at all.
  37395. */
  37396. getMeshByName(name: string): Nullable<AbstractMesh>;
  37397. /**
  37398. * Gets a transform node using a given name
  37399. * @param name defines the name to search for
  37400. * @return the found transform node or null if not found at all.
  37401. */
  37402. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37403. /**
  37404. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37405. * @param id defines the id to search for
  37406. * @return the found skeleton or null if not found at all.
  37407. */
  37408. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37409. /**
  37410. * Gets a skeleton using a given auto generated unique id
  37411. * @param uniqueId defines the unique id to search for
  37412. * @return the found skeleton or null if not found at all.
  37413. */
  37414. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37415. /**
  37416. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37417. * @param id defines the id to search for
  37418. * @return the found skeleton or null if not found at all.
  37419. */
  37420. getSkeletonById(id: string): Nullable<Skeleton>;
  37421. /**
  37422. * Gets a skeleton using a given name
  37423. * @param name defines the name to search for
  37424. * @return the found skeleton or null if not found at all.
  37425. */
  37426. getSkeletonByName(name: string): Nullable<Skeleton>;
  37427. /**
  37428. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37429. * @param id defines the id to search for
  37430. * @return the found morph target manager or null if not found at all.
  37431. */
  37432. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37433. /**
  37434. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37435. * @param id defines the id to search for
  37436. * @return the found morph target or null if not found at all.
  37437. */
  37438. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37439. /**
  37440. * Gets a boolean indicating if the given mesh is active
  37441. * @param mesh defines the mesh to look for
  37442. * @returns true if the mesh is in the active list
  37443. */
  37444. isActiveMesh(mesh: AbstractMesh): boolean;
  37445. /**
  37446. * Return a unique id as a string which can serve as an identifier for the scene
  37447. */
  37448. get uid(): string;
  37449. /**
  37450. * Add an externaly attached data from its key.
  37451. * This method call will fail and return false, if such key already exists.
  37452. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37453. * @param key the unique key that identifies the data
  37454. * @param data the data object to associate to the key for this Engine instance
  37455. * @return true if no such key were already present and the data was added successfully, false otherwise
  37456. */
  37457. addExternalData<T>(key: string, data: T): boolean;
  37458. /**
  37459. * Get an externaly attached data from its key
  37460. * @param key the unique key that identifies the data
  37461. * @return the associated data, if present (can be null), or undefined if not present
  37462. */
  37463. getExternalData<T>(key: string): Nullable<T>;
  37464. /**
  37465. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37466. * @param key the unique key that identifies the data
  37467. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37468. * @return the associated data, can be null if the factory returned null.
  37469. */
  37470. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37471. /**
  37472. * Remove an externaly attached data from the Engine instance
  37473. * @param key the unique key that identifies the data
  37474. * @return true if the data was successfully removed, false if it doesn't exist
  37475. */
  37476. removeExternalData(key: string): boolean;
  37477. private _evaluateSubMesh;
  37478. /**
  37479. * Clear the processed materials smart array preventing retention point in material dispose.
  37480. */
  37481. freeProcessedMaterials(): void;
  37482. private _preventFreeActiveMeshesAndRenderingGroups;
  37483. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37484. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37485. * when disposing several meshes in a row or a hierarchy of meshes.
  37486. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37487. */
  37488. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37489. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37490. /**
  37491. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37492. */
  37493. freeActiveMeshes(): void;
  37494. /**
  37495. * Clear the info related to rendering groups preventing retention points during dispose.
  37496. */
  37497. freeRenderingGroups(): void;
  37498. /** @hidden */
  37499. _isInIntermediateRendering(): boolean;
  37500. /**
  37501. * Lambda returning the list of potentially active meshes.
  37502. */
  37503. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37504. /**
  37505. * Lambda returning the list of potentially active sub meshes.
  37506. */
  37507. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37508. /**
  37509. * Lambda returning the list of potentially intersecting sub meshes.
  37510. */
  37511. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37512. /**
  37513. * Lambda returning the list of potentially colliding sub meshes.
  37514. */
  37515. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37516. private _activeMeshesFrozen;
  37517. private _skipEvaluateActiveMeshesCompletely;
  37518. /**
  37519. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37520. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37521. * @returns the current scene
  37522. */
  37523. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37524. /**
  37525. * Use this function to restart evaluating active meshes on every frame
  37526. * @returns the current scene
  37527. */
  37528. unfreezeActiveMeshes(): Scene;
  37529. private _evaluateActiveMeshes;
  37530. private _activeMesh;
  37531. /**
  37532. * Update the transform matrix to update from the current active camera
  37533. * @param force defines a boolean used to force the update even if cache is up to date
  37534. */
  37535. updateTransformMatrix(force?: boolean): void;
  37536. private _bindFrameBuffer;
  37537. /** @hidden */
  37538. _allowPostProcessClearColor: boolean;
  37539. /** @hidden */
  37540. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37541. private _processSubCameras;
  37542. private _checkIntersections;
  37543. /** @hidden */
  37544. _advancePhysicsEngineStep(step: number): void;
  37545. /**
  37546. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37547. */
  37548. getDeterministicFrameTime: () => number;
  37549. /** @hidden */
  37550. _animate(): void;
  37551. /** Execute all animations (for a frame) */
  37552. animate(): void;
  37553. /**
  37554. * Render the scene
  37555. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37556. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37557. */
  37558. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37559. /**
  37560. * Freeze all materials
  37561. * A frozen material will not be updatable but should be faster to render
  37562. */
  37563. freezeMaterials(): void;
  37564. /**
  37565. * Unfreeze all materials
  37566. * A frozen material will not be updatable but should be faster to render
  37567. */
  37568. unfreezeMaterials(): void;
  37569. /**
  37570. * Releases all held ressources
  37571. */
  37572. dispose(): void;
  37573. /**
  37574. * Gets if the scene is already disposed
  37575. */
  37576. get isDisposed(): boolean;
  37577. /**
  37578. * Call this function to reduce memory footprint of the scene.
  37579. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37580. */
  37581. clearCachedVertexData(): void;
  37582. /**
  37583. * This function will remove the local cached buffer data from texture.
  37584. * It will save memory but will prevent the texture from being rebuilt
  37585. */
  37586. cleanCachedTextureBuffer(): void;
  37587. /**
  37588. * Get the world extend vectors with an optional filter
  37589. *
  37590. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37591. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37592. */
  37593. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37594. min: Vector3;
  37595. max: Vector3;
  37596. };
  37597. /**
  37598. * Creates a ray that can be used to pick in the scene
  37599. * @param x defines the x coordinate of the origin (on-screen)
  37600. * @param y defines the y coordinate of the origin (on-screen)
  37601. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37602. * @param camera defines the camera to use for the picking
  37603. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37604. * @returns a Ray
  37605. */
  37606. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37607. /**
  37608. * Creates a ray that can be used to pick in the scene
  37609. * @param x defines the x coordinate of the origin (on-screen)
  37610. * @param y defines the y coordinate of the origin (on-screen)
  37611. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37612. * @param result defines the ray where to store the picking ray
  37613. * @param camera defines the camera to use for the picking
  37614. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37615. * @returns the current scene
  37616. */
  37617. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37618. /**
  37619. * Creates a ray that can be used to pick in the scene
  37620. * @param x defines the x coordinate of the origin (on-screen)
  37621. * @param y defines the y coordinate of the origin (on-screen)
  37622. * @param camera defines the camera to use for the picking
  37623. * @returns a Ray
  37624. */
  37625. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37626. /**
  37627. * Creates a ray that can be used to pick in the scene
  37628. * @param x defines the x coordinate of the origin (on-screen)
  37629. * @param y defines the y coordinate of the origin (on-screen)
  37630. * @param result defines the ray where to store the picking ray
  37631. * @param camera defines the camera to use for the picking
  37632. * @returns the current scene
  37633. */
  37634. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37635. /** Launch a ray to try to pick a mesh in the scene
  37636. * @param x position on screen
  37637. * @param y position on screen
  37638. * @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
  37639. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37640. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37641. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37642. * @returns a PickingInfo
  37643. */
  37644. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37645. /** Use the given ray to pick a mesh in the scene
  37646. * @param ray The ray to use to pick meshes
  37647. * @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
  37648. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37649. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37650. * @returns a PickingInfo
  37651. */
  37652. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37653. /**
  37654. * Launch a ray to try to pick a mesh in the scene
  37655. * @param x X position on screen
  37656. * @param y Y position on screen
  37657. * @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
  37658. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37659. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37660. * @returns an array of PickingInfo
  37661. */
  37662. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37663. /**
  37664. * Launch a ray to try to pick a mesh in the scene
  37665. * @param ray Ray to use
  37666. * @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
  37667. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37668. * @returns an array of PickingInfo
  37669. */
  37670. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37671. /**
  37672. * Force the value of meshUnderPointer
  37673. * @param mesh defines the mesh to use
  37674. */
  37675. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37676. /**
  37677. * Gets the mesh under the pointer
  37678. * @returns a Mesh or null if no mesh is under the pointer
  37679. */
  37680. getPointerOverMesh(): Nullable<AbstractMesh>;
  37681. /** @hidden */
  37682. _rebuildGeometries(): void;
  37683. /** @hidden */
  37684. _rebuildTextures(): void;
  37685. private _getByTags;
  37686. /**
  37687. * Get a list of meshes by tags
  37688. * @param tagsQuery defines the tags query to use
  37689. * @param forEach defines a predicate used to filter results
  37690. * @returns an array of Mesh
  37691. */
  37692. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37693. /**
  37694. * Get a list of cameras by tags
  37695. * @param tagsQuery defines the tags query to use
  37696. * @param forEach defines a predicate used to filter results
  37697. * @returns an array of Camera
  37698. */
  37699. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37700. /**
  37701. * Get a list of lights by tags
  37702. * @param tagsQuery defines the tags query to use
  37703. * @param forEach defines a predicate used to filter results
  37704. * @returns an array of Light
  37705. */
  37706. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37707. /**
  37708. * Get a list of materials by tags
  37709. * @param tagsQuery defines the tags query to use
  37710. * @param forEach defines a predicate used to filter results
  37711. * @returns an array of Material
  37712. */
  37713. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37714. /**
  37715. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37716. * This allowed control for front to back rendering or reversly depending of the special needs.
  37717. *
  37718. * @param renderingGroupId The rendering group id corresponding to its index
  37719. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37720. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37721. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37722. */
  37723. 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;
  37724. /**
  37725. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37726. *
  37727. * @param renderingGroupId The rendering group id corresponding to its index
  37728. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37729. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37730. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37731. */
  37732. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37733. /**
  37734. * Gets the current auto clear configuration for one rendering group of the rendering
  37735. * manager.
  37736. * @param index the rendering group index to get the information for
  37737. * @returns The auto clear setup for the requested rendering group
  37738. */
  37739. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37740. private _blockMaterialDirtyMechanism;
  37741. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37742. get blockMaterialDirtyMechanism(): boolean;
  37743. set blockMaterialDirtyMechanism(value: boolean);
  37744. /**
  37745. * Will flag all materials as dirty to trigger new shader compilation
  37746. * @param flag defines the flag used to specify which material part must be marked as dirty
  37747. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37748. */
  37749. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37750. /** @hidden */
  37751. _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;
  37752. /** @hidden */
  37753. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37754. /** @hidden */
  37755. _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;
  37756. /** @hidden */
  37757. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37758. /** @hidden */
  37759. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37760. /** @hidden */
  37761. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37762. }
  37763. }
  37764. declare module "babylonjs/assetContainer" {
  37765. import { AbstractScene } from "babylonjs/abstractScene";
  37766. import { Scene } from "babylonjs/scene";
  37767. import { Mesh } from "babylonjs/Meshes/mesh";
  37768. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37769. import { Skeleton } from "babylonjs/Bones/skeleton";
  37770. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37771. import { Animatable } from "babylonjs/Animations/animatable";
  37772. import { Nullable } from "babylonjs/types";
  37773. import { Node } from "babylonjs/node";
  37774. /**
  37775. * Set of assets to keep when moving a scene into an asset container.
  37776. */
  37777. export class KeepAssets extends AbstractScene {
  37778. }
  37779. /**
  37780. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37781. */
  37782. export class InstantiatedEntries {
  37783. /**
  37784. * List of new root nodes (eg. nodes with no parent)
  37785. */
  37786. rootNodes: TransformNode[];
  37787. /**
  37788. * List of new skeletons
  37789. */
  37790. skeletons: Skeleton[];
  37791. /**
  37792. * List of new animation groups
  37793. */
  37794. animationGroups: AnimationGroup[];
  37795. }
  37796. /**
  37797. * Container with a set of assets that can be added or removed from a scene.
  37798. */
  37799. export class AssetContainer extends AbstractScene {
  37800. /**
  37801. * The scene the AssetContainer belongs to.
  37802. */
  37803. scene: Scene;
  37804. /**
  37805. * Instantiates an AssetContainer.
  37806. * @param scene The scene the AssetContainer belongs to.
  37807. */
  37808. constructor(scene: Scene);
  37809. /**
  37810. * Instantiate or clone all meshes and add the new ones to the scene.
  37811. * Skeletons and animation groups will all be cloned
  37812. * @param nameFunction defines an optional function used to get new names for clones
  37813. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37814. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37815. */
  37816. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37817. /**
  37818. * Adds all the assets from the container to the scene.
  37819. */
  37820. addAllToScene(): void;
  37821. /**
  37822. * Removes all the assets in the container from the scene
  37823. */
  37824. removeAllFromScene(): void;
  37825. /**
  37826. * Disposes all the assets in the container
  37827. */
  37828. dispose(): void;
  37829. private _moveAssets;
  37830. /**
  37831. * Removes all the assets contained in the scene and adds them to the container.
  37832. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37833. */
  37834. moveAllFromScene(keepAssets?: KeepAssets): void;
  37835. /**
  37836. * 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.
  37837. * @returns the root mesh
  37838. */
  37839. createRootMesh(): Mesh;
  37840. /**
  37841. * Merge animations from this asset container into a scene
  37842. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37843. * @param animatables set of animatables to retarget to a node from the scene
  37844. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37845. */
  37846. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37847. }
  37848. }
  37849. declare module "babylonjs/abstractScene" {
  37850. import { Scene } from "babylonjs/scene";
  37851. import { Nullable } from "babylonjs/types";
  37852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37853. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37854. import { Geometry } from "babylonjs/Meshes/geometry";
  37855. import { Skeleton } from "babylonjs/Bones/skeleton";
  37856. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37857. import { AssetContainer } from "babylonjs/assetContainer";
  37858. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37859. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37860. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37861. import { Material } from "babylonjs/Materials/material";
  37862. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37863. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37864. import { Camera } from "babylonjs/Cameras/camera";
  37865. import { Light } from "babylonjs/Lights/light";
  37866. import { Node } from "babylonjs/node";
  37867. import { Animation } from "babylonjs/Animations/animation";
  37868. /**
  37869. * Defines how the parser contract is defined.
  37870. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37871. */
  37872. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37873. /**
  37874. * Defines how the individual parser contract is defined.
  37875. * These parser can parse an individual asset
  37876. */
  37877. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37878. /**
  37879. * Base class of the scene acting as a container for the different elements composing a scene.
  37880. * This class is dynamically extended by the different components of the scene increasing
  37881. * flexibility and reducing coupling
  37882. */
  37883. export abstract class AbstractScene {
  37884. /**
  37885. * Stores the list of available parsers in the application.
  37886. */
  37887. private static _BabylonFileParsers;
  37888. /**
  37889. * Stores the list of available individual parsers in the application.
  37890. */
  37891. private static _IndividualBabylonFileParsers;
  37892. /**
  37893. * Adds a parser in the list of available ones
  37894. * @param name Defines the name of the parser
  37895. * @param parser Defines the parser to add
  37896. */
  37897. static AddParser(name: string, parser: BabylonFileParser): void;
  37898. /**
  37899. * Gets a general parser from the list of avaialble ones
  37900. * @param name Defines the name of the parser
  37901. * @returns the requested parser or null
  37902. */
  37903. static GetParser(name: string): Nullable<BabylonFileParser>;
  37904. /**
  37905. * Adds n individual parser in the list of available ones
  37906. * @param name Defines the name of the parser
  37907. * @param parser Defines the parser to add
  37908. */
  37909. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37910. /**
  37911. * Gets an individual parser from the list of avaialble ones
  37912. * @param name Defines the name of the parser
  37913. * @returns the requested parser or null
  37914. */
  37915. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37916. /**
  37917. * Parser json data and populate both a scene and its associated container object
  37918. * @param jsonData Defines the data to parse
  37919. * @param scene Defines the scene to parse the data for
  37920. * @param container Defines the container attached to the parsing sequence
  37921. * @param rootUrl Defines the root url of the data
  37922. */
  37923. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37924. /**
  37925. * Gets the list of root nodes (ie. nodes with no parent)
  37926. */
  37927. rootNodes: Node[];
  37928. /** All of the cameras added to this scene
  37929. * @see http://doc.babylonjs.com/babylon101/cameras
  37930. */
  37931. cameras: Camera[];
  37932. /**
  37933. * All of the lights added to this scene
  37934. * @see http://doc.babylonjs.com/babylon101/lights
  37935. */
  37936. lights: Light[];
  37937. /**
  37938. * All of the (abstract) meshes added to this scene
  37939. */
  37940. meshes: AbstractMesh[];
  37941. /**
  37942. * The list of skeletons added to the scene
  37943. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37944. */
  37945. skeletons: Skeleton[];
  37946. /**
  37947. * All of the particle systems added to this scene
  37948. * @see http://doc.babylonjs.com/babylon101/particles
  37949. */
  37950. particleSystems: IParticleSystem[];
  37951. /**
  37952. * Gets a list of Animations associated with the scene
  37953. */
  37954. animations: Animation[];
  37955. /**
  37956. * All of the animation groups added to this scene
  37957. * @see http://doc.babylonjs.com/how_to/group
  37958. */
  37959. animationGroups: AnimationGroup[];
  37960. /**
  37961. * All of the multi-materials added to this scene
  37962. * @see http://doc.babylonjs.com/how_to/multi_materials
  37963. */
  37964. multiMaterials: MultiMaterial[];
  37965. /**
  37966. * All of the materials added to this scene
  37967. * In the context of a Scene, it is not supposed to be modified manually.
  37968. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37969. * Note also that the order of the Material within the array is not significant and might change.
  37970. * @see http://doc.babylonjs.com/babylon101/materials
  37971. */
  37972. materials: Material[];
  37973. /**
  37974. * The list of morph target managers added to the scene
  37975. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37976. */
  37977. morphTargetManagers: MorphTargetManager[];
  37978. /**
  37979. * The list of geometries used in the scene.
  37980. */
  37981. geometries: Geometry[];
  37982. /**
  37983. * All of the tranform nodes added to this scene
  37984. * In the context of a Scene, it is not supposed to be modified manually.
  37985. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37986. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37987. * @see http://doc.babylonjs.com/how_to/transformnode
  37988. */
  37989. transformNodes: TransformNode[];
  37990. /**
  37991. * ActionManagers available on the scene.
  37992. */
  37993. actionManagers: AbstractActionManager[];
  37994. /**
  37995. * Textures to keep.
  37996. */
  37997. textures: BaseTexture[];
  37998. /**
  37999. * Environment texture for the scene
  38000. */
  38001. environmentTexture: Nullable<BaseTexture>;
  38002. /**
  38003. * @returns all meshes, lights, cameras, transformNodes and bones
  38004. */
  38005. getNodes(): Array<Node>;
  38006. }
  38007. }
  38008. declare module "babylonjs/Audio/sound" {
  38009. import { Observable } from "babylonjs/Misc/observable";
  38010. import { Vector3 } from "babylonjs/Maths/math.vector";
  38011. import { Nullable } from "babylonjs/types";
  38012. import { Scene } from "babylonjs/scene";
  38013. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38014. /**
  38015. * Interface used to define options for Sound class
  38016. */
  38017. export interface ISoundOptions {
  38018. /**
  38019. * Does the sound autoplay once loaded.
  38020. */
  38021. autoplay?: boolean;
  38022. /**
  38023. * Does the sound loop after it finishes playing once.
  38024. */
  38025. loop?: boolean;
  38026. /**
  38027. * Sound's volume
  38028. */
  38029. volume?: number;
  38030. /**
  38031. * Is it a spatial sound?
  38032. */
  38033. spatialSound?: boolean;
  38034. /**
  38035. * Maximum distance to hear that sound
  38036. */
  38037. maxDistance?: number;
  38038. /**
  38039. * Uses user defined attenuation function
  38040. */
  38041. useCustomAttenuation?: boolean;
  38042. /**
  38043. * Define the roll off factor of spatial sounds.
  38044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38045. */
  38046. rolloffFactor?: number;
  38047. /**
  38048. * Define the reference distance the sound should be heard perfectly.
  38049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38050. */
  38051. refDistance?: number;
  38052. /**
  38053. * Define the distance attenuation model the sound will follow.
  38054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38055. */
  38056. distanceModel?: string;
  38057. /**
  38058. * Defines the playback speed (1 by default)
  38059. */
  38060. playbackRate?: number;
  38061. /**
  38062. * Defines if the sound is from a streaming source
  38063. */
  38064. streaming?: boolean;
  38065. /**
  38066. * Defines an optional length (in seconds) inside the sound file
  38067. */
  38068. length?: number;
  38069. /**
  38070. * Defines an optional offset (in seconds) inside the sound file
  38071. */
  38072. offset?: number;
  38073. /**
  38074. * If true, URLs will not be required to state the audio file codec to use.
  38075. */
  38076. skipCodecCheck?: boolean;
  38077. }
  38078. /**
  38079. * Defines a sound that can be played in the application.
  38080. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38082. */
  38083. export class Sound {
  38084. /**
  38085. * The name of the sound in the scene.
  38086. */
  38087. name: string;
  38088. /**
  38089. * Does the sound autoplay once loaded.
  38090. */
  38091. autoplay: boolean;
  38092. /**
  38093. * Does the sound loop after it finishes playing once.
  38094. */
  38095. loop: boolean;
  38096. /**
  38097. * Does the sound use a custom attenuation curve to simulate the falloff
  38098. * happening when the source gets further away from the camera.
  38099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38100. */
  38101. useCustomAttenuation: boolean;
  38102. /**
  38103. * The sound track id this sound belongs to.
  38104. */
  38105. soundTrackId: number;
  38106. /**
  38107. * Is this sound currently played.
  38108. */
  38109. isPlaying: boolean;
  38110. /**
  38111. * Is this sound currently paused.
  38112. */
  38113. isPaused: boolean;
  38114. /**
  38115. * Does this sound enables spatial sound.
  38116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38117. */
  38118. spatialSound: boolean;
  38119. /**
  38120. * Define the reference distance the sound should be heard perfectly.
  38121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38122. */
  38123. refDistance: number;
  38124. /**
  38125. * Define the roll off factor of spatial sounds.
  38126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38127. */
  38128. rolloffFactor: number;
  38129. /**
  38130. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38131. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38132. */
  38133. maxDistance: number;
  38134. /**
  38135. * Define the distance attenuation model the sound will follow.
  38136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38137. */
  38138. distanceModel: string;
  38139. /**
  38140. * @hidden
  38141. * Back Compat
  38142. **/
  38143. onended: () => any;
  38144. /**
  38145. * Observable event when the current playing sound finishes.
  38146. */
  38147. onEndedObservable: Observable<Sound>;
  38148. private _panningModel;
  38149. private _playbackRate;
  38150. private _streaming;
  38151. private _startTime;
  38152. private _startOffset;
  38153. private _position;
  38154. /** @hidden */
  38155. _positionInEmitterSpace: boolean;
  38156. private _localDirection;
  38157. private _volume;
  38158. private _isReadyToPlay;
  38159. private _isDirectional;
  38160. private _readyToPlayCallback;
  38161. private _audioBuffer;
  38162. private _soundSource;
  38163. private _streamingSource;
  38164. private _soundPanner;
  38165. private _soundGain;
  38166. private _inputAudioNode;
  38167. private _outputAudioNode;
  38168. private _coneInnerAngle;
  38169. private _coneOuterAngle;
  38170. private _coneOuterGain;
  38171. private _scene;
  38172. private _connectedTransformNode;
  38173. private _customAttenuationFunction;
  38174. private _registerFunc;
  38175. private _isOutputConnected;
  38176. private _htmlAudioElement;
  38177. private _urlType;
  38178. private _length?;
  38179. private _offset?;
  38180. /** @hidden */
  38181. static _SceneComponentInitialization: (scene: Scene) => void;
  38182. /**
  38183. * Create a sound and attach it to a scene
  38184. * @param name Name of your sound
  38185. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38186. * @param scene defines the scene the sound belongs to
  38187. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38188. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38189. */
  38190. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38191. /**
  38192. * Release the sound and its associated resources
  38193. */
  38194. dispose(): void;
  38195. /**
  38196. * Gets if the sounds is ready to be played or not.
  38197. * @returns true if ready, otherwise false
  38198. */
  38199. isReady(): boolean;
  38200. private _soundLoaded;
  38201. /**
  38202. * Sets the data of the sound from an audiobuffer
  38203. * @param audioBuffer The audioBuffer containing the data
  38204. */
  38205. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38206. /**
  38207. * Updates the current sounds options such as maxdistance, loop...
  38208. * @param options A JSON object containing values named as the object properties
  38209. */
  38210. updateOptions(options: ISoundOptions): void;
  38211. private _createSpatialParameters;
  38212. private _updateSpatialParameters;
  38213. /**
  38214. * Switch the panning model to HRTF:
  38215. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38217. */
  38218. switchPanningModelToHRTF(): void;
  38219. /**
  38220. * Switch the panning model to Equal Power:
  38221. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38223. */
  38224. switchPanningModelToEqualPower(): void;
  38225. private _switchPanningModel;
  38226. /**
  38227. * Connect this sound to a sound track audio node like gain...
  38228. * @param soundTrackAudioNode the sound track audio node to connect to
  38229. */
  38230. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38231. /**
  38232. * Transform this sound into a directional source
  38233. * @param coneInnerAngle Size of the inner cone in degree
  38234. * @param coneOuterAngle Size of the outer cone in degree
  38235. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38236. */
  38237. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38238. /**
  38239. * Gets or sets the inner angle for the directional cone.
  38240. */
  38241. get directionalConeInnerAngle(): number;
  38242. /**
  38243. * Gets or sets the inner angle for the directional cone.
  38244. */
  38245. set directionalConeInnerAngle(value: number);
  38246. /**
  38247. * Gets or sets the outer angle for the directional cone.
  38248. */
  38249. get directionalConeOuterAngle(): number;
  38250. /**
  38251. * Gets or sets the outer angle for the directional cone.
  38252. */
  38253. set directionalConeOuterAngle(value: number);
  38254. /**
  38255. * Sets the position of the emitter if spatial sound is enabled
  38256. * @param newPosition Defines the new posisiton
  38257. */
  38258. setPosition(newPosition: Vector3): void;
  38259. /**
  38260. * Sets the local direction of the emitter if spatial sound is enabled
  38261. * @param newLocalDirection Defines the new local direction
  38262. */
  38263. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38264. private _updateDirection;
  38265. /** @hidden */
  38266. updateDistanceFromListener(): void;
  38267. /**
  38268. * Sets a new custom attenuation function for the sound.
  38269. * @param callback Defines the function used for the attenuation
  38270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38271. */
  38272. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38273. /**
  38274. * Play the sound
  38275. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38276. * @param offset (optional) Start the sound at a specific time in seconds
  38277. * @param length (optional) Sound duration (in seconds)
  38278. */
  38279. play(time?: number, offset?: number, length?: number): void;
  38280. private _onended;
  38281. /**
  38282. * Stop the sound
  38283. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38284. */
  38285. stop(time?: number): void;
  38286. /**
  38287. * Put the sound in pause
  38288. */
  38289. pause(): void;
  38290. /**
  38291. * Sets a dedicated volume for this sounds
  38292. * @param newVolume Define the new volume of the sound
  38293. * @param time Define time for gradual change to new volume
  38294. */
  38295. setVolume(newVolume: number, time?: number): void;
  38296. /**
  38297. * Set the sound play back rate
  38298. * @param newPlaybackRate Define the playback rate the sound should be played at
  38299. */
  38300. setPlaybackRate(newPlaybackRate: number): void;
  38301. /**
  38302. * Gets the volume of the sound.
  38303. * @returns the volume of the sound
  38304. */
  38305. getVolume(): number;
  38306. /**
  38307. * Attach the sound to a dedicated mesh
  38308. * @param transformNode The transform node to connect the sound with
  38309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38310. */
  38311. attachToMesh(transformNode: TransformNode): void;
  38312. /**
  38313. * Detach the sound from the previously attached mesh
  38314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38315. */
  38316. detachFromMesh(): void;
  38317. private _onRegisterAfterWorldMatrixUpdate;
  38318. /**
  38319. * Clone the current sound in the scene.
  38320. * @returns the new sound clone
  38321. */
  38322. clone(): Nullable<Sound>;
  38323. /**
  38324. * Gets the current underlying audio buffer containing the data
  38325. * @returns the audio buffer
  38326. */
  38327. getAudioBuffer(): Nullable<AudioBuffer>;
  38328. /**
  38329. * Serializes the Sound in a JSON representation
  38330. * @returns the JSON representation of the sound
  38331. */
  38332. serialize(): any;
  38333. /**
  38334. * Parse a JSON representation of a sound to innstantiate in a given scene
  38335. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38336. * @param scene Define the scene the new parsed sound should be created in
  38337. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38338. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38339. * @returns the newly parsed sound
  38340. */
  38341. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38342. }
  38343. }
  38344. declare module "babylonjs/Actions/directAudioActions" {
  38345. import { Action } from "babylonjs/Actions/action";
  38346. import { Condition } from "babylonjs/Actions/condition";
  38347. import { Sound } from "babylonjs/Audio/sound";
  38348. /**
  38349. * This defines an action helpful to play a defined sound on a triggered action.
  38350. */
  38351. export class PlaySoundAction extends Action {
  38352. private _sound;
  38353. /**
  38354. * Instantiate the action
  38355. * @param triggerOptions defines the trigger options
  38356. * @param sound defines the sound to play
  38357. * @param condition defines the trigger related conditions
  38358. */
  38359. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38360. /** @hidden */
  38361. _prepare(): void;
  38362. /**
  38363. * Execute the action and play the sound.
  38364. */
  38365. execute(): void;
  38366. /**
  38367. * Serializes the actions and its related information.
  38368. * @param parent defines the object to serialize in
  38369. * @returns the serialized object
  38370. */
  38371. serialize(parent: any): any;
  38372. }
  38373. /**
  38374. * This defines an action helpful to stop a defined sound on a triggered action.
  38375. */
  38376. export class StopSoundAction extends Action {
  38377. private _sound;
  38378. /**
  38379. * Instantiate the action
  38380. * @param triggerOptions defines the trigger options
  38381. * @param sound defines the sound to stop
  38382. * @param condition defines the trigger related conditions
  38383. */
  38384. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38385. /** @hidden */
  38386. _prepare(): void;
  38387. /**
  38388. * Execute the action and stop the sound.
  38389. */
  38390. execute(): void;
  38391. /**
  38392. * Serializes the actions and its related information.
  38393. * @param parent defines the object to serialize in
  38394. * @returns the serialized object
  38395. */
  38396. serialize(parent: any): any;
  38397. }
  38398. }
  38399. declare module "babylonjs/Actions/interpolateValueAction" {
  38400. import { Action } from "babylonjs/Actions/action";
  38401. import { Condition } from "babylonjs/Actions/condition";
  38402. import { Observable } from "babylonjs/Misc/observable";
  38403. /**
  38404. * This defines an action responsible to change the value of a property
  38405. * by interpolating between its current value and the newly set one once triggered.
  38406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38407. */
  38408. export class InterpolateValueAction extends Action {
  38409. /**
  38410. * Defines the path of the property where the value should be interpolated
  38411. */
  38412. propertyPath: string;
  38413. /**
  38414. * Defines the target value at the end of the interpolation.
  38415. */
  38416. value: any;
  38417. /**
  38418. * Defines the time it will take for the property to interpolate to the value.
  38419. */
  38420. duration: number;
  38421. /**
  38422. * Defines if the other scene animations should be stopped when the action has been triggered
  38423. */
  38424. stopOtherAnimations?: boolean;
  38425. /**
  38426. * Defines a callback raised once the interpolation animation has been done.
  38427. */
  38428. onInterpolationDone?: () => void;
  38429. /**
  38430. * Observable triggered once the interpolation animation has been done.
  38431. */
  38432. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38433. private _target;
  38434. private _effectiveTarget;
  38435. private _property;
  38436. /**
  38437. * Instantiate the action
  38438. * @param triggerOptions defines the trigger options
  38439. * @param target defines the object containing the value to interpolate
  38440. * @param propertyPath defines the path to the property in the target object
  38441. * @param value defines the target value at the end of the interpolation
  38442. * @param duration deines the time it will take for the property to interpolate to the value.
  38443. * @param condition defines the trigger related conditions
  38444. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38445. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38446. */
  38447. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38448. /** @hidden */
  38449. _prepare(): void;
  38450. /**
  38451. * Execute the action starts the value interpolation.
  38452. */
  38453. execute(): void;
  38454. /**
  38455. * Serializes the actions and its related information.
  38456. * @param parent defines the object to serialize in
  38457. * @returns the serialized object
  38458. */
  38459. serialize(parent: any): any;
  38460. }
  38461. }
  38462. declare module "babylonjs/Actions/index" {
  38463. export * from "babylonjs/Actions/abstractActionManager";
  38464. export * from "babylonjs/Actions/action";
  38465. export * from "babylonjs/Actions/actionEvent";
  38466. export * from "babylonjs/Actions/actionManager";
  38467. export * from "babylonjs/Actions/condition";
  38468. export * from "babylonjs/Actions/directActions";
  38469. export * from "babylonjs/Actions/directAudioActions";
  38470. export * from "babylonjs/Actions/interpolateValueAction";
  38471. }
  38472. declare module "babylonjs/Animations/index" {
  38473. export * from "babylonjs/Animations/animatable";
  38474. export * from "babylonjs/Animations/animation";
  38475. export * from "babylonjs/Animations/animationGroup";
  38476. export * from "babylonjs/Animations/animationPropertiesOverride";
  38477. export * from "babylonjs/Animations/easing";
  38478. export * from "babylonjs/Animations/runtimeAnimation";
  38479. export * from "babylonjs/Animations/animationEvent";
  38480. export * from "babylonjs/Animations/animationGroup";
  38481. export * from "babylonjs/Animations/animationKey";
  38482. export * from "babylonjs/Animations/animationRange";
  38483. export * from "babylonjs/Animations/animatable.interface";
  38484. }
  38485. declare module "babylonjs/Audio/soundTrack" {
  38486. import { Sound } from "babylonjs/Audio/sound";
  38487. import { Analyser } from "babylonjs/Audio/analyser";
  38488. import { Scene } from "babylonjs/scene";
  38489. /**
  38490. * Options allowed during the creation of a sound track.
  38491. */
  38492. export interface ISoundTrackOptions {
  38493. /**
  38494. * The volume the sound track should take during creation
  38495. */
  38496. volume?: number;
  38497. /**
  38498. * Define if the sound track is the main sound track of the scene
  38499. */
  38500. mainTrack?: boolean;
  38501. }
  38502. /**
  38503. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38504. * It will be also used in a future release to apply effects on a specific track.
  38505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38506. */
  38507. export class SoundTrack {
  38508. /**
  38509. * The unique identifier of the sound track in the scene.
  38510. */
  38511. id: number;
  38512. /**
  38513. * The list of sounds included in the sound track.
  38514. */
  38515. soundCollection: Array<Sound>;
  38516. private _outputAudioNode;
  38517. private _scene;
  38518. private _connectedAnalyser;
  38519. private _options;
  38520. private _isInitialized;
  38521. /**
  38522. * Creates a new sound track.
  38523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38524. * @param scene Define the scene the sound track belongs to
  38525. * @param options
  38526. */
  38527. constructor(scene: Scene, options?: ISoundTrackOptions);
  38528. private _initializeSoundTrackAudioGraph;
  38529. /**
  38530. * Release the sound track and its associated resources
  38531. */
  38532. dispose(): void;
  38533. /**
  38534. * Adds a sound to this sound track
  38535. * @param sound define the cound to add
  38536. * @ignoreNaming
  38537. */
  38538. AddSound(sound: Sound): void;
  38539. /**
  38540. * Removes a sound to this sound track
  38541. * @param sound define the cound to remove
  38542. * @ignoreNaming
  38543. */
  38544. RemoveSound(sound: Sound): void;
  38545. /**
  38546. * Set a global volume for the full sound track.
  38547. * @param newVolume Define the new volume of the sound track
  38548. */
  38549. setVolume(newVolume: number): void;
  38550. /**
  38551. * Switch the panning model to HRTF:
  38552. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38554. */
  38555. switchPanningModelToHRTF(): void;
  38556. /**
  38557. * Switch the panning model to Equal Power:
  38558. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38560. */
  38561. switchPanningModelToEqualPower(): void;
  38562. /**
  38563. * Connect the sound track to an audio analyser allowing some amazing
  38564. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38566. * @param analyser The analyser to connect to the engine
  38567. */
  38568. connectToAnalyser(analyser: Analyser): void;
  38569. }
  38570. }
  38571. declare module "babylonjs/Audio/audioSceneComponent" {
  38572. import { Sound } from "babylonjs/Audio/sound";
  38573. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38574. import { Nullable } from "babylonjs/types";
  38575. import { Vector3 } from "babylonjs/Maths/math.vector";
  38576. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38577. import { Scene } from "babylonjs/scene";
  38578. import { AbstractScene } from "babylonjs/abstractScene";
  38579. import "babylonjs/Audio/audioEngine";
  38580. module "babylonjs/abstractScene" {
  38581. interface AbstractScene {
  38582. /**
  38583. * The list of sounds used in the scene.
  38584. */
  38585. sounds: Nullable<Array<Sound>>;
  38586. }
  38587. }
  38588. module "babylonjs/scene" {
  38589. interface Scene {
  38590. /**
  38591. * @hidden
  38592. * Backing field
  38593. */
  38594. _mainSoundTrack: SoundTrack;
  38595. /**
  38596. * The main sound track played by the scene.
  38597. * It cotains your primary collection of sounds.
  38598. */
  38599. mainSoundTrack: SoundTrack;
  38600. /**
  38601. * The list of sound tracks added to the scene
  38602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38603. */
  38604. soundTracks: Nullable<Array<SoundTrack>>;
  38605. /**
  38606. * Gets a sound using a given name
  38607. * @param name defines the name to search for
  38608. * @return the found sound or null if not found at all.
  38609. */
  38610. getSoundByName(name: string): Nullable<Sound>;
  38611. /**
  38612. * Gets or sets if audio support is enabled
  38613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38614. */
  38615. audioEnabled: boolean;
  38616. /**
  38617. * Gets or sets if audio will be output to headphones
  38618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38619. */
  38620. headphone: boolean;
  38621. /**
  38622. * Gets or sets custom audio listener position provider
  38623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38624. */
  38625. audioListenerPositionProvider: Nullable<() => Vector3>;
  38626. /**
  38627. * Gets or sets a refresh rate when using 3D audio positioning
  38628. */
  38629. audioPositioningRefreshRate: number;
  38630. }
  38631. }
  38632. /**
  38633. * Defines the sound scene component responsible to manage any sounds
  38634. * in a given scene.
  38635. */
  38636. export class AudioSceneComponent implements ISceneSerializableComponent {
  38637. /**
  38638. * The component name helpfull to identify the component in the list of scene components.
  38639. */
  38640. readonly name: string;
  38641. /**
  38642. * The scene the component belongs to.
  38643. */
  38644. scene: Scene;
  38645. private _audioEnabled;
  38646. /**
  38647. * Gets whether audio is enabled or not.
  38648. * Please use related enable/disable method to switch state.
  38649. */
  38650. get audioEnabled(): boolean;
  38651. private _headphone;
  38652. /**
  38653. * Gets whether audio is outputing to headphone or not.
  38654. * Please use the according Switch methods to change output.
  38655. */
  38656. get headphone(): boolean;
  38657. /**
  38658. * Gets or sets a refresh rate when using 3D audio positioning
  38659. */
  38660. audioPositioningRefreshRate: number;
  38661. private _audioListenerPositionProvider;
  38662. /**
  38663. * Gets the current audio listener position provider
  38664. */
  38665. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38666. /**
  38667. * Sets a custom listener position for all sounds in the scene
  38668. * By default, this is the position of the first active camera
  38669. */
  38670. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38671. /**
  38672. * Creates a new instance of the component for the given scene
  38673. * @param scene Defines the scene to register the component in
  38674. */
  38675. constructor(scene: Scene);
  38676. /**
  38677. * Registers the component in a given scene
  38678. */
  38679. register(): void;
  38680. /**
  38681. * Rebuilds the elements related to this component in case of
  38682. * context lost for instance.
  38683. */
  38684. rebuild(): void;
  38685. /**
  38686. * Serializes the component data to the specified json object
  38687. * @param serializationObject The object to serialize to
  38688. */
  38689. serialize(serializationObject: any): void;
  38690. /**
  38691. * Adds all the elements from the container to the scene
  38692. * @param container the container holding the elements
  38693. */
  38694. addFromContainer(container: AbstractScene): void;
  38695. /**
  38696. * Removes all the elements in the container from the scene
  38697. * @param container contains the elements to remove
  38698. * @param dispose if the removed element should be disposed (default: false)
  38699. */
  38700. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38701. /**
  38702. * Disposes the component and the associated ressources.
  38703. */
  38704. dispose(): void;
  38705. /**
  38706. * Disables audio in the associated scene.
  38707. */
  38708. disableAudio(): void;
  38709. /**
  38710. * Enables audio in the associated scene.
  38711. */
  38712. enableAudio(): void;
  38713. /**
  38714. * Switch audio to headphone output.
  38715. */
  38716. switchAudioModeForHeadphones(): void;
  38717. /**
  38718. * Switch audio to normal speakers.
  38719. */
  38720. switchAudioModeForNormalSpeakers(): void;
  38721. private _cachedCameraDirection;
  38722. private _cachedCameraPosition;
  38723. private _lastCheck;
  38724. private _afterRender;
  38725. }
  38726. }
  38727. declare module "babylonjs/Audio/weightedsound" {
  38728. import { Sound } from "babylonjs/Audio/sound";
  38729. /**
  38730. * Wraps one or more Sound objects and selects one with random weight for playback.
  38731. */
  38732. export class WeightedSound {
  38733. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38734. loop: boolean;
  38735. private _coneInnerAngle;
  38736. private _coneOuterAngle;
  38737. private _volume;
  38738. /** A Sound is currently playing. */
  38739. isPlaying: boolean;
  38740. /** A Sound is currently paused. */
  38741. isPaused: boolean;
  38742. private _sounds;
  38743. private _weights;
  38744. private _currentIndex?;
  38745. /**
  38746. * Creates a new WeightedSound from the list of sounds given.
  38747. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38748. * @param sounds Array of Sounds that will be selected from.
  38749. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38750. */
  38751. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38752. /**
  38753. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38754. */
  38755. get directionalConeInnerAngle(): number;
  38756. /**
  38757. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38758. */
  38759. set directionalConeInnerAngle(value: number);
  38760. /**
  38761. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38762. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38763. */
  38764. get directionalConeOuterAngle(): number;
  38765. /**
  38766. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38767. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38768. */
  38769. set directionalConeOuterAngle(value: number);
  38770. /**
  38771. * Playback volume.
  38772. */
  38773. get volume(): number;
  38774. /**
  38775. * Playback volume.
  38776. */
  38777. set volume(value: number);
  38778. private _onended;
  38779. /**
  38780. * Suspend playback
  38781. */
  38782. pause(): void;
  38783. /**
  38784. * Stop playback
  38785. */
  38786. stop(): void;
  38787. /**
  38788. * Start playback.
  38789. * @param startOffset Position the clip head at a specific time in seconds.
  38790. */
  38791. play(startOffset?: number): void;
  38792. }
  38793. }
  38794. declare module "babylonjs/Audio/index" {
  38795. export * from "babylonjs/Audio/analyser";
  38796. export * from "babylonjs/Audio/audioEngine";
  38797. export * from "babylonjs/Audio/audioSceneComponent";
  38798. export * from "babylonjs/Audio/sound";
  38799. export * from "babylonjs/Audio/soundTrack";
  38800. export * from "babylonjs/Audio/weightedsound";
  38801. }
  38802. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38803. import { Behavior } from "babylonjs/Behaviors/behavior";
  38804. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38805. import { BackEase } from "babylonjs/Animations/easing";
  38806. /**
  38807. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38808. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38809. */
  38810. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38811. /**
  38812. * Gets the name of the behavior.
  38813. */
  38814. get name(): string;
  38815. /**
  38816. * The easing function used by animations
  38817. */
  38818. static EasingFunction: BackEase;
  38819. /**
  38820. * The easing mode used by animations
  38821. */
  38822. static EasingMode: number;
  38823. /**
  38824. * The duration of the animation, in milliseconds
  38825. */
  38826. transitionDuration: number;
  38827. /**
  38828. * Length of the distance animated by the transition when lower radius is reached
  38829. */
  38830. lowerRadiusTransitionRange: number;
  38831. /**
  38832. * Length of the distance animated by the transition when upper radius is reached
  38833. */
  38834. upperRadiusTransitionRange: number;
  38835. private _autoTransitionRange;
  38836. /**
  38837. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38838. */
  38839. get autoTransitionRange(): boolean;
  38840. /**
  38841. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38842. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38843. */
  38844. set autoTransitionRange(value: boolean);
  38845. private _attachedCamera;
  38846. private _onAfterCheckInputsObserver;
  38847. private _onMeshTargetChangedObserver;
  38848. /**
  38849. * Initializes the behavior.
  38850. */
  38851. init(): void;
  38852. /**
  38853. * Attaches the behavior to its arc rotate camera.
  38854. * @param camera Defines the camera to attach the behavior to
  38855. */
  38856. attach(camera: ArcRotateCamera): void;
  38857. /**
  38858. * Detaches the behavior from its current arc rotate camera.
  38859. */
  38860. detach(): void;
  38861. private _radiusIsAnimating;
  38862. private _radiusBounceTransition;
  38863. private _animatables;
  38864. private _cachedWheelPrecision;
  38865. /**
  38866. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38867. * @param radiusLimit The limit to check against.
  38868. * @return Bool to indicate if at limit.
  38869. */
  38870. private _isRadiusAtLimit;
  38871. /**
  38872. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38873. * @param radiusDelta The delta by which to animate to. Can be negative.
  38874. */
  38875. private _applyBoundRadiusAnimation;
  38876. /**
  38877. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38878. */
  38879. protected _clearAnimationLocks(): void;
  38880. /**
  38881. * Stops and removes all animations that have been applied to the camera
  38882. */
  38883. stopAllAnimations(): void;
  38884. }
  38885. }
  38886. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38887. import { Behavior } from "babylonjs/Behaviors/behavior";
  38888. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38889. import { ExponentialEase } from "babylonjs/Animations/easing";
  38890. import { Nullable } from "babylonjs/types";
  38891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38892. import { Vector3 } from "babylonjs/Maths/math.vector";
  38893. /**
  38894. * 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.
  38895. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38896. */
  38897. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38898. /**
  38899. * Gets the name of the behavior.
  38900. */
  38901. get name(): string;
  38902. private _mode;
  38903. private _radiusScale;
  38904. private _positionScale;
  38905. private _defaultElevation;
  38906. private _elevationReturnTime;
  38907. private _elevationReturnWaitTime;
  38908. private _zoomStopsAnimation;
  38909. private _framingTime;
  38910. /**
  38911. * The easing function used by animations
  38912. */
  38913. static EasingFunction: ExponentialEase;
  38914. /**
  38915. * The easing mode used by animations
  38916. */
  38917. static EasingMode: number;
  38918. /**
  38919. * Sets the current mode used by the behavior
  38920. */
  38921. set mode(mode: number);
  38922. /**
  38923. * Gets current mode used by the behavior.
  38924. */
  38925. get mode(): number;
  38926. /**
  38927. * Sets the scale applied to the radius (1 by default)
  38928. */
  38929. set radiusScale(radius: number);
  38930. /**
  38931. * Gets the scale applied to the radius
  38932. */
  38933. get radiusScale(): number;
  38934. /**
  38935. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38936. */
  38937. set positionScale(scale: number);
  38938. /**
  38939. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38940. */
  38941. get positionScale(): number;
  38942. /**
  38943. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38944. * behaviour is triggered, in radians.
  38945. */
  38946. set defaultElevation(elevation: number);
  38947. /**
  38948. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38949. * behaviour is triggered, in radians.
  38950. */
  38951. get defaultElevation(): number;
  38952. /**
  38953. * Sets the time (in milliseconds) taken to return to the default beta position.
  38954. * Negative value indicates camera should not return to default.
  38955. */
  38956. set elevationReturnTime(speed: number);
  38957. /**
  38958. * Gets the time (in milliseconds) taken to return to the default beta position.
  38959. * Negative value indicates camera should not return to default.
  38960. */
  38961. get elevationReturnTime(): number;
  38962. /**
  38963. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38964. */
  38965. set elevationReturnWaitTime(time: number);
  38966. /**
  38967. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38968. */
  38969. get elevationReturnWaitTime(): number;
  38970. /**
  38971. * Sets the flag that indicates if user zooming should stop animation.
  38972. */
  38973. set zoomStopsAnimation(flag: boolean);
  38974. /**
  38975. * Gets the flag that indicates if user zooming should stop animation.
  38976. */
  38977. get zoomStopsAnimation(): boolean;
  38978. /**
  38979. * Sets the transition time when framing the mesh, in milliseconds
  38980. */
  38981. set framingTime(time: number);
  38982. /**
  38983. * Gets the transition time when framing the mesh, in milliseconds
  38984. */
  38985. get framingTime(): number;
  38986. /**
  38987. * Define if the behavior should automatically change the configured
  38988. * camera limits and sensibilities.
  38989. */
  38990. autoCorrectCameraLimitsAndSensibility: boolean;
  38991. private _onPrePointerObservableObserver;
  38992. private _onAfterCheckInputsObserver;
  38993. private _onMeshTargetChangedObserver;
  38994. private _attachedCamera;
  38995. private _isPointerDown;
  38996. private _lastInteractionTime;
  38997. /**
  38998. * Initializes the behavior.
  38999. */
  39000. init(): void;
  39001. /**
  39002. * Attaches the behavior to its arc rotate camera.
  39003. * @param camera Defines the camera to attach the behavior to
  39004. */
  39005. attach(camera: ArcRotateCamera): void;
  39006. /**
  39007. * Detaches the behavior from its current arc rotate camera.
  39008. */
  39009. detach(): void;
  39010. private _animatables;
  39011. private _betaIsAnimating;
  39012. private _betaTransition;
  39013. private _radiusTransition;
  39014. private _vectorTransition;
  39015. /**
  39016. * Targets the given mesh and updates zoom level accordingly.
  39017. * @param mesh The mesh to target.
  39018. * @param radius Optional. If a cached radius position already exists, overrides default.
  39019. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39020. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39021. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39022. */
  39023. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39024. /**
  39025. * Targets the given mesh with its children and updates zoom level accordingly.
  39026. * @param mesh The mesh to target.
  39027. * @param radius Optional. If a cached radius position already exists, overrides default.
  39028. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39029. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39030. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39031. */
  39032. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39033. /**
  39034. * Targets the given meshes with their children and updates zoom level accordingly.
  39035. * @param meshes The mesh to target.
  39036. * @param radius Optional. If a cached radius position already exists, overrides default.
  39037. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39038. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39039. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39040. */
  39041. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39042. /**
  39043. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39044. * @param minimumWorld Determines the smaller position of the bounding box extend
  39045. * @param maximumWorld Determines the bigger position of the bounding box extend
  39046. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39047. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39048. */
  39049. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39050. /**
  39051. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39052. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39053. * frustum width.
  39054. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39055. * to fully enclose the mesh in the viewing frustum.
  39056. */
  39057. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39058. /**
  39059. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39060. * is automatically returned to its default position (expected to be above ground plane).
  39061. */
  39062. private _maintainCameraAboveGround;
  39063. /**
  39064. * Returns the frustum slope based on the canvas ratio and camera FOV
  39065. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39066. */
  39067. private _getFrustumSlope;
  39068. /**
  39069. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39070. */
  39071. private _clearAnimationLocks;
  39072. /**
  39073. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39074. */
  39075. private _applyUserInteraction;
  39076. /**
  39077. * Stops and removes all animations that have been applied to the camera
  39078. */
  39079. stopAllAnimations(): void;
  39080. /**
  39081. * Gets a value indicating if the user is moving the camera
  39082. */
  39083. get isUserIsMoving(): boolean;
  39084. /**
  39085. * The camera can move all the way towards the mesh.
  39086. */
  39087. static IgnoreBoundsSizeMode: number;
  39088. /**
  39089. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39090. */
  39091. static FitFrustumSidesMode: number;
  39092. }
  39093. }
  39094. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39095. import { Nullable } from "babylonjs/types";
  39096. import { Camera } from "babylonjs/Cameras/camera";
  39097. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39098. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39099. /**
  39100. * Base class for Camera Pointer Inputs.
  39101. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39102. * for example usage.
  39103. */
  39104. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39105. /**
  39106. * Defines the camera the input is attached to.
  39107. */
  39108. abstract camera: Camera;
  39109. /**
  39110. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39111. */
  39112. protected _altKey: boolean;
  39113. protected _ctrlKey: boolean;
  39114. protected _metaKey: boolean;
  39115. protected _shiftKey: boolean;
  39116. /**
  39117. * Which mouse buttons were pressed at time of last mouse event.
  39118. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39119. */
  39120. protected _buttonsPressed: number;
  39121. /**
  39122. * Defines the buttons associated with the input to handle camera move.
  39123. */
  39124. buttons: number[];
  39125. /**
  39126. * Attach the input controls to a specific dom element to get the input from.
  39127. * @param element Defines the element the controls should be listened from
  39128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39129. */
  39130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39131. /**
  39132. * Detach the current controls from the specified dom element.
  39133. * @param element Defines the element to stop listening the inputs from
  39134. */
  39135. detachControl(element: Nullable<HTMLElement>): void;
  39136. /**
  39137. * Gets the class name of the current input.
  39138. * @returns the class name
  39139. */
  39140. getClassName(): string;
  39141. /**
  39142. * Get the friendly name associated with the input class.
  39143. * @returns the input friendly name
  39144. */
  39145. getSimpleName(): string;
  39146. /**
  39147. * Called on pointer POINTERDOUBLETAP event.
  39148. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39149. */
  39150. protected onDoubleTap(type: string): void;
  39151. /**
  39152. * Called on pointer POINTERMOVE event if only a single touch is active.
  39153. * Override this method to provide functionality.
  39154. */
  39155. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39156. /**
  39157. * Called on pointer POINTERMOVE event if multiple touches are active.
  39158. * Override this method to provide functionality.
  39159. */
  39160. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39161. /**
  39162. * Called on JS contextmenu event.
  39163. * Override this method to provide functionality.
  39164. */
  39165. protected onContextMenu(evt: PointerEvent): void;
  39166. /**
  39167. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39168. * press.
  39169. * Override this method to provide functionality.
  39170. */
  39171. protected onButtonDown(evt: PointerEvent): void;
  39172. /**
  39173. * Called each time a new POINTERUP event occurs. Ie, for each button
  39174. * release.
  39175. * Override this method to provide functionality.
  39176. */
  39177. protected onButtonUp(evt: PointerEvent): void;
  39178. /**
  39179. * Called when window becomes inactive.
  39180. * Override this method to provide functionality.
  39181. */
  39182. protected onLostFocus(): void;
  39183. private _pointerInput;
  39184. private _observer;
  39185. private _onLostFocus;
  39186. private pointA;
  39187. private pointB;
  39188. }
  39189. }
  39190. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39191. import { Nullable } from "babylonjs/types";
  39192. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39193. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39194. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39195. /**
  39196. * Manage the pointers inputs to control an arc rotate camera.
  39197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39198. */
  39199. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39200. /**
  39201. * Defines the camera the input is attached to.
  39202. */
  39203. camera: ArcRotateCamera;
  39204. /**
  39205. * Gets the class name of the current input.
  39206. * @returns the class name
  39207. */
  39208. getClassName(): string;
  39209. /**
  39210. * Defines the buttons associated with the input to handle camera move.
  39211. */
  39212. buttons: number[];
  39213. /**
  39214. * Defines the pointer angular sensibility along the X axis or how fast is
  39215. * the camera rotating.
  39216. */
  39217. angularSensibilityX: number;
  39218. /**
  39219. * Defines the pointer angular sensibility along the Y axis or how fast is
  39220. * the camera rotating.
  39221. */
  39222. angularSensibilityY: number;
  39223. /**
  39224. * Defines the pointer pinch precision or how fast is the camera zooming.
  39225. */
  39226. pinchPrecision: number;
  39227. /**
  39228. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39229. * from 0.
  39230. * It defines the percentage of current camera.radius to use as delta when
  39231. * pinch zoom is used.
  39232. */
  39233. pinchDeltaPercentage: number;
  39234. /**
  39235. * Defines the pointer panning sensibility or how fast is the camera moving.
  39236. */
  39237. panningSensibility: number;
  39238. /**
  39239. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39240. */
  39241. multiTouchPanning: boolean;
  39242. /**
  39243. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39244. * zoom (pinch) through multitouch.
  39245. */
  39246. multiTouchPanAndZoom: boolean;
  39247. /**
  39248. * Revers pinch action direction.
  39249. */
  39250. pinchInwards: boolean;
  39251. private _isPanClick;
  39252. private _twoFingerActivityCount;
  39253. private _isPinching;
  39254. /**
  39255. * Called on pointer POINTERMOVE event if only a single touch is active.
  39256. */
  39257. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39258. /**
  39259. * Called on pointer POINTERDOUBLETAP event.
  39260. */
  39261. protected onDoubleTap(type: string): void;
  39262. /**
  39263. * Called on pointer POINTERMOVE event if multiple touches are active.
  39264. */
  39265. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39266. /**
  39267. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39268. * press.
  39269. */
  39270. protected onButtonDown(evt: PointerEvent): void;
  39271. /**
  39272. * Called each time a new POINTERUP event occurs. Ie, for each button
  39273. * release.
  39274. */
  39275. protected onButtonUp(evt: PointerEvent): void;
  39276. /**
  39277. * Called when window becomes inactive.
  39278. */
  39279. protected onLostFocus(): void;
  39280. }
  39281. }
  39282. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39283. import { Nullable } from "babylonjs/types";
  39284. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39285. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39286. /**
  39287. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39289. */
  39290. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39291. /**
  39292. * Defines the camera the input is attached to.
  39293. */
  39294. camera: ArcRotateCamera;
  39295. /**
  39296. * Defines the list of key codes associated with the up action (increase alpha)
  39297. */
  39298. keysUp: number[];
  39299. /**
  39300. * Defines the list of key codes associated with the down action (decrease alpha)
  39301. */
  39302. keysDown: number[];
  39303. /**
  39304. * Defines the list of key codes associated with the left action (increase beta)
  39305. */
  39306. keysLeft: number[];
  39307. /**
  39308. * Defines the list of key codes associated with the right action (decrease beta)
  39309. */
  39310. keysRight: number[];
  39311. /**
  39312. * Defines the list of key codes associated with the reset action.
  39313. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39314. */
  39315. keysReset: number[];
  39316. /**
  39317. * Defines the panning sensibility of the inputs.
  39318. * (How fast is the camera paning)
  39319. */
  39320. panningSensibility: number;
  39321. /**
  39322. * Defines the zooming sensibility of the inputs.
  39323. * (How fast is the camera zooming)
  39324. */
  39325. zoomingSensibility: number;
  39326. /**
  39327. * Defines wether maintaining the alt key down switch the movement mode from
  39328. * orientation to zoom.
  39329. */
  39330. useAltToZoom: boolean;
  39331. /**
  39332. * Rotation speed of the camera
  39333. */
  39334. angularSpeed: number;
  39335. private _keys;
  39336. private _ctrlPressed;
  39337. private _altPressed;
  39338. private _onCanvasBlurObserver;
  39339. private _onKeyboardObserver;
  39340. private _engine;
  39341. private _scene;
  39342. /**
  39343. * Attach the input controls to a specific dom element to get the input from.
  39344. * @param element Defines the element the controls should be listened from
  39345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39346. */
  39347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39348. /**
  39349. * Detach the current controls from the specified dom element.
  39350. * @param element Defines the element to stop listening the inputs from
  39351. */
  39352. detachControl(element: Nullable<HTMLElement>): void;
  39353. /**
  39354. * Update the current camera state depending on the inputs that have been used this frame.
  39355. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39356. */
  39357. checkInputs(): void;
  39358. /**
  39359. * Gets the class name of the current intput.
  39360. * @returns the class name
  39361. */
  39362. getClassName(): string;
  39363. /**
  39364. * Get the friendly name associated with the input class.
  39365. * @returns the input friendly name
  39366. */
  39367. getSimpleName(): string;
  39368. }
  39369. }
  39370. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39371. import { Nullable } from "babylonjs/types";
  39372. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39373. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39374. /**
  39375. * Manage the mouse wheel inputs to control an arc rotate camera.
  39376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39377. */
  39378. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39379. /**
  39380. * Defines the camera the input is attached to.
  39381. */
  39382. camera: ArcRotateCamera;
  39383. /**
  39384. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39385. */
  39386. wheelPrecision: number;
  39387. /**
  39388. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39389. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39390. */
  39391. wheelDeltaPercentage: number;
  39392. private _wheel;
  39393. private _observer;
  39394. private computeDeltaFromMouseWheelLegacyEvent;
  39395. /**
  39396. * Attach the input controls to a specific dom element to get the input from.
  39397. * @param element Defines the element the controls should be listened from
  39398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39399. */
  39400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39401. /**
  39402. * Detach the current controls from the specified dom element.
  39403. * @param element Defines the element to stop listening the inputs from
  39404. */
  39405. detachControl(element: Nullable<HTMLElement>): void;
  39406. /**
  39407. * Gets the class name of the current intput.
  39408. * @returns the class name
  39409. */
  39410. getClassName(): string;
  39411. /**
  39412. * Get the friendly name associated with the input class.
  39413. * @returns the input friendly name
  39414. */
  39415. getSimpleName(): string;
  39416. }
  39417. }
  39418. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39419. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39420. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39421. /**
  39422. * Default Inputs manager for the ArcRotateCamera.
  39423. * It groups all the default supported inputs for ease of use.
  39424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39425. */
  39426. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39427. /**
  39428. * Instantiates a new ArcRotateCameraInputsManager.
  39429. * @param camera Defines the camera the inputs belong to
  39430. */
  39431. constructor(camera: ArcRotateCamera);
  39432. /**
  39433. * Add mouse wheel input support to the input manager.
  39434. * @returns the current input manager
  39435. */
  39436. addMouseWheel(): ArcRotateCameraInputsManager;
  39437. /**
  39438. * Add pointers input support to the input manager.
  39439. * @returns the current input manager
  39440. */
  39441. addPointers(): ArcRotateCameraInputsManager;
  39442. /**
  39443. * Add keyboard input support to the input manager.
  39444. * @returns the current input manager
  39445. */
  39446. addKeyboard(): ArcRotateCameraInputsManager;
  39447. }
  39448. }
  39449. declare module "babylonjs/Cameras/arcRotateCamera" {
  39450. import { Observable } from "babylonjs/Misc/observable";
  39451. import { Nullable } from "babylonjs/types";
  39452. import { Scene } from "babylonjs/scene";
  39453. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39455. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39456. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39457. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39458. import { Camera } from "babylonjs/Cameras/camera";
  39459. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39460. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39461. import { Collider } from "babylonjs/Collisions/collider";
  39462. /**
  39463. * This represents an orbital type of camera.
  39464. *
  39465. * 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.
  39466. * 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.
  39467. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39468. */
  39469. export class ArcRotateCamera extends TargetCamera {
  39470. /**
  39471. * Defines the rotation angle of the camera along the longitudinal axis.
  39472. */
  39473. alpha: number;
  39474. /**
  39475. * Defines the rotation angle of the camera along the latitudinal axis.
  39476. */
  39477. beta: number;
  39478. /**
  39479. * Defines the radius of the camera from it s target point.
  39480. */
  39481. radius: number;
  39482. protected _target: Vector3;
  39483. protected _targetHost: Nullable<AbstractMesh>;
  39484. /**
  39485. * Defines the target point of the camera.
  39486. * The camera looks towards it form the radius distance.
  39487. */
  39488. get target(): Vector3;
  39489. set target(value: Vector3);
  39490. /**
  39491. * Define the current local position of the camera in the scene
  39492. */
  39493. get position(): Vector3;
  39494. set position(newPosition: Vector3);
  39495. protected _upVector: Vector3;
  39496. protected _upToYMatrix: Matrix;
  39497. protected _YToUpMatrix: Matrix;
  39498. /**
  39499. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39500. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39501. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39502. */
  39503. set upVector(vec: Vector3);
  39504. get upVector(): Vector3;
  39505. /**
  39506. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39507. */
  39508. setMatUp(): void;
  39509. /**
  39510. * Current inertia value on the longitudinal axis.
  39511. * The bigger this number the longer it will take for the camera to stop.
  39512. */
  39513. inertialAlphaOffset: number;
  39514. /**
  39515. * Current inertia value on the latitudinal axis.
  39516. * The bigger this number the longer it will take for the camera to stop.
  39517. */
  39518. inertialBetaOffset: number;
  39519. /**
  39520. * Current inertia value on the radius axis.
  39521. * The bigger this number the longer it will take for the camera to stop.
  39522. */
  39523. inertialRadiusOffset: number;
  39524. /**
  39525. * Minimum allowed angle on the longitudinal axis.
  39526. * This can help limiting how the Camera is able to move in the scene.
  39527. */
  39528. lowerAlphaLimit: Nullable<number>;
  39529. /**
  39530. * Maximum allowed angle on the longitudinal axis.
  39531. * This can help limiting how the Camera is able to move in the scene.
  39532. */
  39533. upperAlphaLimit: Nullable<number>;
  39534. /**
  39535. * Minimum allowed angle on the latitudinal axis.
  39536. * This can help limiting how the Camera is able to move in the scene.
  39537. */
  39538. lowerBetaLimit: number;
  39539. /**
  39540. * Maximum allowed angle on the latitudinal axis.
  39541. * This can help limiting how the Camera is able to move in the scene.
  39542. */
  39543. upperBetaLimit: number;
  39544. /**
  39545. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39546. * This can help limiting how the Camera is able to move in the scene.
  39547. */
  39548. lowerRadiusLimit: Nullable<number>;
  39549. /**
  39550. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39551. * This can help limiting how the Camera is able to move in the scene.
  39552. */
  39553. upperRadiusLimit: Nullable<number>;
  39554. /**
  39555. * Defines the current inertia value used during panning of the camera along the X axis.
  39556. */
  39557. inertialPanningX: number;
  39558. /**
  39559. * Defines the current inertia value used during panning of the camera along the Y axis.
  39560. */
  39561. inertialPanningY: number;
  39562. /**
  39563. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39564. * Basically if your fingers moves away from more than this distance you will be considered
  39565. * in pinch mode.
  39566. */
  39567. pinchToPanMaxDistance: number;
  39568. /**
  39569. * Defines the maximum distance the camera can pan.
  39570. * This could help keeping the cammera always in your scene.
  39571. */
  39572. panningDistanceLimit: Nullable<number>;
  39573. /**
  39574. * Defines the target of the camera before paning.
  39575. */
  39576. panningOriginTarget: Vector3;
  39577. /**
  39578. * Defines the value of the inertia used during panning.
  39579. * 0 would mean stop inertia and one would mean no decelleration at all.
  39580. */
  39581. panningInertia: number;
  39582. /**
  39583. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39584. */
  39585. get angularSensibilityX(): number;
  39586. set angularSensibilityX(value: number);
  39587. /**
  39588. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39589. */
  39590. get angularSensibilityY(): number;
  39591. set angularSensibilityY(value: number);
  39592. /**
  39593. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39594. */
  39595. get pinchPrecision(): number;
  39596. set pinchPrecision(value: number);
  39597. /**
  39598. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39599. * It will be used instead of pinchDeltaPrecision if different from 0.
  39600. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39601. */
  39602. get pinchDeltaPercentage(): number;
  39603. set pinchDeltaPercentage(value: number);
  39604. /**
  39605. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39606. */
  39607. get panningSensibility(): number;
  39608. set panningSensibility(value: number);
  39609. /**
  39610. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39611. */
  39612. get keysUp(): number[];
  39613. set keysUp(value: number[]);
  39614. /**
  39615. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39616. */
  39617. get keysDown(): number[];
  39618. set keysDown(value: number[]);
  39619. /**
  39620. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39621. */
  39622. get keysLeft(): number[];
  39623. set keysLeft(value: number[]);
  39624. /**
  39625. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39626. */
  39627. get keysRight(): number[];
  39628. set keysRight(value: number[]);
  39629. /**
  39630. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39631. */
  39632. get wheelPrecision(): number;
  39633. set wheelPrecision(value: number);
  39634. /**
  39635. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39636. * It will be used instead of pinchDeltaPrecision if different from 0.
  39637. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39638. */
  39639. get wheelDeltaPercentage(): number;
  39640. set wheelDeltaPercentage(value: number);
  39641. /**
  39642. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39643. */
  39644. zoomOnFactor: number;
  39645. /**
  39646. * Defines a screen offset for the camera position.
  39647. */
  39648. targetScreenOffset: Vector2;
  39649. /**
  39650. * Allows the camera to be completely reversed.
  39651. * If false the camera can not arrive upside down.
  39652. */
  39653. allowUpsideDown: boolean;
  39654. /**
  39655. * Define if double tap/click is used to restore the previously saved state of the camera.
  39656. */
  39657. useInputToRestoreState: boolean;
  39658. /** @hidden */
  39659. _viewMatrix: Matrix;
  39660. /** @hidden */
  39661. _useCtrlForPanning: boolean;
  39662. /** @hidden */
  39663. _panningMouseButton: number;
  39664. /**
  39665. * Defines the input associated to the camera.
  39666. */
  39667. inputs: ArcRotateCameraInputsManager;
  39668. /** @hidden */
  39669. _reset: () => void;
  39670. /**
  39671. * Defines the allowed panning axis.
  39672. */
  39673. panningAxis: Vector3;
  39674. protected _localDirection: Vector3;
  39675. protected _transformedDirection: Vector3;
  39676. private _bouncingBehavior;
  39677. /**
  39678. * Gets the bouncing behavior of the camera if it has been enabled.
  39679. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39680. */
  39681. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39682. /**
  39683. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39684. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39685. */
  39686. get useBouncingBehavior(): boolean;
  39687. set useBouncingBehavior(value: boolean);
  39688. private _framingBehavior;
  39689. /**
  39690. * Gets the framing behavior of the camera if it has been enabled.
  39691. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39692. */
  39693. get framingBehavior(): Nullable<FramingBehavior>;
  39694. /**
  39695. * Defines if the framing behavior of the camera is enabled on the camera.
  39696. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39697. */
  39698. get useFramingBehavior(): boolean;
  39699. set useFramingBehavior(value: boolean);
  39700. private _autoRotationBehavior;
  39701. /**
  39702. * Gets the auto rotation behavior of the camera if it has been enabled.
  39703. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39704. */
  39705. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39706. /**
  39707. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39708. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39709. */
  39710. get useAutoRotationBehavior(): boolean;
  39711. set useAutoRotationBehavior(value: boolean);
  39712. /**
  39713. * Observable triggered when the mesh target has been changed on the camera.
  39714. */
  39715. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39716. /**
  39717. * Event raised when the camera is colliding with a mesh.
  39718. */
  39719. onCollide: (collidedMesh: AbstractMesh) => void;
  39720. /**
  39721. * Defines whether the camera should check collision with the objects oh the scene.
  39722. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39723. */
  39724. checkCollisions: boolean;
  39725. /**
  39726. * Defines the collision radius of the camera.
  39727. * This simulates a sphere around the camera.
  39728. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39729. */
  39730. collisionRadius: Vector3;
  39731. protected _collider: Collider;
  39732. protected _previousPosition: Vector3;
  39733. protected _collisionVelocity: Vector3;
  39734. protected _newPosition: Vector3;
  39735. protected _previousAlpha: number;
  39736. protected _previousBeta: number;
  39737. protected _previousRadius: number;
  39738. protected _collisionTriggered: boolean;
  39739. protected _targetBoundingCenter: Nullable<Vector3>;
  39740. private _computationVector;
  39741. /**
  39742. * Instantiates a new ArcRotateCamera in a given scene
  39743. * @param name Defines the name of the camera
  39744. * @param alpha Defines the camera rotation along the logitudinal axis
  39745. * @param beta Defines the camera rotation along the latitudinal axis
  39746. * @param radius Defines the camera distance from its target
  39747. * @param target Defines the camera target
  39748. * @param scene Defines the scene the camera belongs to
  39749. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39750. */
  39751. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39752. /** @hidden */
  39753. _initCache(): void;
  39754. /** @hidden */
  39755. _updateCache(ignoreParentClass?: boolean): void;
  39756. protected _getTargetPosition(): Vector3;
  39757. private _storedAlpha;
  39758. private _storedBeta;
  39759. private _storedRadius;
  39760. private _storedTarget;
  39761. private _storedTargetScreenOffset;
  39762. /**
  39763. * Stores the current state of the camera (alpha, beta, radius and target)
  39764. * @returns the camera itself
  39765. */
  39766. storeState(): Camera;
  39767. /**
  39768. * @hidden
  39769. * Restored camera state. You must call storeState() first
  39770. */
  39771. _restoreStateValues(): boolean;
  39772. /** @hidden */
  39773. _isSynchronizedViewMatrix(): boolean;
  39774. /**
  39775. * Attached controls to the current camera.
  39776. * @param element Defines the element the controls should be listened from
  39777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39778. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39779. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39780. */
  39781. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39782. /**
  39783. * Detach the current controls from the camera.
  39784. * The camera will stop reacting to inputs.
  39785. * @param element Defines the element to stop listening the inputs from
  39786. */
  39787. detachControl(element: HTMLElement): void;
  39788. /** @hidden */
  39789. _checkInputs(): void;
  39790. protected _checkLimits(): void;
  39791. /**
  39792. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39793. */
  39794. rebuildAnglesAndRadius(): void;
  39795. /**
  39796. * Use a position to define the current camera related information like alpha, beta and radius
  39797. * @param position Defines the position to set the camera at
  39798. */
  39799. setPosition(position: Vector3): void;
  39800. /**
  39801. * Defines the target the camera should look at.
  39802. * This will automatically adapt alpha beta and radius to fit within the new target.
  39803. * @param target Defines the new target as a Vector or a mesh
  39804. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39805. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39806. */
  39807. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39808. /** @hidden */
  39809. _getViewMatrix(): Matrix;
  39810. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39811. /**
  39812. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39813. * @param meshes Defines the mesh to zoom on
  39814. * @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)
  39815. */
  39816. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39817. /**
  39818. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39819. * The target will be changed but the radius
  39820. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39821. * @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)
  39822. */
  39823. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39824. min: Vector3;
  39825. max: Vector3;
  39826. distance: number;
  39827. }, doNotUpdateMaxZ?: boolean): void;
  39828. /**
  39829. * @override
  39830. * Override Camera.createRigCamera
  39831. */
  39832. createRigCamera(name: string, cameraIndex: number): Camera;
  39833. /**
  39834. * @hidden
  39835. * @override
  39836. * Override Camera._updateRigCameras
  39837. */
  39838. _updateRigCameras(): void;
  39839. /**
  39840. * Destroy the camera and release the current resources hold by it.
  39841. */
  39842. dispose(): void;
  39843. /**
  39844. * Gets the current object class name.
  39845. * @return the class name
  39846. */
  39847. getClassName(): string;
  39848. }
  39849. }
  39850. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39851. import { Behavior } from "babylonjs/Behaviors/behavior";
  39852. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39853. /**
  39854. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39855. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39856. */
  39857. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39858. /**
  39859. * Gets the name of the behavior.
  39860. */
  39861. get name(): string;
  39862. private _zoomStopsAnimation;
  39863. private _idleRotationSpeed;
  39864. private _idleRotationWaitTime;
  39865. private _idleRotationSpinupTime;
  39866. /**
  39867. * Sets the flag that indicates if user zooming should stop animation.
  39868. */
  39869. set zoomStopsAnimation(flag: boolean);
  39870. /**
  39871. * Gets the flag that indicates if user zooming should stop animation.
  39872. */
  39873. get zoomStopsAnimation(): boolean;
  39874. /**
  39875. * Sets the default speed at which the camera rotates around the model.
  39876. */
  39877. set idleRotationSpeed(speed: number);
  39878. /**
  39879. * Gets the default speed at which the camera rotates around the model.
  39880. */
  39881. get idleRotationSpeed(): number;
  39882. /**
  39883. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39884. */
  39885. set idleRotationWaitTime(time: number);
  39886. /**
  39887. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39888. */
  39889. get idleRotationWaitTime(): number;
  39890. /**
  39891. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39892. */
  39893. set idleRotationSpinupTime(time: number);
  39894. /**
  39895. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39896. */
  39897. get idleRotationSpinupTime(): number;
  39898. /**
  39899. * Gets a value indicating if the camera is currently rotating because of this behavior
  39900. */
  39901. get rotationInProgress(): boolean;
  39902. private _onPrePointerObservableObserver;
  39903. private _onAfterCheckInputsObserver;
  39904. private _attachedCamera;
  39905. private _isPointerDown;
  39906. private _lastFrameTime;
  39907. private _lastInteractionTime;
  39908. private _cameraRotationSpeed;
  39909. /**
  39910. * Initializes the behavior.
  39911. */
  39912. init(): void;
  39913. /**
  39914. * Attaches the behavior to its arc rotate camera.
  39915. * @param camera Defines the camera to attach the behavior to
  39916. */
  39917. attach(camera: ArcRotateCamera): void;
  39918. /**
  39919. * Detaches the behavior from its current arc rotate camera.
  39920. */
  39921. detach(): void;
  39922. /**
  39923. * Returns true if user is scrolling.
  39924. * @return true if user is scrolling.
  39925. */
  39926. private _userIsZooming;
  39927. private _lastFrameRadius;
  39928. private _shouldAnimationStopForInteraction;
  39929. /**
  39930. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39931. */
  39932. private _applyUserInteraction;
  39933. private _userIsMoving;
  39934. }
  39935. }
  39936. declare module "babylonjs/Behaviors/Cameras/index" {
  39937. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39938. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39939. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39940. }
  39941. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39942. import { Mesh } from "babylonjs/Meshes/mesh";
  39943. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39944. import { Behavior } from "babylonjs/Behaviors/behavior";
  39945. /**
  39946. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39947. */
  39948. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39949. private ui;
  39950. /**
  39951. * The name of the behavior
  39952. */
  39953. name: string;
  39954. /**
  39955. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39956. */
  39957. distanceAwayFromFace: number;
  39958. /**
  39959. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39960. */
  39961. distanceAwayFromBottomOfFace: number;
  39962. private _faceVectors;
  39963. private _target;
  39964. private _scene;
  39965. private _onRenderObserver;
  39966. private _tmpMatrix;
  39967. private _tmpVector;
  39968. /**
  39969. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39970. * @param ui The transform node that should be attched to the mesh
  39971. */
  39972. constructor(ui: TransformNode);
  39973. /**
  39974. * Initializes the behavior
  39975. */
  39976. init(): void;
  39977. private _closestFace;
  39978. private _zeroVector;
  39979. private _lookAtTmpMatrix;
  39980. private _lookAtToRef;
  39981. /**
  39982. * Attaches the AttachToBoxBehavior to the passed in mesh
  39983. * @param target The mesh that the specified node will be attached to
  39984. */
  39985. attach(target: Mesh): void;
  39986. /**
  39987. * Detaches the behavior from the mesh
  39988. */
  39989. detach(): void;
  39990. }
  39991. }
  39992. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39993. import { Behavior } from "babylonjs/Behaviors/behavior";
  39994. import { Mesh } from "babylonjs/Meshes/mesh";
  39995. /**
  39996. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39997. */
  39998. export class FadeInOutBehavior implements Behavior<Mesh> {
  39999. /**
  40000. * Time in milliseconds to delay before fading in (Default: 0)
  40001. */
  40002. delay: number;
  40003. /**
  40004. * Time in milliseconds for the mesh to fade in (Default: 300)
  40005. */
  40006. fadeInTime: number;
  40007. private _millisecondsPerFrame;
  40008. private _hovered;
  40009. private _hoverValue;
  40010. private _ownerNode;
  40011. /**
  40012. * Instatiates the FadeInOutBehavior
  40013. */
  40014. constructor();
  40015. /**
  40016. * The name of the behavior
  40017. */
  40018. get name(): string;
  40019. /**
  40020. * Initializes the behavior
  40021. */
  40022. init(): void;
  40023. /**
  40024. * Attaches the fade behavior on the passed in mesh
  40025. * @param ownerNode The mesh that will be faded in/out once attached
  40026. */
  40027. attach(ownerNode: Mesh): void;
  40028. /**
  40029. * Detaches the behavior from the mesh
  40030. */
  40031. detach(): void;
  40032. /**
  40033. * Triggers the mesh to begin fading in or out
  40034. * @param value if the object should fade in or out (true to fade in)
  40035. */
  40036. fadeIn(value: boolean): void;
  40037. private _update;
  40038. private _setAllVisibility;
  40039. }
  40040. }
  40041. declare module "babylonjs/Misc/pivotTools" {
  40042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40043. /**
  40044. * Class containing a set of static utilities functions for managing Pivots
  40045. * @hidden
  40046. */
  40047. export class PivotTools {
  40048. private static _PivotCached;
  40049. private static _OldPivotPoint;
  40050. private static _PivotTranslation;
  40051. private static _PivotTmpVector;
  40052. /** @hidden */
  40053. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40054. /** @hidden */
  40055. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40056. }
  40057. }
  40058. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40059. import { Scene } from "babylonjs/scene";
  40060. import { Vector4 } from "babylonjs/Maths/math.vector";
  40061. import { Mesh } from "babylonjs/Meshes/mesh";
  40062. import { Nullable } from "babylonjs/types";
  40063. import { Plane } from "babylonjs/Maths/math.plane";
  40064. /**
  40065. * Class containing static functions to help procedurally build meshes
  40066. */
  40067. export class PlaneBuilder {
  40068. /**
  40069. * Creates a plane mesh
  40070. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40071. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40072. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40076. * @param name defines the name of the mesh
  40077. * @param options defines the options used to create the mesh
  40078. * @param scene defines the hosting scene
  40079. * @returns the plane mesh
  40080. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40081. */
  40082. static CreatePlane(name: string, options: {
  40083. size?: number;
  40084. width?: number;
  40085. height?: number;
  40086. sideOrientation?: number;
  40087. frontUVs?: Vector4;
  40088. backUVs?: Vector4;
  40089. updatable?: boolean;
  40090. sourcePlane?: Plane;
  40091. }, scene?: Nullable<Scene>): Mesh;
  40092. }
  40093. }
  40094. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40095. import { Behavior } from "babylonjs/Behaviors/behavior";
  40096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40097. import { Observable } from "babylonjs/Misc/observable";
  40098. import { Vector3 } from "babylonjs/Maths/math.vector";
  40099. import { Ray } from "babylonjs/Culling/ray";
  40100. import "babylonjs/Meshes/Builders/planeBuilder";
  40101. /**
  40102. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40103. */
  40104. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40105. private static _AnyMouseID;
  40106. /**
  40107. * Abstract mesh the behavior is set on
  40108. */
  40109. attachedNode: AbstractMesh;
  40110. private _dragPlane;
  40111. private _scene;
  40112. private _pointerObserver;
  40113. private _beforeRenderObserver;
  40114. private static _planeScene;
  40115. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40116. /**
  40117. * 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)
  40118. */
  40119. maxDragAngle: number;
  40120. /**
  40121. * @hidden
  40122. */
  40123. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40124. /**
  40125. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40126. */
  40127. currentDraggingPointerID: number;
  40128. /**
  40129. * The last position where the pointer hit the drag plane in world space
  40130. */
  40131. lastDragPosition: Vector3;
  40132. /**
  40133. * If the behavior is currently in a dragging state
  40134. */
  40135. dragging: boolean;
  40136. /**
  40137. * 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)
  40138. */
  40139. dragDeltaRatio: number;
  40140. /**
  40141. * If the drag plane orientation should be updated during the dragging (Default: true)
  40142. */
  40143. updateDragPlane: boolean;
  40144. private _debugMode;
  40145. private _moving;
  40146. /**
  40147. * Fires each time the attached mesh is dragged with the pointer
  40148. * * delta between last drag position and current drag position in world space
  40149. * * dragDistance along the drag axis
  40150. * * dragPlaneNormal normal of the current drag plane used during the drag
  40151. * * dragPlanePoint in world space where the drag intersects the drag plane
  40152. */
  40153. onDragObservable: Observable<{
  40154. delta: Vector3;
  40155. dragPlanePoint: Vector3;
  40156. dragPlaneNormal: Vector3;
  40157. dragDistance: number;
  40158. pointerId: number;
  40159. }>;
  40160. /**
  40161. * Fires each time a drag begins (eg. mouse down on mesh)
  40162. */
  40163. onDragStartObservable: Observable<{
  40164. dragPlanePoint: Vector3;
  40165. pointerId: number;
  40166. }>;
  40167. /**
  40168. * Fires each time a drag ends (eg. mouse release after drag)
  40169. */
  40170. onDragEndObservable: Observable<{
  40171. dragPlanePoint: Vector3;
  40172. pointerId: number;
  40173. }>;
  40174. /**
  40175. * If the attached mesh should be moved when dragged
  40176. */
  40177. moveAttached: boolean;
  40178. /**
  40179. * If the drag behavior will react to drag events (Default: true)
  40180. */
  40181. enabled: boolean;
  40182. /**
  40183. * If pointer events should start and release the drag (Default: true)
  40184. */
  40185. startAndReleaseDragOnPointerEvents: boolean;
  40186. /**
  40187. * If camera controls should be detached during the drag
  40188. */
  40189. detachCameraControls: boolean;
  40190. /**
  40191. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40192. */
  40193. useObjectOrientationForDragging: boolean;
  40194. private _options;
  40195. /**
  40196. * Gets the options used by the behavior
  40197. */
  40198. get options(): {
  40199. dragAxis?: Vector3;
  40200. dragPlaneNormal?: Vector3;
  40201. };
  40202. /**
  40203. * Sets the options used by the behavior
  40204. */
  40205. set options(options: {
  40206. dragAxis?: Vector3;
  40207. dragPlaneNormal?: Vector3;
  40208. });
  40209. /**
  40210. * Creates a pointer drag behavior that can be attached to a mesh
  40211. * @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)
  40212. */
  40213. constructor(options?: {
  40214. dragAxis?: Vector3;
  40215. dragPlaneNormal?: Vector3;
  40216. });
  40217. /**
  40218. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40219. */
  40220. validateDrag: (targetPosition: Vector3) => boolean;
  40221. /**
  40222. * The name of the behavior
  40223. */
  40224. get name(): string;
  40225. /**
  40226. * Initializes the behavior
  40227. */
  40228. init(): void;
  40229. private _tmpVector;
  40230. private _alternatePickedPoint;
  40231. private _worldDragAxis;
  40232. private _targetPosition;
  40233. private _attachedElement;
  40234. /**
  40235. * Attaches the drag behavior the passed in mesh
  40236. * @param ownerNode The mesh that will be dragged around once attached
  40237. * @param predicate Predicate to use for pick filtering
  40238. */
  40239. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40240. /**
  40241. * Force relase the drag action by code.
  40242. */
  40243. releaseDrag(): void;
  40244. private _startDragRay;
  40245. private _lastPointerRay;
  40246. /**
  40247. * Simulates the start of a pointer drag event on the behavior
  40248. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40249. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40250. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40251. */
  40252. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40253. private _startDrag;
  40254. private _dragDelta;
  40255. private _moveDrag;
  40256. private _pickWithRayOnDragPlane;
  40257. private _pointA;
  40258. private _pointB;
  40259. private _pointC;
  40260. private _lineA;
  40261. private _lineB;
  40262. private _localAxis;
  40263. private _lookAt;
  40264. private _updateDragPlanePosition;
  40265. /**
  40266. * Detaches the behavior from the mesh
  40267. */
  40268. detach(): void;
  40269. }
  40270. }
  40271. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40272. import { Mesh } from "babylonjs/Meshes/mesh";
  40273. import { Behavior } from "babylonjs/Behaviors/behavior";
  40274. /**
  40275. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40276. */
  40277. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40278. private _dragBehaviorA;
  40279. private _dragBehaviorB;
  40280. private _startDistance;
  40281. private _initialScale;
  40282. private _targetScale;
  40283. private _ownerNode;
  40284. private _sceneRenderObserver;
  40285. /**
  40286. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40287. */
  40288. constructor();
  40289. /**
  40290. * The name of the behavior
  40291. */
  40292. get name(): string;
  40293. /**
  40294. * Initializes the behavior
  40295. */
  40296. init(): void;
  40297. private _getCurrentDistance;
  40298. /**
  40299. * Attaches the scale behavior the passed in mesh
  40300. * @param ownerNode The mesh that will be scaled around once attached
  40301. */
  40302. attach(ownerNode: Mesh): void;
  40303. /**
  40304. * Detaches the behavior from the mesh
  40305. */
  40306. detach(): void;
  40307. }
  40308. }
  40309. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40310. import { Behavior } from "babylonjs/Behaviors/behavior";
  40311. import { Mesh } from "babylonjs/Meshes/mesh";
  40312. import { Observable } from "babylonjs/Misc/observable";
  40313. /**
  40314. * 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
  40315. */
  40316. export class SixDofDragBehavior implements Behavior<Mesh> {
  40317. private static _virtualScene;
  40318. private _ownerNode;
  40319. private _sceneRenderObserver;
  40320. private _scene;
  40321. private _targetPosition;
  40322. private _virtualOriginMesh;
  40323. private _virtualDragMesh;
  40324. private _pointerObserver;
  40325. private _moving;
  40326. private _startingOrientation;
  40327. /**
  40328. * 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)
  40329. */
  40330. private zDragFactor;
  40331. /**
  40332. * If the object should rotate to face the drag origin
  40333. */
  40334. rotateDraggedObject: boolean;
  40335. /**
  40336. * If the behavior is currently in a dragging state
  40337. */
  40338. dragging: boolean;
  40339. /**
  40340. * 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)
  40341. */
  40342. dragDeltaRatio: number;
  40343. /**
  40344. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40345. */
  40346. currentDraggingPointerID: number;
  40347. /**
  40348. * If camera controls should be detached during the drag
  40349. */
  40350. detachCameraControls: boolean;
  40351. /**
  40352. * Fires each time a drag starts
  40353. */
  40354. onDragStartObservable: Observable<{}>;
  40355. /**
  40356. * Fires each time a drag ends (eg. mouse release after drag)
  40357. */
  40358. onDragEndObservable: Observable<{}>;
  40359. /**
  40360. * 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
  40361. */
  40362. constructor();
  40363. /**
  40364. * The name of the behavior
  40365. */
  40366. get name(): string;
  40367. /**
  40368. * Initializes the behavior
  40369. */
  40370. init(): void;
  40371. /**
  40372. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40373. */
  40374. private get _pointerCamera();
  40375. /**
  40376. * Attaches the scale behavior the passed in mesh
  40377. * @param ownerNode The mesh that will be scaled around once attached
  40378. */
  40379. attach(ownerNode: Mesh): void;
  40380. /**
  40381. * Detaches the behavior from the mesh
  40382. */
  40383. detach(): void;
  40384. }
  40385. }
  40386. declare module "babylonjs/Behaviors/Meshes/index" {
  40387. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40388. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40389. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40390. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40391. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40392. }
  40393. declare module "babylonjs/Behaviors/index" {
  40394. export * from "babylonjs/Behaviors/behavior";
  40395. export * from "babylonjs/Behaviors/Cameras/index";
  40396. export * from "babylonjs/Behaviors/Meshes/index";
  40397. }
  40398. declare module "babylonjs/Bones/boneIKController" {
  40399. import { Bone } from "babylonjs/Bones/bone";
  40400. import { Vector3 } from "babylonjs/Maths/math.vector";
  40401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40402. import { Nullable } from "babylonjs/types";
  40403. /**
  40404. * Class used to apply inverse kinematics to bones
  40405. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40406. */
  40407. export class BoneIKController {
  40408. private static _tmpVecs;
  40409. private static _tmpQuat;
  40410. private static _tmpMats;
  40411. /**
  40412. * Gets or sets the target mesh
  40413. */
  40414. targetMesh: AbstractMesh;
  40415. /** Gets or sets the mesh used as pole */
  40416. poleTargetMesh: AbstractMesh;
  40417. /**
  40418. * Gets or sets the bone used as pole
  40419. */
  40420. poleTargetBone: Nullable<Bone>;
  40421. /**
  40422. * Gets or sets the target position
  40423. */
  40424. targetPosition: Vector3;
  40425. /**
  40426. * Gets or sets the pole target position
  40427. */
  40428. poleTargetPosition: Vector3;
  40429. /**
  40430. * Gets or sets the pole target local offset
  40431. */
  40432. poleTargetLocalOffset: Vector3;
  40433. /**
  40434. * Gets or sets the pole angle
  40435. */
  40436. poleAngle: number;
  40437. /**
  40438. * Gets or sets the mesh associated with the controller
  40439. */
  40440. mesh: AbstractMesh;
  40441. /**
  40442. * 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)
  40443. */
  40444. slerpAmount: number;
  40445. private _bone1Quat;
  40446. private _bone1Mat;
  40447. private _bone2Ang;
  40448. private _bone1;
  40449. private _bone2;
  40450. private _bone1Length;
  40451. private _bone2Length;
  40452. private _maxAngle;
  40453. private _maxReach;
  40454. private _rightHandedSystem;
  40455. private _bendAxis;
  40456. private _slerping;
  40457. private _adjustRoll;
  40458. /**
  40459. * Gets or sets maximum allowed angle
  40460. */
  40461. get maxAngle(): number;
  40462. set maxAngle(value: number);
  40463. /**
  40464. * Creates a new BoneIKController
  40465. * @param mesh defines the mesh to control
  40466. * @param bone defines the bone to control
  40467. * @param options defines options to set up the controller
  40468. */
  40469. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40470. targetMesh?: AbstractMesh;
  40471. poleTargetMesh?: AbstractMesh;
  40472. poleTargetBone?: Bone;
  40473. poleTargetLocalOffset?: Vector3;
  40474. poleAngle?: number;
  40475. bendAxis?: Vector3;
  40476. maxAngle?: number;
  40477. slerpAmount?: number;
  40478. });
  40479. private _setMaxAngle;
  40480. /**
  40481. * Force the controller to update the bones
  40482. */
  40483. update(): void;
  40484. }
  40485. }
  40486. declare module "babylonjs/Bones/boneLookController" {
  40487. import { Vector3 } from "babylonjs/Maths/math.vector";
  40488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40489. import { Bone } from "babylonjs/Bones/bone";
  40490. import { Space } from "babylonjs/Maths/math.axis";
  40491. /**
  40492. * Class used to make a bone look toward a point in space
  40493. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40494. */
  40495. export class BoneLookController {
  40496. private static _tmpVecs;
  40497. private static _tmpQuat;
  40498. private static _tmpMats;
  40499. /**
  40500. * The target Vector3 that the bone will look at
  40501. */
  40502. target: Vector3;
  40503. /**
  40504. * The mesh that the bone is attached to
  40505. */
  40506. mesh: AbstractMesh;
  40507. /**
  40508. * The bone that will be looking to the target
  40509. */
  40510. bone: Bone;
  40511. /**
  40512. * The up axis of the coordinate system that is used when the bone is rotated
  40513. */
  40514. upAxis: Vector3;
  40515. /**
  40516. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40517. */
  40518. upAxisSpace: Space;
  40519. /**
  40520. * Used to make an adjustment to the yaw of the bone
  40521. */
  40522. adjustYaw: number;
  40523. /**
  40524. * Used to make an adjustment to the pitch of the bone
  40525. */
  40526. adjustPitch: number;
  40527. /**
  40528. * Used to make an adjustment to the roll of the bone
  40529. */
  40530. adjustRoll: number;
  40531. /**
  40532. * 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)
  40533. */
  40534. slerpAmount: number;
  40535. private _minYaw;
  40536. private _maxYaw;
  40537. private _minPitch;
  40538. private _maxPitch;
  40539. private _minYawSin;
  40540. private _minYawCos;
  40541. private _maxYawSin;
  40542. private _maxYawCos;
  40543. private _midYawConstraint;
  40544. private _minPitchTan;
  40545. private _maxPitchTan;
  40546. private _boneQuat;
  40547. private _slerping;
  40548. private _transformYawPitch;
  40549. private _transformYawPitchInv;
  40550. private _firstFrameSkipped;
  40551. private _yawRange;
  40552. private _fowardAxis;
  40553. /**
  40554. * Gets or sets the minimum yaw angle that the bone can look to
  40555. */
  40556. get minYaw(): number;
  40557. set minYaw(value: number);
  40558. /**
  40559. * Gets or sets the maximum yaw angle that the bone can look to
  40560. */
  40561. get maxYaw(): number;
  40562. set maxYaw(value: number);
  40563. /**
  40564. * Gets or sets the minimum pitch angle that the bone can look to
  40565. */
  40566. get minPitch(): number;
  40567. set minPitch(value: number);
  40568. /**
  40569. * Gets or sets the maximum pitch angle that the bone can look to
  40570. */
  40571. get maxPitch(): number;
  40572. set maxPitch(value: number);
  40573. /**
  40574. * Create a BoneLookController
  40575. * @param mesh the mesh that the bone belongs to
  40576. * @param bone the bone that will be looking to the target
  40577. * @param target the target Vector3 to look at
  40578. * @param options optional settings:
  40579. * * maxYaw: the maximum angle the bone will yaw to
  40580. * * minYaw: the minimum angle the bone will yaw to
  40581. * * maxPitch: the maximum angle the bone will pitch to
  40582. * * minPitch: the minimum angle the bone will yaw to
  40583. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40584. * * upAxis: the up axis of the coordinate system
  40585. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40586. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40587. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40588. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40589. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40590. * * adjustRoll: used to make an adjustment to the roll of the bone
  40591. **/
  40592. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40593. maxYaw?: number;
  40594. minYaw?: number;
  40595. maxPitch?: number;
  40596. minPitch?: number;
  40597. slerpAmount?: number;
  40598. upAxis?: Vector3;
  40599. upAxisSpace?: Space;
  40600. yawAxis?: Vector3;
  40601. pitchAxis?: Vector3;
  40602. adjustYaw?: number;
  40603. adjustPitch?: number;
  40604. adjustRoll?: number;
  40605. });
  40606. /**
  40607. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40608. */
  40609. update(): void;
  40610. private _getAngleDiff;
  40611. private _getAngleBetween;
  40612. private _isAngleBetween;
  40613. }
  40614. }
  40615. declare module "babylonjs/Bones/index" {
  40616. export * from "babylonjs/Bones/bone";
  40617. export * from "babylonjs/Bones/boneIKController";
  40618. export * from "babylonjs/Bones/boneLookController";
  40619. export * from "babylonjs/Bones/skeleton";
  40620. }
  40621. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40622. import { Nullable } from "babylonjs/types";
  40623. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40624. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40625. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40626. /**
  40627. * Manage the gamepad inputs to control an arc rotate camera.
  40628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40629. */
  40630. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40631. /**
  40632. * Defines the camera the input is attached to.
  40633. */
  40634. camera: ArcRotateCamera;
  40635. /**
  40636. * Defines the gamepad the input is gathering event from.
  40637. */
  40638. gamepad: Nullable<Gamepad>;
  40639. /**
  40640. * Defines the gamepad rotation sensiblity.
  40641. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40642. */
  40643. gamepadRotationSensibility: number;
  40644. /**
  40645. * Defines the gamepad move sensiblity.
  40646. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40647. */
  40648. gamepadMoveSensibility: number;
  40649. private _yAxisScale;
  40650. /**
  40651. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40652. */
  40653. get invertYAxis(): boolean;
  40654. set invertYAxis(value: boolean);
  40655. private _onGamepadConnectedObserver;
  40656. private _onGamepadDisconnectedObserver;
  40657. /**
  40658. * Attach the input controls to a specific dom element to get the input from.
  40659. * @param element Defines the element the controls should be listened from
  40660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40661. */
  40662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40663. /**
  40664. * Detach the current controls from the specified dom element.
  40665. * @param element Defines the element to stop listening the inputs from
  40666. */
  40667. detachControl(element: Nullable<HTMLElement>): void;
  40668. /**
  40669. * Update the current camera state depending on the inputs that have been used this frame.
  40670. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40671. */
  40672. checkInputs(): void;
  40673. /**
  40674. * Gets the class name of the current intput.
  40675. * @returns the class name
  40676. */
  40677. getClassName(): string;
  40678. /**
  40679. * Get the friendly name associated with the input class.
  40680. * @returns the input friendly name
  40681. */
  40682. getSimpleName(): string;
  40683. }
  40684. }
  40685. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40686. import { Nullable } from "babylonjs/types";
  40687. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40688. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40689. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40690. interface ArcRotateCameraInputsManager {
  40691. /**
  40692. * Add orientation input support to the input manager.
  40693. * @returns the current input manager
  40694. */
  40695. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40696. }
  40697. }
  40698. /**
  40699. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40701. */
  40702. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40703. /**
  40704. * Defines the camera the input is attached to.
  40705. */
  40706. camera: ArcRotateCamera;
  40707. /**
  40708. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40709. */
  40710. alphaCorrection: number;
  40711. /**
  40712. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40713. */
  40714. gammaCorrection: number;
  40715. private _alpha;
  40716. private _gamma;
  40717. private _dirty;
  40718. private _deviceOrientationHandler;
  40719. /**
  40720. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40721. */
  40722. constructor();
  40723. /**
  40724. * Attach the input controls to a specific dom element to get the input from.
  40725. * @param element Defines the element the controls should be listened from
  40726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40727. */
  40728. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40729. /** @hidden */
  40730. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40731. /**
  40732. * Update the current camera state depending on the inputs that have been used this frame.
  40733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40734. */
  40735. checkInputs(): void;
  40736. /**
  40737. * Detach the current controls from the specified dom element.
  40738. * @param element Defines the element to stop listening the inputs from
  40739. */
  40740. detachControl(element: Nullable<HTMLElement>): void;
  40741. /**
  40742. * Gets the class name of the current intput.
  40743. * @returns the class name
  40744. */
  40745. getClassName(): string;
  40746. /**
  40747. * Get the friendly name associated with the input class.
  40748. * @returns the input friendly name
  40749. */
  40750. getSimpleName(): string;
  40751. }
  40752. }
  40753. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40754. import { Nullable } from "babylonjs/types";
  40755. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40756. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40757. /**
  40758. * Listen to mouse events to control the camera.
  40759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40760. */
  40761. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40762. /**
  40763. * Defines the camera the input is attached to.
  40764. */
  40765. camera: FlyCamera;
  40766. /**
  40767. * Defines if touch is enabled. (Default is true.)
  40768. */
  40769. touchEnabled: boolean;
  40770. /**
  40771. * Defines the buttons associated with the input to handle camera rotation.
  40772. */
  40773. buttons: number[];
  40774. /**
  40775. * Assign buttons for Yaw control.
  40776. */
  40777. buttonsYaw: number[];
  40778. /**
  40779. * Assign buttons for Pitch control.
  40780. */
  40781. buttonsPitch: number[];
  40782. /**
  40783. * Assign buttons for Roll control.
  40784. */
  40785. buttonsRoll: number[];
  40786. /**
  40787. * Detect if any button is being pressed while mouse is moved.
  40788. * -1 = Mouse locked.
  40789. * 0 = Left button.
  40790. * 1 = Middle Button.
  40791. * 2 = Right Button.
  40792. */
  40793. activeButton: number;
  40794. /**
  40795. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40796. * Higher values reduce its sensitivity.
  40797. */
  40798. angularSensibility: number;
  40799. private _mousemoveCallback;
  40800. private _observer;
  40801. private _rollObserver;
  40802. private previousPosition;
  40803. private noPreventDefault;
  40804. private element;
  40805. /**
  40806. * Listen to mouse events to control the camera.
  40807. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40809. */
  40810. constructor(touchEnabled?: boolean);
  40811. /**
  40812. * Attach the mouse control to the HTML DOM element.
  40813. * @param element Defines the element that listens to the input events.
  40814. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40815. */
  40816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40817. /**
  40818. * Detach the current controls from the specified dom element.
  40819. * @param element Defines the element to stop listening the inputs from
  40820. */
  40821. detachControl(element: Nullable<HTMLElement>): void;
  40822. /**
  40823. * Gets the class name of the current input.
  40824. * @returns the class name.
  40825. */
  40826. getClassName(): string;
  40827. /**
  40828. * Get the friendly name associated with the input class.
  40829. * @returns the input's friendly name.
  40830. */
  40831. getSimpleName(): string;
  40832. private _pointerInput;
  40833. private _onMouseMove;
  40834. /**
  40835. * Rotate camera by mouse offset.
  40836. */
  40837. private rotateCamera;
  40838. }
  40839. }
  40840. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40841. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40842. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40843. /**
  40844. * Default Inputs manager for the FlyCamera.
  40845. * It groups all the default supported inputs for ease of use.
  40846. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40847. */
  40848. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40849. /**
  40850. * Instantiates a new FlyCameraInputsManager.
  40851. * @param camera Defines the camera the inputs belong to.
  40852. */
  40853. constructor(camera: FlyCamera);
  40854. /**
  40855. * Add keyboard input support to the input manager.
  40856. * @returns the new FlyCameraKeyboardMoveInput().
  40857. */
  40858. addKeyboard(): FlyCameraInputsManager;
  40859. /**
  40860. * Add mouse input support to the input manager.
  40861. * @param touchEnabled Enable touch screen support.
  40862. * @returns the new FlyCameraMouseInput().
  40863. */
  40864. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40865. }
  40866. }
  40867. declare module "babylonjs/Cameras/flyCamera" {
  40868. import { Scene } from "babylonjs/scene";
  40869. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40871. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40872. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40873. /**
  40874. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40875. * such as in a 3D Space Shooter or a Flight Simulator.
  40876. */
  40877. export class FlyCamera extends TargetCamera {
  40878. /**
  40879. * Define the collision ellipsoid of the camera.
  40880. * This is helpful for simulating a camera body, like a player's body.
  40881. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40882. */
  40883. ellipsoid: Vector3;
  40884. /**
  40885. * Define an offset for the position of the ellipsoid around the camera.
  40886. * This can be helpful if the camera is attached away from the player's body center,
  40887. * such as at its head.
  40888. */
  40889. ellipsoidOffset: Vector3;
  40890. /**
  40891. * Enable or disable collisions of the camera with the rest of the scene objects.
  40892. */
  40893. checkCollisions: boolean;
  40894. /**
  40895. * Enable or disable gravity on the camera.
  40896. */
  40897. applyGravity: boolean;
  40898. /**
  40899. * Define the current direction the camera is moving to.
  40900. */
  40901. cameraDirection: Vector3;
  40902. /**
  40903. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40904. * This overrides and empties cameraRotation.
  40905. */
  40906. rotationQuaternion: Quaternion;
  40907. /**
  40908. * Track Roll to maintain the wanted Rolling when looking around.
  40909. */
  40910. _trackRoll: number;
  40911. /**
  40912. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40913. */
  40914. rollCorrect: number;
  40915. /**
  40916. * Mimic a banked turn, Rolling the camera when Yawing.
  40917. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40918. */
  40919. bankedTurn: boolean;
  40920. /**
  40921. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40922. */
  40923. bankedTurnLimit: number;
  40924. /**
  40925. * Value of 0 disables the banked Roll.
  40926. * Value of 1 is equal to the Yaw angle in radians.
  40927. */
  40928. bankedTurnMultiplier: number;
  40929. /**
  40930. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40931. */
  40932. inputs: FlyCameraInputsManager;
  40933. /**
  40934. * Gets the input sensibility for mouse input.
  40935. * Higher values reduce sensitivity.
  40936. */
  40937. get angularSensibility(): number;
  40938. /**
  40939. * Sets the input sensibility for a mouse input.
  40940. * Higher values reduce sensitivity.
  40941. */
  40942. set angularSensibility(value: number);
  40943. /**
  40944. * Get the keys for camera movement forward.
  40945. */
  40946. get keysForward(): number[];
  40947. /**
  40948. * Set the keys for camera movement forward.
  40949. */
  40950. set keysForward(value: number[]);
  40951. /**
  40952. * Get the keys for camera movement backward.
  40953. */
  40954. get keysBackward(): number[];
  40955. set keysBackward(value: number[]);
  40956. /**
  40957. * Get the keys for camera movement up.
  40958. */
  40959. get keysUp(): number[];
  40960. /**
  40961. * Set the keys for camera movement up.
  40962. */
  40963. set keysUp(value: number[]);
  40964. /**
  40965. * Get the keys for camera movement down.
  40966. */
  40967. get keysDown(): number[];
  40968. /**
  40969. * Set the keys for camera movement down.
  40970. */
  40971. set keysDown(value: number[]);
  40972. /**
  40973. * Get the keys for camera movement left.
  40974. */
  40975. get keysLeft(): number[];
  40976. /**
  40977. * Set the keys for camera movement left.
  40978. */
  40979. set keysLeft(value: number[]);
  40980. /**
  40981. * Set the keys for camera movement right.
  40982. */
  40983. get keysRight(): number[];
  40984. /**
  40985. * Set the keys for camera movement right.
  40986. */
  40987. set keysRight(value: number[]);
  40988. /**
  40989. * Event raised when the camera collides with a mesh in the scene.
  40990. */
  40991. onCollide: (collidedMesh: AbstractMesh) => void;
  40992. private _collider;
  40993. private _needMoveForGravity;
  40994. private _oldPosition;
  40995. private _diffPosition;
  40996. private _newPosition;
  40997. /** @hidden */
  40998. _localDirection: Vector3;
  40999. /** @hidden */
  41000. _transformedDirection: Vector3;
  41001. /**
  41002. * Instantiates a FlyCamera.
  41003. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41004. * such as in a 3D Space Shooter or a Flight Simulator.
  41005. * @param name Define the name of the camera in the scene.
  41006. * @param position Define the starting position of the camera in the scene.
  41007. * @param scene Define the scene the camera belongs to.
  41008. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41009. */
  41010. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41011. /**
  41012. * Attach a control to the HTML DOM element.
  41013. * @param element Defines the element that listens to the input events.
  41014. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41015. */
  41016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41017. /**
  41018. * Detach a control from the HTML DOM element.
  41019. * The camera will stop reacting to that input.
  41020. * @param element Defines the element that listens to the input events.
  41021. */
  41022. detachControl(element: HTMLElement): void;
  41023. private _collisionMask;
  41024. /**
  41025. * Get the mask that the camera ignores in collision events.
  41026. */
  41027. get collisionMask(): number;
  41028. /**
  41029. * Set the mask that the camera ignores in collision events.
  41030. */
  41031. set collisionMask(mask: number);
  41032. /** @hidden */
  41033. _collideWithWorld(displacement: Vector3): void;
  41034. /** @hidden */
  41035. private _onCollisionPositionChange;
  41036. /** @hidden */
  41037. _checkInputs(): void;
  41038. /** @hidden */
  41039. _decideIfNeedsToMove(): boolean;
  41040. /** @hidden */
  41041. _updatePosition(): void;
  41042. /**
  41043. * Restore the Roll to its target value at the rate specified.
  41044. * @param rate - Higher means slower restoring.
  41045. * @hidden
  41046. */
  41047. restoreRoll(rate: number): void;
  41048. /**
  41049. * Destroy the camera and release the current resources held by it.
  41050. */
  41051. dispose(): void;
  41052. /**
  41053. * Get the current object class name.
  41054. * @returns the class name.
  41055. */
  41056. getClassName(): string;
  41057. }
  41058. }
  41059. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41060. import { Nullable } from "babylonjs/types";
  41061. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41062. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41063. /**
  41064. * Listen to keyboard events to control the camera.
  41065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41066. */
  41067. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41068. /**
  41069. * Defines the camera the input is attached to.
  41070. */
  41071. camera: FlyCamera;
  41072. /**
  41073. * The list of keyboard keys used to control the forward move of the camera.
  41074. */
  41075. keysForward: number[];
  41076. /**
  41077. * The list of keyboard keys used to control the backward move of the camera.
  41078. */
  41079. keysBackward: number[];
  41080. /**
  41081. * The list of keyboard keys used to control the forward move of the camera.
  41082. */
  41083. keysUp: number[];
  41084. /**
  41085. * The list of keyboard keys used to control the backward move of the camera.
  41086. */
  41087. keysDown: number[];
  41088. /**
  41089. * The list of keyboard keys used to control the right strafe move of the camera.
  41090. */
  41091. keysRight: number[];
  41092. /**
  41093. * The list of keyboard keys used to control the left strafe move of the camera.
  41094. */
  41095. keysLeft: number[];
  41096. private _keys;
  41097. private _onCanvasBlurObserver;
  41098. private _onKeyboardObserver;
  41099. private _engine;
  41100. private _scene;
  41101. /**
  41102. * Attach the input controls to a specific dom element to get the input from.
  41103. * @param element Defines the element the controls should be listened from
  41104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41105. */
  41106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41107. /**
  41108. * Detach the current controls from the specified dom element.
  41109. * @param element Defines the element to stop listening the inputs from
  41110. */
  41111. detachControl(element: Nullable<HTMLElement>): void;
  41112. /**
  41113. * Gets the class name of the current intput.
  41114. * @returns the class name
  41115. */
  41116. getClassName(): string;
  41117. /** @hidden */
  41118. _onLostFocus(e: FocusEvent): void;
  41119. /**
  41120. * Get the friendly name associated with the input class.
  41121. * @returns the input friendly name
  41122. */
  41123. getSimpleName(): string;
  41124. /**
  41125. * Update the current camera state depending on the inputs that have been used this frame.
  41126. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41127. */
  41128. checkInputs(): void;
  41129. }
  41130. }
  41131. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41132. import { Nullable } from "babylonjs/types";
  41133. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41134. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41135. /**
  41136. * Manage the mouse wheel inputs to control a follow camera.
  41137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41138. */
  41139. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41140. /**
  41141. * Defines the camera the input is attached to.
  41142. */
  41143. camera: FollowCamera;
  41144. /**
  41145. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41146. */
  41147. axisControlRadius: boolean;
  41148. /**
  41149. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41150. */
  41151. axisControlHeight: boolean;
  41152. /**
  41153. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41154. */
  41155. axisControlRotation: boolean;
  41156. /**
  41157. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41158. * relation to mouseWheel events.
  41159. */
  41160. wheelPrecision: number;
  41161. /**
  41162. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41163. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41164. */
  41165. wheelDeltaPercentage: number;
  41166. private _wheel;
  41167. private _observer;
  41168. /**
  41169. * Attach the input controls to a specific dom element to get the input from.
  41170. * @param element Defines the element the controls should be listened from
  41171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41172. */
  41173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41174. /**
  41175. * Detach the current controls from the specified dom element.
  41176. * @param element Defines the element to stop listening the inputs from
  41177. */
  41178. detachControl(element: Nullable<HTMLElement>): void;
  41179. /**
  41180. * Gets the class name of the current intput.
  41181. * @returns the class name
  41182. */
  41183. getClassName(): string;
  41184. /**
  41185. * Get the friendly name associated with the input class.
  41186. * @returns the input friendly name
  41187. */
  41188. getSimpleName(): string;
  41189. }
  41190. }
  41191. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41192. import { Nullable } from "babylonjs/types";
  41193. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41194. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41195. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41196. /**
  41197. * Manage the pointers inputs to control an follow camera.
  41198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41199. */
  41200. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41201. /**
  41202. * Defines the camera the input is attached to.
  41203. */
  41204. camera: FollowCamera;
  41205. /**
  41206. * Gets the class name of the current input.
  41207. * @returns the class name
  41208. */
  41209. getClassName(): string;
  41210. /**
  41211. * Defines the pointer angular sensibility along the X axis or how fast is
  41212. * the camera rotating.
  41213. * A negative number will reverse the axis direction.
  41214. */
  41215. angularSensibilityX: number;
  41216. /**
  41217. * Defines the pointer angular sensibility along the Y axis or how fast is
  41218. * the camera rotating.
  41219. * A negative number will reverse the axis direction.
  41220. */
  41221. angularSensibilityY: number;
  41222. /**
  41223. * Defines the pointer pinch precision or how fast is the camera zooming.
  41224. * A negative number will reverse the axis direction.
  41225. */
  41226. pinchPrecision: number;
  41227. /**
  41228. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41229. * from 0.
  41230. * It defines the percentage of current camera.radius to use as delta when
  41231. * pinch zoom is used.
  41232. */
  41233. pinchDeltaPercentage: number;
  41234. /**
  41235. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41236. */
  41237. axisXControlRadius: boolean;
  41238. /**
  41239. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41240. */
  41241. axisXControlHeight: boolean;
  41242. /**
  41243. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41244. */
  41245. axisXControlRotation: boolean;
  41246. /**
  41247. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41248. */
  41249. axisYControlRadius: boolean;
  41250. /**
  41251. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41252. */
  41253. axisYControlHeight: boolean;
  41254. /**
  41255. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41256. */
  41257. axisYControlRotation: boolean;
  41258. /**
  41259. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41260. */
  41261. axisPinchControlRadius: boolean;
  41262. /**
  41263. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41264. */
  41265. axisPinchControlHeight: boolean;
  41266. /**
  41267. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41268. */
  41269. axisPinchControlRotation: boolean;
  41270. /**
  41271. * Log error messages if basic misconfiguration has occurred.
  41272. */
  41273. warningEnable: boolean;
  41274. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41275. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41276. private _warningCounter;
  41277. private _warning;
  41278. }
  41279. }
  41280. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41281. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41282. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41283. /**
  41284. * Default Inputs manager for the FollowCamera.
  41285. * It groups all the default supported inputs for ease of use.
  41286. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41287. */
  41288. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41289. /**
  41290. * Instantiates a new FollowCameraInputsManager.
  41291. * @param camera Defines the camera the inputs belong to
  41292. */
  41293. constructor(camera: FollowCamera);
  41294. /**
  41295. * Add keyboard input support to the input manager.
  41296. * @returns the current input manager
  41297. */
  41298. addKeyboard(): FollowCameraInputsManager;
  41299. /**
  41300. * Add mouse wheel input support to the input manager.
  41301. * @returns the current input manager
  41302. */
  41303. addMouseWheel(): FollowCameraInputsManager;
  41304. /**
  41305. * Add pointers input support to the input manager.
  41306. * @returns the current input manager
  41307. */
  41308. addPointers(): FollowCameraInputsManager;
  41309. /**
  41310. * Add orientation input support to the input manager.
  41311. * @returns the current input manager
  41312. */
  41313. addVRDeviceOrientation(): FollowCameraInputsManager;
  41314. }
  41315. }
  41316. declare module "babylonjs/Cameras/followCamera" {
  41317. import { Nullable } from "babylonjs/types";
  41318. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41319. import { Scene } from "babylonjs/scene";
  41320. import { Vector3 } from "babylonjs/Maths/math.vector";
  41321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41322. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41323. /**
  41324. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41325. * an arc rotate version arcFollowCamera are available.
  41326. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41327. */
  41328. export class FollowCamera extends TargetCamera {
  41329. /**
  41330. * Distance the follow camera should follow an object at
  41331. */
  41332. radius: number;
  41333. /**
  41334. * Minimum allowed distance of the camera to the axis of rotation
  41335. * (The camera can not get closer).
  41336. * This can help limiting how the Camera is able to move in the scene.
  41337. */
  41338. lowerRadiusLimit: Nullable<number>;
  41339. /**
  41340. * Maximum allowed distance of the camera to the axis of rotation
  41341. * (The camera can not get further).
  41342. * This can help limiting how the Camera is able to move in the scene.
  41343. */
  41344. upperRadiusLimit: Nullable<number>;
  41345. /**
  41346. * Define a rotation offset between the camera and the object it follows
  41347. */
  41348. rotationOffset: number;
  41349. /**
  41350. * Minimum allowed angle to camera position relative to target object.
  41351. * This can help limiting how the Camera is able to move in the scene.
  41352. */
  41353. lowerRotationOffsetLimit: Nullable<number>;
  41354. /**
  41355. * Maximum allowed angle to camera position relative to target object.
  41356. * This can help limiting how the Camera is able to move in the scene.
  41357. */
  41358. upperRotationOffsetLimit: Nullable<number>;
  41359. /**
  41360. * Define a height offset between the camera and the object it follows.
  41361. * It can help following an object from the top (like a car chaing a plane)
  41362. */
  41363. heightOffset: number;
  41364. /**
  41365. * Minimum allowed height of camera position relative to target object.
  41366. * This can help limiting how the Camera is able to move in the scene.
  41367. */
  41368. lowerHeightOffsetLimit: Nullable<number>;
  41369. /**
  41370. * Maximum allowed height of camera position relative to target object.
  41371. * This can help limiting how the Camera is able to move in the scene.
  41372. */
  41373. upperHeightOffsetLimit: Nullable<number>;
  41374. /**
  41375. * Define how fast the camera can accelerate to follow it s target.
  41376. */
  41377. cameraAcceleration: number;
  41378. /**
  41379. * Define the speed limit of the camera following an object.
  41380. */
  41381. maxCameraSpeed: number;
  41382. /**
  41383. * Define the target of the camera.
  41384. */
  41385. lockedTarget: Nullable<AbstractMesh>;
  41386. /**
  41387. * Defines the input associated with the camera.
  41388. */
  41389. inputs: FollowCameraInputsManager;
  41390. /**
  41391. * Instantiates the follow camera.
  41392. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41393. * @param name Define the name of the camera in the scene
  41394. * @param position Define the position of the camera
  41395. * @param scene Define the scene the camera belong to
  41396. * @param lockedTarget Define the target of the camera
  41397. */
  41398. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41399. private _follow;
  41400. /**
  41401. * Attached controls to the current camera.
  41402. * @param element Defines the element the controls should be listened from
  41403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41404. */
  41405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41406. /**
  41407. * Detach the current controls from the camera.
  41408. * The camera will stop reacting to inputs.
  41409. * @param element Defines the element to stop listening the inputs from
  41410. */
  41411. detachControl(element: HTMLElement): void;
  41412. /** @hidden */
  41413. _checkInputs(): void;
  41414. private _checkLimits;
  41415. /**
  41416. * Gets the camera class name.
  41417. * @returns the class name
  41418. */
  41419. getClassName(): string;
  41420. }
  41421. /**
  41422. * Arc Rotate version of the follow camera.
  41423. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41424. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41425. */
  41426. export class ArcFollowCamera extends TargetCamera {
  41427. /** The longitudinal angle of the camera */
  41428. alpha: number;
  41429. /** The latitudinal angle of the camera */
  41430. beta: number;
  41431. /** The radius of the camera from its target */
  41432. radius: number;
  41433. /** Define the camera target (the messh it should follow) */
  41434. target: Nullable<AbstractMesh>;
  41435. private _cartesianCoordinates;
  41436. /**
  41437. * Instantiates a new ArcFollowCamera
  41438. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41439. * @param name Define the name of the camera
  41440. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41441. * @param beta Define the rotation angle of the camera around the elevation axis
  41442. * @param radius Define the radius of the camera from its target point
  41443. * @param target Define the target of the camera
  41444. * @param scene Define the scene the camera belongs to
  41445. */
  41446. constructor(name: string,
  41447. /** The longitudinal angle of the camera */
  41448. alpha: number,
  41449. /** The latitudinal angle of the camera */
  41450. beta: number,
  41451. /** The radius of the camera from its target */
  41452. radius: number,
  41453. /** Define the camera target (the messh it should follow) */
  41454. target: Nullable<AbstractMesh>, scene: Scene);
  41455. private _follow;
  41456. /** @hidden */
  41457. _checkInputs(): void;
  41458. /**
  41459. * Returns the class name of the object.
  41460. * It is mostly used internally for serialization purposes.
  41461. */
  41462. getClassName(): string;
  41463. }
  41464. }
  41465. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41466. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41467. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41468. import { Nullable } from "babylonjs/types";
  41469. /**
  41470. * Manage the keyboard inputs to control the movement of a follow camera.
  41471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41472. */
  41473. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41474. /**
  41475. * Defines the camera the input is attached to.
  41476. */
  41477. camera: FollowCamera;
  41478. /**
  41479. * Defines the list of key codes associated with the up action (increase heightOffset)
  41480. */
  41481. keysHeightOffsetIncr: number[];
  41482. /**
  41483. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41484. */
  41485. keysHeightOffsetDecr: number[];
  41486. /**
  41487. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41488. */
  41489. keysHeightOffsetModifierAlt: boolean;
  41490. /**
  41491. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41492. */
  41493. keysHeightOffsetModifierCtrl: boolean;
  41494. /**
  41495. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41496. */
  41497. keysHeightOffsetModifierShift: boolean;
  41498. /**
  41499. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41500. */
  41501. keysRotationOffsetIncr: number[];
  41502. /**
  41503. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41504. */
  41505. keysRotationOffsetDecr: number[];
  41506. /**
  41507. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41508. */
  41509. keysRotationOffsetModifierAlt: boolean;
  41510. /**
  41511. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41512. */
  41513. keysRotationOffsetModifierCtrl: boolean;
  41514. /**
  41515. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41516. */
  41517. keysRotationOffsetModifierShift: boolean;
  41518. /**
  41519. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41520. */
  41521. keysRadiusIncr: number[];
  41522. /**
  41523. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41524. */
  41525. keysRadiusDecr: number[];
  41526. /**
  41527. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41528. */
  41529. keysRadiusModifierAlt: boolean;
  41530. /**
  41531. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41532. */
  41533. keysRadiusModifierCtrl: boolean;
  41534. /**
  41535. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41536. */
  41537. keysRadiusModifierShift: boolean;
  41538. /**
  41539. * Defines the rate of change of heightOffset.
  41540. */
  41541. heightSensibility: number;
  41542. /**
  41543. * Defines the rate of change of rotationOffset.
  41544. */
  41545. rotationSensibility: number;
  41546. /**
  41547. * Defines the rate of change of radius.
  41548. */
  41549. radiusSensibility: number;
  41550. private _keys;
  41551. private _ctrlPressed;
  41552. private _altPressed;
  41553. private _shiftPressed;
  41554. private _onCanvasBlurObserver;
  41555. private _onKeyboardObserver;
  41556. private _engine;
  41557. private _scene;
  41558. /**
  41559. * Attach the input controls to a specific dom element to get the input from.
  41560. * @param element Defines the element the controls should be listened from
  41561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41562. */
  41563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41564. /**
  41565. * Detach the current controls from the specified dom element.
  41566. * @param element Defines the element to stop listening the inputs from
  41567. */
  41568. detachControl(element: Nullable<HTMLElement>): void;
  41569. /**
  41570. * Update the current camera state depending on the inputs that have been used this frame.
  41571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41572. */
  41573. checkInputs(): void;
  41574. /**
  41575. * Gets the class name of the current input.
  41576. * @returns the class name
  41577. */
  41578. getClassName(): string;
  41579. /**
  41580. * Get the friendly name associated with the input class.
  41581. * @returns the input friendly name
  41582. */
  41583. getSimpleName(): string;
  41584. /**
  41585. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41586. * allow modification of the heightOffset value.
  41587. */
  41588. private _modifierHeightOffset;
  41589. /**
  41590. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41591. * allow modification of the rotationOffset value.
  41592. */
  41593. private _modifierRotationOffset;
  41594. /**
  41595. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41596. * allow modification of the radius value.
  41597. */
  41598. private _modifierRadius;
  41599. }
  41600. }
  41601. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41602. import { Nullable } from "babylonjs/types";
  41603. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41604. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41605. import { Observable } from "babylonjs/Misc/observable";
  41606. module "babylonjs/Cameras/freeCameraInputsManager" {
  41607. interface FreeCameraInputsManager {
  41608. /**
  41609. * @hidden
  41610. */
  41611. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41612. /**
  41613. * Add orientation input support to the input manager.
  41614. * @returns the current input manager
  41615. */
  41616. addDeviceOrientation(): FreeCameraInputsManager;
  41617. }
  41618. }
  41619. /**
  41620. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41621. * Screen rotation is taken into account.
  41622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41623. */
  41624. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41625. private _camera;
  41626. private _screenOrientationAngle;
  41627. private _constantTranform;
  41628. private _screenQuaternion;
  41629. private _alpha;
  41630. private _beta;
  41631. private _gamma;
  41632. /**
  41633. * Can be used to detect if a device orientation sensor is available on a device
  41634. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41635. * @returns a promise that will resolve on orientation change
  41636. */
  41637. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41638. /**
  41639. * @hidden
  41640. */
  41641. _onDeviceOrientationChangedObservable: Observable<void>;
  41642. /**
  41643. * Instantiates a new input
  41644. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41645. */
  41646. constructor();
  41647. /**
  41648. * Define the camera controlled by the input.
  41649. */
  41650. get camera(): FreeCamera;
  41651. set camera(camera: FreeCamera);
  41652. /**
  41653. * Attach the input controls to a specific dom element to get the input from.
  41654. * @param element Defines the element the controls should be listened from
  41655. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41656. */
  41657. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41658. private _orientationChanged;
  41659. private _deviceOrientation;
  41660. /**
  41661. * Detach the current controls from the specified dom element.
  41662. * @param element Defines the element to stop listening the inputs from
  41663. */
  41664. detachControl(element: Nullable<HTMLElement>): void;
  41665. /**
  41666. * Update the current camera state depending on the inputs that have been used this frame.
  41667. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41668. */
  41669. checkInputs(): void;
  41670. /**
  41671. * Gets the class name of the current intput.
  41672. * @returns the class name
  41673. */
  41674. getClassName(): string;
  41675. /**
  41676. * Get the friendly name associated with the input class.
  41677. * @returns the input friendly name
  41678. */
  41679. getSimpleName(): string;
  41680. }
  41681. }
  41682. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41683. import { Nullable } from "babylonjs/types";
  41684. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41685. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41686. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41687. /**
  41688. * Manage the gamepad inputs to control a free camera.
  41689. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41690. */
  41691. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41692. /**
  41693. * Define the camera the input is attached to.
  41694. */
  41695. camera: FreeCamera;
  41696. /**
  41697. * Define the Gamepad controlling the input
  41698. */
  41699. gamepad: Nullable<Gamepad>;
  41700. /**
  41701. * Defines the gamepad rotation sensiblity.
  41702. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41703. */
  41704. gamepadAngularSensibility: number;
  41705. /**
  41706. * Defines the gamepad move sensiblity.
  41707. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41708. */
  41709. gamepadMoveSensibility: number;
  41710. private _yAxisScale;
  41711. /**
  41712. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41713. */
  41714. get invertYAxis(): boolean;
  41715. set invertYAxis(value: boolean);
  41716. private _onGamepadConnectedObserver;
  41717. private _onGamepadDisconnectedObserver;
  41718. private _cameraTransform;
  41719. private _deltaTransform;
  41720. private _vector3;
  41721. private _vector2;
  41722. /**
  41723. * Attach the input controls to a specific dom element to get the input from.
  41724. * @param element Defines the element the controls should be listened from
  41725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41726. */
  41727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41728. /**
  41729. * Detach the current controls from the specified dom element.
  41730. * @param element Defines the element to stop listening the inputs from
  41731. */
  41732. detachControl(element: Nullable<HTMLElement>): void;
  41733. /**
  41734. * Update the current camera state depending on the inputs that have been used this frame.
  41735. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41736. */
  41737. checkInputs(): void;
  41738. /**
  41739. * Gets the class name of the current intput.
  41740. * @returns the class name
  41741. */
  41742. getClassName(): string;
  41743. /**
  41744. * Get the friendly name associated with the input class.
  41745. * @returns the input friendly name
  41746. */
  41747. getSimpleName(): string;
  41748. }
  41749. }
  41750. declare module "babylonjs/Misc/virtualJoystick" {
  41751. import { Nullable } from "babylonjs/types";
  41752. import { Vector3 } from "babylonjs/Maths/math.vector";
  41753. /**
  41754. * Defines the potential axis of a Joystick
  41755. */
  41756. export enum JoystickAxis {
  41757. /** X axis */
  41758. X = 0,
  41759. /** Y axis */
  41760. Y = 1,
  41761. /** Z axis */
  41762. Z = 2
  41763. }
  41764. /**
  41765. * Class used to define virtual joystick (used in touch mode)
  41766. */
  41767. export class VirtualJoystick {
  41768. /**
  41769. * Gets or sets a boolean indicating that left and right values must be inverted
  41770. */
  41771. reverseLeftRight: boolean;
  41772. /**
  41773. * Gets or sets a boolean indicating that up and down values must be inverted
  41774. */
  41775. reverseUpDown: boolean;
  41776. /**
  41777. * Gets the offset value for the position (ie. the change of the position value)
  41778. */
  41779. deltaPosition: Vector3;
  41780. /**
  41781. * Gets a boolean indicating if the virtual joystick was pressed
  41782. */
  41783. pressed: boolean;
  41784. /**
  41785. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41786. */
  41787. static Canvas: Nullable<HTMLCanvasElement>;
  41788. private static _globalJoystickIndex;
  41789. private static vjCanvasContext;
  41790. private static vjCanvasWidth;
  41791. private static vjCanvasHeight;
  41792. private static halfWidth;
  41793. private _action;
  41794. private _axisTargetedByLeftAndRight;
  41795. private _axisTargetedByUpAndDown;
  41796. private _joystickSensibility;
  41797. private _inversedSensibility;
  41798. private _joystickPointerID;
  41799. private _joystickColor;
  41800. private _joystickPointerPos;
  41801. private _joystickPreviousPointerPos;
  41802. private _joystickPointerStartPos;
  41803. private _deltaJoystickVector;
  41804. private _leftJoystick;
  41805. private _touches;
  41806. private _onPointerDownHandlerRef;
  41807. private _onPointerMoveHandlerRef;
  41808. private _onPointerUpHandlerRef;
  41809. private _onResize;
  41810. /**
  41811. * Creates a new virtual joystick
  41812. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41813. */
  41814. constructor(leftJoystick?: boolean);
  41815. /**
  41816. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41817. * @param newJoystickSensibility defines the new sensibility
  41818. */
  41819. setJoystickSensibility(newJoystickSensibility: number): void;
  41820. private _onPointerDown;
  41821. private _onPointerMove;
  41822. private _onPointerUp;
  41823. /**
  41824. * Change the color of the virtual joystick
  41825. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41826. */
  41827. setJoystickColor(newColor: string): void;
  41828. /**
  41829. * Defines a callback to call when the joystick is touched
  41830. * @param action defines the callback
  41831. */
  41832. setActionOnTouch(action: () => any): void;
  41833. /**
  41834. * Defines which axis you'd like to control for left & right
  41835. * @param axis defines the axis to use
  41836. */
  41837. setAxisForLeftRight(axis: JoystickAxis): void;
  41838. /**
  41839. * Defines which axis you'd like to control for up & down
  41840. * @param axis defines the axis to use
  41841. */
  41842. setAxisForUpDown(axis: JoystickAxis): void;
  41843. private _drawVirtualJoystick;
  41844. /**
  41845. * Release internal HTML canvas
  41846. */
  41847. releaseCanvas(): void;
  41848. }
  41849. }
  41850. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41851. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41852. import { Nullable } from "babylonjs/types";
  41853. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41854. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41855. module "babylonjs/Cameras/freeCameraInputsManager" {
  41856. interface FreeCameraInputsManager {
  41857. /**
  41858. * Add virtual joystick input support to the input manager.
  41859. * @returns the current input manager
  41860. */
  41861. addVirtualJoystick(): FreeCameraInputsManager;
  41862. }
  41863. }
  41864. /**
  41865. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41867. */
  41868. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41869. /**
  41870. * Defines the camera the input is attached to.
  41871. */
  41872. camera: FreeCamera;
  41873. private _leftjoystick;
  41874. private _rightjoystick;
  41875. /**
  41876. * Gets the left stick of the virtual joystick.
  41877. * @returns The virtual Joystick
  41878. */
  41879. getLeftJoystick(): VirtualJoystick;
  41880. /**
  41881. * Gets the right stick of the virtual joystick.
  41882. * @returns The virtual Joystick
  41883. */
  41884. getRightJoystick(): VirtualJoystick;
  41885. /**
  41886. * Update the current camera state depending on the inputs that have been used this frame.
  41887. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41888. */
  41889. checkInputs(): void;
  41890. /**
  41891. * Attach the input controls to a specific dom element to get the input from.
  41892. * @param element Defines the element the controls should be listened from
  41893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41894. */
  41895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41896. /**
  41897. * Detach the current controls from the specified dom element.
  41898. * @param element Defines the element to stop listening the inputs from
  41899. */
  41900. detachControl(element: Nullable<HTMLElement>): void;
  41901. /**
  41902. * Gets the class name of the current intput.
  41903. * @returns the class name
  41904. */
  41905. getClassName(): string;
  41906. /**
  41907. * Get the friendly name associated with the input class.
  41908. * @returns the input friendly name
  41909. */
  41910. getSimpleName(): string;
  41911. }
  41912. }
  41913. declare module "babylonjs/Cameras/Inputs/index" {
  41914. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41915. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41916. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41917. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41918. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41919. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41920. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41921. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41922. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41923. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41924. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41925. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41926. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41927. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41928. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41929. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41930. }
  41931. declare module "babylonjs/Cameras/touchCamera" {
  41932. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41933. import { Scene } from "babylonjs/scene";
  41934. import { Vector3 } from "babylonjs/Maths/math.vector";
  41935. /**
  41936. * This represents a FPS type of camera controlled by touch.
  41937. * This is like a universal camera minus the Gamepad controls.
  41938. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41939. */
  41940. export class TouchCamera extends FreeCamera {
  41941. /**
  41942. * Defines the touch sensibility for rotation.
  41943. * The higher the faster.
  41944. */
  41945. get touchAngularSensibility(): number;
  41946. set touchAngularSensibility(value: number);
  41947. /**
  41948. * Defines the touch sensibility for move.
  41949. * The higher the faster.
  41950. */
  41951. get touchMoveSensibility(): number;
  41952. set touchMoveSensibility(value: number);
  41953. /**
  41954. * Instantiates a new touch camera.
  41955. * This represents a FPS type of camera controlled by touch.
  41956. * This is like a universal camera minus the Gamepad controls.
  41957. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41958. * @param name Define the name of the camera in the scene
  41959. * @param position Define the start position of the camera in the scene
  41960. * @param scene Define the scene the camera belongs to
  41961. */
  41962. constructor(name: string, position: Vector3, scene: Scene);
  41963. /**
  41964. * Gets the current object class name.
  41965. * @return the class name
  41966. */
  41967. getClassName(): string;
  41968. /** @hidden */
  41969. _setupInputs(): void;
  41970. }
  41971. }
  41972. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41974. import { Scene } from "babylonjs/scene";
  41975. import { Vector3 } from "babylonjs/Maths/math.vector";
  41976. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41977. import { Axis } from "babylonjs/Maths/math.axis";
  41978. /**
  41979. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41980. * being tilted forward or back and left or right.
  41981. */
  41982. export class DeviceOrientationCamera extends FreeCamera {
  41983. private _initialQuaternion;
  41984. private _quaternionCache;
  41985. private _tmpDragQuaternion;
  41986. private _disablePointerInputWhenUsingDeviceOrientation;
  41987. /**
  41988. * Creates a new device orientation camera
  41989. * @param name The name of the camera
  41990. * @param position The start position camera
  41991. * @param scene The scene the camera belongs to
  41992. */
  41993. constructor(name: string, position: Vector3, scene: Scene);
  41994. /**
  41995. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41996. */
  41997. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41998. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41999. private _dragFactor;
  42000. /**
  42001. * Enabled turning on the y axis when the orientation sensor is active
  42002. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42003. */
  42004. enableHorizontalDragging(dragFactor?: number): void;
  42005. /**
  42006. * Gets the current instance class name ("DeviceOrientationCamera").
  42007. * This helps avoiding instanceof at run time.
  42008. * @returns the class name
  42009. */
  42010. getClassName(): string;
  42011. /**
  42012. * @hidden
  42013. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42014. */
  42015. _checkInputs(): void;
  42016. /**
  42017. * Reset the camera to its default orientation on the specified axis only.
  42018. * @param axis The axis to reset
  42019. */
  42020. resetToCurrentRotation(axis?: Axis): void;
  42021. }
  42022. }
  42023. declare module "babylonjs/Gamepads/xboxGamepad" {
  42024. import { Observable } from "babylonjs/Misc/observable";
  42025. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42026. /**
  42027. * Defines supported buttons for XBox360 compatible gamepads
  42028. */
  42029. export enum Xbox360Button {
  42030. /** A */
  42031. A = 0,
  42032. /** B */
  42033. B = 1,
  42034. /** X */
  42035. X = 2,
  42036. /** Y */
  42037. Y = 3,
  42038. /** Start */
  42039. Start = 4,
  42040. /** Back */
  42041. Back = 5,
  42042. /** Left button */
  42043. LB = 6,
  42044. /** Right button */
  42045. RB = 7,
  42046. /** Left stick */
  42047. LeftStick = 8,
  42048. /** Right stick */
  42049. RightStick = 9
  42050. }
  42051. /** Defines values for XBox360 DPad */
  42052. export enum Xbox360Dpad {
  42053. /** Up */
  42054. Up = 0,
  42055. /** Down */
  42056. Down = 1,
  42057. /** Left */
  42058. Left = 2,
  42059. /** Right */
  42060. Right = 3
  42061. }
  42062. /**
  42063. * Defines a XBox360 gamepad
  42064. */
  42065. export class Xbox360Pad extends Gamepad {
  42066. private _leftTrigger;
  42067. private _rightTrigger;
  42068. private _onlefttriggerchanged;
  42069. private _onrighttriggerchanged;
  42070. private _onbuttondown;
  42071. private _onbuttonup;
  42072. private _ondpaddown;
  42073. private _ondpadup;
  42074. /** Observable raised when a button is pressed */
  42075. onButtonDownObservable: Observable<Xbox360Button>;
  42076. /** Observable raised when a button is released */
  42077. onButtonUpObservable: Observable<Xbox360Button>;
  42078. /** Observable raised when a pad is pressed */
  42079. onPadDownObservable: Observable<Xbox360Dpad>;
  42080. /** Observable raised when a pad is released */
  42081. onPadUpObservable: Observable<Xbox360Dpad>;
  42082. private _buttonA;
  42083. private _buttonB;
  42084. private _buttonX;
  42085. private _buttonY;
  42086. private _buttonBack;
  42087. private _buttonStart;
  42088. private _buttonLB;
  42089. private _buttonRB;
  42090. private _buttonLeftStick;
  42091. private _buttonRightStick;
  42092. private _dPadUp;
  42093. private _dPadDown;
  42094. private _dPadLeft;
  42095. private _dPadRight;
  42096. private _isXboxOnePad;
  42097. /**
  42098. * Creates a new XBox360 gamepad object
  42099. * @param id defines the id of this gamepad
  42100. * @param index defines its index
  42101. * @param gamepad defines the internal HTML gamepad object
  42102. * @param xboxOne defines if it is a XBox One gamepad
  42103. */
  42104. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42105. /**
  42106. * Defines the callback to call when left trigger is pressed
  42107. * @param callback defines the callback to use
  42108. */
  42109. onlefttriggerchanged(callback: (value: number) => void): void;
  42110. /**
  42111. * Defines the callback to call when right trigger is pressed
  42112. * @param callback defines the callback to use
  42113. */
  42114. onrighttriggerchanged(callback: (value: number) => void): void;
  42115. /**
  42116. * Gets the left trigger value
  42117. */
  42118. get leftTrigger(): number;
  42119. /**
  42120. * Sets the left trigger value
  42121. */
  42122. set leftTrigger(newValue: number);
  42123. /**
  42124. * Gets the right trigger value
  42125. */
  42126. get rightTrigger(): number;
  42127. /**
  42128. * Sets the right trigger value
  42129. */
  42130. set rightTrigger(newValue: number);
  42131. /**
  42132. * Defines the callback to call when a button is pressed
  42133. * @param callback defines the callback to use
  42134. */
  42135. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42136. /**
  42137. * Defines the callback to call when a button is released
  42138. * @param callback defines the callback to use
  42139. */
  42140. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42141. /**
  42142. * Defines the callback to call when a pad is pressed
  42143. * @param callback defines the callback to use
  42144. */
  42145. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42146. /**
  42147. * Defines the callback to call when a pad is released
  42148. * @param callback defines the callback to use
  42149. */
  42150. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42151. private _setButtonValue;
  42152. private _setDPadValue;
  42153. /**
  42154. * Gets the value of the `A` button
  42155. */
  42156. get buttonA(): number;
  42157. /**
  42158. * Sets the value of the `A` button
  42159. */
  42160. set buttonA(value: number);
  42161. /**
  42162. * Gets the value of the `B` button
  42163. */
  42164. get buttonB(): number;
  42165. /**
  42166. * Sets the value of the `B` button
  42167. */
  42168. set buttonB(value: number);
  42169. /**
  42170. * Gets the value of the `X` button
  42171. */
  42172. get buttonX(): number;
  42173. /**
  42174. * Sets the value of the `X` button
  42175. */
  42176. set buttonX(value: number);
  42177. /**
  42178. * Gets the value of the `Y` button
  42179. */
  42180. get buttonY(): number;
  42181. /**
  42182. * Sets the value of the `Y` button
  42183. */
  42184. set buttonY(value: number);
  42185. /**
  42186. * Gets the value of the `Start` button
  42187. */
  42188. get buttonStart(): number;
  42189. /**
  42190. * Sets the value of the `Start` button
  42191. */
  42192. set buttonStart(value: number);
  42193. /**
  42194. * Gets the value of the `Back` button
  42195. */
  42196. get buttonBack(): number;
  42197. /**
  42198. * Sets the value of the `Back` button
  42199. */
  42200. set buttonBack(value: number);
  42201. /**
  42202. * Gets the value of the `Left` button
  42203. */
  42204. get buttonLB(): number;
  42205. /**
  42206. * Sets the value of the `Left` button
  42207. */
  42208. set buttonLB(value: number);
  42209. /**
  42210. * Gets the value of the `Right` button
  42211. */
  42212. get buttonRB(): number;
  42213. /**
  42214. * Sets the value of the `Right` button
  42215. */
  42216. set buttonRB(value: number);
  42217. /**
  42218. * Gets the value of the Left joystick
  42219. */
  42220. get buttonLeftStick(): number;
  42221. /**
  42222. * Sets the value of the Left joystick
  42223. */
  42224. set buttonLeftStick(value: number);
  42225. /**
  42226. * Gets the value of the Right joystick
  42227. */
  42228. get buttonRightStick(): number;
  42229. /**
  42230. * Sets the value of the Right joystick
  42231. */
  42232. set buttonRightStick(value: number);
  42233. /**
  42234. * Gets the value of D-pad up
  42235. */
  42236. get dPadUp(): number;
  42237. /**
  42238. * Sets the value of D-pad up
  42239. */
  42240. set dPadUp(value: number);
  42241. /**
  42242. * Gets the value of D-pad down
  42243. */
  42244. get dPadDown(): number;
  42245. /**
  42246. * Sets the value of D-pad down
  42247. */
  42248. set dPadDown(value: number);
  42249. /**
  42250. * Gets the value of D-pad left
  42251. */
  42252. get dPadLeft(): number;
  42253. /**
  42254. * Sets the value of D-pad left
  42255. */
  42256. set dPadLeft(value: number);
  42257. /**
  42258. * Gets the value of D-pad right
  42259. */
  42260. get dPadRight(): number;
  42261. /**
  42262. * Sets the value of D-pad right
  42263. */
  42264. set dPadRight(value: number);
  42265. /**
  42266. * Force the gamepad to synchronize with device values
  42267. */
  42268. update(): void;
  42269. /**
  42270. * Disposes the gamepad
  42271. */
  42272. dispose(): void;
  42273. }
  42274. }
  42275. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42276. import { Observable } from "babylonjs/Misc/observable";
  42277. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42278. /**
  42279. * Defines supported buttons for DualShock compatible gamepads
  42280. */
  42281. export enum DualShockButton {
  42282. /** Cross */
  42283. Cross = 0,
  42284. /** Circle */
  42285. Circle = 1,
  42286. /** Square */
  42287. Square = 2,
  42288. /** Triangle */
  42289. Triangle = 3,
  42290. /** Options */
  42291. Options = 4,
  42292. /** Share */
  42293. Share = 5,
  42294. /** L1 */
  42295. L1 = 6,
  42296. /** R1 */
  42297. R1 = 7,
  42298. /** Left stick */
  42299. LeftStick = 8,
  42300. /** Right stick */
  42301. RightStick = 9
  42302. }
  42303. /** Defines values for DualShock DPad */
  42304. export enum DualShockDpad {
  42305. /** Up */
  42306. Up = 0,
  42307. /** Down */
  42308. Down = 1,
  42309. /** Left */
  42310. Left = 2,
  42311. /** Right */
  42312. Right = 3
  42313. }
  42314. /**
  42315. * Defines a DualShock gamepad
  42316. */
  42317. export class DualShockPad extends Gamepad {
  42318. private _leftTrigger;
  42319. private _rightTrigger;
  42320. private _onlefttriggerchanged;
  42321. private _onrighttriggerchanged;
  42322. private _onbuttondown;
  42323. private _onbuttonup;
  42324. private _ondpaddown;
  42325. private _ondpadup;
  42326. /** Observable raised when a button is pressed */
  42327. onButtonDownObservable: Observable<DualShockButton>;
  42328. /** Observable raised when a button is released */
  42329. onButtonUpObservable: Observable<DualShockButton>;
  42330. /** Observable raised when a pad is pressed */
  42331. onPadDownObservable: Observable<DualShockDpad>;
  42332. /** Observable raised when a pad is released */
  42333. onPadUpObservable: Observable<DualShockDpad>;
  42334. private _buttonCross;
  42335. private _buttonCircle;
  42336. private _buttonSquare;
  42337. private _buttonTriangle;
  42338. private _buttonShare;
  42339. private _buttonOptions;
  42340. private _buttonL1;
  42341. private _buttonR1;
  42342. private _buttonLeftStick;
  42343. private _buttonRightStick;
  42344. private _dPadUp;
  42345. private _dPadDown;
  42346. private _dPadLeft;
  42347. private _dPadRight;
  42348. /**
  42349. * Creates a new DualShock gamepad object
  42350. * @param id defines the id of this gamepad
  42351. * @param index defines its index
  42352. * @param gamepad defines the internal HTML gamepad object
  42353. */
  42354. constructor(id: string, index: number, gamepad: any);
  42355. /**
  42356. * Defines the callback to call when left trigger is pressed
  42357. * @param callback defines the callback to use
  42358. */
  42359. onlefttriggerchanged(callback: (value: number) => void): void;
  42360. /**
  42361. * Defines the callback to call when right trigger is pressed
  42362. * @param callback defines the callback to use
  42363. */
  42364. onrighttriggerchanged(callback: (value: number) => void): void;
  42365. /**
  42366. * Gets the left trigger value
  42367. */
  42368. get leftTrigger(): number;
  42369. /**
  42370. * Sets the left trigger value
  42371. */
  42372. set leftTrigger(newValue: number);
  42373. /**
  42374. * Gets the right trigger value
  42375. */
  42376. get rightTrigger(): number;
  42377. /**
  42378. * Sets the right trigger value
  42379. */
  42380. set rightTrigger(newValue: number);
  42381. /**
  42382. * Defines the callback to call when a button is pressed
  42383. * @param callback defines the callback to use
  42384. */
  42385. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42386. /**
  42387. * Defines the callback to call when a button is released
  42388. * @param callback defines the callback to use
  42389. */
  42390. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42391. /**
  42392. * Defines the callback to call when a pad is pressed
  42393. * @param callback defines the callback to use
  42394. */
  42395. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42396. /**
  42397. * Defines the callback to call when a pad is released
  42398. * @param callback defines the callback to use
  42399. */
  42400. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42401. private _setButtonValue;
  42402. private _setDPadValue;
  42403. /**
  42404. * Gets the value of the `Cross` button
  42405. */
  42406. get buttonCross(): number;
  42407. /**
  42408. * Sets the value of the `Cross` button
  42409. */
  42410. set buttonCross(value: number);
  42411. /**
  42412. * Gets the value of the `Circle` button
  42413. */
  42414. get buttonCircle(): number;
  42415. /**
  42416. * Sets the value of the `Circle` button
  42417. */
  42418. set buttonCircle(value: number);
  42419. /**
  42420. * Gets the value of the `Square` button
  42421. */
  42422. get buttonSquare(): number;
  42423. /**
  42424. * Sets the value of the `Square` button
  42425. */
  42426. set buttonSquare(value: number);
  42427. /**
  42428. * Gets the value of the `Triangle` button
  42429. */
  42430. get buttonTriangle(): number;
  42431. /**
  42432. * Sets the value of the `Triangle` button
  42433. */
  42434. set buttonTriangle(value: number);
  42435. /**
  42436. * Gets the value of the `Options` button
  42437. */
  42438. get buttonOptions(): number;
  42439. /**
  42440. * Sets the value of the `Options` button
  42441. */
  42442. set buttonOptions(value: number);
  42443. /**
  42444. * Gets the value of the `Share` button
  42445. */
  42446. get buttonShare(): number;
  42447. /**
  42448. * Sets the value of the `Share` button
  42449. */
  42450. set buttonShare(value: number);
  42451. /**
  42452. * Gets the value of the `L1` button
  42453. */
  42454. get buttonL1(): number;
  42455. /**
  42456. * Sets the value of the `L1` button
  42457. */
  42458. set buttonL1(value: number);
  42459. /**
  42460. * Gets the value of the `R1` button
  42461. */
  42462. get buttonR1(): number;
  42463. /**
  42464. * Sets the value of the `R1` button
  42465. */
  42466. set buttonR1(value: number);
  42467. /**
  42468. * Gets the value of the Left joystick
  42469. */
  42470. get buttonLeftStick(): number;
  42471. /**
  42472. * Sets the value of the Left joystick
  42473. */
  42474. set buttonLeftStick(value: number);
  42475. /**
  42476. * Gets the value of the Right joystick
  42477. */
  42478. get buttonRightStick(): number;
  42479. /**
  42480. * Sets the value of the Right joystick
  42481. */
  42482. set buttonRightStick(value: number);
  42483. /**
  42484. * Gets the value of D-pad up
  42485. */
  42486. get dPadUp(): number;
  42487. /**
  42488. * Sets the value of D-pad up
  42489. */
  42490. set dPadUp(value: number);
  42491. /**
  42492. * Gets the value of D-pad down
  42493. */
  42494. get dPadDown(): number;
  42495. /**
  42496. * Sets the value of D-pad down
  42497. */
  42498. set dPadDown(value: number);
  42499. /**
  42500. * Gets the value of D-pad left
  42501. */
  42502. get dPadLeft(): number;
  42503. /**
  42504. * Sets the value of D-pad left
  42505. */
  42506. set dPadLeft(value: number);
  42507. /**
  42508. * Gets the value of D-pad right
  42509. */
  42510. get dPadRight(): number;
  42511. /**
  42512. * Sets the value of D-pad right
  42513. */
  42514. set dPadRight(value: number);
  42515. /**
  42516. * Force the gamepad to synchronize with device values
  42517. */
  42518. update(): void;
  42519. /**
  42520. * Disposes the gamepad
  42521. */
  42522. dispose(): void;
  42523. }
  42524. }
  42525. declare module "babylonjs/Gamepads/gamepadManager" {
  42526. import { Observable } from "babylonjs/Misc/observable";
  42527. import { Nullable } from "babylonjs/types";
  42528. import { Scene } from "babylonjs/scene";
  42529. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42530. /**
  42531. * Manager for handling gamepads
  42532. */
  42533. export class GamepadManager {
  42534. private _scene?;
  42535. private _babylonGamepads;
  42536. private _oneGamepadConnected;
  42537. /** @hidden */
  42538. _isMonitoring: boolean;
  42539. private _gamepadEventSupported;
  42540. private _gamepadSupport?;
  42541. /**
  42542. * observable to be triggered when the gamepad controller has been connected
  42543. */
  42544. onGamepadConnectedObservable: Observable<Gamepad>;
  42545. /**
  42546. * observable to be triggered when the gamepad controller has been disconnected
  42547. */
  42548. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42549. private _onGamepadConnectedEvent;
  42550. private _onGamepadDisconnectedEvent;
  42551. /**
  42552. * Initializes the gamepad manager
  42553. * @param _scene BabylonJS scene
  42554. */
  42555. constructor(_scene?: Scene | undefined);
  42556. /**
  42557. * The gamepads in the game pad manager
  42558. */
  42559. get gamepads(): Gamepad[];
  42560. /**
  42561. * Get the gamepad controllers based on type
  42562. * @param type The type of gamepad controller
  42563. * @returns Nullable gamepad
  42564. */
  42565. getGamepadByType(type?: number): Nullable<Gamepad>;
  42566. /**
  42567. * Disposes the gamepad manager
  42568. */
  42569. dispose(): void;
  42570. private _addNewGamepad;
  42571. private _startMonitoringGamepads;
  42572. private _stopMonitoringGamepads;
  42573. /** @hidden */
  42574. _checkGamepadsStatus(): void;
  42575. private _updateGamepadObjects;
  42576. }
  42577. }
  42578. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42579. import { Nullable } from "babylonjs/types";
  42580. import { Scene } from "babylonjs/scene";
  42581. import { ISceneComponent } from "babylonjs/sceneComponent";
  42582. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42583. module "babylonjs/scene" {
  42584. interface Scene {
  42585. /** @hidden */
  42586. _gamepadManager: Nullable<GamepadManager>;
  42587. /**
  42588. * Gets the gamepad manager associated with the scene
  42589. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42590. */
  42591. gamepadManager: GamepadManager;
  42592. }
  42593. }
  42594. module "babylonjs/Cameras/freeCameraInputsManager" {
  42595. /**
  42596. * Interface representing a free camera inputs manager
  42597. */
  42598. interface FreeCameraInputsManager {
  42599. /**
  42600. * Adds gamepad input support to the FreeCameraInputsManager.
  42601. * @returns the FreeCameraInputsManager
  42602. */
  42603. addGamepad(): FreeCameraInputsManager;
  42604. }
  42605. }
  42606. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42607. /**
  42608. * Interface representing an arc rotate camera inputs manager
  42609. */
  42610. interface ArcRotateCameraInputsManager {
  42611. /**
  42612. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42613. * @returns the camera inputs manager
  42614. */
  42615. addGamepad(): ArcRotateCameraInputsManager;
  42616. }
  42617. }
  42618. /**
  42619. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42620. */
  42621. export class GamepadSystemSceneComponent implements ISceneComponent {
  42622. /**
  42623. * The component name helpfull to identify the component in the list of scene components.
  42624. */
  42625. readonly name: string;
  42626. /**
  42627. * The scene the component belongs to.
  42628. */
  42629. scene: Scene;
  42630. /**
  42631. * Creates a new instance of the component for the given scene
  42632. * @param scene Defines the scene to register the component in
  42633. */
  42634. constructor(scene: Scene);
  42635. /**
  42636. * Registers the component in a given scene
  42637. */
  42638. register(): void;
  42639. /**
  42640. * Rebuilds the elements related to this component in case of
  42641. * context lost for instance.
  42642. */
  42643. rebuild(): void;
  42644. /**
  42645. * Disposes the component and the associated ressources
  42646. */
  42647. dispose(): void;
  42648. private _beforeCameraUpdate;
  42649. }
  42650. }
  42651. declare module "babylonjs/Cameras/universalCamera" {
  42652. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42653. import { Scene } from "babylonjs/scene";
  42654. import { Vector3 } from "babylonjs/Maths/math.vector";
  42655. import "babylonjs/Gamepads/gamepadSceneComponent";
  42656. /**
  42657. * 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,
  42658. * which still works and will still be found in many Playgrounds.
  42659. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42660. */
  42661. export class UniversalCamera extends TouchCamera {
  42662. /**
  42663. * Defines the gamepad rotation sensiblity.
  42664. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42665. */
  42666. get gamepadAngularSensibility(): number;
  42667. set gamepadAngularSensibility(value: number);
  42668. /**
  42669. * Defines the gamepad move sensiblity.
  42670. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42671. */
  42672. get gamepadMoveSensibility(): number;
  42673. set gamepadMoveSensibility(value: number);
  42674. /**
  42675. * 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,
  42676. * which still works and will still be found in many Playgrounds.
  42677. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42678. * @param name Define the name of the camera in the scene
  42679. * @param position Define the start position of the camera in the scene
  42680. * @param scene Define the scene the camera belongs to
  42681. */
  42682. constructor(name: string, position: Vector3, scene: Scene);
  42683. /**
  42684. * Gets the current object class name.
  42685. * @return the class name
  42686. */
  42687. getClassName(): string;
  42688. }
  42689. }
  42690. declare module "babylonjs/Cameras/gamepadCamera" {
  42691. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42692. import { Scene } from "babylonjs/scene";
  42693. import { Vector3 } from "babylonjs/Maths/math.vector";
  42694. /**
  42695. * This represents a FPS type of camera. This is only here for back compat purpose.
  42696. * Please use the UniversalCamera instead as both are identical.
  42697. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42698. */
  42699. export class GamepadCamera extends UniversalCamera {
  42700. /**
  42701. * Instantiates a new Gamepad Camera
  42702. * This represents a FPS type of camera. This is only here for back compat purpose.
  42703. * Please use the UniversalCamera instead as both are identical.
  42704. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42705. * @param name Define the name of the camera in the scene
  42706. * @param position Define the start position of the camera in the scene
  42707. * @param scene Define the scene the camera belongs to
  42708. */
  42709. constructor(name: string, position: Vector3, scene: Scene);
  42710. /**
  42711. * Gets the current object class name.
  42712. * @return the class name
  42713. */
  42714. getClassName(): string;
  42715. }
  42716. }
  42717. declare module "babylonjs/Shaders/pass.fragment" {
  42718. /** @hidden */
  42719. export var passPixelShader: {
  42720. name: string;
  42721. shader: string;
  42722. };
  42723. }
  42724. declare module "babylonjs/Shaders/passCube.fragment" {
  42725. /** @hidden */
  42726. export var passCubePixelShader: {
  42727. name: string;
  42728. shader: string;
  42729. };
  42730. }
  42731. declare module "babylonjs/PostProcesses/passPostProcess" {
  42732. import { Nullable } from "babylonjs/types";
  42733. import { Camera } from "babylonjs/Cameras/camera";
  42734. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42735. import { Engine } from "babylonjs/Engines/engine";
  42736. import "babylonjs/Shaders/pass.fragment";
  42737. import "babylonjs/Shaders/passCube.fragment";
  42738. /**
  42739. * PassPostProcess which produces an output the same as it's input
  42740. */
  42741. export class PassPostProcess extends PostProcess {
  42742. /**
  42743. * Creates the PassPostProcess
  42744. * @param name The name of the effect.
  42745. * @param options The required width/height ratio to downsize to before computing the render pass.
  42746. * @param camera The camera to apply the render pass to.
  42747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42748. * @param engine The engine which the post process will be applied. (default: current engine)
  42749. * @param reusable If the post process can be reused on the same frame. (default: false)
  42750. * @param textureType The type of texture to be used when performing the post processing.
  42751. * @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)
  42752. */
  42753. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42754. }
  42755. /**
  42756. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42757. */
  42758. export class PassCubePostProcess extends PostProcess {
  42759. private _face;
  42760. /**
  42761. * Gets or sets the cube face to display.
  42762. * * 0 is +X
  42763. * * 1 is -X
  42764. * * 2 is +Y
  42765. * * 3 is -Y
  42766. * * 4 is +Z
  42767. * * 5 is -Z
  42768. */
  42769. get face(): number;
  42770. set face(value: number);
  42771. /**
  42772. * Creates the PassCubePostProcess
  42773. * @param name The name of the effect.
  42774. * @param options The required width/height ratio to downsize to before computing the render pass.
  42775. * @param camera The camera to apply the render pass to.
  42776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42777. * @param engine The engine which the post process will be applied. (default: current engine)
  42778. * @param reusable If the post process can be reused on the same frame. (default: false)
  42779. * @param textureType The type of texture to be used when performing the post processing.
  42780. * @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)
  42781. */
  42782. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42783. }
  42784. }
  42785. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42786. /** @hidden */
  42787. export var anaglyphPixelShader: {
  42788. name: string;
  42789. shader: string;
  42790. };
  42791. }
  42792. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42793. import { Engine } from "babylonjs/Engines/engine";
  42794. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42795. import { Camera } from "babylonjs/Cameras/camera";
  42796. import "babylonjs/Shaders/anaglyph.fragment";
  42797. /**
  42798. * Postprocess used to generate anaglyphic rendering
  42799. */
  42800. export class AnaglyphPostProcess extends PostProcess {
  42801. private _passedProcess;
  42802. /**
  42803. * Creates a new AnaglyphPostProcess
  42804. * @param name defines postprocess name
  42805. * @param options defines creation options or target ratio scale
  42806. * @param rigCameras defines cameras using this postprocess
  42807. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42808. * @param engine defines hosting engine
  42809. * @param reusable defines if the postprocess will be reused multiple times per frame
  42810. */
  42811. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42812. }
  42813. }
  42814. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42815. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42816. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42817. import { Scene } from "babylonjs/scene";
  42818. import { Vector3 } from "babylonjs/Maths/math.vector";
  42819. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42820. /**
  42821. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42822. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42823. */
  42824. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42825. /**
  42826. * Creates a new AnaglyphArcRotateCamera
  42827. * @param name defines camera name
  42828. * @param alpha defines alpha angle (in radians)
  42829. * @param beta defines beta angle (in radians)
  42830. * @param radius defines radius
  42831. * @param target defines camera target
  42832. * @param interaxialDistance defines distance between each color axis
  42833. * @param scene defines the hosting scene
  42834. */
  42835. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42836. /**
  42837. * Gets camera class name
  42838. * @returns AnaglyphArcRotateCamera
  42839. */
  42840. getClassName(): string;
  42841. }
  42842. }
  42843. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42844. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42845. import { Scene } from "babylonjs/scene";
  42846. import { Vector3 } from "babylonjs/Maths/math.vector";
  42847. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42848. /**
  42849. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42850. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42851. */
  42852. export class AnaglyphFreeCamera extends FreeCamera {
  42853. /**
  42854. * Creates a new AnaglyphFreeCamera
  42855. * @param name defines camera name
  42856. * @param position defines initial position
  42857. * @param interaxialDistance defines distance between each color axis
  42858. * @param scene defines the hosting scene
  42859. */
  42860. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42861. /**
  42862. * Gets camera class name
  42863. * @returns AnaglyphFreeCamera
  42864. */
  42865. getClassName(): string;
  42866. }
  42867. }
  42868. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42869. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42870. import { Scene } from "babylonjs/scene";
  42871. import { Vector3 } from "babylonjs/Maths/math.vector";
  42872. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42873. /**
  42874. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42875. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42876. */
  42877. export class AnaglyphGamepadCamera extends GamepadCamera {
  42878. /**
  42879. * Creates a new AnaglyphGamepadCamera
  42880. * @param name defines camera name
  42881. * @param position defines initial position
  42882. * @param interaxialDistance defines distance between each color axis
  42883. * @param scene defines the hosting scene
  42884. */
  42885. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42886. /**
  42887. * Gets camera class name
  42888. * @returns AnaglyphGamepadCamera
  42889. */
  42890. getClassName(): string;
  42891. }
  42892. }
  42893. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42894. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42895. import { Scene } from "babylonjs/scene";
  42896. import { Vector3 } from "babylonjs/Maths/math.vector";
  42897. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42898. /**
  42899. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42900. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42901. */
  42902. export class AnaglyphUniversalCamera extends UniversalCamera {
  42903. /**
  42904. * Creates a new AnaglyphUniversalCamera
  42905. * @param name defines camera name
  42906. * @param position defines initial position
  42907. * @param interaxialDistance defines distance between each color axis
  42908. * @param scene defines the hosting scene
  42909. */
  42910. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42911. /**
  42912. * Gets camera class name
  42913. * @returns AnaglyphUniversalCamera
  42914. */
  42915. getClassName(): string;
  42916. }
  42917. }
  42918. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42919. /** @hidden */
  42920. export var stereoscopicInterlacePixelShader: {
  42921. name: string;
  42922. shader: string;
  42923. };
  42924. }
  42925. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42926. import { Camera } from "babylonjs/Cameras/camera";
  42927. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42928. import { Engine } from "babylonjs/Engines/engine";
  42929. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42930. /**
  42931. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42932. */
  42933. export class StereoscopicInterlacePostProcess extends PostProcess {
  42934. private _stepSize;
  42935. private _passedProcess;
  42936. /**
  42937. * Initializes a StereoscopicInterlacePostProcess
  42938. * @param name The name of the effect.
  42939. * @param rigCameras The rig cameras to be appled to the post process
  42940. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42942. * @param engine The engine which the post process will be applied. (default: current engine)
  42943. * @param reusable If the post process can be reused on the same frame. (default: false)
  42944. */
  42945. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42946. }
  42947. }
  42948. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42949. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42950. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42951. import { Scene } from "babylonjs/scene";
  42952. import { Vector3 } from "babylonjs/Maths/math.vector";
  42953. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42954. /**
  42955. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42956. * @see http://doc.babylonjs.com/features/cameras
  42957. */
  42958. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42959. /**
  42960. * Creates a new StereoscopicArcRotateCamera
  42961. * @param name defines camera name
  42962. * @param alpha defines alpha angle (in radians)
  42963. * @param beta defines beta angle (in radians)
  42964. * @param radius defines radius
  42965. * @param target defines camera target
  42966. * @param interaxialDistance defines distance between each color axis
  42967. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42968. * @param scene defines the hosting scene
  42969. */
  42970. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42971. /**
  42972. * Gets camera class name
  42973. * @returns StereoscopicArcRotateCamera
  42974. */
  42975. getClassName(): string;
  42976. }
  42977. }
  42978. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42979. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42980. import { Scene } from "babylonjs/scene";
  42981. import { Vector3 } from "babylonjs/Maths/math.vector";
  42982. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42983. /**
  42984. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42985. * @see http://doc.babylonjs.com/features/cameras
  42986. */
  42987. export class StereoscopicFreeCamera extends FreeCamera {
  42988. /**
  42989. * Creates a new StereoscopicFreeCamera
  42990. * @param name defines camera name
  42991. * @param position defines initial position
  42992. * @param interaxialDistance defines distance between each color axis
  42993. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42994. * @param scene defines the hosting scene
  42995. */
  42996. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42997. /**
  42998. * Gets camera class name
  42999. * @returns StereoscopicFreeCamera
  43000. */
  43001. getClassName(): string;
  43002. }
  43003. }
  43004. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43005. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43006. import { Scene } from "babylonjs/scene";
  43007. import { Vector3 } from "babylonjs/Maths/math.vector";
  43008. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43009. /**
  43010. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43011. * @see http://doc.babylonjs.com/features/cameras
  43012. */
  43013. export class StereoscopicGamepadCamera extends GamepadCamera {
  43014. /**
  43015. * Creates a new StereoscopicGamepadCamera
  43016. * @param name defines camera name
  43017. * @param position defines initial position
  43018. * @param interaxialDistance defines distance between each color axis
  43019. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43020. * @param scene defines the hosting scene
  43021. */
  43022. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43023. /**
  43024. * Gets camera class name
  43025. * @returns StereoscopicGamepadCamera
  43026. */
  43027. getClassName(): string;
  43028. }
  43029. }
  43030. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43031. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43032. import { Scene } from "babylonjs/scene";
  43033. import { Vector3 } from "babylonjs/Maths/math.vector";
  43034. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43035. /**
  43036. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43037. * @see http://doc.babylonjs.com/features/cameras
  43038. */
  43039. export class StereoscopicUniversalCamera extends UniversalCamera {
  43040. /**
  43041. * Creates a new StereoscopicUniversalCamera
  43042. * @param name defines camera name
  43043. * @param position defines initial position
  43044. * @param interaxialDistance defines distance between each color axis
  43045. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43046. * @param scene defines the hosting scene
  43047. */
  43048. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43049. /**
  43050. * Gets camera class name
  43051. * @returns StereoscopicUniversalCamera
  43052. */
  43053. getClassName(): string;
  43054. }
  43055. }
  43056. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43057. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43058. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43059. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43060. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43061. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43062. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43063. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43064. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43065. }
  43066. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43067. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43068. import { Scene } from "babylonjs/scene";
  43069. import { Vector3 } from "babylonjs/Maths/math.vector";
  43070. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43071. /**
  43072. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43073. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43074. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43075. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43076. */
  43077. export class VirtualJoysticksCamera extends FreeCamera {
  43078. /**
  43079. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43080. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43081. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43082. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43083. * @param name Define the name of the camera in the scene
  43084. * @param position Define the start position of the camera in the scene
  43085. * @param scene Define the scene the camera belongs to
  43086. */
  43087. constructor(name: string, position: Vector3, scene: Scene);
  43088. /**
  43089. * Gets the current object class name.
  43090. * @return the class name
  43091. */
  43092. getClassName(): string;
  43093. }
  43094. }
  43095. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43096. import { Matrix } from "babylonjs/Maths/math.vector";
  43097. /**
  43098. * This represents all the required metrics to create a VR camera.
  43099. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43100. */
  43101. export class VRCameraMetrics {
  43102. /**
  43103. * Define the horizontal resolution off the screen.
  43104. */
  43105. hResolution: number;
  43106. /**
  43107. * Define the vertical resolution off the screen.
  43108. */
  43109. vResolution: number;
  43110. /**
  43111. * Define the horizontal screen size.
  43112. */
  43113. hScreenSize: number;
  43114. /**
  43115. * Define the vertical screen size.
  43116. */
  43117. vScreenSize: number;
  43118. /**
  43119. * Define the vertical screen center position.
  43120. */
  43121. vScreenCenter: number;
  43122. /**
  43123. * Define the distance of the eyes to the screen.
  43124. */
  43125. eyeToScreenDistance: number;
  43126. /**
  43127. * Define the distance between both lenses
  43128. */
  43129. lensSeparationDistance: number;
  43130. /**
  43131. * Define the distance between both viewer's eyes.
  43132. */
  43133. interpupillaryDistance: number;
  43134. /**
  43135. * Define the distortion factor of the VR postprocess.
  43136. * Please, touch with care.
  43137. */
  43138. distortionK: number[];
  43139. /**
  43140. * Define the chromatic aberration correction factors for the VR post process.
  43141. */
  43142. chromaAbCorrection: number[];
  43143. /**
  43144. * Define the scale factor of the post process.
  43145. * The smaller the better but the slower.
  43146. */
  43147. postProcessScaleFactor: number;
  43148. /**
  43149. * Define an offset for the lens center.
  43150. */
  43151. lensCenterOffset: number;
  43152. /**
  43153. * Define if the current vr camera should compensate the distortion of the lense or not.
  43154. */
  43155. compensateDistortion: boolean;
  43156. /**
  43157. * Defines if multiview should be enabled when rendering (Default: false)
  43158. */
  43159. multiviewEnabled: boolean;
  43160. /**
  43161. * Gets the rendering aspect ratio based on the provided resolutions.
  43162. */
  43163. get aspectRatio(): number;
  43164. /**
  43165. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43166. */
  43167. get aspectRatioFov(): number;
  43168. /**
  43169. * @hidden
  43170. */
  43171. get leftHMatrix(): Matrix;
  43172. /**
  43173. * @hidden
  43174. */
  43175. get rightHMatrix(): Matrix;
  43176. /**
  43177. * @hidden
  43178. */
  43179. get leftPreViewMatrix(): Matrix;
  43180. /**
  43181. * @hidden
  43182. */
  43183. get rightPreViewMatrix(): Matrix;
  43184. /**
  43185. * Get the default VRMetrics based on the most generic setup.
  43186. * @returns the default vr metrics
  43187. */
  43188. static GetDefault(): VRCameraMetrics;
  43189. }
  43190. }
  43191. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43192. /** @hidden */
  43193. export var vrDistortionCorrectionPixelShader: {
  43194. name: string;
  43195. shader: string;
  43196. };
  43197. }
  43198. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43199. import { Camera } from "babylonjs/Cameras/camera";
  43200. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43201. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43202. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43203. /**
  43204. * VRDistortionCorrectionPostProcess used for mobile VR
  43205. */
  43206. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43207. private _isRightEye;
  43208. private _distortionFactors;
  43209. private _postProcessScaleFactor;
  43210. private _lensCenterOffset;
  43211. private _scaleIn;
  43212. private _scaleFactor;
  43213. private _lensCenter;
  43214. /**
  43215. * Initializes the VRDistortionCorrectionPostProcess
  43216. * @param name The name of the effect.
  43217. * @param camera The camera to apply the render pass to.
  43218. * @param isRightEye If this is for the right eye distortion
  43219. * @param vrMetrics All the required metrics for the VR camera
  43220. */
  43221. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43222. }
  43223. }
  43224. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43225. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43226. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43227. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43228. import { Scene } from "babylonjs/scene";
  43229. import { Vector3 } from "babylonjs/Maths/math.vector";
  43230. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43231. import "babylonjs/Cameras/RigModes/vrRigMode";
  43232. /**
  43233. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43234. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43235. */
  43236. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43237. /**
  43238. * Creates a new VRDeviceOrientationArcRotateCamera
  43239. * @param name defines camera name
  43240. * @param alpha defines the camera rotation along the logitudinal axis
  43241. * @param beta defines the camera rotation along the latitudinal axis
  43242. * @param radius defines the camera distance from its target
  43243. * @param target defines the camera target
  43244. * @param scene defines the scene the camera belongs to
  43245. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43246. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43247. */
  43248. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43249. /**
  43250. * Gets camera class name
  43251. * @returns VRDeviceOrientationArcRotateCamera
  43252. */
  43253. getClassName(): string;
  43254. }
  43255. }
  43256. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43257. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43258. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43259. import { Scene } from "babylonjs/scene";
  43260. import { Vector3 } from "babylonjs/Maths/math.vector";
  43261. import "babylonjs/Cameras/RigModes/vrRigMode";
  43262. /**
  43263. * Camera used to simulate VR rendering (based on FreeCamera)
  43264. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43265. */
  43266. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43267. /**
  43268. * Creates a new VRDeviceOrientationFreeCamera
  43269. * @param name defines camera name
  43270. * @param position defines the start position of the camera
  43271. * @param scene defines the scene the camera belongs to
  43272. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43273. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43274. */
  43275. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43276. /**
  43277. * Gets camera class name
  43278. * @returns VRDeviceOrientationFreeCamera
  43279. */
  43280. getClassName(): string;
  43281. }
  43282. }
  43283. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43284. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43285. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43286. import { Scene } from "babylonjs/scene";
  43287. import { Vector3 } from "babylonjs/Maths/math.vector";
  43288. import "babylonjs/Gamepads/gamepadSceneComponent";
  43289. /**
  43290. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43291. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43292. */
  43293. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43294. /**
  43295. * Creates a new VRDeviceOrientationGamepadCamera
  43296. * @param name defines camera name
  43297. * @param position defines the start position of the camera
  43298. * @param scene defines the scene the camera belongs to
  43299. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43300. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43301. */
  43302. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43303. /**
  43304. * Gets camera class name
  43305. * @returns VRDeviceOrientationGamepadCamera
  43306. */
  43307. getClassName(): string;
  43308. }
  43309. }
  43310. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43311. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43312. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43313. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43314. /** @hidden */
  43315. export var imageProcessingPixelShader: {
  43316. name: string;
  43317. shader: string;
  43318. };
  43319. }
  43320. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43321. import { Nullable } from "babylonjs/types";
  43322. import { Color4 } from "babylonjs/Maths/math.color";
  43323. import { Camera } from "babylonjs/Cameras/camera";
  43324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43325. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43326. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43327. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43328. import { Engine } from "babylonjs/Engines/engine";
  43329. import "babylonjs/Shaders/imageProcessing.fragment";
  43330. import "babylonjs/Shaders/postprocess.vertex";
  43331. /**
  43332. * ImageProcessingPostProcess
  43333. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43334. */
  43335. export class ImageProcessingPostProcess extends PostProcess {
  43336. /**
  43337. * Default configuration related to image processing available in the PBR Material.
  43338. */
  43339. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43340. /**
  43341. * Gets the image processing configuration used either in this material.
  43342. */
  43343. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43344. /**
  43345. * Sets the Default image processing configuration used either in the this material.
  43346. *
  43347. * If sets to null, the scene one is in use.
  43348. */
  43349. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43350. /**
  43351. * Keep track of the image processing observer to allow dispose and replace.
  43352. */
  43353. private _imageProcessingObserver;
  43354. /**
  43355. * Attaches a new image processing configuration to the PBR Material.
  43356. * @param configuration
  43357. */
  43358. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43359. /**
  43360. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43361. */
  43362. get colorCurves(): Nullable<ColorCurves>;
  43363. /**
  43364. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43365. */
  43366. set colorCurves(value: Nullable<ColorCurves>);
  43367. /**
  43368. * Gets wether the color curves effect is enabled.
  43369. */
  43370. get colorCurvesEnabled(): boolean;
  43371. /**
  43372. * Sets wether the color curves effect is enabled.
  43373. */
  43374. set colorCurvesEnabled(value: boolean);
  43375. /**
  43376. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43377. */
  43378. get colorGradingTexture(): Nullable<BaseTexture>;
  43379. /**
  43380. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43381. */
  43382. set colorGradingTexture(value: Nullable<BaseTexture>);
  43383. /**
  43384. * Gets wether the color grading effect is enabled.
  43385. */
  43386. get colorGradingEnabled(): boolean;
  43387. /**
  43388. * Gets wether the color grading effect is enabled.
  43389. */
  43390. set colorGradingEnabled(value: boolean);
  43391. /**
  43392. * Gets exposure used in the effect.
  43393. */
  43394. get exposure(): number;
  43395. /**
  43396. * Sets exposure used in the effect.
  43397. */
  43398. set exposure(value: number);
  43399. /**
  43400. * Gets wether tonemapping is enabled or not.
  43401. */
  43402. get toneMappingEnabled(): boolean;
  43403. /**
  43404. * Sets wether tonemapping is enabled or not
  43405. */
  43406. set toneMappingEnabled(value: boolean);
  43407. /**
  43408. * Gets the type of tone mapping effect.
  43409. */
  43410. get toneMappingType(): number;
  43411. /**
  43412. * Sets the type of tone mapping effect.
  43413. */
  43414. set toneMappingType(value: number);
  43415. /**
  43416. * Gets contrast used in the effect.
  43417. */
  43418. get contrast(): number;
  43419. /**
  43420. * Sets contrast used in the effect.
  43421. */
  43422. set contrast(value: number);
  43423. /**
  43424. * Gets Vignette stretch size.
  43425. */
  43426. get vignetteStretch(): number;
  43427. /**
  43428. * Sets Vignette stretch size.
  43429. */
  43430. set vignetteStretch(value: number);
  43431. /**
  43432. * Gets Vignette centre X Offset.
  43433. */
  43434. get vignetteCentreX(): number;
  43435. /**
  43436. * Sets Vignette centre X Offset.
  43437. */
  43438. set vignetteCentreX(value: number);
  43439. /**
  43440. * Gets Vignette centre Y Offset.
  43441. */
  43442. get vignetteCentreY(): number;
  43443. /**
  43444. * Sets Vignette centre Y Offset.
  43445. */
  43446. set vignetteCentreY(value: number);
  43447. /**
  43448. * Gets Vignette weight or intensity of the vignette effect.
  43449. */
  43450. get vignetteWeight(): number;
  43451. /**
  43452. * Sets Vignette weight or intensity of the vignette effect.
  43453. */
  43454. set vignetteWeight(value: number);
  43455. /**
  43456. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43457. * if vignetteEnabled is set to true.
  43458. */
  43459. get vignetteColor(): Color4;
  43460. /**
  43461. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43462. * if vignetteEnabled is set to true.
  43463. */
  43464. set vignetteColor(value: Color4);
  43465. /**
  43466. * Gets Camera field of view used by the Vignette effect.
  43467. */
  43468. get vignetteCameraFov(): number;
  43469. /**
  43470. * Sets Camera field of view used by the Vignette effect.
  43471. */
  43472. set vignetteCameraFov(value: number);
  43473. /**
  43474. * Gets the vignette blend mode allowing different kind of effect.
  43475. */
  43476. get vignetteBlendMode(): number;
  43477. /**
  43478. * Sets the vignette blend mode allowing different kind of effect.
  43479. */
  43480. set vignetteBlendMode(value: number);
  43481. /**
  43482. * Gets wether the vignette effect is enabled.
  43483. */
  43484. get vignetteEnabled(): boolean;
  43485. /**
  43486. * Sets wether the vignette effect is enabled.
  43487. */
  43488. set vignetteEnabled(value: boolean);
  43489. private _fromLinearSpace;
  43490. /**
  43491. * Gets wether the input of the processing is in Gamma or Linear Space.
  43492. */
  43493. get fromLinearSpace(): boolean;
  43494. /**
  43495. * Sets wether the input of the processing is in Gamma or Linear Space.
  43496. */
  43497. set fromLinearSpace(value: boolean);
  43498. /**
  43499. * Defines cache preventing GC.
  43500. */
  43501. private _defines;
  43502. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43503. /**
  43504. * "ImageProcessingPostProcess"
  43505. * @returns "ImageProcessingPostProcess"
  43506. */
  43507. getClassName(): string;
  43508. protected _updateParameters(): void;
  43509. dispose(camera?: Camera): void;
  43510. }
  43511. }
  43512. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43513. import { Scene } from "babylonjs/scene";
  43514. import { Color3 } from "babylonjs/Maths/math.color";
  43515. import { Mesh } from "babylonjs/Meshes/mesh";
  43516. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43517. import { Nullable } from "babylonjs/types";
  43518. /**
  43519. * Class containing static functions to help procedurally build meshes
  43520. */
  43521. export class GroundBuilder {
  43522. /**
  43523. * Creates a ground mesh
  43524. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43525. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43527. * @param name defines the name of the mesh
  43528. * @param options defines the options used to create the mesh
  43529. * @param scene defines the hosting scene
  43530. * @returns the ground mesh
  43531. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43532. */
  43533. static CreateGround(name: string, options: {
  43534. width?: number;
  43535. height?: number;
  43536. subdivisions?: number;
  43537. subdivisionsX?: number;
  43538. subdivisionsY?: number;
  43539. updatable?: boolean;
  43540. }, scene: any): Mesh;
  43541. /**
  43542. * Creates a tiled ground mesh
  43543. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43544. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43545. * * 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
  43546. * * 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
  43547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43548. * @param name defines the name of the mesh
  43549. * @param options defines the options used to create the mesh
  43550. * @param scene defines the hosting scene
  43551. * @returns the tiled ground mesh
  43552. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43553. */
  43554. static CreateTiledGround(name: string, options: {
  43555. xmin: number;
  43556. zmin: number;
  43557. xmax: number;
  43558. zmax: number;
  43559. subdivisions?: {
  43560. w: number;
  43561. h: number;
  43562. };
  43563. precision?: {
  43564. w: number;
  43565. h: number;
  43566. };
  43567. updatable?: boolean;
  43568. }, scene?: Nullable<Scene>): Mesh;
  43569. /**
  43570. * Creates a ground mesh from a height map
  43571. * * The parameter `url` sets the URL of the height map image resource.
  43572. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43573. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43574. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43575. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43576. * * 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.
  43577. * * 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).
  43578. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43580. * @param name defines the name of the mesh
  43581. * @param url defines the url to the height map
  43582. * @param options defines the options used to create the mesh
  43583. * @param scene defines the hosting scene
  43584. * @returns the ground mesh
  43585. * @see https://doc.babylonjs.com/babylon101/height_map
  43586. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43587. */
  43588. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43589. width?: number;
  43590. height?: number;
  43591. subdivisions?: number;
  43592. minHeight?: number;
  43593. maxHeight?: number;
  43594. colorFilter?: Color3;
  43595. alphaFilter?: number;
  43596. updatable?: boolean;
  43597. onReady?: (mesh: GroundMesh) => void;
  43598. }, scene?: Nullable<Scene>): GroundMesh;
  43599. }
  43600. }
  43601. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43602. import { Vector4 } from "babylonjs/Maths/math.vector";
  43603. import { Mesh } from "babylonjs/Meshes/mesh";
  43604. /**
  43605. * Class containing static functions to help procedurally build meshes
  43606. */
  43607. export class TorusBuilder {
  43608. /**
  43609. * Creates a torus mesh
  43610. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43611. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43612. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43616. * @param name defines the name of the mesh
  43617. * @param options defines the options used to create the mesh
  43618. * @param scene defines the hosting scene
  43619. * @returns the torus mesh
  43620. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43621. */
  43622. static CreateTorus(name: string, options: {
  43623. diameter?: number;
  43624. thickness?: number;
  43625. tessellation?: number;
  43626. updatable?: boolean;
  43627. sideOrientation?: number;
  43628. frontUVs?: Vector4;
  43629. backUVs?: Vector4;
  43630. }, scene: any): Mesh;
  43631. }
  43632. }
  43633. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43634. import { Vector4 } from "babylonjs/Maths/math.vector";
  43635. import { Color4 } from "babylonjs/Maths/math.color";
  43636. import { Mesh } from "babylonjs/Meshes/mesh";
  43637. /**
  43638. * Class containing static functions to help procedurally build meshes
  43639. */
  43640. export class CylinderBuilder {
  43641. /**
  43642. * Creates a cylinder or a cone mesh
  43643. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43644. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43645. * * 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.
  43646. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43647. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43648. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43649. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43650. * * 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).
  43651. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43652. * * 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).
  43653. * * 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
  43654. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43655. * * 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
  43656. * * 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.
  43657. * * If `enclose` is false, a ring surface is one element.
  43658. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43659. * * 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
  43660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43663. * @param name defines the name of the mesh
  43664. * @param options defines the options used to create the mesh
  43665. * @param scene defines the hosting scene
  43666. * @returns the cylinder mesh
  43667. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43668. */
  43669. static CreateCylinder(name: string, options: {
  43670. height?: number;
  43671. diameterTop?: number;
  43672. diameterBottom?: number;
  43673. diameter?: number;
  43674. tessellation?: number;
  43675. subdivisions?: number;
  43676. arc?: number;
  43677. faceColors?: Color4[];
  43678. faceUV?: Vector4[];
  43679. updatable?: boolean;
  43680. hasRings?: boolean;
  43681. enclose?: boolean;
  43682. cap?: number;
  43683. sideOrientation?: number;
  43684. frontUVs?: Vector4;
  43685. backUVs?: Vector4;
  43686. }, scene: any): Mesh;
  43687. }
  43688. }
  43689. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43690. import { Nullable } from "babylonjs/types";
  43691. import { IDisposable } from "babylonjs/scene";
  43692. /**
  43693. * States of the webXR experience
  43694. */
  43695. export enum WebXRState {
  43696. /**
  43697. * Transitioning to being in XR mode
  43698. */
  43699. ENTERING_XR = 0,
  43700. /**
  43701. * Transitioning to non XR mode
  43702. */
  43703. EXITING_XR = 1,
  43704. /**
  43705. * In XR mode and presenting
  43706. */
  43707. IN_XR = 2,
  43708. /**
  43709. * Not entered XR mode
  43710. */
  43711. NOT_IN_XR = 3
  43712. }
  43713. /**
  43714. * Abstraction of the XR render target
  43715. */
  43716. export interface WebXRRenderTarget extends IDisposable {
  43717. /**
  43718. * xrpresent context of the canvas which can be used to display/mirror xr content
  43719. */
  43720. canvasContext: WebGLRenderingContext;
  43721. /**
  43722. * xr layer for the canvas
  43723. */
  43724. xrLayer: Nullable<XRWebGLLayer>;
  43725. /**
  43726. * Initializes the xr layer for the session
  43727. * @param xrSession xr session
  43728. * @returns a promise that will resolve once the XR Layer has been created
  43729. */
  43730. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43731. }
  43732. }
  43733. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43734. import { Nullable } from "babylonjs/types";
  43735. import { Observable } from "babylonjs/Misc/observable";
  43736. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43737. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43738. /**
  43739. * COnfiguration object for WebXR output canvas
  43740. */
  43741. export class WebXRManagedOutputCanvasOptions {
  43742. /**
  43743. * Options for this XR Layer output
  43744. */
  43745. canvasOptions: XRWebGLLayerOptions;
  43746. /**
  43747. * CSS styling for a newly created canvas (if not provided)
  43748. */
  43749. newCanvasCssStyle?: string;
  43750. /**
  43751. * Get the default values of the configuration object
  43752. * @returns default values of this configuration object
  43753. */
  43754. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43755. }
  43756. /**
  43757. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43758. */
  43759. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43760. private configuration;
  43761. private _engine;
  43762. private _canvas;
  43763. /**
  43764. * xrpresent context of the canvas which can be used to display/mirror xr content
  43765. */
  43766. canvasContext: WebGLRenderingContext;
  43767. /**
  43768. * xr layer for the canvas
  43769. */
  43770. xrLayer: Nullable<XRWebGLLayer>;
  43771. /**
  43772. * Initializes the xr layer for the session
  43773. * @param xrSession xr session
  43774. * @returns a promise that will resolve once the XR Layer has been created
  43775. */
  43776. initializeXRLayerAsync(xrSession: any): any;
  43777. /**
  43778. * Initializes the canvas to be added/removed upon entering/exiting xr
  43779. * @param engine the Babylon engine
  43780. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43781. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43782. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43783. */
  43784. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43785. /**
  43786. * Disposes of the object
  43787. */
  43788. dispose(): void;
  43789. private _setManagedOutputCanvas;
  43790. private _addCanvas;
  43791. private _removeCanvas;
  43792. }
  43793. }
  43794. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43795. import { Observable } from "babylonjs/Misc/observable";
  43796. import { Nullable } from "babylonjs/types";
  43797. import { IDisposable, Scene } from "babylonjs/scene";
  43798. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43799. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43800. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43801. /**
  43802. * Manages an XRSession to work with Babylon's engine
  43803. * @see https://doc.babylonjs.com/how_to/webxr
  43804. */
  43805. export class WebXRSessionManager implements IDisposable {
  43806. /** The scene which the session should be created for */
  43807. scene: Scene;
  43808. /**
  43809. * Fires every time a new xrFrame arrives which can be used to update the camera
  43810. */
  43811. onXRFrameObservable: Observable<XRFrame>;
  43812. /**
  43813. * Fires when the xr session is ended either by the device or manually done
  43814. */
  43815. onXRSessionEnded: Observable<any>;
  43816. /**
  43817. * Fires when the xr session is ended either by the device or manually done
  43818. */
  43819. onXRSessionInit: Observable<XRSession>;
  43820. /**
  43821. * Underlying xr session
  43822. */
  43823. session: XRSession;
  43824. /**
  43825. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43826. * or get the offset the player is currently at.
  43827. */
  43828. viewerReferenceSpace: XRReferenceSpace;
  43829. /**
  43830. * The current reference space used in this session. This reference space can constantly change!
  43831. * It is mainly used to offset the camera's position.
  43832. */
  43833. referenceSpace: XRReferenceSpace;
  43834. /**
  43835. * The base reference space from which the session started. good if you want to reset your
  43836. * reference space
  43837. */
  43838. baseReferenceSpace: XRReferenceSpace;
  43839. /**
  43840. * Used just in case of a failure to initialize an immersive session.
  43841. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43842. */
  43843. defaultHeightCompensation: number;
  43844. /**
  43845. * Current XR frame
  43846. */
  43847. currentFrame: Nullable<XRFrame>;
  43848. /** WebXR timestamp updated every frame */
  43849. currentTimestamp: number;
  43850. private _xrNavigator;
  43851. private baseLayer;
  43852. private _rttProvider;
  43853. private _sessionEnded;
  43854. /**
  43855. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43856. * @param scene The scene which the session should be created for
  43857. */
  43858. constructor(
  43859. /** The scene which the session should be created for */
  43860. scene: Scene);
  43861. /**
  43862. * Initializes the manager
  43863. * After initialization enterXR can be called to start an XR session
  43864. * @returns Promise which resolves after it is initialized
  43865. */
  43866. initializeAsync(): Promise<void>;
  43867. /**
  43868. * Initializes an xr session
  43869. * @param xrSessionMode mode to initialize
  43870. * @param optionalFeatures defines optional values to pass to the session builder
  43871. * @returns a promise which will resolve once the session has been initialized
  43872. */
  43873. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43874. /**
  43875. * Sets the reference space on the xr session
  43876. * @param referenceSpace space to set
  43877. * @returns a promise that will resolve once the reference space has been set
  43878. */
  43879. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43880. /**
  43881. * Updates the render state of the session
  43882. * @param state state to set
  43883. * @returns a promise that resolves once the render state has been updated
  43884. */
  43885. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43886. /**
  43887. * Starts rendering to the xr layer
  43888. * @returns a promise that will resolve once rendering has started
  43889. */
  43890. startRenderingToXRAsync(): Promise<void>;
  43891. /**
  43892. * Gets the correct render target texture to be rendered this frame for this eye
  43893. * @param eye the eye for which to get the render target
  43894. * @returns the render target for the specified eye
  43895. */
  43896. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43897. /**
  43898. * Stops the xrSession and restores the renderloop
  43899. * @returns Promise which resolves after it exits XR
  43900. */
  43901. exitXRAsync(): Promise<void>;
  43902. /**
  43903. * Checks if a session would be supported for the creation options specified
  43904. * @param sessionMode session mode to check if supported eg. immersive-vr
  43905. * @returns true if supported
  43906. */
  43907. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43908. /**
  43909. * Creates a WebXRRenderTarget object for the XR session
  43910. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43911. * @param options optional options to provide when creating a new render target
  43912. * @returns a WebXR render target to which the session can render
  43913. */
  43914. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43915. /**
  43916. * @hidden
  43917. * Converts the render layer of xrSession to a render target
  43918. * @param session session to create render target for
  43919. * @param scene scene the new render target should be created for
  43920. * @param baseLayer the webgl layer to create the render target for
  43921. */
  43922. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43923. /**
  43924. * Disposes of the session manager
  43925. */
  43926. dispose(): void;
  43927. /**
  43928. * Gets a promise returning true when fullfiled if the given session mode is supported
  43929. * @param sessionMode defines the session to test
  43930. * @returns a promise
  43931. */
  43932. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43933. }
  43934. }
  43935. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43936. import { Scene } from "babylonjs/scene";
  43937. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43938. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43939. /**
  43940. * WebXR Camera which holds the views for the xrSession
  43941. * @see https://doc.babylonjs.com/how_to/webxr
  43942. */
  43943. export class WebXRCamera extends FreeCamera {
  43944. private _xrSessionManager;
  43945. /**
  43946. * Is the camera in debug mode. Used when using an emulator
  43947. */
  43948. debugMode: boolean;
  43949. private _firstFrame;
  43950. private _referencedPosition;
  43951. private _referenceQuaternion;
  43952. private _xrInvPositionCache;
  43953. private _xrInvQuaternionCache;
  43954. /**
  43955. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43956. * @param name the name of the camera
  43957. * @param scene the scene to add the camera to
  43958. */
  43959. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43960. private _updateNumberOfRigCameras;
  43961. /** @hidden */
  43962. _updateForDualEyeDebugging(): void;
  43963. /**
  43964. * Updates the cameras position from the current pose information of the XR session
  43965. * @param xrSessionManager the session containing pose information
  43966. */
  43967. update(): void;
  43968. private _updateReferenceSpace;
  43969. private _updateReferenceSpaceOffset;
  43970. private _updateFromXRSession;
  43971. }
  43972. }
  43973. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  43974. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43975. import { IDisposable } from "babylonjs/scene";
  43976. /**
  43977. * Defining the interface required for a (webxr) feature
  43978. */
  43979. export interface IWebXRFeature extends IDisposable {
  43980. /**
  43981. * Attach the feature to the session
  43982. * Will usually be called by the features manager
  43983. *
  43984. * @returns true if successful.
  43985. */
  43986. attach(): boolean;
  43987. /**
  43988. * Detach the feature from the session
  43989. * Will usually be called by the features manager
  43990. *
  43991. * @returns true if successful.
  43992. */
  43993. detach(): boolean;
  43994. }
  43995. /**
  43996. * Defining the constructor of a feature. Used to register the modules.
  43997. */
  43998. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43999. /**
  44000. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44001. * It is mainly used in AR sessions.
  44002. *
  44003. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44004. */
  44005. export class WebXRFeaturesManager implements IDisposable {
  44006. private _xrSessionManager;
  44007. private static readonly _AvailableFeatures;
  44008. /**
  44009. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44010. * Mainly used internally.
  44011. *
  44012. * @param featureName the name of the feature to register
  44013. * @param constructorFunction the function used to construct the module
  44014. * @param version the (babylon) version of the module
  44015. * @param stable is that a stable version of this module
  44016. */
  44017. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44018. /**
  44019. * Returns a constructor of a specific feature.
  44020. *
  44021. * @param featureName the name of the feature to construct
  44022. * @param version the version of the feature to load
  44023. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44024. * @param options optional options provided to the module.
  44025. * @returns a function that, when called, will return a new instance of this feature
  44026. */
  44027. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44028. /**
  44029. * Return the latest unstable version of this feature
  44030. * @param featureName the name of the feature to search
  44031. * @returns the version number. if not found will return -1
  44032. */
  44033. static GetLatestVersionOfFeature(featureName: string): number;
  44034. /**
  44035. * Return the latest stable version of this feature
  44036. * @param featureName the name of the feature to search
  44037. * @returns the version number. if not found will return -1
  44038. */
  44039. static GetStableVersionOfFeature(featureName: string): number;
  44040. /**
  44041. * Can be used to return the list of features currently registered
  44042. *
  44043. * @returns an Array of available features
  44044. */
  44045. static GetAvailableFeatures(): string[];
  44046. /**
  44047. * Gets the versions available for a specific feature
  44048. * @param featureName the name of the feature
  44049. * @returns an array with the available versions
  44050. */
  44051. static GetAvailableVersions(featureName: string): string[];
  44052. private _features;
  44053. /**
  44054. * constructs a new features manages.
  44055. *
  44056. * @param _xrSessionManager an instance of WebXRSessionManager
  44057. */
  44058. constructor(_xrSessionManager: WebXRSessionManager);
  44059. /**
  44060. * 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.
  44061. *
  44062. * @param featureName the name of the feature to load or the class of the feature
  44063. * @param version optional version to load. if not provided the latest version will be enabled
  44064. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44065. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44066. * @returns a new constructed feature or throws an error if feature not found.
  44067. */
  44068. enableFeature(featureName: string | {
  44069. Name: string;
  44070. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44071. /**
  44072. * Used to disable an already-enabled feature
  44073. * @param featureName the feature to disable
  44074. * @returns true if disable was successful
  44075. */
  44076. disableFeature(featureName: string | {
  44077. Name: string;
  44078. }): boolean;
  44079. /**
  44080. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44081. * Can be used during a session to start a feature
  44082. * @param featureName the name of feature to attach
  44083. */
  44084. attachFeature(featureName: string): void;
  44085. /**
  44086. * Can be used inside a session or when the session ends to detach a specific feature
  44087. * @param featureName the name of the feature to detach
  44088. */
  44089. detachFeature(featureName: string): void;
  44090. /**
  44091. * Get the list of enabled features
  44092. * @returns an array of enabled features
  44093. */
  44094. getEnabledFeatures(): string[];
  44095. /**
  44096. * get the implementation of an enabled feature.
  44097. * @param featureName the name of the feature to load
  44098. * @returns the feature class, if found
  44099. */
  44100. getEnabledFeature(featureName: string): IWebXRFeature;
  44101. /**
  44102. * dispose this features manager
  44103. */
  44104. dispose(): void;
  44105. }
  44106. }
  44107. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44108. import { Observable } from "babylonjs/Misc/observable";
  44109. import { IDisposable, Scene } from "babylonjs/scene";
  44110. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44111. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44112. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44113. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44114. /**
  44115. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44116. * @see https://doc.babylonjs.com/how_to/webxr
  44117. */
  44118. export class WebXRExperienceHelper implements IDisposable {
  44119. private scene;
  44120. /**
  44121. * Camera used to render xr content
  44122. */
  44123. camera: WebXRCamera;
  44124. /**
  44125. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44126. */
  44127. state: WebXRState;
  44128. private _setState;
  44129. /**
  44130. * Fires when the state of the experience helper has changed
  44131. */
  44132. onStateChangedObservable: Observable<WebXRState>;
  44133. /**
  44134. * Observers registered here will be triggered after the camera's initial transformation is set
  44135. * This can be used to set a different ground level or an extra rotation.
  44136. *
  44137. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44138. * to the position set after this observable is done executing.
  44139. */
  44140. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44141. /** Session manager used to keep track of xr session */
  44142. sessionManager: WebXRSessionManager;
  44143. /** A features manager for this xr session */
  44144. featuresManager: WebXRFeaturesManager;
  44145. private _nonVRCamera;
  44146. private _originalSceneAutoClear;
  44147. private _supported;
  44148. /**
  44149. * Creates the experience helper
  44150. * @param scene the scene to attach the experience helper to
  44151. * @returns a promise for the experience helper
  44152. */
  44153. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44154. /**
  44155. * Creates a WebXRExperienceHelper
  44156. * @param scene The scene the helper should be created in
  44157. */
  44158. private constructor();
  44159. /**
  44160. * Exits XR mode and returns the scene to its original state
  44161. * @returns promise that resolves after xr mode has exited
  44162. */
  44163. exitXRAsync(): Promise<void>;
  44164. /**
  44165. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44166. * @param sessionMode options for the XR session
  44167. * @param referenceSpaceType frame of reference of the XR session
  44168. * @param renderTarget the output canvas that will be used to enter XR mode
  44169. * @returns promise that resolves after xr mode has entered
  44170. */
  44171. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44172. /**
  44173. * Disposes of the experience helper
  44174. */
  44175. dispose(): void;
  44176. private _nonXRToXRCamera;
  44177. }
  44178. }
  44179. declare module "babylonjs/Cameras/XR/webXRController" {
  44180. import { Nullable } from "babylonjs/types";
  44181. import { Observable } from "babylonjs/Misc/observable";
  44182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44183. import { Ray } from "babylonjs/Culling/ray";
  44184. import { Scene } from "babylonjs/scene";
  44185. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44186. /**
  44187. * Represents an XR input
  44188. */
  44189. export class WebXRController {
  44190. private scene;
  44191. /** The underlying input source for the controller */
  44192. inputSource: XRInputSource;
  44193. private parentContainer;
  44194. /**
  44195. * 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
  44196. */
  44197. grip?: AbstractMesh;
  44198. /**
  44199. * Pointer which can be used to select objects or attach a visible laser to
  44200. */
  44201. pointer: AbstractMesh;
  44202. private _gamepadMode;
  44203. /**
  44204. * If available, this is the gamepad object related to this controller.
  44205. * Using this object it is possible to get click events and trackpad changes of the
  44206. * webxr controller that is currently being used.
  44207. */
  44208. gamepadController?: WebVRController;
  44209. /**
  44210. * Event that fires when the controller is removed/disposed
  44211. */
  44212. onDisposeObservable: Observable<{}>;
  44213. private _tmpQuaternion;
  44214. private _tmpVector;
  44215. /**
  44216. * Creates the controller
  44217. * @see https://doc.babylonjs.com/how_to/webxr
  44218. * @param scene the scene which the controller should be associated to
  44219. * @param inputSource the underlying input source for the controller
  44220. * @param parentContainer parent that the controller meshes should be children of
  44221. */
  44222. constructor(scene: Scene,
  44223. /** The underlying input source for the controller */
  44224. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  44225. /**
  44226. * Updates the controller pose based on the given XRFrame
  44227. * @param xrFrame xr frame to update the pose with
  44228. * @param referenceSpace reference space to use
  44229. */
  44230. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44231. /**
  44232. * Gets a world space ray coming from the controller
  44233. * @param result the resulting ray
  44234. */
  44235. getWorldPointerRayToRef(result: Ray): void;
  44236. /**
  44237. * Get the scene associated with this controller
  44238. * @returns the scene object
  44239. */
  44240. getScene(): Scene;
  44241. /**
  44242. * Disposes of the object
  44243. */
  44244. dispose(): void;
  44245. }
  44246. }
  44247. declare module "babylonjs/Cameras/XR/webXRInput" {
  44248. import { Observable } from "babylonjs/Misc/observable";
  44249. import { IDisposable } from "babylonjs/scene";
  44250. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44251. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44252. /**
  44253. * XR input used to track XR inputs such as controllers/rays
  44254. */
  44255. export class WebXRInput implements IDisposable {
  44256. /**
  44257. * Base experience the input listens to
  44258. */
  44259. baseExperience: WebXRExperienceHelper;
  44260. /**
  44261. * XR controllers being tracked
  44262. */
  44263. controllers: Array<WebXRController>;
  44264. private _frameObserver;
  44265. private _stateObserver;
  44266. /**
  44267. * Event when a controller has been connected/added
  44268. */
  44269. onControllerAddedObservable: Observable<WebXRController>;
  44270. /**
  44271. * Event when a controller has been removed/disconnected
  44272. */
  44273. onControllerRemovedObservable: Observable<WebXRController>;
  44274. /**
  44275. * Initializes the WebXRInput
  44276. * @param baseExperience experience helper which the input should be created for
  44277. */
  44278. constructor(
  44279. /**
  44280. * Base experience the input listens to
  44281. */
  44282. baseExperience: WebXRExperienceHelper);
  44283. private _onInputSourcesChange;
  44284. private _addAndRemoveControllers;
  44285. /**
  44286. * Disposes of the object
  44287. */
  44288. dispose(): void;
  44289. }
  44290. }
  44291. declare module "babylonjs/Loading/sceneLoader" {
  44292. import { Observable } from "babylonjs/Misc/observable";
  44293. import { Nullable } from "babylonjs/types";
  44294. import { Scene } from "babylonjs/scene";
  44295. import { Engine } from "babylonjs/Engines/engine";
  44296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44297. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44298. import { AssetContainer } from "babylonjs/assetContainer";
  44299. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44300. import { Skeleton } from "babylonjs/Bones/skeleton";
  44301. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44302. import { WebRequest } from "babylonjs/Misc/webRequest";
  44303. /**
  44304. * Class used to represent data loading progression
  44305. */
  44306. export class SceneLoaderProgressEvent {
  44307. /** defines if data length to load can be evaluated */
  44308. readonly lengthComputable: boolean;
  44309. /** defines the loaded data length */
  44310. readonly loaded: number;
  44311. /** defines the data length to load */
  44312. readonly total: number;
  44313. /**
  44314. * Create a new progress event
  44315. * @param lengthComputable defines if data length to load can be evaluated
  44316. * @param loaded defines the loaded data length
  44317. * @param total defines the data length to load
  44318. */
  44319. constructor(
  44320. /** defines if data length to load can be evaluated */
  44321. lengthComputable: boolean,
  44322. /** defines the loaded data length */
  44323. loaded: number,
  44324. /** defines the data length to load */
  44325. total: number);
  44326. /**
  44327. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44328. * @param event defines the source event
  44329. * @returns a new SceneLoaderProgressEvent
  44330. */
  44331. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44332. }
  44333. /**
  44334. * Interface used by SceneLoader plugins to define supported file extensions
  44335. */
  44336. export interface ISceneLoaderPluginExtensions {
  44337. /**
  44338. * Defines the list of supported extensions
  44339. */
  44340. [extension: string]: {
  44341. isBinary: boolean;
  44342. };
  44343. }
  44344. /**
  44345. * Interface used by SceneLoader plugin factory
  44346. */
  44347. export interface ISceneLoaderPluginFactory {
  44348. /**
  44349. * Defines the name of the factory
  44350. */
  44351. name: string;
  44352. /**
  44353. * Function called to create a new plugin
  44354. * @return the new plugin
  44355. */
  44356. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44357. /**
  44358. * The callback that returns true if the data can be directly loaded.
  44359. * @param data string containing the file data
  44360. * @returns if the data can be loaded directly
  44361. */
  44362. canDirectLoad?(data: string): boolean;
  44363. }
  44364. /**
  44365. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44366. */
  44367. export interface ISceneLoaderPluginBase {
  44368. /**
  44369. * The friendly name of this plugin.
  44370. */
  44371. name: string;
  44372. /**
  44373. * The file extensions supported by this plugin.
  44374. */
  44375. extensions: string | ISceneLoaderPluginExtensions;
  44376. /**
  44377. * The callback called when loading from a url.
  44378. * @param scene scene loading this url
  44379. * @param url url to load
  44380. * @param onSuccess callback called when the file successfully loads
  44381. * @param onProgress callback called while file is loading (if the server supports this mode)
  44382. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44383. * @param onError callback called when the file fails to load
  44384. * @returns a file request object
  44385. */
  44386. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44387. /**
  44388. * The callback called when loading from a file object.
  44389. * @param scene scene loading this file
  44390. * @param file defines the file to load
  44391. * @param onSuccess defines the callback to call when data is loaded
  44392. * @param onProgress defines the callback to call during loading process
  44393. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44394. * @param onError defines the callback to call when an error occurs
  44395. * @returns a file request object
  44396. */
  44397. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44398. /**
  44399. * The callback that returns true if the data can be directly loaded.
  44400. * @param data string containing the file data
  44401. * @returns if the data can be loaded directly
  44402. */
  44403. canDirectLoad?(data: string): boolean;
  44404. /**
  44405. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44406. * @param scene scene loading this data
  44407. * @param data string containing the data
  44408. * @returns data to pass to the plugin
  44409. */
  44410. directLoad?(scene: Scene, data: string): any;
  44411. /**
  44412. * The callback that allows custom handling of the root url based on the response url.
  44413. * @param rootUrl the original root url
  44414. * @param responseURL the response url if available
  44415. * @returns the new root url
  44416. */
  44417. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44418. }
  44419. /**
  44420. * Interface used to define a SceneLoader plugin
  44421. */
  44422. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44423. /**
  44424. * Import meshes into a scene.
  44425. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44426. * @param scene The scene to import into
  44427. * @param data The data to import
  44428. * @param rootUrl The root url for scene and resources
  44429. * @param meshes The meshes array to import into
  44430. * @param particleSystems The particle systems array to import into
  44431. * @param skeletons The skeletons array to import into
  44432. * @param onError The callback when import fails
  44433. * @returns True if successful or false otherwise
  44434. */
  44435. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44436. /**
  44437. * Load into a scene.
  44438. * @param scene The scene to load into
  44439. * @param data The data to import
  44440. * @param rootUrl The root url for scene and resources
  44441. * @param onError The callback when import fails
  44442. * @returns True if successful or false otherwise
  44443. */
  44444. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44445. /**
  44446. * Load into an asset container.
  44447. * @param scene The scene to load into
  44448. * @param data The data to import
  44449. * @param rootUrl The root url for scene and resources
  44450. * @param onError The callback when import fails
  44451. * @returns The loaded asset container
  44452. */
  44453. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44454. }
  44455. /**
  44456. * Interface used to define an async SceneLoader plugin
  44457. */
  44458. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44459. /**
  44460. * Import meshes into a scene.
  44461. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44462. * @param scene The scene to import into
  44463. * @param data The data to import
  44464. * @param rootUrl The root url for scene and resources
  44465. * @param onProgress The callback when the load progresses
  44466. * @param fileName Defines the name of the file to load
  44467. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44468. */
  44469. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44470. meshes: AbstractMesh[];
  44471. particleSystems: IParticleSystem[];
  44472. skeletons: Skeleton[];
  44473. animationGroups: AnimationGroup[];
  44474. }>;
  44475. /**
  44476. * Load into a scene.
  44477. * @param scene The scene to load into
  44478. * @param data The data to import
  44479. * @param rootUrl The root url for scene and resources
  44480. * @param onProgress The callback when the load progresses
  44481. * @param fileName Defines the name of the file to load
  44482. * @returns Nothing
  44483. */
  44484. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44485. /**
  44486. * Load into an asset container.
  44487. * @param scene The scene to load into
  44488. * @param data The data to import
  44489. * @param rootUrl The root url for scene and resources
  44490. * @param onProgress The callback when the load progresses
  44491. * @param fileName Defines the name of the file to load
  44492. * @returns The loaded asset container
  44493. */
  44494. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44495. }
  44496. /**
  44497. * Mode that determines how to handle old animation groups before loading new ones.
  44498. */
  44499. export enum SceneLoaderAnimationGroupLoadingMode {
  44500. /**
  44501. * Reset all old animations to initial state then dispose them.
  44502. */
  44503. Clean = 0,
  44504. /**
  44505. * Stop all old animations.
  44506. */
  44507. Stop = 1,
  44508. /**
  44509. * Restart old animations from first frame.
  44510. */
  44511. Sync = 2,
  44512. /**
  44513. * Old animations remains untouched.
  44514. */
  44515. NoSync = 3
  44516. }
  44517. /**
  44518. * Class used to load scene from various file formats using registered plugins
  44519. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44520. */
  44521. export class SceneLoader {
  44522. /**
  44523. * No logging while loading
  44524. */
  44525. static readonly NO_LOGGING: number;
  44526. /**
  44527. * Minimal logging while loading
  44528. */
  44529. static readonly MINIMAL_LOGGING: number;
  44530. /**
  44531. * Summary logging while loading
  44532. */
  44533. static readonly SUMMARY_LOGGING: number;
  44534. /**
  44535. * Detailled logging while loading
  44536. */
  44537. static readonly DETAILED_LOGGING: number;
  44538. /**
  44539. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44540. */
  44541. static get ForceFullSceneLoadingForIncremental(): boolean;
  44542. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44543. /**
  44544. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44545. */
  44546. static get ShowLoadingScreen(): boolean;
  44547. static set ShowLoadingScreen(value: boolean);
  44548. /**
  44549. * Defines the current logging level (while loading the scene)
  44550. * @ignorenaming
  44551. */
  44552. static get loggingLevel(): number;
  44553. static set loggingLevel(value: number);
  44554. /**
  44555. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44556. */
  44557. static get CleanBoneMatrixWeights(): boolean;
  44558. static set CleanBoneMatrixWeights(value: boolean);
  44559. /**
  44560. * Event raised when a plugin is used to load a scene
  44561. */
  44562. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44563. private static _registeredPlugins;
  44564. private static _getDefaultPlugin;
  44565. private static _getPluginForExtension;
  44566. private static _getPluginForDirectLoad;
  44567. private static _getPluginForFilename;
  44568. private static _getDirectLoad;
  44569. private static _loadData;
  44570. private static _getFileInfo;
  44571. /**
  44572. * Gets a plugin that can load the given extension
  44573. * @param extension defines the extension to load
  44574. * @returns a plugin or null if none works
  44575. */
  44576. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44577. /**
  44578. * Gets a boolean indicating that the given extension can be loaded
  44579. * @param extension defines the extension to load
  44580. * @returns true if the extension is supported
  44581. */
  44582. static IsPluginForExtensionAvailable(extension: string): boolean;
  44583. /**
  44584. * Adds a new plugin to the list of registered plugins
  44585. * @param plugin defines the plugin to add
  44586. */
  44587. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44588. /**
  44589. * Import meshes into a scene
  44590. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44591. * @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)
  44592. * @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)
  44593. * @param scene the instance of BABYLON.Scene to append to
  44594. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44595. * @param onProgress a callback with a progress event for each file being loaded
  44596. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44597. * @param pluginExtension the extension used to determine the plugin
  44598. * @returns The loaded plugin
  44599. */
  44600. 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>;
  44601. /**
  44602. * Import meshes into a scene
  44603. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44604. * @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)
  44605. * @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)
  44606. * @param scene the instance of BABYLON.Scene to append to
  44607. * @param onProgress a callback with a progress event for each file being loaded
  44608. * @param pluginExtension the extension used to determine the plugin
  44609. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44610. */
  44611. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44612. meshes: AbstractMesh[];
  44613. particleSystems: IParticleSystem[];
  44614. skeletons: Skeleton[];
  44615. animationGroups: AnimationGroup[];
  44616. }>;
  44617. /**
  44618. * Load a scene
  44619. * @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)
  44620. * @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)
  44621. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44622. * @param onSuccess a callback with the scene when import succeeds
  44623. * @param onProgress a callback with a progress event for each file being loaded
  44624. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44625. * @param pluginExtension the extension used to determine the plugin
  44626. * @returns The loaded plugin
  44627. */
  44628. 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>;
  44629. /**
  44630. * Load a scene
  44631. * @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)
  44632. * @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)
  44633. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44634. * @param onProgress a callback with a progress event for each file being loaded
  44635. * @param pluginExtension the extension used to determine the plugin
  44636. * @returns The loaded scene
  44637. */
  44638. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44639. /**
  44640. * Append a scene
  44641. * @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)
  44642. * @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)
  44643. * @param scene is the instance of BABYLON.Scene to append to
  44644. * @param onSuccess a callback with the scene when import succeeds
  44645. * @param onProgress a callback with a progress event for each file being loaded
  44646. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44647. * @param pluginExtension the extension used to determine the plugin
  44648. * @returns The loaded plugin
  44649. */
  44650. 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>;
  44651. /**
  44652. * Append a scene
  44653. * @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)
  44654. * @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)
  44655. * @param scene is the instance of BABYLON.Scene to append to
  44656. * @param onProgress a callback with a progress event for each file being loaded
  44657. * @param pluginExtension the extension used to determine the plugin
  44658. * @returns The given scene
  44659. */
  44660. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44661. /**
  44662. * Load a scene into an asset container
  44663. * @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)
  44664. * @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)
  44665. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44666. * @param onSuccess a callback with the scene when import succeeds
  44667. * @param onProgress a callback with a progress event for each file being loaded
  44668. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44669. * @param pluginExtension the extension used to determine the plugin
  44670. * @returns The loaded plugin
  44671. */
  44672. 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>;
  44673. /**
  44674. * Load a scene into an asset container
  44675. * @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)
  44676. * @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)
  44677. * @param scene is the instance of Scene to append to
  44678. * @param onProgress a callback with a progress event for each file being loaded
  44679. * @param pluginExtension the extension used to determine the plugin
  44680. * @returns The loaded asset container
  44681. */
  44682. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44683. /**
  44684. * Import animations from a file into a scene
  44685. * @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)
  44686. * @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)
  44687. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44688. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44689. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44690. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44691. * @param onSuccess a callback with the scene when import succeeds
  44692. * @param onProgress a callback with a progress event for each file being loaded
  44693. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44694. */
  44695. 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;
  44696. /**
  44697. * Import animations from a file into a scene
  44698. * @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)
  44699. * @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)
  44700. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44701. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44702. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44703. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44704. * @param onSuccess a callback with the scene when import succeeds
  44705. * @param onProgress a callback with a progress event for each file being loaded
  44706. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44707. * @returns the updated scene with imported animations
  44708. */
  44709. 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>;
  44710. }
  44711. }
  44712. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44713. import { Scene } from "babylonjs/scene";
  44714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44715. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44716. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44717. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44718. /**
  44719. * Generic Controller
  44720. */
  44721. export class GenericController extends WebVRController {
  44722. /**
  44723. * Base Url for the controller model.
  44724. */
  44725. static readonly MODEL_BASE_URL: string;
  44726. /**
  44727. * File name for the controller model.
  44728. */
  44729. static readonly MODEL_FILENAME: string;
  44730. /**
  44731. * Creates a new GenericController from a gamepad
  44732. * @param vrGamepad the gamepad that the controller should be created from
  44733. */
  44734. constructor(vrGamepad: any);
  44735. /**
  44736. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44737. * @param scene scene in which to add meshes
  44738. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44739. */
  44740. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44741. /**
  44742. * Called once for each button that changed state since the last frame
  44743. * @param buttonIdx Which button index changed
  44744. * @param state New state of the button
  44745. * @param changes Which properties on the state changed since last frame
  44746. */
  44747. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44748. }
  44749. }
  44750. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44751. import { Observable } from "babylonjs/Misc/observable";
  44752. import { Scene } from "babylonjs/scene";
  44753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44754. import { Ray } from "babylonjs/Culling/ray";
  44755. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44756. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44757. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44758. /**
  44759. * Defines the WindowsMotionController object that the state of the windows motion controller
  44760. */
  44761. export class WindowsMotionController extends WebVRController {
  44762. /**
  44763. * The base url used to load the left and right controller models
  44764. */
  44765. static MODEL_BASE_URL: string;
  44766. /**
  44767. * The name of the left controller model file
  44768. */
  44769. static MODEL_LEFT_FILENAME: string;
  44770. /**
  44771. * The name of the right controller model file
  44772. */
  44773. static MODEL_RIGHT_FILENAME: string;
  44774. /**
  44775. * The controller name prefix for this controller type
  44776. */
  44777. static readonly GAMEPAD_ID_PREFIX: string;
  44778. /**
  44779. * The controller id pattern for this controller type
  44780. */
  44781. private static readonly GAMEPAD_ID_PATTERN;
  44782. private _loadedMeshInfo;
  44783. protected readonly _mapping: {
  44784. buttons: string[];
  44785. buttonMeshNames: {
  44786. 'trigger': string;
  44787. 'menu': string;
  44788. 'grip': string;
  44789. 'thumbstick': string;
  44790. 'trackpad': string;
  44791. };
  44792. buttonObservableNames: {
  44793. 'trigger': string;
  44794. 'menu': string;
  44795. 'grip': string;
  44796. 'thumbstick': string;
  44797. 'trackpad': string;
  44798. };
  44799. axisMeshNames: string[];
  44800. pointingPoseMeshName: string;
  44801. };
  44802. /**
  44803. * Fired when the trackpad on this controller is clicked
  44804. */
  44805. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44806. /**
  44807. * Fired when the trackpad on this controller is modified
  44808. */
  44809. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44810. /**
  44811. * The current x and y values of this controller's trackpad
  44812. */
  44813. trackpad: StickValues;
  44814. /**
  44815. * Creates a new WindowsMotionController from a gamepad
  44816. * @param vrGamepad the gamepad that the controller should be created from
  44817. */
  44818. constructor(vrGamepad: any);
  44819. /**
  44820. * Fired when the trigger on this controller is modified
  44821. */
  44822. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44823. /**
  44824. * Fired when the menu button on this controller is modified
  44825. */
  44826. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44827. /**
  44828. * Fired when the grip button on this controller is modified
  44829. */
  44830. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44831. /**
  44832. * Fired when the thumbstick button on this controller is modified
  44833. */
  44834. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44835. /**
  44836. * Fired when the touchpad button on this controller is modified
  44837. */
  44838. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44839. /**
  44840. * Fired when the touchpad values on this controller are modified
  44841. */
  44842. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  44843. protected _updateTrackpad(): void;
  44844. /**
  44845. * Called once per frame by the engine.
  44846. */
  44847. update(): void;
  44848. /**
  44849. * Called once for each button that changed state since the last frame
  44850. * @param buttonIdx Which button index changed
  44851. * @param state New state of the button
  44852. * @param changes Which properties on the state changed since last frame
  44853. */
  44854. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44855. /**
  44856. * Moves the buttons on the controller mesh based on their current state
  44857. * @param buttonName the name of the button to move
  44858. * @param buttonValue the value of the button which determines the buttons new position
  44859. */
  44860. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44861. /**
  44862. * Moves the axis on the controller mesh based on its current state
  44863. * @param axis the index of the axis
  44864. * @param axisValue the value of the axis which determines the meshes new position
  44865. * @hidden
  44866. */
  44867. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44868. /**
  44869. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44870. * @param scene scene in which to add meshes
  44871. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44872. */
  44873. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44874. /**
  44875. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44876. * can be transformed by button presses and axes values, based on this._mapping.
  44877. *
  44878. * @param scene scene in which the meshes exist
  44879. * @param meshes list of meshes that make up the controller model to process
  44880. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44881. */
  44882. private processModel;
  44883. private createMeshInfo;
  44884. /**
  44885. * Gets the ray of the controller in the direction the controller is pointing
  44886. * @param length the length the resulting ray should be
  44887. * @returns a ray in the direction the controller is pointing
  44888. */
  44889. getForwardRay(length?: number): Ray;
  44890. /**
  44891. * Disposes of the controller
  44892. */
  44893. dispose(): void;
  44894. }
  44895. /**
  44896. * This class represents a new windows motion controller in XR.
  44897. */
  44898. export class XRWindowsMotionController extends WindowsMotionController {
  44899. /**
  44900. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44901. */
  44902. protected readonly _mapping: {
  44903. buttons: string[];
  44904. buttonMeshNames: {
  44905. 'trigger': string;
  44906. 'menu': string;
  44907. 'grip': string;
  44908. 'thumbstick': string;
  44909. 'trackpad': string;
  44910. };
  44911. buttonObservableNames: {
  44912. 'trigger': string;
  44913. 'menu': string;
  44914. 'grip': string;
  44915. 'thumbstick': string;
  44916. 'trackpad': string;
  44917. };
  44918. axisMeshNames: string[];
  44919. pointingPoseMeshName: string;
  44920. };
  44921. /**
  44922. * Construct a new XR-Based windows motion controller
  44923. *
  44924. * @param gamepadInfo the gamepad object from the browser
  44925. */
  44926. constructor(gamepadInfo: any);
  44927. /**
  44928. * holds the thumbstick values (X,Y)
  44929. */
  44930. thumbstickValues: StickValues;
  44931. /**
  44932. * Fired when the thumbstick on this controller is clicked
  44933. */
  44934. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44935. /**
  44936. * Fired when the thumbstick on this controller is modified
  44937. */
  44938. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44939. /**
  44940. * Fired when the touchpad button on this controller is modified
  44941. */
  44942. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44943. /**
  44944. * Fired when the touchpad values on this controller are modified
  44945. */
  44946. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44947. /**
  44948. * Fired when the thumbstick button on this controller is modified
  44949. * here to prevent breaking changes
  44950. */
  44951. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44952. /**
  44953. * updating the thumbstick(!) and not the trackpad.
  44954. * This is named this way due to the difference between WebVR and XR and to avoid
  44955. * changing the parent class.
  44956. */
  44957. protected _updateTrackpad(): void;
  44958. /**
  44959. * Disposes the class with joy
  44960. */
  44961. dispose(): void;
  44962. }
  44963. }
  44964. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44965. import { Observable } from "babylonjs/Misc/observable";
  44966. import { Scene } from "babylonjs/scene";
  44967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44968. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44969. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44970. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44971. /**
  44972. * Oculus Touch Controller
  44973. */
  44974. export class OculusTouchController extends WebVRController {
  44975. /**
  44976. * Base Url for the controller model.
  44977. */
  44978. static MODEL_BASE_URL: string;
  44979. /**
  44980. * File name for the left controller model.
  44981. */
  44982. static MODEL_LEFT_FILENAME: string;
  44983. /**
  44984. * File name for the right controller model.
  44985. */
  44986. static MODEL_RIGHT_FILENAME: string;
  44987. /**
  44988. * Base Url for the Quest controller model.
  44989. */
  44990. static QUEST_MODEL_BASE_URL: string;
  44991. /**
  44992. * @hidden
  44993. * If the controllers are running on a device that needs the updated Quest controller models
  44994. */
  44995. static _IsQuest: boolean;
  44996. /**
  44997. * Fired when the secondary trigger on this controller is modified
  44998. */
  44999. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  45000. /**
  45001. * Fired when the thumb rest on this controller is modified
  45002. */
  45003. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  45004. /**
  45005. * Creates a new OculusTouchController from a gamepad
  45006. * @param vrGamepad the gamepad that the controller should be created from
  45007. */
  45008. constructor(vrGamepad: any);
  45009. /**
  45010. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45011. * @param scene scene in which to add meshes
  45012. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45013. */
  45014. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45015. /**
  45016. * Fired when the A button on this controller is modified
  45017. */
  45018. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45019. /**
  45020. * Fired when the B button on this controller is modified
  45021. */
  45022. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45023. /**
  45024. * Fired when the X button on this controller is modified
  45025. */
  45026. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45027. /**
  45028. * Fired when the Y button on this controller is modified
  45029. */
  45030. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45031. /**
  45032. * Called once for each button that changed state since the last frame
  45033. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  45034. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  45035. * 2) secondary trigger (same)
  45036. * 3) A (right) X (left), touch, pressed = value
  45037. * 4) B / Y
  45038. * 5) thumb rest
  45039. * @param buttonIdx Which button index changed
  45040. * @param state New state of the button
  45041. * @param changes Which properties on the state changed since last frame
  45042. */
  45043. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45044. }
  45045. }
  45046. declare module "babylonjs/Gamepads/Controllers/viveController" {
  45047. import { Scene } from "babylonjs/scene";
  45048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45049. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45050. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45051. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45052. import { Observable } from "babylonjs/Misc/observable";
  45053. /**
  45054. * Vive Controller
  45055. */
  45056. export class ViveController extends WebVRController {
  45057. /**
  45058. * Base Url for the controller model.
  45059. */
  45060. static MODEL_BASE_URL: string;
  45061. /**
  45062. * File name for the controller model.
  45063. */
  45064. static MODEL_FILENAME: string;
  45065. /**
  45066. * Creates a new ViveController from a gamepad
  45067. * @param vrGamepad the gamepad that the controller should be created from
  45068. */
  45069. constructor(vrGamepad: any);
  45070. /**
  45071. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45072. * @param scene scene in which to add meshes
  45073. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45074. */
  45075. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45076. /**
  45077. * Fired when the left button on this controller is modified
  45078. */
  45079. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45080. /**
  45081. * Fired when the right button on this controller is modified
  45082. */
  45083. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45084. /**
  45085. * Fired when the menu button on this controller is modified
  45086. */
  45087. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45088. /**
  45089. * Called once for each button that changed state since the last frame
  45090. * Vive mapping:
  45091. * 0: touchpad
  45092. * 1: trigger
  45093. * 2: left AND right buttons
  45094. * 3: menu button
  45095. * @param buttonIdx Which button index changed
  45096. * @param state New state of the button
  45097. * @param changes Which properties on the state changed since last frame
  45098. */
  45099. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45100. }
  45101. }
  45102. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  45103. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45104. import { Observable } from "babylonjs/Misc/observable";
  45105. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45106. /**
  45107. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  45108. */
  45109. export class WebXRControllerModelLoader {
  45110. /**
  45111. * an observable that triggers when a new model (the mesh itself) was initialized.
  45112. * To know when the mesh was loaded use the controller's own modelLoaded() method
  45113. */
  45114. onControllerModelLoaded: Observable<WebXRController>;
  45115. /**
  45116. * Creates the WebXRControllerModelLoader
  45117. * @param input xr input that creates the controllers
  45118. */
  45119. constructor(input: WebXRInput);
  45120. }
  45121. }
  45122. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  45123. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45124. /**
  45125. * Handles pointer input automatically for the pointer of XR controllers
  45126. */
  45127. export class WebXRControllerPointerSelection {
  45128. private static _idCounter;
  45129. private _tmpRay;
  45130. /**
  45131. * Creates a WebXRControllerPointerSelection
  45132. * @param input input manager to setup pointer selection
  45133. */
  45134. constructor(input: WebXRInput);
  45135. private _convertNormalToDirectionOfRay;
  45136. private _updatePointerDistance;
  45137. }
  45138. }
  45139. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  45140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45141. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45142. /**
  45143. * Enables teleportation
  45144. */
  45145. export class WebXRControllerTeleportation {
  45146. private _teleportationFillColor;
  45147. private _teleportationBorderColor;
  45148. private _tmpRay;
  45149. private _tmpVector;
  45150. /**
  45151. * when set to true (default) teleportation will wait for thumbstick changes.
  45152. * When set to false teleportation will be disabled.
  45153. *
  45154. * If set to false while teleporting results can be unexpected.
  45155. */
  45156. enabled: boolean;
  45157. /**
  45158. * Creates a WebXRControllerTeleportation
  45159. * @param input input manager to add teleportation to
  45160. * @param floorMeshes floormeshes which can be teleported to
  45161. */
  45162. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  45163. }
  45164. }
  45165. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45166. import { Nullable } from "babylonjs/types";
  45167. import { Observable } from "babylonjs/Misc/observable";
  45168. import { IDisposable, Scene } from "babylonjs/scene";
  45169. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45170. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45171. /**
  45172. * Button which can be used to enter a different mode of XR
  45173. */
  45174. export class WebXREnterExitUIButton {
  45175. /** button element */
  45176. element: HTMLElement;
  45177. /** XR initialization options for the button */
  45178. sessionMode: XRSessionMode;
  45179. /** Reference space type */
  45180. referenceSpaceType: XRReferenceSpaceType;
  45181. /**
  45182. * Creates a WebXREnterExitUIButton
  45183. * @param element button element
  45184. * @param sessionMode XR initialization session mode
  45185. * @param referenceSpaceType the type of reference space to be used
  45186. */
  45187. constructor(
  45188. /** button element */
  45189. element: HTMLElement,
  45190. /** XR initialization options for the button */
  45191. sessionMode: XRSessionMode,
  45192. /** Reference space type */
  45193. referenceSpaceType: XRReferenceSpaceType);
  45194. /**
  45195. * Overwritable function which can be used to update the button's visuals when the state changes
  45196. * @param activeButton the current active button in the UI
  45197. */
  45198. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45199. }
  45200. /**
  45201. * Options to create the webXR UI
  45202. */
  45203. export class WebXREnterExitUIOptions {
  45204. /**
  45205. * Context to enter xr with
  45206. */
  45207. renderTarget?: Nullable<WebXRRenderTarget>;
  45208. /**
  45209. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45210. */
  45211. customButtons?: Array<WebXREnterExitUIButton>;
  45212. /**
  45213. * A session mode to use when creating the default button.
  45214. * Default is immersive-vr
  45215. */
  45216. sessionMode?: XRSessionMode;
  45217. /**
  45218. * A reference space type to use when creating the default button.
  45219. * Default is local-floor
  45220. */
  45221. referenceSpaceType?: XRReferenceSpaceType;
  45222. }
  45223. /**
  45224. * UI to allow the user to enter/exit XR mode
  45225. */
  45226. export class WebXREnterExitUI implements IDisposable {
  45227. private scene;
  45228. /** version of the options passed to this UI */
  45229. options: WebXREnterExitUIOptions;
  45230. private _overlay;
  45231. private _buttons;
  45232. private _activeButton;
  45233. /**
  45234. * Fired every time the active button is changed.
  45235. *
  45236. * When xr is entered via a button that launches xr that button will be the callback parameter
  45237. *
  45238. * When exiting xr the callback parameter will be null)
  45239. */
  45240. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45241. /**
  45242. * Creates UI to allow the user to enter/exit XR mode
  45243. * @param scene the scene to add the ui to
  45244. * @param helper the xr experience helper to enter/exit xr with
  45245. * @param options options to configure the UI
  45246. * @returns the created ui
  45247. */
  45248. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45249. /**
  45250. *
  45251. * @param scene babylon scene object to use
  45252. * @param options (read-only) version of the options passed to this UI
  45253. */
  45254. private constructor();
  45255. private _updateButtons;
  45256. /**
  45257. * Disposes of the object
  45258. */
  45259. dispose(): void;
  45260. }
  45261. }
  45262. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45263. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45264. import { Scene } from "babylonjs/scene";
  45265. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45266. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  45267. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45268. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45269. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45270. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45272. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45273. /**
  45274. * Options for the default xr helper
  45275. */
  45276. export class WebXRDefaultExperienceOptions {
  45277. /**
  45278. * Floor meshes that should be used for teleporting
  45279. */
  45280. floorMeshes: Array<AbstractMesh>;
  45281. /**
  45282. * Enable or disable default UI to enter XR
  45283. */
  45284. disableDefaultUI?: boolean;
  45285. /**
  45286. * optional configuration for the output canvas
  45287. */
  45288. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45289. /**
  45290. * optional UI options. This can be used among other to change session mode and reference space type
  45291. */
  45292. uiOptions?: WebXREnterExitUIOptions;
  45293. }
  45294. /**
  45295. * Default experience which provides a similar setup to the previous webVRExperience
  45296. */
  45297. export class WebXRDefaultExperience {
  45298. /**
  45299. * Base experience
  45300. */
  45301. baseExperience: WebXRExperienceHelper;
  45302. /**
  45303. * Input experience extension
  45304. */
  45305. input: WebXRInput;
  45306. /**
  45307. * Loads the controller models
  45308. */
  45309. controllerModelLoader: WebXRControllerModelLoader;
  45310. /**
  45311. * Enables laser pointer and selection
  45312. */
  45313. pointerSelection: WebXRControllerPointerSelection;
  45314. /**
  45315. * Enables teleportation
  45316. */
  45317. teleportation: WebXRControllerTeleportation;
  45318. /**
  45319. * Enables ui for entering/exiting xr
  45320. */
  45321. enterExitUI: WebXREnterExitUI;
  45322. /**
  45323. * Default target xr should render to
  45324. */
  45325. renderTarget: WebXRRenderTarget;
  45326. /**
  45327. * Creates the default xr experience
  45328. * @param scene scene
  45329. * @param options options for basic configuration
  45330. * @returns resulting WebXRDefaultExperience
  45331. */
  45332. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45333. private constructor();
  45334. /**
  45335. * DIsposes of the experience helper
  45336. */
  45337. dispose(): void;
  45338. }
  45339. }
  45340. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  45341. import { Observable } from "babylonjs/Misc/observable";
  45342. import { Nullable } from "babylonjs/types";
  45343. import { Camera } from "babylonjs/Cameras/camera";
  45344. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  45345. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45346. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  45347. import { Scene } from "babylonjs/scene";
  45348. import { Vector3 } from "babylonjs/Maths/math.vector";
  45349. import { Color3 } from "babylonjs/Maths/math.color";
  45350. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45352. import { Mesh } from "babylonjs/Meshes/mesh";
  45353. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45354. import { EasingFunction } from "babylonjs/Animations/easing";
  45355. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  45356. import "babylonjs/Meshes/Builders/groundBuilder";
  45357. import "babylonjs/Meshes/Builders/torusBuilder";
  45358. import "babylonjs/Meshes/Builders/cylinderBuilder";
  45359. import "babylonjs/Gamepads/gamepadSceneComponent";
  45360. import "babylonjs/Animations/animatable";
  45361. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45362. /**
  45363. * Options to modify the vr teleportation behavior.
  45364. */
  45365. export interface VRTeleportationOptions {
  45366. /**
  45367. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45368. */
  45369. floorMeshName?: string;
  45370. /**
  45371. * A list of meshes to be used as the teleportation floor. (default: empty)
  45372. */
  45373. floorMeshes?: Mesh[];
  45374. /**
  45375. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45376. */
  45377. teleportationMode?: number;
  45378. /**
  45379. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45380. */
  45381. teleportationTime?: number;
  45382. /**
  45383. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45384. */
  45385. teleportationSpeed?: number;
  45386. /**
  45387. * The easing function used in the animation or null for Linear. (default CircleEase)
  45388. */
  45389. easingFunction?: EasingFunction;
  45390. }
  45391. /**
  45392. * Options to modify the vr experience helper's behavior.
  45393. */
  45394. export interface VRExperienceHelperOptions extends WebVROptions {
  45395. /**
  45396. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45397. */
  45398. createDeviceOrientationCamera?: boolean;
  45399. /**
  45400. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45401. */
  45402. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45403. /**
  45404. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45405. */
  45406. laserToggle?: boolean;
  45407. /**
  45408. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45409. */
  45410. floorMeshes?: Mesh[];
  45411. /**
  45412. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45413. */
  45414. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45415. /**
  45416. * Defines if WebXR should be used instead of WebVR (if available)
  45417. */
  45418. useXR?: boolean;
  45419. }
  45420. /**
  45421. * Event containing information after VR has been entered
  45422. */
  45423. export class OnAfterEnteringVRObservableEvent {
  45424. /**
  45425. * If entering vr was successful
  45426. */
  45427. success: boolean;
  45428. }
  45429. /**
  45430. * Helps to quickly add VR support to an existing scene.
  45431. * See http://doc.babylonjs.com/how_to/webvr_helper
  45432. */
  45433. export class VRExperienceHelper {
  45434. /** Options to modify the vr experience helper's behavior. */
  45435. webVROptions: VRExperienceHelperOptions;
  45436. private _scene;
  45437. private _position;
  45438. private _btnVR;
  45439. private _btnVRDisplayed;
  45440. private _webVRsupported;
  45441. private _webVRready;
  45442. private _webVRrequesting;
  45443. private _webVRpresenting;
  45444. private _hasEnteredVR;
  45445. private _fullscreenVRpresenting;
  45446. private _inputElement;
  45447. private _webVRCamera;
  45448. private _vrDeviceOrientationCamera;
  45449. private _deviceOrientationCamera;
  45450. private _existingCamera;
  45451. private _onKeyDown;
  45452. private _onVrDisplayPresentChange;
  45453. private _onVRDisplayChanged;
  45454. private _onVRRequestPresentStart;
  45455. private _onVRRequestPresentComplete;
  45456. /**
  45457. * 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)
  45458. */
  45459. enableGazeEvenWhenNoPointerLock: boolean;
  45460. /**
  45461. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45462. */
  45463. exitVROnDoubleTap: boolean;
  45464. /**
  45465. * Observable raised right before entering VR.
  45466. */
  45467. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45468. /**
  45469. * Observable raised when entering VR has completed.
  45470. */
  45471. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45472. /**
  45473. * Observable raised when exiting VR.
  45474. */
  45475. onExitingVRObservable: Observable<VRExperienceHelper>;
  45476. /**
  45477. * Observable raised when controller mesh is loaded.
  45478. */
  45479. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45480. /** Return this.onEnteringVRObservable
  45481. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45482. */
  45483. get onEnteringVR(): Observable<VRExperienceHelper>;
  45484. /** Return this.onExitingVRObservable
  45485. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45486. */
  45487. get onExitingVR(): Observable<VRExperienceHelper>;
  45488. /** Return this.onControllerMeshLoadedObservable
  45489. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45490. */
  45491. get onControllerMeshLoaded(): Observable<WebVRController>;
  45492. private _rayLength;
  45493. private _useCustomVRButton;
  45494. private _teleportationRequested;
  45495. private _teleportActive;
  45496. private _floorMeshName;
  45497. private _floorMeshesCollection;
  45498. private _teleportationMode;
  45499. private _teleportationTime;
  45500. private _teleportationSpeed;
  45501. private _teleportationEasing;
  45502. private _rotationAllowed;
  45503. private _teleportBackwardsVector;
  45504. private _teleportationTarget;
  45505. private _isDefaultTeleportationTarget;
  45506. private _postProcessMove;
  45507. private _teleportationFillColor;
  45508. private _teleportationBorderColor;
  45509. private _rotationAngle;
  45510. private _haloCenter;
  45511. private _cameraGazer;
  45512. private _padSensibilityUp;
  45513. private _padSensibilityDown;
  45514. private _leftController;
  45515. private _rightController;
  45516. private _gazeColor;
  45517. private _laserColor;
  45518. private _pickedLaserColor;
  45519. private _pickedGazeColor;
  45520. /**
  45521. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45522. */
  45523. onNewMeshSelected: Observable<AbstractMesh>;
  45524. /**
  45525. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45526. * This observable will provide the mesh and the controller used to select the mesh
  45527. */
  45528. onMeshSelectedWithController: Observable<{
  45529. mesh: AbstractMesh;
  45530. controller: WebVRController;
  45531. }>;
  45532. /**
  45533. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45534. */
  45535. onNewMeshPicked: Observable<PickingInfo>;
  45536. private _circleEase;
  45537. /**
  45538. * Observable raised before camera teleportation
  45539. */
  45540. onBeforeCameraTeleport: Observable<Vector3>;
  45541. /**
  45542. * Observable raised after camera teleportation
  45543. */
  45544. onAfterCameraTeleport: Observable<Vector3>;
  45545. /**
  45546. * Observable raised when current selected mesh gets unselected
  45547. */
  45548. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45549. private _raySelectionPredicate;
  45550. /**
  45551. * To be optionaly changed by user to define custom ray selection
  45552. */
  45553. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45554. /**
  45555. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45556. */
  45557. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45558. /**
  45559. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45560. */
  45561. teleportationEnabled: boolean;
  45562. private _defaultHeight;
  45563. private _teleportationInitialized;
  45564. private _interactionsEnabled;
  45565. private _interactionsRequested;
  45566. private _displayGaze;
  45567. private _displayLaserPointer;
  45568. /**
  45569. * The mesh used to display where the user is going to teleport.
  45570. */
  45571. get teleportationTarget(): Mesh;
  45572. /**
  45573. * Sets the mesh to be used to display where the user is going to teleport.
  45574. */
  45575. set teleportationTarget(value: Mesh);
  45576. /**
  45577. * 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
  45578. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45579. * See http://doc.babylonjs.com/resources/baking_transformations
  45580. */
  45581. get gazeTrackerMesh(): Mesh;
  45582. set gazeTrackerMesh(value: Mesh);
  45583. /**
  45584. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45585. */
  45586. updateGazeTrackerScale: boolean;
  45587. /**
  45588. * If the gaze trackers color should be updated when selecting meshes
  45589. */
  45590. updateGazeTrackerColor: boolean;
  45591. /**
  45592. * If the controller laser color should be updated when selecting meshes
  45593. */
  45594. updateControllerLaserColor: boolean;
  45595. /**
  45596. * The gaze tracking mesh corresponding to the left controller
  45597. */
  45598. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45599. /**
  45600. * The gaze tracking mesh corresponding to the right controller
  45601. */
  45602. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45603. /**
  45604. * If the ray of the gaze should be displayed.
  45605. */
  45606. get displayGaze(): boolean;
  45607. /**
  45608. * Sets if the ray of the gaze should be displayed.
  45609. */
  45610. set displayGaze(value: boolean);
  45611. /**
  45612. * If the ray of the LaserPointer should be displayed.
  45613. */
  45614. get displayLaserPointer(): boolean;
  45615. /**
  45616. * Sets if the ray of the LaserPointer should be displayed.
  45617. */
  45618. set displayLaserPointer(value: boolean);
  45619. /**
  45620. * The deviceOrientationCamera used as the camera when not in VR.
  45621. */
  45622. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45623. /**
  45624. * Based on the current WebVR support, returns the current VR camera used.
  45625. */
  45626. get currentVRCamera(): Nullable<Camera>;
  45627. /**
  45628. * The webVRCamera which is used when in VR.
  45629. */
  45630. get webVRCamera(): WebVRFreeCamera;
  45631. /**
  45632. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45633. */
  45634. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45635. /**
  45636. * The html button that is used to trigger entering into VR.
  45637. */
  45638. get vrButton(): Nullable<HTMLButtonElement>;
  45639. private get _teleportationRequestInitiated();
  45640. /**
  45641. * Defines wether or not Pointer lock should be requested when switching to
  45642. * full screen.
  45643. */
  45644. requestPointerLockOnFullScreen: boolean;
  45645. /**
  45646. * If asking to force XR, this will be populated with the default xr experience
  45647. */
  45648. xr: WebXRDefaultExperience;
  45649. /**
  45650. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45651. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45652. */
  45653. xrTestDone: boolean;
  45654. /**
  45655. * Instantiates a VRExperienceHelper.
  45656. * Helps to quickly add VR support to an existing scene.
  45657. * @param scene The scene the VRExperienceHelper belongs to.
  45658. * @param webVROptions Options to modify the vr experience helper's behavior.
  45659. */
  45660. constructor(scene: Scene,
  45661. /** Options to modify the vr experience helper's behavior. */
  45662. webVROptions?: VRExperienceHelperOptions);
  45663. private completeVRInit;
  45664. private _onDefaultMeshLoaded;
  45665. private _onResize;
  45666. private _onFullscreenChange;
  45667. /**
  45668. * Gets a value indicating if we are currently in VR mode.
  45669. */
  45670. get isInVRMode(): boolean;
  45671. private onVrDisplayPresentChange;
  45672. private onVRDisplayChanged;
  45673. private moveButtonToBottomRight;
  45674. private displayVRButton;
  45675. private updateButtonVisibility;
  45676. private _cachedAngularSensibility;
  45677. /**
  45678. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45679. * Otherwise, will use the fullscreen API.
  45680. */
  45681. enterVR(): void;
  45682. /**
  45683. * Attempt to exit VR, or fullscreen.
  45684. */
  45685. exitVR(): void;
  45686. /**
  45687. * The position of the vr experience helper.
  45688. */
  45689. get position(): Vector3;
  45690. /**
  45691. * Sets the position of the vr experience helper.
  45692. */
  45693. set position(value: Vector3);
  45694. /**
  45695. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45696. */
  45697. enableInteractions(): void;
  45698. private get _noControllerIsActive();
  45699. private beforeRender;
  45700. private _isTeleportationFloor;
  45701. /**
  45702. * Adds a floor mesh to be used for teleportation.
  45703. * @param floorMesh the mesh to be used for teleportation.
  45704. */
  45705. addFloorMesh(floorMesh: Mesh): void;
  45706. /**
  45707. * Removes a floor mesh from being used for teleportation.
  45708. * @param floorMesh the mesh to be removed.
  45709. */
  45710. removeFloorMesh(floorMesh: Mesh): void;
  45711. /**
  45712. * Enables interactions and teleportation using the VR controllers and gaze.
  45713. * @param vrTeleportationOptions options to modify teleportation behavior.
  45714. */
  45715. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45716. private _onNewGamepadConnected;
  45717. private _tryEnableInteractionOnController;
  45718. private _onNewGamepadDisconnected;
  45719. private _enableInteractionOnController;
  45720. private _checkTeleportWithRay;
  45721. private _checkRotate;
  45722. private _checkTeleportBackwards;
  45723. private _enableTeleportationOnController;
  45724. private _createTeleportationCircles;
  45725. private _displayTeleportationTarget;
  45726. private _hideTeleportationTarget;
  45727. private _rotateCamera;
  45728. private _moveTeleportationSelectorTo;
  45729. private _workingVector;
  45730. private _workingQuaternion;
  45731. private _workingMatrix;
  45732. /**
  45733. * Time Constant Teleportation Mode
  45734. */
  45735. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45736. /**
  45737. * Speed Constant Teleportation Mode
  45738. */
  45739. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45740. /**
  45741. * Teleports the users feet to the desired location
  45742. * @param location The location where the user's feet should be placed
  45743. */
  45744. teleportCamera(location: Vector3): void;
  45745. private _convertNormalToDirectionOfRay;
  45746. private _castRayAndSelectObject;
  45747. private _notifySelectedMeshUnselected;
  45748. /**
  45749. * Permanently set new colors for the laser pointer
  45750. * @param color the new laser color
  45751. * @param pickedColor the new laser color when picked mesh detected
  45752. */
  45753. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45754. /**
  45755. * Permanently set new colors for the gaze pointer
  45756. * @param color the new gaze color
  45757. * @param pickedColor the new gaze color when picked mesh detected
  45758. */
  45759. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45760. /**
  45761. * Sets the color of the laser ray from the vr controllers.
  45762. * @param color new color for the ray.
  45763. */
  45764. changeLaserColor(color: Color3): void;
  45765. /**
  45766. * Sets the color of the ray from the vr headsets gaze.
  45767. * @param color new color for the ray.
  45768. */
  45769. changeGazeColor(color: Color3): void;
  45770. /**
  45771. * Exits VR and disposes of the vr experience helper
  45772. */
  45773. dispose(): void;
  45774. /**
  45775. * Gets the name of the VRExperienceHelper class
  45776. * @returns "VRExperienceHelper"
  45777. */
  45778. getClassName(): string;
  45779. }
  45780. }
  45781. declare module "babylonjs/Cameras/VR/index" {
  45782. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45783. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45784. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45785. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45786. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45787. export * from "babylonjs/Cameras/VR/webVRCamera";
  45788. }
  45789. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  45790. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45791. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45792. import { Observable } from "babylonjs/Misc/observable";
  45793. import { Matrix } from "babylonjs/Maths/math.vector";
  45794. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45795. /**
  45796. * Options used for hit testing
  45797. */
  45798. export interface IWebXRHitTestOptions {
  45799. /**
  45800. * Only test when user interacted with the scene. Default - hit test every frame
  45801. */
  45802. testOnPointerDownOnly?: boolean;
  45803. /**
  45804. * The node to use to transform the local results to world coordinates
  45805. */
  45806. worldParentNode?: TransformNode;
  45807. }
  45808. /**
  45809. * Interface defining the babylon result of raycasting/hit-test
  45810. */
  45811. export interface IWebXRHitResult {
  45812. /**
  45813. * The native hit test result
  45814. */
  45815. xrHitResult: XRHitResult;
  45816. /**
  45817. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45818. */
  45819. transformationMatrix: Matrix;
  45820. }
  45821. /**
  45822. * The currently-working hit-test module.
  45823. * Hit test (or raycasting) is used to interact with the real world.
  45824. * For further information read here - https://github.com/immersive-web/hit-test
  45825. */
  45826. export class WebXRHitTestLegacy implements IWebXRFeature {
  45827. private _xrSessionManager;
  45828. /**
  45829. * options to use when constructing this feature
  45830. */
  45831. readonly options: IWebXRHitTestOptions;
  45832. /**
  45833. * The module's name
  45834. */
  45835. static readonly Name: string;
  45836. /**
  45837. * The (Babylon) version of this module.
  45838. * This is an integer representing the implementation version.
  45839. * This number does not correspond to the webxr specs version
  45840. */
  45841. static readonly Version: number;
  45842. /**
  45843. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45844. * @param event the (select) event to use to select with
  45845. * @param referenceSpace the reference space to use for this hit test
  45846. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45847. */
  45848. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45849. /**
  45850. * execute a hit test with an XR Ray
  45851. *
  45852. * @param xrSession a native xrSession that will execute this hit test
  45853. * @param xrRay the ray (position and direction) to use for raycasting
  45854. * @param referenceSpace native XR reference space to use for the hit-test
  45855. * @param filter filter function that will filter the results
  45856. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45857. */
  45858. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  45859. /**
  45860. * Triggered when new babylon (transformed) hit test results are available
  45861. */
  45862. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  45863. /**
  45864. * Creates a new instance of the (legacy version) hit test feature
  45865. * @param _xrSessionManager an instance of WebXRSessionManager
  45866. * @param options options to use when constructing this feature
  45867. */
  45868. constructor(_xrSessionManager: WebXRSessionManager,
  45869. /**
  45870. * options to use when constructing this feature
  45871. */
  45872. options?: IWebXRHitTestOptions);
  45873. private _onSelectEnabled;
  45874. private _xrFrameObserver;
  45875. private _attached;
  45876. /**
  45877. * Populated with the last native XR Hit Results
  45878. */
  45879. lastNativeXRHitResults: XRHitResult[];
  45880. /**
  45881. * attach this feature
  45882. * Will usually be called by the features manager
  45883. *
  45884. * @returns true if successful.
  45885. */
  45886. attach(): boolean;
  45887. /**
  45888. * detach this feature.
  45889. * Will usually be called by the features manager
  45890. *
  45891. * @returns true if successful.
  45892. */
  45893. detach(): boolean;
  45894. private _onHitTestResults;
  45895. private _onSelect;
  45896. /**
  45897. * Dispose this feature and all of the resources attached
  45898. */
  45899. dispose(): void;
  45900. }
  45901. }
  45902. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  45903. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45904. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45905. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45906. import { Observable } from "babylonjs/Misc/observable";
  45907. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  45908. /**
  45909. * Options used in the plane detector module
  45910. */
  45911. export interface IWebXRPlaneDetectorOptions {
  45912. /**
  45913. * The node to use to transform the local results to world coordinates
  45914. */
  45915. worldParentNode?: TransformNode;
  45916. }
  45917. /**
  45918. * A babylon interface for a webxr plane.
  45919. * A Plane is actually a polygon, built from N points in space
  45920. */
  45921. export interface IWebXRPlane {
  45922. /**
  45923. * a babylon-assigned ID for this polygon
  45924. */
  45925. id: number;
  45926. /**
  45927. * the native xr-plane object
  45928. */
  45929. xrPlane: XRPlane;
  45930. /**
  45931. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45932. */
  45933. polygonDefinition: Array<Vector3>;
  45934. /**
  45935. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45936. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45937. */
  45938. transformationMatrix: Matrix;
  45939. }
  45940. /**
  45941. * The plane detector is used to detect planes in the real world when in AR
  45942. * For more information see https://github.com/immersive-web/real-world-geometry/
  45943. */
  45944. export class WebXRPlaneDetector implements IWebXRFeature {
  45945. private _xrSessionManager;
  45946. private _options;
  45947. /**
  45948. * The module's name
  45949. */
  45950. static readonly Name: string;
  45951. /**
  45952. * The (Babylon) version of this module.
  45953. * This is an integer representing the implementation version.
  45954. * This number does not correspond to the webxr specs version
  45955. */
  45956. static readonly Version: number;
  45957. /**
  45958. * Observers registered here will be executed when a new plane was added to the session
  45959. */
  45960. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45961. /**
  45962. * Observers registered here will be executed when a plane is no longer detected in the session
  45963. */
  45964. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45965. /**
  45966. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45967. * This can execute N times every frame
  45968. */
  45969. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45970. private _enabled;
  45971. private _attached;
  45972. private _detectedPlanes;
  45973. private _lastFrameDetected;
  45974. private _observerTracked;
  45975. /**
  45976. * construct a new Plane Detector
  45977. * @param _xrSessionManager an instance of xr Session manager
  45978. * @param _options configuration to use when constructing this feature
  45979. */
  45980. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45981. /**
  45982. * attach this feature
  45983. * Will usually be called by the features manager
  45984. *
  45985. * @returns true if successful.
  45986. */
  45987. attach(): boolean;
  45988. /**
  45989. * detach this feature.
  45990. * Will usually be called by the features manager
  45991. *
  45992. * @returns true if successful.
  45993. */
  45994. detach(): boolean;
  45995. /**
  45996. * Dispose this feature and all of the resources attached
  45997. */
  45998. dispose(): void;
  45999. private _updatePlaneWithXRPlane;
  46000. /**
  46001. * avoiding using Array.find for global support.
  46002. * @param xrPlane the plane to find in the array
  46003. */
  46004. private findIndexInPlaneArray;
  46005. }
  46006. }
  46007. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  46008. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46009. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46010. import { Observable } from "babylonjs/Misc/observable";
  46011. import { Matrix } from "babylonjs/Maths/math.vector";
  46012. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46013. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46014. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46015. /**
  46016. * Configuration options of the anchor system
  46017. */
  46018. export interface IWebXRAnchorSystemOptions {
  46019. /**
  46020. * a node that will be used to convert local to world coordinates
  46021. */
  46022. worldParentNode?: TransformNode;
  46023. /**
  46024. * should the anchor system use plane detection.
  46025. * If set to true, the plane-detection feature should be set using setPlaneDetector
  46026. */
  46027. usePlaneDetection?: boolean;
  46028. /**
  46029. * Should a new anchor be added every time a select event is triggered
  46030. */
  46031. addAnchorOnSelect?: boolean;
  46032. }
  46033. /**
  46034. * A babylon container for an XR Anchor
  46035. */
  46036. export interface IWebXRAnchor {
  46037. /**
  46038. * A babylon-assigned ID for this anchor
  46039. */
  46040. id: number;
  46041. /**
  46042. * The native anchor object
  46043. */
  46044. xrAnchor: XRAnchor;
  46045. /**
  46046. * Transformation matrix to apply to an object attached to this anchor
  46047. */
  46048. transformationMatrix: Matrix;
  46049. }
  46050. /**
  46051. * An implementation of the anchor system of WebXR.
  46052. * Note that the current documented implementation is not available in any browser. Future implementations
  46053. * will use the frame to create an anchor and not the session or a detected plane
  46054. * For further information see https://github.com/immersive-web/anchors/
  46055. */
  46056. export class WebXRAnchorSystem implements IWebXRFeature {
  46057. private _xrSessionManager;
  46058. private _options;
  46059. /**
  46060. * The module's name
  46061. */
  46062. static readonly Name: string;
  46063. /**
  46064. * The (Babylon) version of this module.
  46065. * This is an integer representing the implementation version.
  46066. * This number does not correspond to the webxr specs version
  46067. */
  46068. static readonly Version: number;
  46069. /**
  46070. * Observers registered here will be executed when a new anchor was added to the session
  46071. */
  46072. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  46073. /**
  46074. * Observers registered here will be executed when an existing anchor updates
  46075. * This can execute N times every frame
  46076. */
  46077. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  46078. /**
  46079. * Observers registered here will be executed when an anchor was removed from the session
  46080. */
  46081. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  46082. private _planeDetector;
  46083. private _hitTestModule;
  46084. private _enabled;
  46085. private _attached;
  46086. private _trackedAnchors;
  46087. private _lastFrameDetected;
  46088. private _observerTracked;
  46089. /**
  46090. * constructs a new anchor system
  46091. * @param _xrSessionManager an instance of WebXRSessionManager
  46092. * @param _options configuration object for this feature
  46093. */
  46094. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46095. /**
  46096. * set the plane detector to use in order to create anchors from frames
  46097. * @param planeDetector the plane-detector module to use
  46098. * @param enable enable plane-anchors. default is true
  46099. */
  46100. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46101. /**
  46102. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46103. * @param hitTestModule the hit-test module to use.
  46104. */
  46105. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46106. /**
  46107. * attach this feature
  46108. * Will usually be called by the features manager
  46109. *
  46110. * @returns true if successful.
  46111. */
  46112. attach(): boolean;
  46113. /**
  46114. * detach this feature.
  46115. * Will usually be called by the features manager
  46116. *
  46117. * @returns true if successful.
  46118. */
  46119. detach(): boolean;
  46120. /**
  46121. * Dispose this feature and all of the resources attached
  46122. */
  46123. dispose(): void;
  46124. private _onSelect;
  46125. /**
  46126. * Add anchor at a specific XR point.
  46127. *
  46128. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46129. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46130. * @returns a promise the fulfills when the anchor was created
  46131. */
  46132. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46133. private _updateAnchorWithXRFrame;
  46134. /**
  46135. * avoiding using Array.find for global support.
  46136. * @param xrAnchor the plane to find in the array
  46137. */
  46138. private _findIndexInAnchorArray;
  46139. }
  46140. }
  46141. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46142. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46143. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46145. import { Observable } from "babylonjs/Misc/observable";
  46146. /**
  46147. * Options interface for the background remover plugin
  46148. */
  46149. export interface IWebXRBackgroundRemoverOptions {
  46150. /**
  46151. * don't disable the environment helper
  46152. */
  46153. ignoreEnvironmentHelper?: boolean;
  46154. /**
  46155. * flags to configure the removal of the environment helper.
  46156. * If not set, the entire background will be removed. If set, flags should be set as well.
  46157. */
  46158. environmentHelperRemovalFlags?: {
  46159. /**
  46160. * Should the skybox be removed (default false)
  46161. */
  46162. skyBox?: boolean;
  46163. /**
  46164. * Should the ground be removed (default false)
  46165. */
  46166. ground?: boolean;
  46167. };
  46168. /**
  46169. * Further background meshes to disable when entering AR
  46170. */
  46171. backgroundMeshes?: AbstractMesh[];
  46172. }
  46173. /**
  46174. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46175. */
  46176. export class WebXRBackgroundRemover implements IWebXRFeature {
  46177. private _xrSessionManager;
  46178. /**
  46179. * read-only options to be used in this module
  46180. */
  46181. readonly options: IWebXRBackgroundRemoverOptions;
  46182. /**
  46183. * The module's name
  46184. */
  46185. static readonly Name: string;
  46186. /**
  46187. * The (Babylon) version of this module.
  46188. * This is an integer representing the implementation version.
  46189. * This number does not correspond to the webxr specs version
  46190. */
  46191. static readonly Version: number;
  46192. /**
  46193. * registered observers will be triggered when the background state changes
  46194. */
  46195. onBackgroundStateChangedObservable: Observable<boolean>;
  46196. /**
  46197. * constructs a new background remover module
  46198. * @param _xrSessionManager the session manager for this module
  46199. * @param options read-only options to be used in this module
  46200. */
  46201. constructor(_xrSessionManager: WebXRSessionManager,
  46202. /**
  46203. * read-only options to be used in this module
  46204. */
  46205. options?: IWebXRBackgroundRemoverOptions);
  46206. /**
  46207. * attach this feature
  46208. * Will usually be called by the features manager
  46209. *
  46210. * @returns true if successful.
  46211. */
  46212. attach(): boolean;
  46213. /**
  46214. * detach this feature.
  46215. * Will usually be called by the features manager
  46216. *
  46217. * @returns true if successful.
  46218. */
  46219. detach(): boolean;
  46220. private _setBackgroundState;
  46221. /**
  46222. * Dispose this feature and all of the resources attached
  46223. */
  46224. dispose(): void;
  46225. }
  46226. }
  46227. declare module "babylonjs/Cameras/XR/features/index" {
  46228. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46229. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46230. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46231. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46232. }
  46233. declare module "babylonjs/Cameras/XR/index" {
  46234. export * from "babylonjs/Cameras/XR/webXRCamera";
  46235. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  46236. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46237. export * from "babylonjs/Cameras/XR/webXRInput";
  46238. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  46239. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  46240. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  46241. export * from "babylonjs/Cameras/XR/webXRController";
  46242. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  46243. export * from "babylonjs/Cameras/XR/webXRTypes";
  46244. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  46245. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46246. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46247. export * from "babylonjs/Cameras/XR/features/index";
  46248. }
  46249. declare module "babylonjs/Cameras/RigModes/index" {
  46250. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46251. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46252. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46253. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46254. }
  46255. declare module "babylonjs/Cameras/index" {
  46256. export * from "babylonjs/Cameras/Inputs/index";
  46257. export * from "babylonjs/Cameras/cameraInputsManager";
  46258. export * from "babylonjs/Cameras/camera";
  46259. export * from "babylonjs/Cameras/targetCamera";
  46260. export * from "babylonjs/Cameras/freeCamera";
  46261. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46262. export * from "babylonjs/Cameras/touchCamera";
  46263. export * from "babylonjs/Cameras/arcRotateCamera";
  46264. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46265. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46266. export * from "babylonjs/Cameras/flyCamera";
  46267. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46268. export * from "babylonjs/Cameras/followCamera";
  46269. export * from "babylonjs/Cameras/followCameraInputsManager";
  46270. export * from "babylonjs/Cameras/gamepadCamera";
  46271. export * from "babylonjs/Cameras/Stereoscopic/index";
  46272. export * from "babylonjs/Cameras/universalCamera";
  46273. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46274. export * from "babylonjs/Cameras/VR/index";
  46275. export * from "babylonjs/Cameras/XR/index";
  46276. export * from "babylonjs/Cameras/RigModes/index";
  46277. }
  46278. declare module "babylonjs/Collisions/index" {
  46279. export * from "babylonjs/Collisions/collider";
  46280. export * from "babylonjs/Collisions/collisionCoordinator";
  46281. export * from "babylonjs/Collisions/pickingInfo";
  46282. export * from "babylonjs/Collisions/intersectionInfo";
  46283. export * from "babylonjs/Collisions/meshCollisionData";
  46284. }
  46285. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46286. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46287. import { Vector3 } from "babylonjs/Maths/math.vector";
  46288. import { Ray } from "babylonjs/Culling/ray";
  46289. import { Plane } from "babylonjs/Maths/math.plane";
  46290. /**
  46291. * Contains an array of blocks representing the octree
  46292. */
  46293. export interface IOctreeContainer<T> {
  46294. /**
  46295. * Blocks within the octree
  46296. */
  46297. blocks: Array<OctreeBlock<T>>;
  46298. }
  46299. /**
  46300. * Class used to store a cell in an octree
  46301. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46302. */
  46303. export class OctreeBlock<T> {
  46304. /**
  46305. * Gets the content of the current block
  46306. */
  46307. entries: T[];
  46308. /**
  46309. * Gets the list of block children
  46310. */
  46311. blocks: Array<OctreeBlock<T>>;
  46312. private _depth;
  46313. private _maxDepth;
  46314. private _capacity;
  46315. private _minPoint;
  46316. private _maxPoint;
  46317. private _boundingVectors;
  46318. private _creationFunc;
  46319. /**
  46320. * Creates a new block
  46321. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46322. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46323. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46324. * @param depth defines the current depth of this block in the octree
  46325. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46326. * @param creationFunc defines a callback to call when an element is added to the block
  46327. */
  46328. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46329. /**
  46330. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46331. */
  46332. get capacity(): number;
  46333. /**
  46334. * Gets the minimum vector (in world space) of the block's bounding box
  46335. */
  46336. get minPoint(): Vector3;
  46337. /**
  46338. * Gets the maximum vector (in world space) of the block's bounding box
  46339. */
  46340. get maxPoint(): Vector3;
  46341. /**
  46342. * Add a new element to this block
  46343. * @param entry defines the element to add
  46344. */
  46345. addEntry(entry: T): void;
  46346. /**
  46347. * Remove an element from this block
  46348. * @param entry defines the element to remove
  46349. */
  46350. removeEntry(entry: T): void;
  46351. /**
  46352. * Add an array of elements to this block
  46353. * @param entries defines the array of elements to add
  46354. */
  46355. addEntries(entries: T[]): void;
  46356. /**
  46357. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46358. * @param frustumPlanes defines the frustum planes to test
  46359. * @param selection defines the array to store current content if selection is positive
  46360. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46361. */
  46362. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46363. /**
  46364. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46365. * @param sphereCenter defines the bounding sphere center
  46366. * @param sphereRadius defines the bounding sphere radius
  46367. * @param selection defines the array to store current content if selection is positive
  46368. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46369. */
  46370. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46371. /**
  46372. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46373. * @param ray defines the ray to test with
  46374. * @param selection defines the array to store current content if selection is positive
  46375. */
  46376. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46377. /**
  46378. * Subdivide the content into child blocks (this block will then be empty)
  46379. */
  46380. createInnerBlocks(): void;
  46381. /**
  46382. * @hidden
  46383. */
  46384. 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;
  46385. }
  46386. }
  46387. declare module "babylonjs/Culling/Octrees/octree" {
  46388. import { SmartArray } from "babylonjs/Misc/smartArray";
  46389. import { Vector3 } from "babylonjs/Maths/math.vector";
  46390. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46392. import { Ray } from "babylonjs/Culling/ray";
  46393. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46394. import { Plane } from "babylonjs/Maths/math.plane";
  46395. /**
  46396. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46397. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46398. */
  46399. export class Octree<T> {
  46400. /** 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.) */
  46401. maxDepth: number;
  46402. /**
  46403. * Blocks within the octree containing objects
  46404. */
  46405. blocks: Array<OctreeBlock<T>>;
  46406. /**
  46407. * Content stored in the octree
  46408. */
  46409. dynamicContent: T[];
  46410. private _maxBlockCapacity;
  46411. private _selectionContent;
  46412. private _creationFunc;
  46413. /**
  46414. * Creates a octree
  46415. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46416. * @param creationFunc function to be used to instatiate the octree
  46417. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46418. * @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.)
  46419. */
  46420. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46421. /** 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.) */
  46422. maxDepth?: number);
  46423. /**
  46424. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46425. * @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);
  46426. * @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);
  46427. * @param entries meshes to be added to the octree blocks
  46428. */
  46429. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46430. /**
  46431. * Adds a mesh to the octree
  46432. * @param entry Mesh to add to the octree
  46433. */
  46434. addMesh(entry: T): void;
  46435. /**
  46436. * Remove an element from the octree
  46437. * @param entry defines the element to remove
  46438. */
  46439. removeMesh(entry: T): void;
  46440. /**
  46441. * Selects an array of meshes within the frustum
  46442. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46443. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46444. * @returns array of meshes within the frustum
  46445. */
  46446. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46447. /**
  46448. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46449. * @param sphereCenter defines the bounding sphere center
  46450. * @param sphereRadius defines the bounding sphere radius
  46451. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46452. * @returns an array of objects that intersect the sphere
  46453. */
  46454. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46455. /**
  46456. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46457. * @param ray defines the ray to test with
  46458. * @returns array of intersected objects
  46459. */
  46460. intersectsRay(ray: Ray): SmartArray<T>;
  46461. /**
  46462. * Adds a mesh into the octree block if it intersects the block
  46463. */
  46464. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46465. /**
  46466. * Adds a submesh into the octree block if it intersects the block
  46467. */
  46468. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46469. }
  46470. }
  46471. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  46472. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  46473. import { Scene } from "babylonjs/scene";
  46474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46476. import { Ray } from "babylonjs/Culling/ray";
  46477. import { Octree } from "babylonjs/Culling/Octrees/octree";
  46478. import { Collider } from "babylonjs/Collisions/collider";
  46479. module "babylonjs/scene" {
  46480. interface Scene {
  46481. /**
  46482. * @hidden
  46483. * Backing Filed
  46484. */
  46485. _selectionOctree: Octree<AbstractMesh>;
  46486. /**
  46487. * Gets the octree used to boost mesh selection (picking)
  46488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46489. */
  46490. selectionOctree: Octree<AbstractMesh>;
  46491. /**
  46492. * Creates or updates the octree used to boost selection (picking)
  46493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46494. * @param maxCapacity defines the maximum capacity per leaf
  46495. * @param maxDepth defines the maximum depth of the octree
  46496. * @returns an octree of AbstractMesh
  46497. */
  46498. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46499. }
  46500. }
  46501. module "babylonjs/Meshes/abstractMesh" {
  46502. interface AbstractMesh {
  46503. /**
  46504. * @hidden
  46505. * Backing Field
  46506. */
  46507. _submeshesOctree: Octree<SubMesh>;
  46508. /**
  46509. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46510. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46511. * @param maxCapacity defines the maximum size of each block (64 by default)
  46512. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46513. * @returns the new octree
  46514. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46516. */
  46517. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46518. }
  46519. }
  46520. /**
  46521. * Defines the octree scene component responsible to manage any octrees
  46522. * in a given scene.
  46523. */
  46524. export class OctreeSceneComponent {
  46525. /**
  46526. * The component name help to identify the component in the list of scene components.
  46527. */
  46528. readonly name: string;
  46529. /**
  46530. * The scene the component belongs to.
  46531. */
  46532. scene: Scene;
  46533. /**
  46534. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46535. */
  46536. readonly checksIsEnabled: boolean;
  46537. /**
  46538. * Creates a new instance of the component for the given scene
  46539. * @param scene Defines the scene to register the component in
  46540. */
  46541. constructor(scene: Scene);
  46542. /**
  46543. * Registers the component in a given scene
  46544. */
  46545. register(): void;
  46546. /**
  46547. * Return the list of active meshes
  46548. * @returns the list of active meshes
  46549. */
  46550. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46551. /**
  46552. * Return the list of active sub meshes
  46553. * @param mesh The mesh to get the candidates sub meshes from
  46554. * @returns the list of active sub meshes
  46555. */
  46556. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46557. private _tempRay;
  46558. /**
  46559. * Return the list of sub meshes intersecting with a given local ray
  46560. * @param mesh defines the mesh to find the submesh for
  46561. * @param localRay defines the ray in local space
  46562. * @returns the list of intersecting sub meshes
  46563. */
  46564. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46565. /**
  46566. * Return the list of sub meshes colliding with a collider
  46567. * @param mesh defines the mesh to find the submesh for
  46568. * @param collider defines the collider to evaluate the collision against
  46569. * @returns the list of colliding sub meshes
  46570. */
  46571. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46572. /**
  46573. * Rebuilds the elements related to this component in case of
  46574. * context lost for instance.
  46575. */
  46576. rebuild(): void;
  46577. /**
  46578. * Disposes the component and the associated ressources.
  46579. */
  46580. dispose(): void;
  46581. }
  46582. }
  46583. declare module "babylonjs/Culling/Octrees/index" {
  46584. export * from "babylonjs/Culling/Octrees/octree";
  46585. export * from "babylonjs/Culling/Octrees/octreeBlock";
  46586. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  46587. }
  46588. declare module "babylonjs/Culling/index" {
  46589. export * from "babylonjs/Culling/boundingBox";
  46590. export * from "babylonjs/Culling/boundingInfo";
  46591. export * from "babylonjs/Culling/boundingSphere";
  46592. export * from "babylonjs/Culling/Octrees/index";
  46593. export * from "babylonjs/Culling/ray";
  46594. }
  46595. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46596. import { IDisposable, Scene } from "babylonjs/scene";
  46597. import { Nullable } from "babylonjs/types";
  46598. import { Observable } from "babylonjs/Misc/observable";
  46599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46600. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46601. import { Camera } from "babylonjs/Cameras/camera";
  46602. /**
  46603. * Renders a layer on top of an existing scene
  46604. */
  46605. export class UtilityLayerRenderer implements IDisposable {
  46606. /** the original scene that will be rendered on top of */
  46607. originalScene: Scene;
  46608. private _pointerCaptures;
  46609. private _lastPointerEvents;
  46610. private static _DefaultUtilityLayer;
  46611. private static _DefaultKeepDepthUtilityLayer;
  46612. private _sharedGizmoLight;
  46613. private _renderCamera;
  46614. /**
  46615. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46616. * @returns the camera that is used when rendering the utility layer
  46617. */
  46618. getRenderCamera(): Nullable<Camera>;
  46619. /**
  46620. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46621. * @param cam the camera that should be used when rendering the utility layer
  46622. */
  46623. setRenderCamera(cam: Nullable<Camera>): void;
  46624. /**
  46625. * @hidden
  46626. * Light which used by gizmos to get light shading
  46627. */
  46628. _getSharedGizmoLight(): HemisphericLight;
  46629. /**
  46630. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46631. */
  46632. pickUtilitySceneFirst: boolean;
  46633. /**
  46634. * 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)
  46635. */
  46636. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46637. /**
  46638. * 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)
  46639. */
  46640. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46641. /**
  46642. * The scene that is rendered on top of the original scene
  46643. */
  46644. utilityLayerScene: Scene;
  46645. /**
  46646. * If the utility layer should automatically be rendered on top of existing scene
  46647. */
  46648. shouldRender: boolean;
  46649. /**
  46650. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46651. */
  46652. onlyCheckPointerDownEvents: boolean;
  46653. /**
  46654. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46655. */
  46656. processAllEvents: boolean;
  46657. /**
  46658. * Observable raised when the pointer move from the utility layer scene to the main scene
  46659. */
  46660. onPointerOutObservable: Observable<number>;
  46661. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46662. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46663. private _afterRenderObserver;
  46664. private _sceneDisposeObserver;
  46665. private _originalPointerObserver;
  46666. /**
  46667. * Instantiates a UtilityLayerRenderer
  46668. * @param originalScene the original scene that will be rendered on top of
  46669. * @param handleEvents boolean indicating if the utility layer should handle events
  46670. */
  46671. constructor(
  46672. /** the original scene that will be rendered on top of */
  46673. originalScene: Scene, handleEvents?: boolean);
  46674. private _notifyObservers;
  46675. /**
  46676. * Renders the utility layers scene on top of the original scene
  46677. */
  46678. render(): void;
  46679. /**
  46680. * Disposes of the renderer
  46681. */
  46682. dispose(): void;
  46683. private _updateCamera;
  46684. }
  46685. }
  46686. declare module "babylonjs/Gizmos/gizmo" {
  46687. import { Nullable } from "babylonjs/types";
  46688. import { IDisposable } from "babylonjs/scene";
  46689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46690. import { Mesh } from "babylonjs/Meshes/mesh";
  46691. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46692. /**
  46693. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46694. */
  46695. export class Gizmo implements IDisposable {
  46696. /** The utility layer the gizmo will be added to */
  46697. gizmoLayer: UtilityLayerRenderer;
  46698. /**
  46699. * The root mesh of the gizmo
  46700. */
  46701. _rootMesh: Mesh;
  46702. private _attachedMesh;
  46703. /**
  46704. * Ratio for the scale of the gizmo (Default: 1)
  46705. */
  46706. scaleRatio: number;
  46707. /**
  46708. * If a custom mesh has been set (Default: false)
  46709. */
  46710. protected _customMeshSet: boolean;
  46711. /**
  46712. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46713. * * When set, interactions will be enabled
  46714. */
  46715. get attachedMesh(): Nullable<AbstractMesh>;
  46716. set attachedMesh(value: Nullable<AbstractMesh>);
  46717. /**
  46718. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46719. * @param mesh The mesh to replace the default mesh of the gizmo
  46720. */
  46721. setCustomMesh(mesh: Mesh): void;
  46722. /**
  46723. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46724. */
  46725. updateGizmoRotationToMatchAttachedMesh: boolean;
  46726. /**
  46727. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46728. */
  46729. updateGizmoPositionToMatchAttachedMesh: boolean;
  46730. /**
  46731. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46732. */
  46733. updateScale: boolean;
  46734. protected _interactionsEnabled: boolean;
  46735. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46736. private _beforeRenderObserver;
  46737. private _tempVector;
  46738. /**
  46739. * Creates a gizmo
  46740. * @param gizmoLayer The utility layer the gizmo will be added to
  46741. */
  46742. constructor(
  46743. /** The utility layer the gizmo will be added to */
  46744. gizmoLayer?: UtilityLayerRenderer);
  46745. /**
  46746. * Updates the gizmo to match the attached mesh's position/rotation
  46747. */
  46748. protected _update(): void;
  46749. /**
  46750. * Disposes of the gizmo
  46751. */
  46752. dispose(): void;
  46753. }
  46754. }
  46755. declare module "babylonjs/Gizmos/planeDragGizmo" {
  46756. import { Observable } from "babylonjs/Misc/observable";
  46757. import { Nullable } from "babylonjs/types";
  46758. import { Vector3 } from "babylonjs/Maths/math.vector";
  46759. import { Color3 } from "babylonjs/Maths/math.color";
  46760. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46762. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46763. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46764. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46765. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46766. import { Scene } from "babylonjs/scene";
  46767. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46768. /**
  46769. * Single plane drag gizmo
  46770. */
  46771. export class PlaneDragGizmo extends Gizmo {
  46772. /**
  46773. * Drag behavior responsible for the gizmos dragging interactions
  46774. */
  46775. dragBehavior: PointerDragBehavior;
  46776. private _pointerObserver;
  46777. /**
  46778. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46779. */
  46780. snapDistance: number;
  46781. /**
  46782. * Event that fires each time the gizmo snaps to a new location.
  46783. * * snapDistance is the the change in distance
  46784. */
  46785. onSnapObservable: Observable<{
  46786. snapDistance: number;
  46787. }>;
  46788. private _plane;
  46789. private _coloredMaterial;
  46790. private _hoverMaterial;
  46791. private _isEnabled;
  46792. private _parent;
  46793. /** @hidden */
  46794. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46795. /** @hidden */
  46796. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46797. /**
  46798. * Creates a PlaneDragGizmo
  46799. * @param gizmoLayer The utility layer the gizmo will be added to
  46800. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46801. * @param color The color of the gizmo
  46802. */
  46803. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46804. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46805. /**
  46806. * If the gizmo is enabled
  46807. */
  46808. set isEnabled(value: boolean);
  46809. get isEnabled(): boolean;
  46810. /**
  46811. * Disposes of the gizmo
  46812. */
  46813. dispose(): void;
  46814. }
  46815. }
  46816. declare module "babylonjs/Gizmos/positionGizmo" {
  46817. import { Observable } from "babylonjs/Misc/observable";
  46818. import { Nullable } from "babylonjs/types";
  46819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46820. import { Mesh } from "babylonjs/Meshes/mesh";
  46821. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46822. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  46823. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  46824. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46825. /**
  46826. * Gizmo that enables dragging a mesh along 3 axis
  46827. */
  46828. export class PositionGizmo extends Gizmo {
  46829. /**
  46830. * Internal gizmo used for interactions on the x axis
  46831. */
  46832. xGizmo: AxisDragGizmo;
  46833. /**
  46834. * Internal gizmo used for interactions on the y axis
  46835. */
  46836. yGizmo: AxisDragGizmo;
  46837. /**
  46838. * Internal gizmo used for interactions on the z axis
  46839. */
  46840. zGizmo: AxisDragGizmo;
  46841. /**
  46842. * Internal gizmo used for interactions on the yz plane
  46843. */
  46844. xPlaneGizmo: PlaneDragGizmo;
  46845. /**
  46846. * Internal gizmo used for interactions on the xz plane
  46847. */
  46848. yPlaneGizmo: PlaneDragGizmo;
  46849. /**
  46850. * Internal gizmo used for interactions on the xy plane
  46851. */
  46852. zPlaneGizmo: PlaneDragGizmo;
  46853. /**
  46854. * private variables
  46855. */
  46856. private _meshAttached;
  46857. private _updateGizmoRotationToMatchAttachedMesh;
  46858. private _snapDistance;
  46859. private _scaleRatio;
  46860. /** Fires an event when any of it's sub gizmos are dragged */
  46861. onDragStartObservable: Observable<unknown>;
  46862. /** Fires an event when any of it's sub gizmos are released from dragging */
  46863. onDragEndObservable: Observable<unknown>;
  46864. /**
  46865. * If set to true, planar drag is enabled
  46866. */
  46867. private _planarGizmoEnabled;
  46868. get attachedMesh(): Nullable<AbstractMesh>;
  46869. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46870. /**
  46871. * Creates a PositionGizmo
  46872. * @param gizmoLayer The utility layer the gizmo will be added to
  46873. */
  46874. constructor(gizmoLayer?: UtilityLayerRenderer);
  46875. /**
  46876. * If the planar drag gizmo is enabled
  46877. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46878. */
  46879. set planarGizmoEnabled(value: boolean);
  46880. get planarGizmoEnabled(): boolean;
  46881. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46882. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46883. /**
  46884. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46885. */
  46886. set snapDistance(value: number);
  46887. get snapDistance(): number;
  46888. /**
  46889. * Ratio for the scale of the gizmo (Default: 1)
  46890. */
  46891. set scaleRatio(value: number);
  46892. get scaleRatio(): number;
  46893. /**
  46894. * Disposes of the gizmo
  46895. */
  46896. dispose(): void;
  46897. /**
  46898. * CustomMeshes are not supported by this gizmo
  46899. * @param mesh The mesh to replace the default mesh of the gizmo
  46900. */
  46901. setCustomMesh(mesh: Mesh): void;
  46902. }
  46903. }
  46904. declare module "babylonjs/Gizmos/axisDragGizmo" {
  46905. import { Observable } from "babylonjs/Misc/observable";
  46906. import { Nullable } from "babylonjs/types";
  46907. import { Vector3 } from "babylonjs/Maths/math.vector";
  46908. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46910. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46911. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46912. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46913. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46914. import { Scene } from "babylonjs/scene";
  46915. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46916. import { Color3 } from "babylonjs/Maths/math.color";
  46917. /**
  46918. * Single axis drag gizmo
  46919. */
  46920. export class AxisDragGizmo extends Gizmo {
  46921. /**
  46922. * Drag behavior responsible for the gizmos dragging interactions
  46923. */
  46924. dragBehavior: PointerDragBehavior;
  46925. private _pointerObserver;
  46926. /**
  46927. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46928. */
  46929. snapDistance: number;
  46930. /**
  46931. * Event that fires each time the gizmo snaps to a new location.
  46932. * * snapDistance is the the change in distance
  46933. */
  46934. onSnapObservable: Observable<{
  46935. snapDistance: number;
  46936. }>;
  46937. private _isEnabled;
  46938. private _parent;
  46939. private _arrow;
  46940. private _coloredMaterial;
  46941. private _hoverMaterial;
  46942. /** @hidden */
  46943. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46944. /** @hidden */
  46945. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46946. /**
  46947. * Creates an AxisDragGizmo
  46948. * @param gizmoLayer The utility layer the gizmo will be added to
  46949. * @param dragAxis The axis which the gizmo will be able to drag on
  46950. * @param color The color of the gizmo
  46951. */
  46952. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46953. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46954. /**
  46955. * If the gizmo is enabled
  46956. */
  46957. set isEnabled(value: boolean);
  46958. get isEnabled(): boolean;
  46959. /**
  46960. * Disposes of the gizmo
  46961. */
  46962. dispose(): void;
  46963. }
  46964. }
  46965. declare module "babylonjs/Debug/axesViewer" {
  46966. import { Vector3 } from "babylonjs/Maths/math.vector";
  46967. import { Nullable } from "babylonjs/types";
  46968. import { Scene } from "babylonjs/scene";
  46969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46970. /**
  46971. * The Axes viewer will show 3 axes in a specific point in space
  46972. */
  46973. export class AxesViewer {
  46974. private _xAxis;
  46975. private _yAxis;
  46976. private _zAxis;
  46977. private _scaleLinesFactor;
  46978. private _instanced;
  46979. /**
  46980. * Gets the hosting scene
  46981. */
  46982. scene: Scene;
  46983. /**
  46984. * Gets or sets a number used to scale line length
  46985. */
  46986. scaleLines: number;
  46987. /** Gets the node hierarchy used to render x-axis */
  46988. get xAxis(): TransformNode;
  46989. /** Gets the node hierarchy used to render y-axis */
  46990. get yAxis(): TransformNode;
  46991. /** Gets the node hierarchy used to render z-axis */
  46992. get zAxis(): TransformNode;
  46993. /**
  46994. * Creates a new AxesViewer
  46995. * @param scene defines the hosting scene
  46996. * @param scaleLines defines a number used to scale line length (1 by default)
  46997. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46998. * @param xAxis defines the node hierarchy used to render the x-axis
  46999. * @param yAxis defines the node hierarchy used to render the y-axis
  47000. * @param zAxis defines the node hierarchy used to render the z-axis
  47001. */
  47002. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47003. /**
  47004. * Force the viewer to update
  47005. * @param position defines the position of the viewer
  47006. * @param xaxis defines the x axis of the viewer
  47007. * @param yaxis defines the y axis of the viewer
  47008. * @param zaxis defines the z axis of the viewer
  47009. */
  47010. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47011. /**
  47012. * Creates an instance of this axes viewer.
  47013. * @returns a new axes viewer with instanced meshes
  47014. */
  47015. createInstance(): AxesViewer;
  47016. /** Releases resources */
  47017. dispose(): void;
  47018. private static _SetRenderingGroupId;
  47019. }
  47020. }
  47021. declare module "babylonjs/Debug/boneAxesViewer" {
  47022. import { Nullable } from "babylonjs/types";
  47023. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47024. import { Vector3 } from "babylonjs/Maths/math.vector";
  47025. import { Mesh } from "babylonjs/Meshes/mesh";
  47026. import { Bone } from "babylonjs/Bones/bone";
  47027. import { Scene } from "babylonjs/scene";
  47028. /**
  47029. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47030. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47031. */
  47032. export class BoneAxesViewer extends AxesViewer {
  47033. /**
  47034. * Gets or sets the target mesh where to display the axes viewer
  47035. */
  47036. mesh: Nullable<Mesh>;
  47037. /**
  47038. * Gets or sets the target bone where to display the axes viewer
  47039. */
  47040. bone: Nullable<Bone>;
  47041. /** Gets current position */
  47042. pos: Vector3;
  47043. /** Gets direction of X axis */
  47044. xaxis: Vector3;
  47045. /** Gets direction of Y axis */
  47046. yaxis: Vector3;
  47047. /** Gets direction of Z axis */
  47048. zaxis: Vector3;
  47049. /**
  47050. * Creates a new BoneAxesViewer
  47051. * @param scene defines the hosting scene
  47052. * @param bone defines the target bone
  47053. * @param mesh defines the target mesh
  47054. * @param scaleLines defines a scaling factor for line length (1 by default)
  47055. */
  47056. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47057. /**
  47058. * Force the viewer to update
  47059. */
  47060. update(): void;
  47061. /** Releases resources */
  47062. dispose(): void;
  47063. }
  47064. }
  47065. declare module "babylonjs/Debug/debugLayer" {
  47066. import { Scene } from "babylonjs/scene";
  47067. /**
  47068. * Interface used to define scene explorer extensibility option
  47069. */
  47070. export interface IExplorerExtensibilityOption {
  47071. /**
  47072. * Define the option label
  47073. */
  47074. label: string;
  47075. /**
  47076. * Defines the action to execute on click
  47077. */
  47078. action: (entity: any) => void;
  47079. }
  47080. /**
  47081. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47082. */
  47083. export interface IExplorerExtensibilityGroup {
  47084. /**
  47085. * Defines a predicate to test if a given type mut be extended
  47086. */
  47087. predicate: (entity: any) => boolean;
  47088. /**
  47089. * Gets the list of options added to a type
  47090. */
  47091. entries: IExplorerExtensibilityOption[];
  47092. }
  47093. /**
  47094. * Interface used to define the options to use to create the Inspector
  47095. */
  47096. export interface IInspectorOptions {
  47097. /**
  47098. * Display in overlay mode (default: false)
  47099. */
  47100. overlay?: boolean;
  47101. /**
  47102. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47103. */
  47104. globalRoot?: HTMLElement;
  47105. /**
  47106. * Display the Scene explorer
  47107. */
  47108. showExplorer?: boolean;
  47109. /**
  47110. * Display the property inspector
  47111. */
  47112. showInspector?: boolean;
  47113. /**
  47114. * Display in embed mode (both panes on the right)
  47115. */
  47116. embedMode?: boolean;
  47117. /**
  47118. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47119. */
  47120. handleResize?: boolean;
  47121. /**
  47122. * Allow the panes to popup (default: true)
  47123. */
  47124. enablePopup?: boolean;
  47125. /**
  47126. * Allow the panes to be closed by users (default: true)
  47127. */
  47128. enableClose?: boolean;
  47129. /**
  47130. * Optional list of extensibility entries
  47131. */
  47132. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47133. /**
  47134. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47135. */
  47136. inspectorURL?: string;
  47137. /**
  47138. * Optional initial tab (default to DebugLayerTab.Properties)
  47139. */
  47140. initialTab?: DebugLayerTab;
  47141. }
  47142. module "babylonjs/scene" {
  47143. interface Scene {
  47144. /**
  47145. * @hidden
  47146. * Backing field
  47147. */
  47148. _debugLayer: DebugLayer;
  47149. /**
  47150. * Gets the debug layer (aka Inspector) associated with the scene
  47151. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47152. */
  47153. debugLayer: DebugLayer;
  47154. }
  47155. }
  47156. /**
  47157. * Enum of inspector action tab
  47158. */
  47159. export enum DebugLayerTab {
  47160. /**
  47161. * Properties tag (default)
  47162. */
  47163. Properties = 0,
  47164. /**
  47165. * Debug tab
  47166. */
  47167. Debug = 1,
  47168. /**
  47169. * Statistics tab
  47170. */
  47171. Statistics = 2,
  47172. /**
  47173. * Tools tab
  47174. */
  47175. Tools = 3,
  47176. /**
  47177. * Settings tab
  47178. */
  47179. Settings = 4
  47180. }
  47181. /**
  47182. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47183. * what is happening in your scene
  47184. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47185. */
  47186. export class DebugLayer {
  47187. /**
  47188. * Define the url to get the inspector script from.
  47189. * By default it uses the babylonjs CDN.
  47190. * @ignoreNaming
  47191. */
  47192. static InspectorURL: string;
  47193. private _scene;
  47194. private BJSINSPECTOR;
  47195. private _onPropertyChangedObservable?;
  47196. /**
  47197. * Observable triggered when a property is changed through the inspector.
  47198. */
  47199. get onPropertyChangedObservable(): any;
  47200. /**
  47201. * Instantiates a new debug layer.
  47202. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47203. * what is happening in your scene
  47204. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47205. * @param scene Defines the scene to inspect
  47206. */
  47207. constructor(scene: Scene);
  47208. /** Creates the inspector window. */
  47209. private _createInspector;
  47210. /**
  47211. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47212. * @param entity defines the entity to select
  47213. * @param lineContainerTitle defines the specific block to highlight
  47214. */
  47215. select(entity: any, lineContainerTitle?: string): void;
  47216. /** Get the inspector from bundle or global */
  47217. private _getGlobalInspector;
  47218. /**
  47219. * Get if the inspector is visible or not.
  47220. * @returns true if visible otherwise, false
  47221. */
  47222. isVisible(): boolean;
  47223. /**
  47224. * Hide the inspector and close its window.
  47225. */
  47226. hide(): void;
  47227. /**
  47228. * Launch the debugLayer.
  47229. * @param config Define the configuration of the inspector
  47230. * @return a promise fulfilled when the debug layer is visible
  47231. */
  47232. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47233. }
  47234. }
  47235. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47236. import { Nullable } from "babylonjs/types";
  47237. import { Scene } from "babylonjs/scene";
  47238. import { Vector4 } from "babylonjs/Maths/math.vector";
  47239. import { Color4 } from "babylonjs/Maths/math.color";
  47240. import { Mesh } from "babylonjs/Meshes/mesh";
  47241. /**
  47242. * Class containing static functions to help procedurally build meshes
  47243. */
  47244. export class BoxBuilder {
  47245. /**
  47246. * Creates a box mesh
  47247. * * The parameter `size` sets the size (float) of each box side (default 1)
  47248. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47249. * * 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)
  47250. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47254. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47255. * @param name defines the name of the mesh
  47256. * @param options defines the options used to create the mesh
  47257. * @param scene defines the hosting scene
  47258. * @returns the box mesh
  47259. */
  47260. static CreateBox(name: string, options: {
  47261. size?: number;
  47262. width?: number;
  47263. height?: number;
  47264. depth?: number;
  47265. faceUV?: Vector4[];
  47266. faceColors?: Color4[];
  47267. sideOrientation?: number;
  47268. frontUVs?: Vector4;
  47269. backUVs?: Vector4;
  47270. wrap?: boolean;
  47271. topBaseAt?: number;
  47272. bottomBaseAt?: number;
  47273. updatable?: boolean;
  47274. }, scene?: Nullable<Scene>): Mesh;
  47275. }
  47276. }
  47277. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  47278. import { Vector4 } from "babylonjs/Maths/math.vector";
  47279. import { Mesh } from "babylonjs/Meshes/mesh";
  47280. import { Scene } from "babylonjs/scene";
  47281. import { Nullable } from "babylonjs/types";
  47282. /**
  47283. * Class containing static functions to help procedurally build meshes
  47284. */
  47285. export class SphereBuilder {
  47286. /**
  47287. * Creates a sphere mesh
  47288. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47289. * * 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`)
  47290. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47291. * * 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
  47292. * * 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)
  47293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47296. * @param name defines the name of the mesh
  47297. * @param options defines the options used to create the mesh
  47298. * @param scene defines the hosting scene
  47299. * @returns the sphere mesh
  47300. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47301. */
  47302. static CreateSphere(name: string, options: {
  47303. segments?: number;
  47304. diameter?: number;
  47305. diameterX?: number;
  47306. diameterY?: number;
  47307. diameterZ?: number;
  47308. arc?: number;
  47309. slice?: number;
  47310. sideOrientation?: number;
  47311. frontUVs?: Vector4;
  47312. backUVs?: Vector4;
  47313. updatable?: boolean;
  47314. }, scene?: Nullable<Scene>): Mesh;
  47315. }
  47316. }
  47317. declare module "babylonjs/Debug/physicsViewer" {
  47318. import { Nullable } from "babylonjs/types";
  47319. import { Scene } from "babylonjs/scene";
  47320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47321. import { Mesh } from "babylonjs/Meshes/mesh";
  47322. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47323. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47324. /**
  47325. * Used to show the physics impostor around the specific mesh
  47326. */
  47327. export class PhysicsViewer {
  47328. /** @hidden */
  47329. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47330. /** @hidden */
  47331. protected _meshes: Array<Nullable<AbstractMesh>>;
  47332. /** @hidden */
  47333. protected _scene: Nullable<Scene>;
  47334. /** @hidden */
  47335. protected _numMeshes: number;
  47336. /** @hidden */
  47337. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47338. private _renderFunction;
  47339. private _utilityLayer;
  47340. private _debugBoxMesh;
  47341. private _debugSphereMesh;
  47342. private _debugCylinderMesh;
  47343. private _debugMaterial;
  47344. private _debugMeshMeshes;
  47345. /**
  47346. * Creates a new PhysicsViewer
  47347. * @param scene defines the hosting scene
  47348. */
  47349. constructor(scene: Scene);
  47350. /** @hidden */
  47351. protected _updateDebugMeshes(): void;
  47352. /**
  47353. * Renders a specified physic impostor
  47354. * @param impostor defines the impostor to render
  47355. * @param targetMesh defines the mesh represented by the impostor
  47356. * @returns the new debug mesh used to render the impostor
  47357. */
  47358. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47359. /**
  47360. * Hides a specified physic impostor
  47361. * @param impostor defines the impostor to hide
  47362. */
  47363. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47364. private _getDebugMaterial;
  47365. private _getDebugBoxMesh;
  47366. private _getDebugSphereMesh;
  47367. private _getDebugCylinderMesh;
  47368. private _getDebugMeshMesh;
  47369. private _getDebugMesh;
  47370. /** Releases all resources */
  47371. dispose(): void;
  47372. }
  47373. }
  47374. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  47375. import { Vector3 } from "babylonjs/Maths/math.vector";
  47376. import { Color4 } from "babylonjs/Maths/math.color";
  47377. import { Nullable } from "babylonjs/types";
  47378. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47379. import { Scene } from "babylonjs/scene";
  47380. /**
  47381. * Class containing static functions to help procedurally build meshes
  47382. */
  47383. export class LinesBuilder {
  47384. /**
  47385. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47386. * * 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
  47387. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47388. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47389. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47390. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47391. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47392. * * 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
  47393. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47396. * @param name defines the name of the new line system
  47397. * @param options defines the options used to create the line system
  47398. * @param scene defines the hosting scene
  47399. * @returns a new line system mesh
  47400. */
  47401. static CreateLineSystem(name: string, options: {
  47402. lines: Vector3[][];
  47403. updatable?: boolean;
  47404. instance?: Nullable<LinesMesh>;
  47405. colors?: Nullable<Color4[][]>;
  47406. useVertexAlpha?: boolean;
  47407. }, scene: Nullable<Scene>): LinesMesh;
  47408. /**
  47409. * Creates a line mesh
  47410. * 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
  47411. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47412. * * The parameter `points` is an array successive Vector3
  47413. * * 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
  47414. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47415. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47416. * * When updating an instance, remember that only point positions can change, not the number of points
  47417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47419. * @param name defines the name of the new line system
  47420. * @param options defines the options used to create the line system
  47421. * @param scene defines the hosting scene
  47422. * @returns a new line mesh
  47423. */
  47424. static CreateLines(name: string, options: {
  47425. points: Vector3[];
  47426. updatable?: boolean;
  47427. instance?: Nullable<LinesMesh>;
  47428. colors?: Color4[];
  47429. useVertexAlpha?: boolean;
  47430. }, scene?: Nullable<Scene>): LinesMesh;
  47431. /**
  47432. * Creates a dashed line mesh
  47433. * * 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
  47434. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47435. * * The parameter `points` is an array successive Vector3
  47436. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47437. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47438. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47439. * * 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
  47440. * * When updating an instance, remember that only point positions can change, not the number of points
  47441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47442. * @param name defines the name of the mesh
  47443. * @param options defines the options used to create the mesh
  47444. * @param scene defines the hosting scene
  47445. * @returns the dashed line mesh
  47446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47447. */
  47448. static CreateDashedLines(name: string, options: {
  47449. points: Vector3[];
  47450. dashSize?: number;
  47451. gapSize?: number;
  47452. dashNb?: number;
  47453. updatable?: boolean;
  47454. instance?: LinesMesh;
  47455. }, scene?: Nullable<Scene>): LinesMesh;
  47456. }
  47457. }
  47458. declare module "babylonjs/Debug/rayHelper" {
  47459. import { Nullable } from "babylonjs/types";
  47460. import { Ray } from "babylonjs/Culling/ray";
  47461. import { Vector3 } from "babylonjs/Maths/math.vector";
  47462. import { Color3 } from "babylonjs/Maths/math.color";
  47463. import { Scene } from "babylonjs/scene";
  47464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47465. import "babylonjs/Meshes/Builders/linesBuilder";
  47466. /**
  47467. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47468. * in order to better appreciate the issue one might have.
  47469. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47470. */
  47471. export class RayHelper {
  47472. /**
  47473. * Defines the ray we are currently tryin to visualize.
  47474. */
  47475. ray: Nullable<Ray>;
  47476. private _renderPoints;
  47477. private _renderLine;
  47478. private _renderFunction;
  47479. private _scene;
  47480. private _updateToMeshFunction;
  47481. private _attachedToMesh;
  47482. private _meshSpaceDirection;
  47483. private _meshSpaceOrigin;
  47484. /**
  47485. * Helper function to create a colored helper in a scene in one line.
  47486. * @param ray Defines the ray we are currently tryin to visualize
  47487. * @param scene Defines the scene the ray is used in
  47488. * @param color Defines the color we want to see the ray in
  47489. * @returns The newly created ray helper.
  47490. */
  47491. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47492. /**
  47493. * Instantiate a new ray helper.
  47494. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47495. * in order to better appreciate the issue one might have.
  47496. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47497. * @param ray Defines the ray we are currently tryin to visualize
  47498. */
  47499. constructor(ray: Ray);
  47500. /**
  47501. * Shows the ray we are willing to debug.
  47502. * @param scene Defines the scene the ray needs to be rendered in
  47503. * @param color Defines the color the ray needs to be rendered in
  47504. */
  47505. show(scene: Scene, color?: Color3): void;
  47506. /**
  47507. * Hides the ray we are debugging.
  47508. */
  47509. hide(): void;
  47510. private _render;
  47511. /**
  47512. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47513. * @param mesh Defines the mesh we want the helper attached to
  47514. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47515. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47516. * @param length Defines the length of the ray
  47517. */
  47518. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47519. /**
  47520. * Detach the ray helper from the mesh it has previously been attached to.
  47521. */
  47522. detachFromMesh(): void;
  47523. private _updateToMesh;
  47524. /**
  47525. * Dispose the helper and release its associated resources.
  47526. */
  47527. dispose(): void;
  47528. }
  47529. }
  47530. declare module "babylonjs/Debug/skeletonViewer" {
  47531. import { Color3 } from "babylonjs/Maths/math.color";
  47532. import { Scene } from "babylonjs/scene";
  47533. import { Nullable } from "babylonjs/types";
  47534. import { Skeleton } from "babylonjs/Bones/skeleton";
  47535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47536. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47537. /**
  47538. * Class used to render a debug view of a given skeleton
  47539. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47540. */
  47541. export class SkeletonViewer {
  47542. /** defines the skeleton to render */
  47543. skeleton: Skeleton;
  47544. /** defines the mesh attached to the skeleton */
  47545. mesh: AbstractMesh;
  47546. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47547. autoUpdateBonesMatrices: boolean;
  47548. /** defines the rendering group id to use with the viewer */
  47549. renderingGroupId: number;
  47550. /** Gets or sets the color used to render the skeleton */
  47551. color: Color3;
  47552. private _scene;
  47553. private _debugLines;
  47554. private _debugMesh;
  47555. private _isEnabled;
  47556. private _renderFunction;
  47557. private _utilityLayer;
  47558. /**
  47559. * Returns the mesh used to render the bones
  47560. */
  47561. get debugMesh(): Nullable<LinesMesh>;
  47562. /**
  47563. * Creates a new SkeletonViewer
  47564. * @param skeleton defines the skeleton to render
  47565. * @param mesh defines the mesh attached to the skeleton
  47566. * @param scene defines the hosting scene
  47567. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47568. * @param renderingGroupId defines the rendering group id to use with the viewer
  47569. */
  47570. constructor(
  47571. /** defines the skeleton to render */
  47572. skeleton: Skeleton,
  47573. /** defines the mesh attached to the skeleton */
  47574. mesh: AbstractMesh, scene: Scene,
  47575. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47576. autoUpdateBonesMatrices?: boolean,
  47577. /** defines the rendering group id to use with the viewer */
  47578. renderingGroupId?: number);
  47579. /** Gets or sets a boolean indicating if the viewer is enabled */
  47580. set isEnabled(value: boolean);
  47581. get isEnabled(): boolean;
  47582. private _getBonePosition;
  47583. private _getLinesForBonesWithLength;
  47584. private _getLinesForBonesNoLength;
  47585. /** Update the viewer to sync with current skeleton state */
  47586. update(): void;
  47587. /** Release associated resources */
  47588. dispose(): void;
  47589. }
  47590. }
  47591. declare module "babylonjs/Debug/index" {
  47592. export * from "babylonjs/Debug/axesViewer";
  47593. export * from "babylonjs/Debug/boneAxesViewer";
  47594. export * from "babylonjs/Debug/debugLayer";
  47595. export * from "babylonjs/Debug/physicsViewer";
  47596. export * from "babylonjs/Debug/rayHelper";
  47597. export * from "babylonjs/Debug/skeletonViewer";
  47598. }
  47599. declare module "babylonjs/Engines/nullEngine" {
  47600. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  47601. import { Scene } from "babylonjs/scene";
  47602. import { Engine } from "babylonjs/Engines/engine";
  47603. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47604. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47605. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47606. import { Effect } from "babylonjs/Materials/effect";
  47607. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47608. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47609. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  47610. /**
  47611. * Options to create the null engine
  47612. */
  47613. export class NullEngineOptions {
  47614. /**
  47615. * Render width (Default: 512)
  47616. */
  47617. renderWidth: number;
  47618. /**
  47619. * Render height (Default: 256)
  47620. */
  47621. renderHeight: number;
  47622. /**
  47623. * Texture size (Default: 512)
  47624. */
  47625. textureSize: number;
  47626. /**
  47627. * If delta time between frames should be constant
  47628. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47629. */
  47630. deterministicLockstep: boolean;
  47631. /**
  47632. * Maximum about of steps between frames (Default: 4)
  47633. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47634. */
  47635. lockstepMaxSteps: number;
  47636. }
  47637. /**
  47638. * The null engine class provides support for headless version of babylon.js.
  47639. * This can be used in server side scenario or for testing purposes
  47640. */
  47641. export class NullEngine extends Engine {
  47642. private _options;
  47643. /**
  47644. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47645. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47646. * @returns true if engine is in deterministic lock step mode
  47647. */
  47648. isDeterministicLockStep(): boolean;
  47649. /**
  47650. * Gets the max steps when engine is running in deterministic lock step
  47651. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47652. * @returns the max steps
  47653. */
  47654. getLockstepMaxSteps(): number;
  47655. /**
  47656. * Gets the current hardware scaling level.
  47657. * By default the hardware scaling level is computed from the window device ratio.
  47658. * 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.
  47659. * @returns a number indicating the current hardware scaling level
  47660. */
  47661. getHardwareScalingLevel(): number;
  47662. constructor(options?: NullEngineOptions);
  47663. /**
  47664. * Creates a vertex buffer
  47665. * @param vertices the data for the vertex buffer
  47666. * @returns the new WebGL static buffer
  47667. */
  47668. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47669. /**
  47670. * Creates a new index buffer
  47671. * @param indices defines the content of the index buffer
  47672. * @param updatable defines if the index buffer must be updatable
  47673. * @returns a new webGL buffer
  47674. */
  47675. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47676. /**
  47677. * Clear the current render buffer or the current render target (if any is set up)
  47678. * @param color defines the color to use
  47679. * @param backBuffer defines if the back buffer must be cleared
  47680. * @param depth defines if the depth buffer must be cleared
  47681. * @param stencil defines if the stencil buffer must be cleared
  47682. */
  47683. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47684. /**
  47685. * Gets the current render width
  47686. * @param useScreen defines if screen size must be used (or the current render target if any)
  47687. * @returns a number defining the current render width
  47688. */
  47689. getRenderWidth(useScreen?: boolean): number;
  47690. /**
  47691. * Gets the current render height
  47692. * @param useScreen defines if screen size must be used (or the current render target if any)
  47693. * @returns a number defining the current render height
  47694. */
  47695. getRenderHeight(useScreen?: boolean): number;
  47696. /**
  47697. * Set the WebGL's viewport
  47698. * @param viewport defines the viewport element to be used
  47699. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47700. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47701. */
  47702. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47703. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47704. /**
  47705. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47706. * @param pipelineContext defines the pipeline context to use
  47707. * @param uniformsNames defines the list of uniform names
  47708. * @returns an array of webGL uniform locations
  47709. */
  47710. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47711. /**
  47712. * Gets the lsit of active attributes for a given webGL program
  47713. * @param pipelineContext defines the pipeline context to use
  47714. * @param attributesNames defines the list of attribute names to get
  47715. * @returns an array of indices indicating the offset of each attribute
  47716. */
  47717. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47718. /**
  47719. * Binds an effect to the webGL context
  47720. * @param effect defines the effect to bind
  47721. */
  47722. bindSamplers(effect: Effect): void;
  47723. /**
  47724. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47725. * @param effect defines the effect to activate
  47726. */
  47727. enableEffect(effect: Effect): void;
  47728. /**
  47729. * Set various states to the webGL context
  47730. * @param culling defines backface culling state
  47731. * @param zOffset defines the value to apply to zOffset (0 by default)
  47732. * @param force defines if states must be applied even if cache is up to date
  47733. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47734. */
  47735. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47736. /**
  47737. * Set the value of an uniform to an array of int32
  47738. * @param uniform defines the webGL uniform location where to store the value
  47739. * @param array defines the array of int32 to store
  47740. */
  47741. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47742. /**
  47743. * Set the value of an uniform to an array of int32 (stored as vec2)
  47744. * @param uniform defines the webGL uniform location where to store the value
  47745. * @param array defines the array of int32 to store
  47746. */
  47747. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47748. /**
  47749. * Set the value of an uniform to an array of int32 (stored as vec3)
  47750. * @param uniform defines the webGL uniform location where to store the value
  47751. * @param array defines the array of int32 to store
  47752. */
  47753. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47754. /**
  47755. * Set the value of an uniform to an array of int32 (stored as vec4)
  47756. * @param uniform defines the webGL uniform location where to store the value
  47757. * @param array defines the array of int32 to store
  47758. */
  47759. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47760. /**
  47761. * Set the value of an uniform to an array of float32
  47762. * @param uniform defines the webGL uniform location where to store the value
  47763. * @param array defines the array of float32 to store
  47764. */
  47765. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47766. /**
  47767. * Set the value of an uniform to an array of float32 (stored as vec2)
  47768. * @param uniform defines the webGL uniform location where to store the value
  47769. * @param array defines the array of float32 to store
  47770. */
  47771. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47772. /**
  47773. * Set the value of an uniform to an array of float32 (stored as vec3)
  47774. * @param uniform defines the webGL uniform location where to store the value
  47775. * @param array defines the array of float32 to store
  47776. */
  47777. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47778. /**
  47779. * Set the value of an uniform to an array of float32 (stored as vec4)
  47780. * @param uniform defines the webGL uniform location where to store the value
  47781. * @param array defines the array of float32 to store
  47782. */
  47783. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47784. /**
  47785. * Set the value of an uniform to an array of number
  47786. * @param uniform defines the webGL uniform location where to store the value
  47787. * @param array defines the array of number to store
  47788. */
  47789. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47790. /**
  47791. * Set the value of an uniform to an array of number (stored as vec2)
  47792. * @param uniform defines the webGL uniform location where to store the value
  47793. * @param array defines the array of number to store
  47794. */
  47795. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47796. /**
  47797. * Set the value of an uniform to an array of number (stored as vec3)
  47798. * @param uniform defines the webGL uniform location where to store the value
  47799. * @param array defines the array of number to store
  47800. */
  47801. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47802. /**
  47803. * Set the value of an uniform to an array of number (stored as vec4)
  47804. * @param uniform defines the webGL uniform location where to store the value
  47805. * @param array defines the array of number to store
  47806. */
  47807. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47808. /**
  47809. * Set the value of an uniform to an array of float32 (stored as matrices)
  47810. * @param uniform defines the webGL uniform location where to store the value
  47811. * @param matrices defines the array of float32 to store
  47812. */
  47813. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47814. /**
  47815. * Set the value of an uniform to a matrix (3x3)
  47816. * @param uniform defines the webGL uniform location where to store the value
  47817. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47818. */
  47819. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47820. /**
  47821. * Set the value of an uniform to a matrix (2x2)
  47822. * @param uniform defines the webGL uniform location where to store the value
  47823. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47824. */
  47825. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47826. /**
  47827. * Set the value of an uniform to a number (float)
  47828. * @param uniform defines the webGL uniform location where to store the value
  47829. * @param value defines the float number to store
  47830. */
  47831. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47832. /**
  47833. * Set the value of an uniform to a vec2
  47834. * @param uniform defines the webGL uniform location where to store the value
  47835. * @param x defines the 1st component of the value
  47836. * @param y defines the 2nd component of the value
  47837. */
  47838. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47839. /**
  47840. * Set the value of an uniform to a vec3
  47841. * @param uniform defines the webGL uniform location where to store the value
  47842. * @param x defines the 1st component of the value
  47843. * @param y defines the 2nd component of the value
  47844. * @param z defines the 3rd component of the value
  47845. */
  47846. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47847. /**
  47848. * Set the value of an uniform to a boolean
  47849. * @param uniform defines the webGL uniform location where to store the value
  47850. * @param bool defines the boolean to store
  47851. */
  47852. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47853. /**
  47854. * Set the value of an uniform to a vec4
  47855. * @param uniform defines the webGL uniform location where to store the value
  47856. * @param x defines the 1st component of the value
  47857. * @param y defines the 2nd component of the value
  47858. * @param z defines the 3rd component of the value
  47859. * @param w defines the 4th component of the value
  47860. */
  47861. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47862. /**
  47863. * Sets the current alpha mode
  47864. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47865. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47866. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47867. */
  47868. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47869. /**
  47870. * Bind webGl buffers directly to the webGL context
  47871. * @param vertexBuffers defines the vertex buffer to bind
  47872. * @param indexBuffer defines the index buffer to bind
  47873. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47874. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47875. * @param effect defines the effect associated with the vertex buffer
  47876. */
  47877. bindBuffers(vertexBuffers: {
  47878. [key: string]: VertexBuffer;
  47879. }, indexBuffer: DataBuffer, effect: Effect): void;
  47880. /**
  47881. * Force the entire cache to be cleared
  47882. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47883. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47884. */
  47885. wipeCaches(bruteForce?: boolean): void;
  47886. /**
  47887. * Send a draw order
  47888. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47889. * @param indexStart defines the starting index
  47890. * @param indexCount defines the number of index to draw
  47891. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47892. */
  47893. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47894. /**
  47895. * Draw a list of indexed primitives
  47896. * @param fillMode defines the primitive to use
  47897. * @param indexStart defines the starting index
  47898. * @param indexCount defines the number of index to draw
  47899. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47900. */
  47901. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47902. /**
  47903. * Draw a list of unindexed primitives
  47904. * @param fillMode defines the primitive to use
  47905. * @param verticesStart defines the index of first vertex to draw
  47906. * @param verticesCount defines the count of vertices to draw
  47907. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47908. */
  47909. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47910. /** @hidden */
  47911. _createTexture(): WebGLTexture;
  47912. /** @hidden */
  47913. _releaseTexture(texture: InternalTexture): void;
  47914. /**
  47915. * Usually called from Texture.ts.
  47916. * Passed information to create a WebGLTexture
  47917. * @param urlArg defines a value which contains one of the following:
  47918. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47919. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47920. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47921. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47922. * @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)
  47923. * @param scene needed for loading to the correct scene
  47924. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47925. * @param onLoad optional callback to be called upon successful completion
  47926. * @param onError optional callback to be called upon failure
  47927. * @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
  47928. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47929. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47930. * @param forcedExtension defines the extension to use to pick the right loader
  47931. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  47932. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47933. */
  47934. 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;
  47935. /**
  47936. * Creates a new render target texture
  47937. * @param size defines the size of the texture
  47938. * @param options defines the options used to create the texture
  47939. * @returns a new render target texture stored in an InternalTexture
  47940. */
  47941. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47942. /**
  47943. * Update the sampling mode of a given texture
  47944. * @param samplingMode defines the required sampling mode
  47945. * @param texture defines the texture to update
  47946. */
  47947. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47948. /**
  47949. * Binds the frame buffer to the specified texture.
  47950. * @param texture The texture to render to or null for the default canvas
  47951. * @param faceIndex The face of the texture to render to in case of cube texture
  47952. * @param requiredWidth The width of the target to render to
  47953. * @param requiredHeight The height of the target to render to
  47954. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47955. * @param depthStencilTexture The depth stencil texture to use to render
  47956. * @param lodLevel defines le lod level to bind to the frame buffer
  47957. */
  47958. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47959. /**
  47960. * Unbind the current render target texture from the webGL context
  47961. * @param texture defines the render target texture to unbind
  47962. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47963. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47964. */
  47965. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47966. /**
  47967. * Creates a dynamic vertex buffer
  47968. * @param vertices the data for the dynamic vertex buffer
  47969. * @returns the new WebGL dynamic buffer
  47970. */
  47971. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47972. /**
  47973. * Update the content of a dynamic texture
  47974. * @param texture defines the texture to update
  47975. * @param canvas defines the canvas containing the source
  47976. * @param invertY defines if data must be stored with Y axis inverted
  47977. * @param premulAlpha defines if alpha is stored as premultiplied
  47978. * @param format defines the format of the data
  47979. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47980. */
  47981. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47982. /**
  47983. * Gets a boolean indicating if all created effects are ready
  47984. * @returns true if all effects are ready
  47985. */
  47986. areAllEffectsReady(): boolean;
  47987. /**
  47988. * @hidden
  47989. * Get the current error code of the webGL context
  47990. * @returns the error code
  47991. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47992. */
  47993. getError(): number;
  47994. /** @hidden */
  47995. _getUnpackAlignement(): number;
  47996. /** @hidden */
  47997. _unpackFlipY(value: boolean): void;
  47998. /**
  47999. * Update a dynamic index buffer
  48000. * @param indexBuffer defines the target index buffer
  48001. * @param indices defines the data to update
  48002. * @param offset defines the offset in the target index buffer where update should start
  48003. */
  48004. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48005. /**
  48006. * Updates a dynamic vertex buffer.
  48007. * @param vertexBuffer the vertex buffer to update
  48008. * @param vertices the data used to update the vertex buffer
  48009. * @param byteOffset the byte offset of the data (optional)
  48010. * @param byteLength the byte length of the data (optional)
  48011. */
  48012. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48013. /** @hidden */
  48014. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48015. /** @hidden */
  48016. _bindTexture(channel: number, texture: InternalTexture): void;
  48017. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48018. /**
  48019. * 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
  48020. */
  48021. releaseEffects(): void;
  48022. displayLoadingUI(): void;
  48023. hideLoadingUI(): void;
  48024. /** @hidden */
  48025. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48026. /** @hidden */
  48027. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48028. /** @hidden */
  48029. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48030. /** @hidden */
  48031. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48032. }
  48033. }
  48034. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48035. import { Nullable, int } from "babylonjs/types";
  48036. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48037. /** @hidden */
  48038. export class _OcclusionDataStorage {
  48039. /** @hidden */
  48040. occlusionInternalRetryCounter: number;
  48041. /** @hidden */
  48042. isOcclusionQueryInProgress: boolean;
  48043. /** @hidden */
  48044. isOccluded: boolean;
  48045. /** @hidden */
  48046. occlusionRetryCount: number;
  48047. /** @hidden */
  48048. occlusionType: number;
  48049. /** @hidden */
  48050. occlusionQueryAlgorithmType: number;
  48051. }
  48052. module "babylonjs/Engines/engine" {
  48053. interface Engine {
  48054. /**
  48055. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48056. * @return the new query
  48057. */
  48058. createQuery(): WebGLQuery;
  48059. /**
  48060. * Delete and release a webGL query
  48061. * @param query defines the query to delete
  48062. * @return the current engine
  48063. */
  48064. deleteQuery(query: WebGLQuery): Engine;
  48065. /**
  48066. * Check if a given query has resolved and got its value
  48067. * @param query defines the query to check
  48068. * @returns true if the query got its value
  48069. */
  48070. isQueryResultAvailable(query: WebGLQuery): boolean;
  48071. /**
  48072. * Gets the value of a given query
  48073. * @param query defines the query to check
  48074. * @returns the value of the query
  48075. */
  48076. getQueryResult(query: WebGLQuery): number;
  48077. /**
  48078. * Initiates an occlusion query
  48079. * @param algorithmType defines the algorithm to use
  48080. * @param query defines the query to use
  48081. * @returns the current engine
  48082. * @see http://doc.babylonjs.com/features/occlusionquery
  48083. */
  48084. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48085. /**
  48086. * Ends an occlusion query
  48087. * @see http://doc.babylonjs.com/features/occlusionquery
  48088. * @param algorithmType defines the algorithm to use
  48089. * @returns the current engine
  48090. */
  48091. endOcclusionQuery(algorithmType: number): Engine;
  48092. /**
  48093. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48094. * Please note that only one query can be issued at a time
  48095. * @returns a time token used to track the time span
  48096. */
  48097. startTimeQuery(): Nullable<_TimeToken>;
  48098. /**
  48099. * Ends a time query
  48100. * @param token defines the token used to measure the time span
  48101. * @returns the time spent (in ns)
  48102. */
  48103. endTimeQuery(token: _TimeToken): int;
  48104. /** @hidden */
  48105. _currentNonTimestampToken: Nullable<_TimeToken>;
  48106. /** @hidden */
  48107. _createTimeQuery(): WebGLQuery;
  48108. /** @hidden */
  48109. _deleteTimeQuery(query: WebGLQuery): void;
  48110. /** @hidden */
  48111. _getGlAlgorithmType(algorithmType: number): number;
  48112. /** @hidden */
  48113. _getTimeQueryResult(query: WebGLQuery): any;
  48114. /** @hidden */
  48115. _getTimeQueryAvailability(query: WebGLQuery): any;
  48116. }
  48117. }
  48118. module "babylonjs/Meshes/abstractMesh" {
  48119. interface AbstractMesh {
  48120. /**
  48121. * Backing filed
  48122. * @hidden
  48123. */
  48124. __occlusionDataStorage: _OcclusionDataStorage;
  48125. /**
  48126. * Access property
  48127. * @hidden
  48128. */
  48129. _occlusionDataStorage: _OcclusionDataStorage;
  48130. /**
  48131. * 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.
  48132. * The default value is -1 which means don't break the query and wait till the result
  48133. * @see http://doc.babylonjs.com/features/occlusionquery
  48134. */
  48135. occlusionRetryCount: number;
  48136. /**
  48137. * 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:
  48138. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48139. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48140. * * 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.
  48141. * @see http://doc.babylonjs.com/features/occlusionquery
  48142. */
  48143. occlusionType: number;
  48144. /**
  48145. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48146. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48147. * * 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.
  48148. * @see http://doc.babylonjs.com/features/occlusionquery
  48149. */
  48150. occlusionQueryAlgorithmType: number;
  48151. /**
  48152. * 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
  48153. * @see http://doc.babylonjs.com/features/occlusionquery
  48154. */
  48155. isOccluded: boolean;
  48156. /**
  48157. * Flag to check the progress status of the query
  48158. * @see http://doc.babylonjs.com/features/occlusionquery
  48159. */
  48160. isOcclusionQueryInProgress: boolean;
  48161. }
  48162. }
  48163. }
  48164. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48165. import { Nullable } from "babylonjs/types";
  48166. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48167. /** @hidden */
  48168. export var _forceTransformFeedbackToBundle: boolean;
  48169. module "babylonjs/Engines/engine" {
  48170. interface Engine {
  48171. /**
  48172. * Creates a webGL transform feedback object
  48173. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48174. * @returns the webGL transform feedback object
  48175. */
  48176. createTransformFeedback(): WebGLTransformFeedback;
  48177. /**
  48178. * Delete a webGL transform feedback object
  48179. * @param value defines the webGL transform feedback object to delete
  48180. */
  48181. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48182. /**
  48183. * Bind a webGL transform feedback object to the webgl context
  48184. * @param value defines the webGL transform feedback object to bind
  48185. */
  48186. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48187. /**
  48188. * Begins a transform feedback operation
  48189. * @param usePoints defines if points or triangles must be used
  48190. */
  48191. beginTransformFeedback(usePoints: boolean): void;
  48192. /**
  48193. * Ends a transform feedback operation
  48194. */
  48195. endTransformFeedback(): void;
  48196. /**
  48197. * Specify the varyings to use with transform feedback
  48198. * @param program defines the associated webGL program
  48199. * @param value defines the list of strings representing the varying names
  48200. */
  48201. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48202. /**
  48203. * Bind a webGL buffer for a transform feedback operation
  48204. * @param value defines the webGL buffer to bind
  48205. */
  48206. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48207. }
  48208. }
  48209. }
  48210. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48211. import { Scene } from "babylonjs/scene";
  48212. import { Engine } from "babylonjs/Engines/engine";
  48213. import { Texture } from "babylonjs/Materials/Textures/texture";
  48214. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48215. import "babylonjs/Engines/Extensions/engine.multiRender";
  48216. /**
  48217. * Creation options of the multi render target texture.
  48218. */
  48219. export interface IMultiRenderTargetOptions {
  48220. /**
  48221. * Define if the texture needs to create mip maps after render.
  48222. */
  48223. generateMipMaps?: boolean;
  48224. /**
  48225. * Define the types of all the draw buffers we want to create
  48226. */
  48227. types?: number[];
  48228. /**
  48229. * Define the sampling modes of all the draw buffers we want to create
  48230. */
  48231. samplingModes?: number[];
  48232. /**
  48233. * Define if a depth buffer is required
  48234. */
  48235. generateDepthBuffer?: boolean;
  48236. /**
  48237. * Define if a stencil buffer is required
  48238. */
  48239. generateStencilBuffer?: boolean;
  48240. /**
  48241. * Define if a depth texture is required instead of a depth buffer
  48242. */
  48243. generateDepthTexture?: boolean;
  48244. /**
  48245. * Define the number of desired draw buffers
  48246. */
  48247. textureCount?: number;
  48248. /**
  48249. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48250. */
  48251. doNotChangeAspectRatio?: boolean;
  48252. /**
  48253. * Define the default type of the buffers we are creating
  48254. */
  48255. defaultType?: number;
  48256. }
  48257. /**
  48258. * A multi render target, like a render target provides the ability to render to a texture.
  48259. * Unlike the render target, it can render to several draw buffers in one draw.
  48260. * This is specially interesting in deferred rendering or for any effects requiring more than
  48261. * just one color from a single pass.
  48262. */
  48263. export class MultiRenderTarget extends RenderTargetTexture {
  48264. private _internalTextures;
  48265. private _textures;
  48266. private _multiRenderTargetOptions;
  48267. /**
  48268. * Get if draw buffers are currently supported by the used hardware and browser.
  48269. */
  48270. get isSupported(): boolean;
  48271. /**
  48272. * Get the list of textures generated by the multi render target.
  48273. */
  48274. get textures(): Texture[];
  48275. /**
  48276. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48277. */
  48278. get depthTexture(): Texture;
  48279. /**
  48280. * Set the wrapping mode on U of all the textures we are rendering to.
  48281. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48282. */
  48283. set wrapU(wrap: number);
  48284. /**
  48285. * Set the wrapping mode on V of all the textures we are rendering to.
  48286. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48287. */
  48288. set wrapV(wrap: number);
  48289. /**
  48290. * Instantiate a new multi render target texture.
  48291. * A multi render target, like a render target provides the ability to render to a texture.
  48292. * Unlike the render target, it can render to several draw buffers in one draw.
  48293. * This is specially interesting in deferred rendering or for any effects requiring more than
  48294. * just one color from a single pass.
  48295. * @param name Define the name of the texture
  48296. * @param size Define the size of the buffers to render to
  48297. * @param count Define the number of target we are rendering into
  48298. * @param scene Define the scene the texture belongs to
  48299. * @param options Define the options used to create the multi render target
  48300. */
  48301. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48302. /** @hidden */
  48303. _rebuild(): void;
  48304. private _createInternalTextures;
  48305. private _createTextures;
  48306. /**
  48307. * Define the number of samples used if MSAA is enabled.
  48308. */
  48309. get samples(): number;
  48310. set samples(value: number);
  48311. /**
  48312. * Resize all the textures in the multi render target.
  48313. * Be carrefull as it will recreate all the data in the new texture.
  48314. * @param size Define the new size
  48315. */
  48316. resize(size: any): void;
  48317. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48318. /**
  48319. * Dispose the render targets and their associated resources
  48320. */
  48321. dispose(): void;
  48322. /**
  48323. * Release all the underlying texture used as draw buffers.
  48324. */
  48325. releaseInternalTextures(): void;
  48326. }
  48327. }
  48328. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48329. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48330. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48331. import { Nullable } from "babylonjs/types";
  48332. module "babylonjs/Engines/thinEngine" {
  48333. interface ThinEngine {
  48334. /**
  48335. * Unbind a list of render target textures from the webGL context
  48336. * This is used only when drawBuffer extension or webGL2 are active
  48337. * @param textures defines the render target textures to unbind
  48338. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48339. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48340. */
  48341. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48342. /**
  48343. * Create a multi render target texture
  48344. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48345. * @param size defines the size of the texture
  48346. * @param options defines the creation options
  48347. * @returns the cube texture as an InternalTexture
  48348. */
  48349. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48350. /**
  48351. * Update the sample count for a given multiple render target texture
  48352. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48353. * @param textures defines the textures to update
  48354. * @param samples defines the sample count to set
  48355. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48356. */
  48357. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48358. }
  48359. }
  48360. }
  48361. declare module "babylonjs/Engines/Extensions/engine.views" {
  48362. import { Camera } from "babylonjs/Cameras/camera";
  48363. import { Nullable } from "babylonjs/types";
  48364. /**
  48365. * Class used to define an additional view for the engine
  48366. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48367. */
  48368. export class EngineView {
  48369. /** Defines the canvas where to render the view */
  48370. target: HTMLCanvasElement;
  48371. /** Defines an optional camera used to render the view (will use active camera else) */
  48372. camera?: Camera;
  48373. }
  48374. module "babylonjs/Engines/engine" {
  48375. interface Engine {
  48376. /**
  48377. * Gets or sets the HTML element to use for attaching events
  48378. */
  48379. inputElement: Nullable<HTMLElement>;
  48380. /**
  48381. * Gets the current engine view
  48382. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48383. */
  48384. activeView: Nullable<EngineView>;
  48385. /** Gets or sets the list of views */
  48386. views: EngineView[];
  48387. /**
  48388. * Register a new child canvas
  48389. * @param canvas defines the canvas to register
  48390. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48391. * @returns the associated view
  48392. */
  48393. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48394. /**
  48395. * Remove a registered child canvas
  48396. * @param canvas defines the canvas to remove
  48397. * @returns the current engine
  48398. */
  48399. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48400. }
  48401. }
  48402. }
  48403. declare module "babylonjs/Engines/Extensions/index" {
  48404. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48405. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48406. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48407. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48408. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48409. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48410. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48411. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48412. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48413. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48414. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48415. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48416. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48417. export * from "babylonjs/Engines/Extensions/engine.views";
  48418. }
  48419. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48420. import { Nullable } from "babylonjs/types";
  48421. /**
  48422. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48423. */
  48424. export interface CubeMapInfo {
  48425. /**
  48426. * The pixel array for the front face.
  48427. * This is stored in format, left to right, up to down format.
  48428. */
  48429. front: Nullable<ArrayBufferView>;
  48430. /**
  48431. * The pixel array for the back face.
  48432. * This is stored in format, left to right, up to down format.
  48433. */
  48434. back: Nullable<ArrayBufferView>;
  48435. /**
  48436. * The pixel array for the left face.
  48437. * This is stored in format, left to right, up to down format.
  48438. */
  48439. left: Nullable<ArrayBufferView>;
  48440. /**
  48441. * The pixel array for the right face.
  48442. * This is stored in format, left to right, up to down format.
  48443. */
  48444. right: Nullable<ArrayBufferView>;
  48445. /**
  48446. * The pixel array for the up face.
  48447. * This is stored in format, left to right, up to down format.
  48448. */
  48449. up: Nullable<ArrayBufferView>;
  48450. /**
  48451. * The pixel array for the down face.
  48452. * This is stored in format, left to right, up to down format.
  48453. */
  48454. down: Nullable<ArrayBufferView>;
  48455. /**
  48456. * The size of the cubemap stored.
  48457. *
  48458. * Each faces will be size * size pixels.
  48459. */
  48460. size: number;
  48461. /**
  48462. * The format of the texture.
  48463. *
  48464. * RGBA, RGB.
  48465. */
  48466. format: number;
  48467. /**
  48468. * The type of the texture data.
  48469. *
  48470. * UNSIGNED_INT, FLOAT.
  48471. */
  48472. type: number;
  48473. /**
  48474. * Specifies whether the texture is in gamma space.
  48475. */
  48476. gammaSpace: boolean;
  48477. }
  48478. /**
  48479. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48480. */
  48481. export class PanoramaToCubeMapTools {
  48482. private static FACE_FRONT;
  48483. private static FACE_BACK;
  48484. private static FACE_RIGHT;
  48485. private static FACE_LEFT;
  48486. private static FACE_DOWN;
  48487. private static FACE_UP;
  48488. /**
  48489. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48490. *
  48491. * @param float32Array The source data.
  48492. * @param inputWidth The width of the input panorama.
  48493. * @param inputHeight The height of the input panorama.
  48494. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48495. * @return The cubemap data
  48496. */
  48497. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48498. private static CreateCubemapTexture;
  48499. private static CalcProjectionSpherical;
  48500. }
  48501. }
  48502. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48503. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48505. import { Nullable } from "babylonjs/types";
  48506. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48507. /**
  48508. * Helper class dealing with the extraction of spherical polynomial dataArray
  48509. * from a cube map.
  48510. */
  48511. export class CubeMapToSphericalPolynomialTools {
  48512. private static FileFaces;
  48513. /**
  48514. * Converts a texture to the according Spherical Polynomial data.
  48515. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48516. *
  48517. * @param texture The texture to extract the information from.
  48518. * @return The Spherical Polynomial data.
  48519. */
  48520. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48521. /**
  48522. * Converts a cubemap to the according Spherical Polynomial data.
  48523. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48524. *
  48525. * @param cubeInfo The Cube map to extract the information from.
  48526. * @return The Spherical Polynomial data.
  48527. */
  48528. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48529. }
  48530. }
  48531. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48532. import { Nullable } from "babylonjs/types";
  48533. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48534. module "babylonjs/Materials/Textures/baseTexture" {
  48535. interface BaseTexture {
  48536. /**
  48537. * Get the polynomial representation of the texture data.
  48538. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48539. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48540. */
  48541. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48542. }
  48543. }
  48544. }
  48545. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48546. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48547. /** @hidden */
  48548. export var rgbdEncodePixelShader: {
  48549. name: string;
  48550. shader: string;
  48551. };
  48552. }
  48553. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48554. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48555. /** @hidden */
  48556. export var rgbdDecodePixelShader: {
  48557. name: string;
  48558. shader: string;
  48559. };
  48560. }
  48561. declare module "babylonjs/Misc/environmentTextureTools" {
  48562. import { Nullable } from "babylonjs/types";
  48563. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48564. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48565. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48566. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48567. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  48568. import "babylonjs/Shaders/rgbdEncode.fragment";
  48569. import "babylonjs/Shaders/rgbdDecode.fragment";
  48570. /**
  48571. * Raw texture data and descriptor sufficient for WebGL texture upload
  48572. */
  48573. export interface EnvironmentTextureInfo {
  48574. /**
  48575. * Version of the environment map
  48576. */
  48577. version: number;
  48578. /**
  48579. * Width of image
  48580. */
  48581. width: number;
  48582. /**
  48583. * Irradiance information stored in the file.
  48584. */
  48585. irradiance: any;
  48586. /**
  48587. * Specular information stored in the file.
  48588. */
  48589. specular: any;
  48590. }
  48591. /**
  48592. * Defines One Image in the file. It requires only the position in the file
  48593. * as well as the length.
  48594. */
  48595. interface BufferImageData {
  48596. /**
  48597. * Length of the image data.
  48598. */
  48599. length: number;
  48600. /**
  48601. * Position of the data from the null terminator delimiting the end of the JSON.
  48602. */
  48603. position: number;
  48604. }
  48605. /**
  48606. * Defines the specular data enclosed in the file.
  48607. * This corresponds to the version 1 of the data.
  48608. */
  48609. export interface EnvironmentTextureSpecularInfoV1 {
  48610. /**
  48611. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48612. */
  48613. specularDataPosition?: number;
  48614. /**
  48615. * This contains all the images data needed to reconstruct the cubemap.
  48616. */
  48617. mipmaps: Array<BufferImageData>;
  48618. /**
  48619. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48620. */
  48621. lodGenerationScale: number;
  48622. }
  48623. /**
  48624. * Sets of helpers addressing the serialization and deserialization of environment texture
  48625. * stored in a BabylonJS env file.
  48626. * Those files are usually stored as .env files.
  48627. */
  48628. export class EnvironmentTextureTools {
  48629. /**
  48630. * Magic number identifying the env file.
  48631. */
  48632. private static _MagicBytes;
  48633. /**
  48634. * Gets the environment info from an env file.
  48635. * @param data The array buffer containing the .env bytes.
  48636. * @returns the environment file info (the json header) if successfully parsed.
  48637. */
  48638. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48639. /**
  48640. * Creates an environment texture from a loaded cube texture.
  48641. * @param texture defines the cube texture to convert in env file
  48642. * @return a promise containing the environment data if succesfull.
  48643. */
  48644. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48645. /**
  48646. * Creates a JSON representation of the spherical data.
  48647. * @param texture defines the texture containing the polynomials
  48648. * @return the JSON representation of the spherical info
  48649. */
  48650. private static _CreateEnvTextureIrradiance;
  48651. /**
  48652. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48653. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  48654. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48655. * @return the views described by info providing access to the underlying buffer
  48656. */
  48657. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48658. /**
  48659. * Uploads the texture info contained in the env file to the GPU.
  48660. * @param texture defines the internal texture to upload to
  48661. * @param arrayBuffer defines the buffer cotaining the data to load
  48662. * @param info defines the texture info retrieved through the GetEnvInfo method
  48663. * @returns a promise
  48664. */
  48665. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48666. private static _OnImageReadyAsync;
  48667. /**
  48668. * Uploads the levels of image data to the GPU.
  48669. * @param texture defines the internal texture to upload to
  48670. * @param imageData defines the array buffer views of image data [mipmap][face]
  48671. * @returns a promise
  48672. */
  48673. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48674. /**
  48675. * Uploads spherical polynomials information to the texture.
  48676. * @param texture defines the texture we are trying to upload the information to
  48677. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48678. */
  48679. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48680. /** @hidden */
  48681. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48682. }
  48683. }
  48684. declare module "babylonjs/Maths/math.vertexFormat" {
  48685. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48686. /**
  48687. * Contains position and normal vectors for a vertex
  48688. */
  48689. export class PositionNormalVertex {
  48690. /** the position of the vertex (defaut: 0,0,0) */
  48691. position: Vector3;
  48692. /** the normal of the vertex (defaut: 0,1,0) */
  48693. normal: Vector3;
  48694. /**
  48695. * Creates a PositionNormalVertex
  48696. * @param position the position of the vertex (defaut: 0,0,0)
  48697. * @param normal the normal of the vertex (defaut: 0,1,0)
  48698. */
  48699. constructor(
  48700. /** the position of the vertex (defaut: 0,0,0) */
  48701. position?: Vector3,
  48702. /** the normal of the vertex (defaut: 0,1,0) */
  48703. normal?: Vector3);
  48704. /**
  48705. * Clones the PositionNormalVertex
  48706. * @returns the cloned PositionNormalVertex
  48707. */
  48708. clone(): PositionNormalVertex;
  48709. }
  48710. /**
  48711. * Contains position, normal and uv vectors for a vertex
  48712. */
  48713. export class PositionNormalTextureVertex {
  48714. /** the position of the vertex (defaut: 0,0,0) */
  48715. position: Vector3;
  48716. /** the normal of the vertex (defaut: 0,1,0) */
  48717. normal: Vector3;
  48718. /** the uv of the vertex (default: 0,0) */
  48719. uv: Vector2;
  48720. /**
  48721. * Creates a PositionNormalTextureVertex
  48722. * @param position the position of the vertex (defaut: 0,0,0)
  48723. * @param normal the normal of the vertex (defaut: 0,1,0)
  48724. * @param uv the uv of the vertex (default: 0,0)
  48725. */
  48726. constructor(
  48727. /** the position of the vertex (defaut: 0,0,0) */
  48728. position?: Vector3,
  48729. /** the normal of the vertex (defaut: 0,1,0) */
  48730. normal?: Vector3,
  48731. /** the uv of the vertex (default: 0,0) */
  48732. uv?: Vector2);
  48733. /**
  48734. * Clones the PositionNormalTextureVertex
  48735. * @returns the cloned PositionNormalTextureVertex
  48736. */
  48737. clone(): PositionNormalTextureVertex;
  48738. }
  48739. }
  48740. declare module "babylonjs/Maths/math" {
  48741. export * from "babylonjs/Maths/math.axis";
  48742. export * from "babylonjs/Maths/math.color";
  48743. export * from "babylonjs/Maths/math.constants";
  48744. export * from "babylonjs/Maths/math.frustum";
  48745. export * from "babylonjs/Maths/math.path";
  48746. export * from "babylonjs/Maths/math.plane";
  48747. export * from "babylonjs/Maths/math.size";
  48748. export * from "babylonjs/Maths/math.vector";
  48749. export * from "babylonjs/Maths/math.vertexFormat";
  48750. export * from "babylonjs/Maths/math.viewport";
  48751. }
  48752. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  48753. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48754. /** @hidden */
  48755. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48756. private _genericAttributeLocation;
  48757. private _varyingLocationCount;
  48758. private _varyingLocationMap;
  48759. private _replacements;
  48760. private _textureCount;
  48761. private _uniforms;
  48762. lineProcessor(line: string): string;
  48763. attributeProcessor(attribute: string): string;
  48764. varyingProcessor(varying: string, isFragment: boolean): string;
  48765. uniformProcessor(uniform: string): string;
  48766. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48767. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48768. }
  48769. }
  48770. declare module "babylonjs/Engines/nativeEngine" {
  48771. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  48772. import { Engine } from "babylonjs/Engines/engine";
  48773. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48774. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48775. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48776. import { Effect } from "babylonjs/Materials/effect";
  48777. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48778. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  48779. import { IColor4Like } from "babylonjs/Maths/math.like";
  48780. import { Scene } from "babylonjs/scene";
  48781. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48782. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48783. /**
  48784. * Container for accessors for natively-stored mesh data buffers.
  48785. */
  48786. class NativeDataBuffer extends DataBuffer {
  48787. /**
  48788. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48789. */
  48790. nativeIndexBuffer?: any;
  48791. /**
  48792. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48793. */
  48794. nativeVertexBuffer?: any;
  48795. }
  48796. /** @hidden */
  48797. class NativeTexture extends InternalTexture {
  48798. getInternalTexture(): InternalTexture;
  48799. getViewCount(): number;
  48800. }
  48801. /** @hidden */
  48802. export class NativeEngine extends Engine {
  48803. private readonly _native;
  48804. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48805. private readonly INVALID_HANDLE;
  48806. getHardwareScalingLevel(): number;
  48807. constructor();
  48808. /**
  48809. * Can be used to override the current requestAnimationFrame requester.
  48810. * @hidden
  48811. */
  48812. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48813. /**
  48814. * Override default engine behavior.
  48815. * @param color
  48816. * @param backBuffer
  48817. * @param depth
  48818. * @param stencil
  48819. */
  48820. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48821. /**
  48822. * Gets host document
  48823. * @returns the host document object
  48824. */
  48825. getHostDocument(): Nullable<Document>;
  48826. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48827. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48828. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48829. recordVertexArrayObject(vertexBuffers: {
  48830. [key: string]: VertexBuffer;
  48831. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48832. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48833. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48834. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48835. /**
  48836. * Draw a list of indexed primitives
  48837. * @param fillMode defines the primitive to use
  48838. * @param indexStart defines the starting index
  48839. * @param indexCount defines the number of index to draw
  48840. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48841. */
  48842. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48843. /**
  48844. * Draw a list of unindexed primitives
  48845. * @param fillMode defines the primitive to use
  48846. * @param verticesStart defines the index of first vertex to draw
  48847. * @param verticesCount defines the count of vertices to draw
  48848. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48849. */
  48850. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48851. createPipelineContext(): IPipelineContext;
  48852. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48853. /** @hidden */
  48854. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48855. /** @hidden */
  48856. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48857. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48858. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48859. protected _setProgram(program: WebGLProgram): void;
  48860. _releaseEffect(effect: Effect): void;
  48861. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48862. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48863. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48864. bindSamplers(effect: Effect): void;
  48865. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48866. getRenderWidth(useScreen?: boolean): number;
  48867. getRenderHeight(useScreen?: boolean): number;
  48868. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48869. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48870. /**
  48871. * Set the z offset to apply to current rendering
  48872. * @param value defines the offset to apply
  48873. */
  48874. setZOffset(value: number): void;
  48875. /**
  48876. * Gets the current value of the zOffset
  48877. * @returns the current zOffset state
  48878. */
  48879. getZOffset(): number;
  48880. /**
  48881. * Enable or disable depth buffering
  48882. * @param enable defines the state to set
  48883. */
  48884. setDepthBuffer(enable: boolean): void;
  48885. /**
  48886. * Gets a boolean indicating if depth writing is enabled
  48887. * @returns the current depth writing state
  48888. */
  48889. getDepthWrite(): boolean;
  48890. /**
  48891. * Enable or disable depth writing
  48892. * @param enable defines the state to set
  48893. */
  48894. setDepthWrite(enable: boolean): void;
  48895. /**
  48896. * Enable or disable color writing
  48897. * @param enable defines the state to set
  48898. */
  48899. setColorWrite(enable: boolean): void;
  48900. /**
  48901. * Gets a boolean indicating if color writing is enabled
  48902. * @returns the current color writing state
  48903. */
  48904. getColorWrite(): boolean;
  48905. /**
  48906. * Sets alpha constants used by some alpha blending modes
  48907. * @param r defines the red component
  48908. * @param g defines the green component
  48909. * @param b defines the blue component
  48910. * @param a defines the alpha component
  48911. */
  48912. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48913. /**
  48914. * Sets the current alpha mode
  48915. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48916. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48917. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48918. */
  48919. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48920. /**
  48921. * Gets the current alpha mode
  48922. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48923. * @returns the current alpha mode
  48924. */
  48925. getAlphaMode(): number;
  48926. setInt(uniform: WebGLUniformLocation, int: number): void;
  48927. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48928. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48929. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48930. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48931. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48932. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48933. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48934. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48935. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48936. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48937. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48938. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48939. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48940. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48941. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48942. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48943. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48944. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48945. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48946. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48947. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48948. wipeCaches(bruteForce?: boolean): void;
  48949. _createTexture(): WebGLTexture;
  48950. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48951. /**
  48952. * Usually called from BABYLON.Texture.ts.
  48953. * Passed information to create a WebGLTexture
  48954. * @param urlArg defines a value which contains one of the following:
  48955. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48956. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48957. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48958. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48959. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  48960. * @param scene needed for loading to the correct scene
  48961. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  48962. * @param onLoad optional callback to be called upon successful completion
  48963. * @param onError optional callback to be called upon failure
  48964. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  48965. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48966. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48967. * @param forcedExtension defines the extension to use to pick the right loader
  48968. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48969. */
  48970. 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;
  48971. /**
  48972. * Creates a cube texture
  48973. * @param rootUrl defines the url where the files to load is located
  48974. * @param scene defines the current scene
  48975. * @param files defines the list of files to load (1 per face)
  48976. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48977. * @param onLoad defines an optional callback raised when the texture is loaded
  48978. * @param onError defines an optional callback raised if there is an issue to load the texture
  48979. * @param format defines the format of the data
  48980. * @param forcedExtension defines the extension to use to pick the right loader
  48981. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48982. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48983. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48984. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48985. * @returns the cube texture as an InternalTexture
  48986. */
  48987. 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;
  48988. private _getSamplingFilter;
  48989. private static _GetNativeTextureFormat;
  48990. createRenderTargetTexture(size: number | {
  48991. width: number;
  48992. height: number;
  48993. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48994. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48995. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48996. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48997. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48998. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48999. /**
  49000. * Updates a dynamic vertex buffer.
  49001. * @param vertexBuffer the vertex buffer to update
  49002. * @param data the data used to update the vertex buffer
  49003. * @param byteOffset the byte offset of the data (optional)
  49004. * @param byteLength the byte length of the data (optional)
  49005. */
  49006. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49007. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49008. private _updateAnisotropicLevel;
  49009. private _getAddressMode;
  49010. /** @hidden */
  49011. _bindTexture(channel: number, texture: InternalTexture): void;
  49012. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49013. releaseEffects(): void;
  49014. /** @hidden */
  49015. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49016. /** @hidden */
  49017. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49018. /** @hidden */
  49019. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49020. /** @hidden */
  49021. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49022. }
  49023. }
  49024. declare module "babylonjs/Engines/index" {
  49025. export * from "babylonjs/Engines/constants";
  49026. export * from "babylonjs/Engines/engineCapabilities";
  49027. export * from "babylonjs/Engines/instancingAttributeInfo";
  49028. export * from "babylonjs/Engines/thinEngine";
  49029. export * from "babylonjs/Engines/engine";
  49030. export * from "babylonjs/Engines/engineStore";
  49031. export * from "babylonjs/Engines/nullEngine";
  49032. export * from "babylonjs/Engines/Extensions/index";
  49033. export * from "babylonjs/Engines/IPipelineContext";
  49034. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49035. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49036. export * from "babylonjs/Engines/nativeEngine";
  49037. }
  49038. declare module "babylonjs/Events/clipboardEvents" {
  49039. /**
  49040. * Gather the list of clipboard event types as constants.
  49041. */
  49042. export class ClipboardEventTypes {
  49043. /**
  49044. * The clipboard event is fired when a copy command is active (pressed).
  49045. */
  49046. static readonly COPY: number;
  49047. /**
  49048. * The clipboard event is fired when a cut command is active (pressed).
  49049. */
  49050. static readonly CUT: number;
  49051. /**
  49052. * The clipboard event is fired when a paste command is active (pressed).
  49053. */
  49054. static readonly PASTE: number;
  49055. }
  49056. /**
  49057. * This class is used to store clipboard related info for the onClipboardObservable event.
  49058. */
  49059. export class ClipboardInfo {
  49060. /**
  49061. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49062. */
  49063. type: number;
  49064. /**
  49065. * Defines the related dom event
  49066. */
  49067. event: ClipboardEvent;
  49068. /**
  49069. *Creates an instance of ClipboardInfo.
  49070. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49071. * @param event Defines the related dom event
  49072. */
  49073. constructor(
  49074. /**
  49075. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49076. */
  49077. type: number,
  49078. /**
  49079. * Defines the related dom event
  49080. */
  49081. event: ClipboardEvent);
  49082. /**
  49083. * Get the clipboard event's type from the keycode.
  49084. * @param keyCode Defines the keyCode for the current keyboard event.
  49085. * @return {number}
  49086. */
  49087. static GetTypeFromCharacter(keyCode: number): number;
  49088. }
  49089. }
  49090. declare module "babylonjs/Events/index" {
  49091. export * from "babylonjs/Events/keyboardEvents";
  49092. export * from "babylonjs/Events/pointerEvents";
  49093. export * from "babylonjs/Events/clipboardEvents";
  49094. }
  49095. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49096. import { Scene } from "babylonjs/scene";
  49097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49098. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49099. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49100. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49101. /**
  49102. * Google Daydream controller
  49103. */
  49104. export class DaydreamController extends WebVRController {
  49105. /**
  49106. * Base Url for the controller model.
  49107. */
  49108. static MODEL_BASE_URL: string;
  49109. /**
  49110. * File name for the controller model.
  49111. */
  49112. static MODEL_FILENAME: string;
  49113. /**
  49114. * Gamepad Id prefix used to identify Daydream Controller.
  49115. */
  49116. static readonly GAMEPAD_ID_PREFIX: string;
  49117. /**
  49118. * Creates a new DaydreamController from a gamepad
  49119. * @param vrGamepad the gamepad that the controller should be created from
  49120. */
  49121. constructor(vrGamepad: any);
  49122. /**
  49123. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49124. * @param scene scene in which to add meshes
  49125. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49126. */
  49127. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49128. /**
  49129. * Called once for each button that changed state since the last frame
  49130. * @param buttonIdx Which button index changed
  49131. * @param state New state of the button
  49132. * @param changes Which properties on the state changed since last frame
  49133. */
  49134. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49135. }
  49136. }
  49137. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49138. import { Scene } from "babylonjs/scene";
  49139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49140. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49141. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49142. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49143. /**
  49144. * Gear VR Controller
  49145. */
  49146. export class GearVRController extends WebVRController {
  49147. /**
  49148. * Base Url for the controller model.
  49149. */
  49150. static MODEL_BASE_URL: string;
  49151. /**
  49152. * File name for the controller model.
  49153. */
  49154. static MODEL_FILENAME: string;
  49155. /**
  49156. * Gamepad Id prefix used to identify this controller.
  49157. */
  49158. static readonly GAMEPAD_ID_PREFIX: string;
  49159. private readonly _buttonIndexToObservableNameMap;
  49160. /**
  49161. * Creates a new GearVRController from a gamepad
  49162. * @param vrGamepad the gamepad that the controller should be created from
  49163. */
  49164. constructor(vrGamepad: any);
  49165. /**
  49166. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49167. * @param scene scene in which to add meshes
  49168. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49169. */
  49170. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49171. /**
  49172. * Called once for each button that changed state since the last frame
  49173. * @param buttonIdx Which button index changed
  49174. * @param state New state of the button
  49175. * @param changes Which properties on the state changed since last frame
  49176. */
  49177. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49178. }
  49179. }
  49180. declare module "babylonjs/Gamepads/Controllers/index" {
  49181. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  49182. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  49183. export * from "babylonjs/Gamepads/Controllers/genericController";
  49184. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  49185. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49186. export * from "babylonjs/Gamepads/Controllers/viveController";
  49187. export * from "babylonjs/Gamepads/Controllers/webVRController";
  49188. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  49189. }
  49190. declare module "babylonjs/Gamepads/index" {
  49191. export * from "babylonjs/Gamepads/Controllers/index";
  49192. export * from "babylonjs/Gamepads/gamepad";
  49193. export * from "babylonjs/Gamepads/gamepadManager";
  49194. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  49195. export * from "babylonjs/Gamepads/xboxGamepad";
  49196. export * from "babylonjs/Gamepads/dualShockGamepad";
  49197. }
  49198. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  49199. import { Scene } from "babylonjs/scene";
  49200. import { Vector4 } from "babylonjs/Maths/math.vector";
  49201. import { Color4 } from "babylonjs/Maths/math.color";
  49202. import { Mesh } from "babylonjs/Meshes/mesh";
  49203. import { Nullable } from "babylonjs/types";
  49204. /**
  49205. * Class containing static functions to help procedurally build meshes
  49206. */
  49207. export class PolyhedronBuilder {
  49208. /**
  49209. * Creates a polyhedron mesh
  49210. * * 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
  49211. * * The parameter `size` (positive float, default 1) sets the polygon size
  49212. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49213. * * 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`
  49214. * * 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
  49215. * * 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)`)
  49216. * * 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
  49217. * * 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
  49218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49221. * @param name defines the name of the mesh
  49222. * @param options defines the options used to create the mesh
  49223. * @param scene defines the hosting scene
  49224. * @returns the polyhedron mesh
  49225. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49226. */
  49227. static CreatePolyhedron(name: string, options: {
  49228. type?: number;
  49229. size?: number;
  49230. sizeX?: number;
  49231. sizeY?: number;
  49232. sizeZ?: number;
  49233. custom?: any;
  49234. faceUV?: Vector4[];
  49235. faceColors?: Color4[];
  49236. flat?: boolean;
  49237. updatable?: boolean;
  49238. sideOrientation?: number;
  49239. frontUVs?: Vector4;
  49240. backUVs?: Vector4;
  49241. }, scene?: Nullable<Scene>): Mesh;
  49242. }
  49243. }
  49244. declare module "babylonjs/Gizmos/scaleGizmo" {
  49245. import { Observable } from "babylonjs/Misc/observable";
  49246. import { Nullable } from "babylonjs/types";
  49247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49248. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49249. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  49250. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49251. /**
  49252. * Gizmo that enables scaling a mesh along 3 axis
  49253. */
  49254. export class ScaleGizmo extends Gizmo {
  49255. /**
  49256. * Internal gizmo used for interactions on the x axis
  49257. */
  49258. xGizmo: AxisScaleGizmo;
  49259. /**
  49260. * Internal gizmo used for interactions on the y axis
  49261. */
  49262. yGizmo: AxisScaleGizmo;
  49263. /**
  49264. * Internal gizmo used for interactions on the z axis
  49265. */
  49266. zGizmo: AxisScaleGizmo;
  49267. /**
  49268. * Internal gizmo used to scale all axis equally
  49269. */
  49270. uniformScaleGizmo: AxisScaleGizmo;
  49271. private _meshAttached;
  49272. private _updateGizmoRotationToMatchAttachedMesh;
  49273. private _snapDistance;
  49274. private _scaleRatio;
  49275. private _uniformScalingMesh;
  49276. private _octahedron;
  49277. private _sensitivity;
  49278. /** Fires an event when any of it's sub gizmos are dragged */
  49279. onDragStartObservable: Observable<unknown>;
  49280. /** Fires an event when any of it's sub gizmos are released from dragging */
  49281. onDragEndObservable: Observable<unknown>;
  49282. get attachedMesh(): Nullable<AbstractMesh>;
  49283. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49284. /**
  49285. * Creates a ScaleGizmo
  49286. * @param gizmoLayer The utility layer the gizmo will be added to
  49287. */
  49288. constructor(gizmoLayer?: UtilityLayerRenderer);
  49289. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49290. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49291. /**
  49292. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49293. */
  49294. set snapDistance(value: number);
  49295. get snapDistance(): number;
  49296. /**
  49297. * Ratio for the scale of the gizmo (Default: 1)
  49298. */
  49299. set scaleRatio(value: number);
  49300. get scaleRatio(): number;
  49301. /**
  49302. * Sensitivity factor for dragging (Default: 1)
  49303. */
  49304. set sensitivity(value: number);
  49305. get sensitivity(): number;
  49306. /**
  49307. * Disposes of the gizmo
  49308. */
  49309. dispose(): void;
  49310. }
  49311. }
  49312. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  49313. import { Observable } from "babylonjs/Misc/observable";
  49314. import { Nullable } from "babylonjs/types";
  49315. import { Vector3 } from "babylonjs/Maths/math.vector";
  49316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49317. import { Mesh } from "babylonjs/Meshes/mesh";
  49318. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49319. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49320. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49321. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49322. import { Color3 } from "babylonjs/Maths/math.color";
  49323. /**
  49324. * Single axis scale gizmo
  49325. */
  49326. export class AxisScaleGizmo extends Gizmo {
  49327. /**
  49328. * Drag behavior responsible for the gizmos dragging interactions
  49329. */
  49330. dragBehavior: PointerDragBehavior;
  49331. private _pointerObserver;
  49332. /**
  49333. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49334. */
  49335. snapDistance: number;
  49336. /**
  49337. * Event that fires each time the gizmo snaps to a new location.
  49338. * * snapDistance is the the change in distance
  49339. */
  49340. onSnapObservable: Observable<{
  49341. snapDistance: number;
  49342. }>;
  49343. /**
  49344. * If the scaling operation should be done on all axis (default: false)
  49345. */
  49346. uniformScaling: boolean;
  49347. /**
  49348. * Custom sensitivity value for the drag strength
  49349. */
  49350. sensitivity: number;
  49351. private _isEnabled;
  49352. private _parent;
  49353. private _arrow;
  49354. private _coloredMaterial;
  49355. private _hoverMaterial;
  49356. /**
  49357. * Creates an AxisScaleGizmo
  49358. * @param gizmoLayer The utility layer the gizmo will be added to
  49359. * @param dragAxis The axis which the gizmo will be able to scale on
  49360. * @param color The color of the gizmo
  49361. */
  49362. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49363. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49364. /**
  49365. * If the gizmo is enabled
  49366. */
  49367. set isEnabled(value: boolean);
  49368. get isEnabled(): boolean;
  49369. /**
  49370. * Disposes of the gizmo
  49371. */
  49372. dispose(): void;
  49373. /**
  49374. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49375. * @param mesh The mesh to replace the default mesh of the gizmo
  49376. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49377. */
  49378. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49379. }
  49380. }
  49381. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  49382. import { Observable } from "babylonjs/Misc/observable";
  49383. import { Nullable } from "babylonjs/types";
  49384. import { Vector3 } from "babylonjs/Maths/math.vector";
  49385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49386. import { Mesh } from "babylonjs/Meshes/mesh";
  49387. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49388. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49389. import { Color3 } from "babylonjs/Maths/math.color";
  49390. import "babylonjs/Meshes/Builders/boxBuilder";
  49391. /**
  49392. * Bounding box gizmo
  49393. */
  49394. export class BoundingBoxGizmo extends Gizmo {
  49395. private _lineBoundingBox;
  49396. private _rotateSpheresParent;
  49397. private _scaleBoxesParent;
  49398. private _boundingDimensions;
  49399. private _renderObserver;
  49400. private _pointerObserver;
  49401. private _scaleDragSpeed;
  49402. private _tmpQuaternion;
  49403. private _tmpVector;
  49404. private _tmpRotationMatrix;
  49405. /**
  49406. * 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)
  49407. */
  49408. ignoreChildren: boolean;
  49409. /**
  49410. * 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)
  49411. */
  49412. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49413. /**
  49414. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49415. */
  49416. rotationSphereSize: number;
  49417. /**
  49418. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49419. */
  49420. scaleBoxSize: number;
  49421. /**
  49422. * 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)
  49423. */
  49424. fixedDragMeshScreenSize: boolean;
  49425. /**
  49426. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49427. */
  49428. fixedDragMeshScreenSizeDistanceFactor: number;
  49429. /**
  49430. * Fired when a rotation sphere or scale box is dragged
  49431. */
  49432. onDragStartObservable: Observable<{}>;
  49433. /**
  49434. * Fired when a scale box is dragged
  49435. */
  49436. onScaleBoxDragObservable: Observable<{}>;
  49437. /**
  49438. * Fired when a scale box drag is ended
  49439. */
  49440. onScaleBoxDragEndObservable: Observable<{}>;
  49441. /**
  49442. * Fired when a rotation sphere is dragged
  49443. */
  49444. onRotationSphereDragObservable: Observable<{}>;
  49445. /**
  49446. * Fired when a rotation sphere drag is ended
  49447. */
  49448. onRotationSphereDragEndObservable: Observable<{}>;
  49449. /**
  49450. * 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)
  49451. */
  49452. scalePivot: Nullable<Vector3>;
  49453. /**
  49454. * Mesh used as a pivot to rotate the attached mesh
  49455. */
  49456. private _anchorMesh;
  49457. private _existingMeshScale;
  49458. private _dragMesh;
  49459. private pointerDragBehavior;
  49460. private coloredMaterial;
  49461. private hoverColoredMaterial;
  49462. /**
  49463. * Sets the color of the bounding box gizmo
  49464. * @param color the color to set
  49465. */
  49466. setColor(color: Color3): void;
  49467. /**
  49468. * Creates an BoundingBoxGizmo
  49469. * @param gizmoLayer The utility layer the gizmo will be added to
  49470. * @param color The color of the gizmo
  49471. */
  49472. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49473. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49474. private _selectNode;
  49475. /**
  49476. * Updates the bounding box information for the Gizmo
  49477. */
  49478. updateBoundingBox(): void;
  49479. private _updateRotationSpheres;
  49480. private _updateScaleBoxes;
  49481. /**
  49482. * Enables rotation on the specified axis and disables rotation on the others
  49483. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49484. */
  49485. setEnabledRotationAxis(axis: string): void;
  49486. /**
  49487. * Enables/disables scaling
  49488. * @param enable if scaling should be enabled
  49489. */
  49490. setEnabledScaling(enable: boolean): void;
  49491. private _updateDummy;
  49492. /**
  49493. * Enables a pointer drag behavior on the bounding box of the gizmo
  49494. */
  49495. enableDragBehavior(): void;
  49496. /**
  49497. * Disposes of the gizmo
  49498. */
  49499. dispose(): void;
  49500. /**
  49501. * 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)
  49502. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49503. * @returns the bounding box mesh with the passed in mesh as a child
  49504. */
  49505. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49506. /**
  49507. * CustomMeshes are not supported by this gizmo
  49508. * @param mesh The mesh to replace the default mesh of the gizmo
  49509. */
  49510. setCustomMesh(mesh: Mesh): void;
  49511. }
  49512. }
  49513. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  49514. import { Observable } from "babylonjs/Misc/observable";
  49515. import { Nullable } from "babylonjs/types";
  49516. import { Vector3 } from "babylonjs/Maths/math.vector";
  49517. import { Color3 } from "babylonjs/Maths/math.color";
  49518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49519. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49520. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49521. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49522. import "babylonjs/Meshes/Builders/linesBuilder";
  49523. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49524. /**
  49525. * Single plane rotation gizmo
  49526. */
  49527. export class PlaneRotationGizmo extends Gizmo {
  49528. /**
  49529. * Drag behavior responsible for the gizmos dragging interactions
  49530. */
  49531. dragBehavior: PointerDragBehavior;
  49532. private _pointerObserver;
  49533. /**
  49534. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49535. */
  49536. snapDistance: number;
  49537. /**
  49538. * Event that fires each time the gizmo snaps to a new location.
  49539. * * snapDistance is the the change in distance
  49540. */
  49541. onSnapObservable: Observable<{
  49542. snapDistance: number;
  49543. }>;
  49544. private _isEnabled;
  49545. private _parent;
  49546. /**
  49547. * Creates a PlaneRotationGizmo
  49548. * @param gizmoLayer The utility layer the gizmo will be added to
  49549. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49550. * @param color The color of the gizmo
  49551. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49552. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49553. */
  49554. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49555. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49556. /**
  49557. * If the gizmo is enabled
  49558. */
  49559. set isEnabled(value: boolean);
  49560. get isEnabled(): boolean;
  49561. /**
  49562. * Disposes of the gizmo
  49563. */
  49564. dispose(): void;
  49565. }
  49566. }
  49567. declare module "babylonjs/Gizmos/rotationGizmo" {
  49568. import { Observable } from "babylonjs/Misc/observable";
  49569. import { Nullable } from "babylonjs/types";
  49570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49571. import { Mesh } from "babylonjs/Meshes/mesh";
  49572. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49573. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  49574. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49575. /**
  49576. * Gizmo that enables rotating a mesh along 3 axis
  49577. */
  49578. export class RotationGizmo extends Gizmo {
  49579. /**
  49580. * Internal gizmo used for interactions on the x axis
  49581. */
  49582. xGizmo: PlaneRotationGizmo;
  49583. /**
  49584. * Internal gizmo used for interactions on the y axis
  49585. */
  49586. yGizmo: PlaneRotationGizmo;
  49587. /**
  49588. * Internal gizmo used for interactions on the z axis
  49589. */
  49590. zGizmo: PlaneRotationGizmo;
  49591. /** Fires an event when any of it's sub gizmos are dragged */
  49592. onDragStartObservable: Observable<unknown>;
  49593. /** Fires an event when any of it's sub gizmos are released from dragging */
  49594. onDragEndObservable: Observable<unknown>;
  49595. private _meshAttached;
  49596. get attachedMesh(): Nullable<AbstractMesh>;
  49597. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49598. /**
  49599. * Creates a RotationGizmo
  49600. * @param gizmoLayer The utility layer the gizmo will be added to
  49601. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49602. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49603. */
  49604. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49605. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49606. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49607. /**
  49608. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49609. */
  49610. set snapDistance(value: number);
  49611. get snapDistance(): number;
  49612. /**
  49613. * Ratio for the scale of the gizmo (Default: 1)
  49614. */
  49615. set scaleRatio(value: number);
  49616. get scaleRatio(): number;
  49617. /**
  49618. * Disposes of the gizmo
  49619. */
  49620. dispose(): void;
  49621. /**
  49622. * CustomMeshes are not supported by this gizmo
  49623. * @param mesh The mesh to replace the default mesh of the gizmo
  49624. */
  49625. setCustomMesh(mesh: Mesh): void;
  49626. }
  49627. }
  49628. declare module "babylonjs/Gizmos/gizmoManager" {
  49629. import { Observable } from "babylonjs/Misc/observable";
  49630. import { Nullable } from "babylonjs/types";
  49631. import { Scene, IDisposable } from "babylonjs/scene";
  49632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49633. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49634. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49635. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49636. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  49637. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49638. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  49639. /**
  49640. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49641. */
  49642. export class GizmoManager implements IDisposable {
  49643. private scene;
  49644. /**
  49645. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49646. */
  49647. gizmos: {
  49648. positionGizmo: Nullable<PositionGizmo>;
  49649. rotationGizmo: Nullable<RotationGizmo>;
  49650. scaleGizmo: Nullable<ScaleGizmo>;
  49651. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49652. };
  49653. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49654. clearGizmoOnEmptyPointerEvent: boolean;
  49655. /** Fires an event when the manager is attached to a mesh */
  49656. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49657. private _gizmosEnabled;
  49658. private _pointerObserver;
  49659. private _attachedMesh;
  49660. private _boundingBoxColor;
  49661. private _defaultUtilityLayer;
  49662. private _defaultKeepDepthUtilityLayer;
  49663. /**
  49664. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49665. */
  49666. boundingBoxDragBehavior: SixDofDragBehavior;
  49667. /**
  49668. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49669. */
  49670. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49671. /**
  49672. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49673. */
  49674. usePointerToAttachGizmos: boolean;
  49675. /**
  49676. * Utility layer that the bounding box gizmo belongs to
  49677. */
  49678. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49679. /**
  49680. * Utility layer that all gizmos besides bounding box belong to
  49681. */
  49682. get utilityLayer(): UtilityLayerRenderer;
  49683. /**
  49684. * Instatiates a gizmo manager
  49685. * @param scene the scene to overlay the gizmos on top of
  49686. */
  49687. constructor(scene: Scene);
  49688. /**
  49689. * Attaches a set of gizmos to the specified mesh
  49690. * @param mesh The mesh the gizmo's should be attached to
  49691. */
  49692. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49693. /**
  49694. * If the position gizmo is enabled
  49695. */
  49696. set positionGizmoEnabled(value: boolean);
  49697. get positionGizmoEnabled(): boolean;
  49698. /**
  49699. * If the rotation gizmo is enabled
  49700. */
  49701. set rotationGizmoEnabled(value: boolean);
  49702. get rotationGizmoEnabled(): boolean;
  49703. /**
  49704. * If the scale gizmo is enabled
  49705. */
  49706. set scaleGizmoEnabled(value: boolean);
  49707. get scaleGizmoEnabled(): boolean;
  49708. /**
  49709. * If the boundingBox gizmo is enabled
  49710. */
  49711. set boundingBoxGizmoEnabled(value: boolean);
  49712. get boundingBoxGizmoEnabled(): boolean;
  49713. /**
  49714. * Disposes of the gizmo manager
  49715. */
  49716. dispose(): void;
  49717. }
  49718. }
  49719. declare module "babylonjs/Lights/directionalLight" {
  49720. import { Camera } from "babylonjs/Cameras/camera";
  49721. import { Scene } from "babylonjs/scene";
  49722. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49724. import { Light } from "babylonjs/Lights/light";
  49725. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49726. import { Effect } from "babylonjs/Materials/effect";
  49727. /**
  49728. * A directional light is defined by a direction (what a surprise!).
  49729. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49730. * 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.
  49731. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49732. */
  49733. export class DirectionalLight extends ShadowLight {
  49734. private _shadowFrustumSize;
  49735. /**
  49736. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49737. */
  49738. get shadowFrustumSize(): number;
  49739. /**
  49740. * Specifies a fix frustum size for the shadow generation.
  49741. */
  49742. set shadowFrustumSize(value: number);
  49743. private _shadowOrthoScale;
  49744. /**
  49745. * Gets the shadow projection scale against the optimal computed one.
  49746. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49747. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49748. */
  49749. get shadowOrthoScale(): number;
  49750. /**
  49751. * Sets the shadow projection scale against the optimal computed one.
  49752. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49753. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49754. */
  49755. set shadowOrthoScale(value: number);
  49756. /**
  49757. * Automatically compute the projection matrix to best fit (including all the casters)
  49758. * on each frame.
  49759. */
  49760. autoUpdateExtends: boolean;
  49761. /**
  49762. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49763. * on each frame. autoUpdateExtends must be set to true for this to work
  49764. */
  49765. autoCalcShadowZBounds: boolean;
  49766. private _orthoLeft;
  49767. private _orthoRight;
  49768. private _orthoTop;
  49769. private _orthoBottom;
  49770. /**
  49771. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49772. * The directional light is emitted from everywhere in the given direction.
  49773. * It can cast shadows.
  49774. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49775. * @param name The friendly name of the light
  49776. * @param direction The direction of the light
  49777. * @param scene The scene the light belongs to
  49778. */
  49779. constructor(name: string, direction: Vector3, scene: Scene);
  49780. /**
  49781. * Returns the string "DirectionalLight".
  49782. * @return The class name
  49783. */
  49784. getClassName(): string;
  49785. /**
  49786. * Returns the integer 1.
  49787. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49788. */
  49789. getTypeID(): number;
  49790. /**
  49791. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49792. * Returns the DirectionalLight Shadow projection matrix.
  49793. */
  49794. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49795. /**
  49796. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49797. * Returns the DirectionalLight Shadow projection matrix.
  49798. */
  49799. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49800. /**
  49801. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49802. * Returns the DirectionalLight Shadow projection matrix.
  49803. */
  49804. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49805. protected _buildUniformLayout(): void;
  49806. /**
  49807. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49808. * @param effect The effect to update
  49809. * @param lightIndex The index of the light in the effect to update
  49810. * @returns The directional light
  49811. */
  49812. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49813. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49814. /**
  49815. * Gets the minZ used for shadow according to both the scene and the light.
  49816. *
  49817. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49818. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49819. * @param activeCamera The camera we are returning the min for
  49820. * @returns the depth min z
  49821. */
  49822. getDepthMinZ(activeCamera: Camera): number;
  49823. /**
  49824. * Gets the maxZ used for shadow according to both the scene and the light.
  49825. *
  49826. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49827. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49828. * @param activeCamera The camera we are returning the max for
  49829. * @returns the depth max z
  49830. */
  49831. getDepthMaxZ(activeCamera: Camera): number;
  49832. /**
  49833. * Prepares the list of defines specific to the light type.
  49834. * @param defines the list of defines
  49835. * @param lightIndex defines the index of the light for the effect
  49836. */
  49837. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49838. }
  49839. }
  49840. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  49841. import { Mesh } from "babylonjs/Meshes/mesh";
  49842. /**
  49843. * Class containing static functions to help procedurally build meshes
  49844. */
  49845. export class HemisphereBuilder {
  49846. /**
  49847. * Creates a hemisphere mesh
  49848. * @param name defines the name of the mesh
  49849. * @param options defines the options used to create the mesh
  49850. * @param scene defines the hosting scene
  49851. * @returns the hemisphere mesh
  49852. */
  49853. static CreateHemisphere(name: string, options: {
  49854. segments?: number;
  49855. diameter?: number;
  49856. sideOrientation?: number;
  49857. }, scene: any): Mesh;
  49858. }
  49859. }
  49860. declare module "babylonjs/Lights/spotLight" {
  49861. import { Nullable } from "babylonjs/types";
  49862. import { Scene } from "babylonjs/scene";
  49863. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49865. import { Effect } from "babylonjs/Materials/effect";
  49866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49867. import { Light } from "babylonjs/Lights/light";
  49868. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49869. /**
  49870. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49871. * These values define a cone of light starting from the position, emitting toward the direction.
  49872. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49873. * and the exponent defines the speed of the decay of the light with distance (reach).
  49874. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49875. */
  49876. export class SpotLight extends ShadowLight {
  49877. private _angle;
  49878. private _innerAngle;
  49879. private _cosHalfAngle;
  49880. private _lightAngleScale;
  49881. private _lightAngleOffset;
  49882. /**
  49883. * Gets the cone angle of the spot light in Radians.
  49884. */
  49885. get angle(): number;
  49886. /**
  49887. * Sets the cone angle of the spot light in Radians.
  49888. */
  49889. set angle(value: number);
  49890. /**
  49891. * Only used in gltf falloff mode, this defines the angle where
  49892. * the directional falloff will start before cutting at angle which could be seen
  49893. * as outer angle.
  49894. */
  49895. get innerAngle(): number;
  49896. /**
  49897. * Only used in gltf falloff mode, this defines the angle where
  49898. * the directional falloff will start before cutting at angle which could be seen
  49899. * as outer angle.
  49900. */
  49901. set innerAngle(value: number);
  49902. private _shadowAngleScale;
  49903. /**
  49904. * Allows scaling the angle of the light for shadow generation only.
  49905. */
  49906. get shadowAngleScale(): number;
  49907. /**
  49908. * Allows scaling the angle of the light for shadow generation only.
  49909. */
  49910. set shadowAngleScale(value: number);
  49911. /**
  49912. * The light decay speed with the distance from the emission spot.
  49913. */
  49914. exponent: number;
  49915. private _projectionTextureMatrix;
  49916. /**
  49917. * Allows reading the projecton texture
  49918. */
  49919. get projectionTextureMatrix(): Matrix;
  49920. protected _projectionTextureLightNear: number;
  49921. /**
  49922. * Gets the near clip of the Spotlight for texture projection.
  49923. */
  49924. get projectionTextureLightNear(): number;
  49925. /**
  49926. * Sets the near clip of the Spotlight for texture projection.
  49927. */
  49928. set projectionTextureLightNear(value: number);
  49929. protected _projectionTextureLightFar: number;
  49930. /**
  49931. * Gets the far clip of the Spotlight for texture projection.
  49932. */
  49933. get projectionTextureLightFar(): number;
  49934. /**
  49935. * Sets the far clip of the Spotlight for texture projection.
  49936. */
  49937. set projectionTextureLightFar(value: number);
  49938. protected _projectionTextureUpDirection: Vector3;
  49939. /**
  49940. * Gets the Up vector of the Spotlight for texture projection.
  49941. */
  49942. get projectionTextureUpDirection(): Vector3;
  49943. /**
  49944. * Sets the Up vector of the Spotlight for texture projection.
  49945. */
  49946. set projectionTextureUpDirection(value: Vector3);
  49947. private _projectionTexture;
  49948. /**
  49949. * Gets the projection texture of the light.
  49950. */
  49951. get projectionTexture(): Nullable<BaseTexture>;
  49952. /**
  49953. * Sets the projection texture of the light.
  49954. */
  49955. set projectionTexture(value: Nullable<BaseTexture>);
  49956. private _projectionTextureViewLightDirty;
  49957. private _projectionTextureProjectionLightDirty;
  49958. private _projectionTextureDirty;
  49959. private _projectionTextureViewTargetVector;
  49960. private _projectionTextureViewLightMatrix;
  49961. private _projectionTextureProjectionLightMatrix;
  49962. private _projectionTextureScalingMatrix;
  49963. /**
  49964. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49965. * It can cast shadows.
  49966. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49967. * @param name The light friendly name
  49968. * @param position The position of the spot light in the scene
  49969. * @param direction The direction of the light in the scene
  49970. * @param angle The cone angle of the light in Radians
  49971. * @param exponent The light decay speed with the distance from the emission spot
  49972. * @param scene The scene the lights belongs to
  49973. */
  49974. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49975. /**
  49976. * Returns the string "SpotLight".
  49977. * @returns the class name
  49978. */
  49979. getClassName(): string;
  49980. /**
  49981. * Returns the integer 2.
  49982. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49983. */
  49984. getTypeID(): number;
  49985. /**
  49986. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49987. */
  49988. protected _setDirection(value: Vector3): void;
  49989. /**
  49990. * Overrides the position setter to recompute the projection texture view light Matrix.
  49991. */
  49992. protected _setPosition(value: Vector3): void;
  49993. /**
  49994. * 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.
  49995. * Returns the SpotLight.
  49996. */
  49997. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49998. protected _computeProjectionTextureViewLightMatrix(): void;
  49999. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50000. /**
  50001. * Main function for light texture projection matrix computing.
  50002. */
  50003. protected _computeProjectionTextureMatrix(): void;
  50004. protected _buildUniformLayout(): void;
  50005. private _computeAngleValues;
  50006. /**
  50007. * Sets the passed Effect "effect" with the Light textures.
  50008. * @param effect The effect to update
  50009. * @param lightIndex The index of the light in the effect to update
  50010. * @returns The light
  50011. */
  50012. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50013. /**
  50014. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50015. * @param effect The effect to update
  50016. * @param lightIndex The index of the light in the effect to update
  50017. * @returns The spot light
  50018. */
  50019. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50020. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50021. /**
  50022. * Disposes the light and the associated resources.
  50023. */
  50024. dispose(): void;
  50025. /**
  50026. * Prepares the list of defines specific to the light type.
  50027. * @param defines the list of defines
  50028. * @param lightIndex defines the index of the light for the effect
  50029. */
  50030. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50031. }
  50032. }
  50033. declare module "babylonjs/Gizmos/lightGizmo" {
  50034. import { Nullable } from "babylonjs/types";
  50035. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50036. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50037. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50038. import { Light } from "babylonjs/Lights/light";
  50039. /**
  50040. * Gizmo that enables viewing a light
  50041. */
  50042. export class LightGizmo extends Gizmo {
  50043. private _lightMesh;
  50044. private _material;
  50045. private _cachedPosition;
  50046. private _cachedForward;
  50047. private _attachedMeshParent;
  50048. /**
  50049. * Creates a LightGizmo
  50050. * @param gizmoLayer The utility layer the gizmo will be added to
  50051. */
  50052. constructor(gizmoLayer?: UtilityLayerRenderer);
  50053. private _light;
  50054. /**
  50055. * The light that the gizmo is attached to
  50056. */
  50057. set light(light: Nullable<Light>);
  50058. get light(): Nullable<Light>;
  50059. /**
  50060. * Gets the material used to render the light gizmo
  50061. */
  50062. get material(): StandardMaterial;
  50063. /**
  50064. * @hidden
  50065. * Updates the gizmo to match the attached mesh's position/rotation
  50066. */
  50067. protected _update(): void;
  50068. private static _Scale;
  50069. /**
  50070. * Creates the lines for a light mesh
  50071. */
  50072. private static _CreateLightLines;
  50073. /**
  50074. * Disposes of the light gizmo
  50075. */
  50076. dispose(): void;
  50077. private static _CreateHemisphericLightMesh;
  50078. private static _CreatePointLightMesh;
  50079. private static _CreateSpotLightMesh;
  50080. private static _CreateDirectionalLightMesh;
  50081. }
  50082. }
  50083. declare module "babylonjs/Gizmos/index" {
  50084. export * from "babylonjs/Gizmos/axisDragGizmo";
  50085. export * from "babylonjs/Gizmos/axisScaleGizmo";
  50086. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  50087. export * from "babylonjs/Gizmos/gizmo";
  50088. export * from "babylonjs/Gizmos/gizmoManager";
  50089. export * from "babylonjs/Gizmos/planeRotationGizmo";
  50090. export * from "babylonjs/Gizmos/positionGizmo";
  50091. export * from "babylonjs/Gizmos/rotationGizmo";
  50092. export * from "babylonjs/Gizmos/scaleGizmo";
  50093. export * from "babylonjs/Gizmos/lightGizmo";
  50094. export * from "babylonjs/Gizmos/planeDragGizmo";
  50095. }
  50096. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  50097. /** @hidden */
  50098. export var backgroundFragmentDeclaration: {
  50099. name: string;
  50100. shader: string;
  50101. };
  50102. }
  50103. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  50104. /** @hidden */
  50105. export var backgroundUboDeclaration: {
  50106. name: string;
  50107. shader: string;
  50108. };
  50109. }
  50110. declare module "babylonjs/Shaders/background.fragment" {
  50111. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50112. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50113. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50114. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50115. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50116. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50117. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50118. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50119. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50120. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50121. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50122. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50123. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50124. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50125. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50126. /** @hidden */
  50127. export var backgroundPixelShader: {
  50128. name: string;
  50129. shader: string;
  50130. };
  50131. }
  50132. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50133. /** @hidden */
  50134. export var backgroundVertexDeclaration: {
  50135. name: string;
  50136. shader: string;
  50137. };
  50138. }
  50139. declare module "babylonjs/Shaders/background.vertex" {
  50140. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50141. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50142. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50143. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50144. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50145. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50146. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50147. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50148. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50149. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50150. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50151. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50152. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50153. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50154. /** @hidden */
  50155. export var backgroundVertexShader: {
  50156. name: string;
  50157. shader: string;
  50158. };
  50159. }
  50160. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  50161. import { Nullable, int, float } from "babylonjs/types";
  50162. import { Scene } from "babylonjs/scene";
  50163. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50164. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50166. import { Mesh } from "babylonjs/Meshes/mesh";
  50167. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50168. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50169. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50170. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50171. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  50172. import { Color3 } from "babylonjs/Maths/math.color";
  50173. import "babylonjs/Shaders/background.fragment";
  50174. import "babylonjs/Shaders/background.vertex";
  50175. /**
  50176. * Background material used to create an efficient environement around your scene.
  50177. */
  50178. export class BackgroundMaterial extends PushMaterial {
  50179. /**
  50180. * Standard reflectance value at parallel view angle.
  50181. */
  50182. static StandardReflectance0: number;
  50183. /**
  50184. * Standard reflectance value at grazing angle.
  50185. */
  50186. static StandardReflectance90: number;
  50187. protected _primaryColor: Color3;
  50188. /**
  50189. * Key light Color (multiply against the environement texture)
  50190. */
  50191. primaryColor: Color3;
  50192. protected __perceptualColor: Nullable<Color3>;
  50193. /**
  50194. * Experimental Internal Use Only.
  50195. *
  50196. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50197. * This acts as a helper to set the primary color to a more "human friendly" value.
  50198. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50199. * output color as close as possible from the chosen value.
  50200. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50201. * part of lighting setup.)
  50202. */
  50203. get _perceptualColor(): Nullable<Color3>;
  50204. set _perceptualColor(value: Nullable<Color3>);
  50205. protected _primaryColorShadowLevel: float;
  50206. /**
  50207. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50208. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50209. */
  50210. get primaryColorShadowLevel(): float;
  50211. set primaryColorShadowLevel(value: float);
  50212. protected _primaryColorHighlightLevel: float;
  50213. /**
  50214. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50215. * The primary color is used at the level chosen to define what the white area would look.
  50216. */
  50217. get primaryColorHighlightLevel(): float;
  50218. set primaryColorHighlightLevel(value: float);
  50219. protected _reflectionTexture: Nullable<BaseTexture>;
  50220. /**
  50221. * Reflection Texture used in the material.
  50222. * Should be author in a specific way for the best result (refer to the documentation).
  50223. */
  50224. reflectionTexture: Nullable<BaseTexture>;
  50225. protected _reflectionBlur: float;
  50226. /**
  50227. * Reflection Texture level of blur.
  50228. *
  50229. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50230. * texture twice.
  50231. */
  50232. reflectionBlur: float;
  50233. protected _diffuseTexture: Nullable<BaseTexture>;
  50234. /**
  50235. * Diffuse Texture used in the material.
  50236. * Should be author in a specific way for the best result (refer to the documentation).
  50237. */
  50238. diffuseTexture: Nullable<BaseTexture>;
  50239. protected _shadowLights: Nullable<IShadowLight[]>;
  50240. /**
  50241. * Specify the list of lights casting shadow on the material.
  50242. * All scene shadow lights will be included if null.
  50243. */
  50244. shadowLights: Nullable<IShadowLight[]>;
  50245. protected _shadowLevel: float;
  50246. /**
  50247. * Helps adjusting the shadow to a softer level if required.
  50248. * 0 means black shadows and 1 means no shadows.
  50249. */
  50250. shadowLevel: float;
  50251. protected _sceneCenter: Vector3;
  50252. /**
  50253. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50254. * It is usually zero but might be interesting to modify according to your setup.
  50255. */
  50256. sceneCenter: Vector3;
  50257. protected _opacityFresnel: boolean;
  50258. /**
  50259. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50260. * This helps ensuring a nice transition when the camera goes under the ground.
  50261. */
  50262. opacityFresnel: boolean;
  50263. protected _reflectionFresnel: boolean;
  50264. /**
  50265. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50266. * This helps adding a mirror texture on the ground.
  50267. */
  50268. reflectionFresnel: boolean;
  50269. protected _reflectionFalloffDistance: number;
  50270. /**
  50271. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50272. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50273. */
  50274. reflectionFalloffDistance: number;
  50275. protected _reflectionAmount: number;
  50276. /**
  50277. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50278. */
  50279. reflectionAmount: number;
  50280. protected _reflectionReflectance0: number;
  50281. /**
  50282. * This specifies the weight of the reflection at grazing angle.
  50283. */
  50284. reflectionReflectance0: number;
  50285. protected _reflectionReflectance90: number;
  50286. /**
  50287. * This specifies the weight of the reflection at a perpendicular point of view.
  50288. */
  50289. reflectionReflectance90: number;
  50290. /**
  50291. * Sets the reflection reflectance fresnel values according to the default standard
  50292. * empirically know to work well :-)
  50293. */
  50294. set reflectionStandardFresnelWeight(value: number);
  50295. protected _useRGBColor: boolean;
  50296. /**
  50297. * Helps to directly use the maps channels instead of their level.
  50298. */
  50299. useRGBColor: boolean;
  50300. protected _enableNoise: boolean;
  50301. /**
  50302. * This helps reducing the banding effect that could occur on the background.
  50303. */
  50304. enableNoise: boolean;
  50305. /**
  50306. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50307. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50308. * Recommended to be keep at 1.0 except for special cases.
  50309. */
  50310. get fovMultiplier(): number;
  50311. set fovMultiplier(value: number);
  50312. private _fovMultiplier;
  50313. /**
  50314. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50315. */
  50316. useEquirectangularFOV: boolean;
  50317. private _maxSimultaneousLights;
  50318. /**
  50319. * Number of Simultaneous lights allowed on the material.
  50320. */
  50321. maxSimultaneousLights: int;
  50322. /**
  50323. * Default configuration related to image processing available in the Background Material.
  50324. */
  50325. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50326. /**
  50327. * Keep track of the image processing observer to allow dispose and replace.
  50328. */
  50329. private _imageProcessingObserver;
  50330. /**
  50331. * Attaches a new image processing configuration to the PBR Material.
  50332. * @param configuration (if null the scene configuration will be use)
  50333. */
  50334. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50335. /**
  50336. * Gets the image processing configuration used either in this material.
  50337. */
  50338. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  50339. /**
  50340. * Sets the Default image processing configuration used either in the this material.
  50341. *
  50342. * If sets to null, the scene one is in use.
  50343. */
  50344. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  50345. /**
  50346. * Gets wether the color curves effect is enabled.
  50347. */
  50348. get cameraColorCurvesEnabled(): boolean;
  50349. /**
  50350. * Sets wether the color curves effect is enabled.
  50351. */
  50352. set cameraColorCurvesEnabled(value: boolean);
  50353. /**
  50354. * Gets wether the color grading effect is enabled.
  50355. */
  50356. get cameraColorGradingEnabled(): boolean;
  50357. /**
  50358. * Gets wether the color grading effect is enabled.
  50359. */
  50360. set cameraColorGradingEnabled(value: boolean);
  50361. /**
  50362. * Gets wether tonemapping is enabled or not.
  50363. */
  50364. get cameraToneMappingEnabled(): boolean;
  50365. /**
  50366. * Sets wether tonemapping is enabled or not
  50367. */
  50368. set cameraToneMappingEnabled(value: boolean);
  50369. /**
  50370. * The camera exposure used on this material.
  50371. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50372. * This corresponds to a photographic exposure.
  50373. */
  50374. get cameraExposure(): float;
  50375. /**
  50376. * The camera exposure used on this material.
  50377. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50378. * This corresponds to a photographic exposure.
  50379. */
  50380. set cameraExposure(value: float);
  50381. /**
  50382. * Gets The camera contrast used on this material.
  50383. */
  50384. get cameraContrast(): float;
  50385. /**
  50386. * Sets The camera contrast used on this material.
  50387. */
  50388. set cameraContrast(value: float);
  50389. /**
  50390. * Gets the Color Grading 2D Lookup Texture.
  50391. */
  50392. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50393. /**
  50394. * Sets the Color Grading 2D Lookup Texture.
  50395. */
  50396. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50397. /**
  50398. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50399. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50400. * 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;
  50401. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50402. */
  50403. get cameraColorCurves(): Nullable<ColorCurves>;
  50404. /**
  50405. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50406. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50407. * 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;
  50408. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50409. */
  50410. set cameraColorCurves(value: Nullable<ColorCurves>);
  50411. /**
  50412. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50413. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50414. */
  50415. switchToBGR: boolean;
  50416. private _renderTargets;
  50417. private _reflectionControls;
  50418. private _white;
  50419. private _primaryShadowColor;
  50420. private _primaryHighlightColor;
  50421. /**
  50422. * Instantiates a Background Material in the given scene
  50423. * @param name The friendly name of the material
  50424. * @param scene The scene to add the material to
  50425. */
  50426. constructor(name: string, scene: Scene);
  50427. /**
  50428. * Gets a boolean indicating that current material needs to register RTT
  50429. */
  50430. get hasRenderTargetTextures(): boolean;
  50431. /**
  50432. * The entire material has been created in order to prevent overdraw.
  50433. * @returns false
  50434. */
  50435. needAlphaTesting(): boolean;
  50436. /**
  50437. * The entire material has been created in order to prevent overdraw.
  50438. * @returns true if blending is enable
  50439. */
  50440. needAlphaBlending(): boolean;
  50441. /**
  50442. * Checks wether the material is ready to be rendered for a given mesh.
  50443. * @param mesh The mesh to render
  50444. * @param subMesh The submesh to check against
  50445. * @param useInstances Specify wether or not the material is used with instances
  50446. * @returns true if all the dependencies are ready (Textures, Effects...)
  50447. */
  50448. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50449. /**
  50450. * Compute the primary color according to the chosen perceptual color.
  50451. */
  50452. private _computePrimaryColorFromPerceptualColor;
  50453. /**
  50454. * Compute the highlights and shadow colors according to their chosen levels.
  50455. */
  50456. private _computePrimaryColors;
  50457. /**
  50458. * Build the uniform buffer used in the material.
  50459. */
  50460. buildUniformLayout(): void;
  50461. /**
  50462. * Unbind the material.
  50463. */
  50464. unbind(): void;
  50465. /**
  50466. * Bind only the world matrix to the material.
  50467. * @param world The world matrix to bind.
  50468. */
  50469. bindOnlyWorldMatrix(world: Matrix): void;
  50470. /**
  50471. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50472. * @param world The world matrix to bind.
  50473. * @param subMesh The submesh to bind for.
  50474. */
  50475. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50476. /**
  50477. * Checks to see if a texture is used in the material.
  50478. * @param texture - Base texture to use.
  50479. * @returns - Boolean specifying if a texture is used in the material.
  50480. */
  50481. hasTexture(texture: BaseTexture): boolean;
  50482. /**
  50483. * Dispose the material.
  50484. * @param forceDisposeEffect Force disposal of the associated effect.
  50485. * @param forceDisposeTextures Force disposal of the associated textures.
  50486. */
  50487. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50488. /**
  50489. * Clones the material.
  50490. * @param name The cloned name.
  50491. * @returns The cloned material.
  50492. */
  50493. clone(name: string): BackgroundMaterial;
  50494. /**
  50495. * Serializes the current material to its JSON representation.
  50496. * @returns The JSON representation.
  50497. */
  50498. serialize(): any;
  50499. /**
  50500. * Gets the class name of the material
  50501. * @returns "BackgroundMaterial"
  50502. */
  50503. getClassName(): string;
  50504. /**
  50505. * Parse a JSON input to create back a background material.
  50506. * @param source The JSON data to parse
  50507. * @param scene The scene to create the parsed material in
  50508. * @param rootUrl The root url of the assets the material depends upon
  50509. * @returns the instantiated BackgroundMaterial.
  50510. */
  50511. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50512. }
  50513. }
  50514. declare module "babylonjs/Helpers/environmentHelper" {
  50515. import { Observable } from "babylonjs/Misc/observable";
  50516. import { Nullable } from "babylonjs/types";
  50517. import { Scene } from "babylonjs/scene";
  50518. import { Vector3 } from "babylonjs/Maths/math.vector";
  50519. import { Color3 } from "babylonjs/Maths/math.color";
  50520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50521. import { Mesh } from "babylonjs/Meshes/mesh";
  50522. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50523. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  50524. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50525. import "babylonjs/Meshes/Builders/planeBuilder";
  50526. import "babylonjs/Meshes/Builders/boxBuilder";
  50527. /**
  50528. * Represents the different options available during the creation of
  50529. * a Environment helper.
  50530. *
  50531. * This can control the default ground, skybox and image processing setup of your scene.
  50532. */
  50533. export interface IEnvironmentHelperOptions {
  50534. /**
  50535. * Specifies wether or not to create a ground.
  50536. * True by default.
  50537. */
  50538. createGround: boolean;
  50539. /**
  50540. * Specifies the ground size.
  50541. * 15 by default.
  50542. */
  50543. groundSize: number;
  50544. /**
  50545. * The texture used on the ground for the main color.
  50546. * Comes from the BabylonJS CDN by default.
  50547. *
  50548. * Remarks: Can be either a texture or a url.
  50549. */
  50550. groundTexture: string | BaseTexture;
  50551. /**
  50552. * The color mixed in the ground texture by default.
  50553. * BabylonJS clearColor by default.
  50554. */
  50555. groundColor: Color3;
  50556. /**
  50557. * Specifies the ground opacity.
  50558. * 1 by default.
  50559. */
  50560. groundOpacity: number;
  50561. /**
  50562. * Enables the ground to receive shadows.
  50563. * True by default.
  50564. */
  50565. enableGroundShadow: boolean;
  50566. /**
  50567. * Helps preventing the shadow to be fully black on the ground.
  50568. * 0.5 by default.
  50569. */
  50570. groundShadowLevel: number;
  50571. /**
  50572. * Creates a mirror texture attach to the ground.
  50573. * false by default.
  50574. */
  50575. enableGroundMirror: boolean;
  50576. /**
  50577. * Specifies the ground mirror size ratio.
  50578. * 0.3 by default as the default kernel is 64.
  50579. */
  50580. groundMirrorSizeRatio: number;
  50581. /**
  50582. * Specifies the ground mirror blur kernel size.
  50583. * 64 by default.
  50584. */
  50585. groundMirrorBlurKernel: number;
  50586. /**
  50587. * Specifies the ground mirror visibility amount.
  50588. * 1 by default
  50589. */
  50590. groundMirrorAmount: number;
  50591. /**
  50592. * Specifies the ground mirror reflectance weight.
  50593. * This uses the standard weight of the background material to setup the fresnel effect
  50594. * of the mirror.
  50595. * 1 by default.
  50596. */
  50597. groundMirrorFresnelWeight: number;
  50598. /**
  50599. * Specifies the ground mirror Falloff distance.
  50600. * This can helps reducing the size of the reflection.
  50601. * 0 by Default.
  50602. */
  50603. groundMirrorFallOffDistance: number;
  50604. /**
  50605. * Specifies the ground mirror texture type.
  50606. * Unsigned Int by Default.
  50607. */
  50608. groundMirrorTextureType: number;
  50609. /**
  50610. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50611. * the shown objects.
  50612. */
  50613. groundYBias: number;
  50614. /**
  50615. * Specifies wether or not to create a skybox.
  50616. * True by default.
  50617. */
  50618. createSkybox: boolean;
  50619. /**
  50620. * Specifies the skybox size.
  50621. * 20 by default.
  50622. */
  50623. skyboxSize: number;
  50624. /**
  50625. * The texture used on the skybox for the main color.
  50626. * Comes from the BabylonJS CDN by default.
  50627. *
  50628. * Remarks: Can be either a texture or a url.
  50629. */
  50630. skyboxTexture: string | BaseTexture;
  50631. /**
  50632. * The color mixed in the skybox texture by default.
  50633. * BabylonJS clearColor by default.
  50634. */
  50635. skyboxColor: Color3;
  50636. /**
  50637. * The background rotation around the Y axis of the scene.
  50638. * This helps aligning the key lights of your scene with the background.
  50639. * 0 by default.
  50640. */
  50641. backgroundYRotation: number;
  50642. /**
  50643. * Compute automatically the size of the elements to best fit with the scene.
  50644. */
  50645. sizeAuto: boolean;
  50646. /**
  50647. * Default position of the rootMesh if autoSize is not true.
  50648. */
  50649. rootPosition: Vector3;
  50650. /**
  50651. * Sets up the image processing in the scene.
  50652. * true by default.
  50653. */
  50654. setupImageProcessing: boolean;
  50655. /**
  50656. * The texture used as your environment texture in the scene.
  50657. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50658. *
  50659. * Remarks: Can be either a texture or a url.
  50660. */
  50661. environmentTexture: string | BaseTexture;
  50662. /**
  50663. * The value of the exposure to apply to the scene.
  50664. * 0.6 by default if setupImageProcessing is true.
  50665. */
  50666. cameraExposure: number;
  50667. /**
  50668. * The value of the contrast to apply to the scene.
  50669. * 1.6 by default if setupImageProcessing is true.
  50670. */
  50671. cameraContrast: number;
  50672. /**
  50673. * Specifies wether or not tonemapping should be enabled in the scene.
  50674. * true by default if setupImageProcessing is true.
  50675. */
  50676. toneMappingEnabled: boolean;
  50677. }
  50678. /**
  50679. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50680. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50681. * It also helps with the default setup of your imageProcessing configuration.
  50682. */
  50683. export class EnvironmentHelper {
  50684. /**
  50685. * Default ground texture URL.
  50686. */
  50687. private static _groundTextureCDNUrl;
  50688. /**
  50689. * Default skybox texture URL.
  50690. */
  50691. private static _skyboxTextureCDNUrl;
  50692. /**
  50693. * Default environment texture URL.
  50694. */
  50695. private static _environmentTextureCDNUrl;
  50696. /**
  50697. * Creates the default options for the helper.
  50698. */
  50699. private static _getDefaultOptions;
  50700. private _rootMesh;
  50701. /**
  50702. * Gets the root mesh created by the helper.
  50703. */
  50704. get rootMesh(): Mesh;
  50705. private _skybox;
  50706. /**
  50707. * Gets the skybox created by the helper.
  50708. */
  50709. get skybox(): Nullable<Mesh>;
  50710. private _skyboxTexture;
  50711. /**
  50712. * Gets the skybox texture created by the helper.
  50713. */
  50714. get skyboxTexture(): Nullable<BaseTexture>;
  50715. private _skyboxMaterial;
  50716. /**
  50717. * Gets the skybox material created by the helper.
  50718. */
  50719. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50720. private _ground;
  50721. /**
  50722. * Gets the ground mesh created by the helper.
  50723. */
  50724. get ground(): Nullable<Mesh>;
  50725. private _groundTexture;
  50726. /**
  50727. * Gets the ground texture created by the helper.
  50728. */
  50729. get groundTexture(): Nullable<BaseTexture>;
  50730. private _groundMirror;
  50731. /**
  50732. * Gets the ground mirror created by the helper.
  50733. */
  50734. get groundMirror(): Nullable<MirrorTexture>;
  50735. /**
  50736. * Gets the ground mirror render list to helps pushing the meshes
  50737. * you wish in the ground reflection.
  50738. */
  50739. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50740. private _groundMaterial;
  50741. /**
  50742. * Gets the ground material created by the helper.
  50743. */
  50744. get groundMaterial(): Nullable<BackgroundMaterial>;
  50745. /**
  50746. * Stores the creation options.
  50747. */
  50748. private readonly _scene;
  50749. private _options;
  50750. /**
  50751. * This observable will be notified with any error during the creation of the environment,
  50752. * mainly texture creation errors.
  50753. */
  50754. onErrorObservable: Observable<{
  50755. message?: string;
  50756. exception?: any;
  50757. }>;
  50758. /**
  50759. * constructor
  50760. * @param options Defines the options we want to customize the helper
  50761. * @param scene The scene to add the material to
  50762. */
  50763. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50764. /**
  50765. * Updates the background according to the new options
  50766. * @param options
  50767. */
  50768. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50769. /**
  50770. * Sets the primary color of all the available elements.
  50771. * @param color the main color to affect to the ground and the background
  50772. */
  50773. setMainColor(color: Color3): void;
  50774. /**
  50775. * Setup the image processing according to the specified options.
  50776. */
  50777. private _setupImageProcessing;
  50778. /**
  50779. * Setup the environment texture according to the specified options.
  50780. */
  50781. private _setupEnvironmentTexture;
  50782. /**
  50783. * Setup the background according to the specified options.
  50784. */
  50785. private _setupBackground;
  50786. /**
  50787. * Get the scene sizes according to the setup.
  50788. */
  50789. private _getSceneSize;
  50790. /**
  50791. * Setup the ground according to the specified options.
  50792. */
  50793. private _setupGround;
  50794. /**
  50795. * Setup the ground material according to the specified options.
  50796. */
  50797. private _setupGroundMaterial;
  50798. /**
  50799. * Setup the ground diffuse texture according to the specified options.
  50800. */
  50801. private _setupGroundDiffuseTexture;
  50802. /**
  50803. * Setup the ground mirror texture according to the specified options.
  50804. */
  50805. private _setupGroundMirrorTexture;
  50806. /**
  50807. * Setup the ground to receive the mirror texture.
  50808. */
  50809. private _setupMirrorInGroundMaterial;
  50810. /**
  50811. * Setup the skybox according to the specified options.
  50812. */
  50813. private _setupSkybox;
  50814. /**
  50815. * Setup the skybox material according to the specified options.
  50816. */
  50817. private _setupSkyboxMaterial;
  50818. /**
  50819. * Setup the skybox reflection texture according to the specified options.
  50820. */
  50821. private _setupSkyboxReflectionTexture;
  50822. private _errorHandler;
  50823. /**
  50824. * Dispose all the elements created by the Helper.
  50825. */
  50826. dispose(): void;
  50827. }
  50828. }
  50829. declare module "babylonjs/Helpers/photoDome" {
  50830. import { Observable } from "babylonjs/Misc/observable";
  50831. import { Nullable } from "babylonjs/types";
  50832. import { Scene } from "babylonjs/scene";
  50833. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50834. import { Mesh } from "babylonjs/Meshes/mesh";
  50835. import { Texture } from "babylonjs/Materials/Textures/texture";
  50836. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50837. import "babylonjs/Meshes/Builders/sphereBuilder";
  50838. /**
  50839. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50840. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50841. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50842. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50843. */
  50844. export class PhotoDome extends TransformNode {
  50845. /**
  50846. * Define the image as a Monoscopic panoramic 360 image.
  50847. */
  50848. static readonly MODE_MONOSCOPIC: number;
  50849. /**
  50850. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50851. */
  50852. static readonly MODE_TOPBOTTOM: number;
  50853. /**
  50854. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50855. */
  50856. static readonly MODE_SIDEBYSIDE: number;
  50857. private _useDirectMapping;
  50858. /**
  50859. * The texture being displayed on the sphere
  50860. */
  50861. protected _photoTexture: Texture;
  50862. /**
  50863. * Gets or sets the texture being displayed on the sphere
  50864. */
  50865. get photoTexture(): Texture;
  50866. set photoTexture(value: Texture);
  50867. /**
  50868. * Observable raised when an error occured while loading the 360 image
  50869. */
  50870. onLoadErrorObservable: Observable<string>;
  50871. /**
  50872. * The skybox material
  50873. */
  50874. protected _material: BackgroundMaterial;
  50875. /**
  50876. * The surface used for the skybox
  50877. */
  50878. protected _mesh: Mesh;
  50879. /**
  50880. * Gets the mesh used for the skybox.
  50881. */
  50882. get mesh(): Mesh;
  50883. /**
  50884. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50885. * Also see the options.resolution property.
  50886. */
  50887. get fovMultiplier(): number;
  50888. set fovMultiplier(value: number);
  50889. private _imageMode;
  50890. /**
  50891. * Gets or set the current video mode for the video. It can be:
  50892. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50893. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50894. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50895. */
  50896. get imageMode(): number;
  50897. set imageMode(value: number);
  50898. /**
  50899. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50900. * @param name Element's name, child elements will append suffixes for their own names.
  50901. * @param urlsOfPhoto defines the url of the photo to display
  50902. * @param options defines an object containing optional or exposed sub element properties
  50903. * @param onError defines a callback called when an error occured while loading the texture
  50904. */
  50905. constructor(name: string, urlOfPhoto: string, options: {
  50906. resolution?: number;
  50907. size?: number;
  50908. useDirectMapping?: boolean;
  50909. faceForward?: boolean;
  50910. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50911. private _onBeforeCameraRenderObserver;
  50912. private _changeImageMode;
  50913. /**
  50914. * Releases resources associated with this node.
  50915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50917. */
  50918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50919. }
  50920. }
  50921. declare module "babylonjs/Misc/rgbdTextureTools" {
  50922. import "babylonjs/Shaders/rgbdDecode.fragment";
  50923. import "babylonjs/Engines/Extensions/engine.renderTarget";
  50924. import { Texture } from "babylonjs/Materials/Textures/texture";
  50925. /**
  50926. * Class used to host RGBD texture specific utilities
  50927. */
  50928. export class RGBDTextureTools {
  50929. /**
  50930. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50931. * @param texture the texture to expand.
  50932. */
  50933. static ExpandRGBDTexture(texture: Texture): void;
  50934. }
  50935. }
  50936. declare module "babylonjs/Misc/brdfTextureTools" {
  50937. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50938. import { Scene } from "babylonjs/scene";
  50939. /**
  50940. * Class used to host texture specific utilities
  50941. */
  50942. export class BRDFTextureTools {
  50943. /**
  50944. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50945. * @param scene defines the hosting scene
  50946. * @returns the environment BRDF texture
  50947. */
  50948. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50949. private static _environmentBRDFBase64Texture;
  50950. }
  50951. }
  50952. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  50953. import { Nullable } from "babylonjs/types";
  50954. import { Color3 } from "babylonjs/Maths/math.color";
  50955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50956. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50957. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50958. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50959. import { Engine } from "babylonjs/Engines/engine";
  50960. import { Scene } from "babylonjs/scene";
  50961. /**
  50962. * @hidden
  50963. */
  50964. export interface IMaterialClearCoatDefines {
  50965. CLEARCOAT: boolean;
  50966. CLEARCOAT_DEFAULTIOR: boolean;
  50967. CLEARCOAT_TEXTURE: boolean;
  50968. CLEARCOAT_TEXTUREDIRECTUV: number;
  50969. CLEARCOAT_BUMP: boolean;
  50970. CLEARCOAT_BUMPDIRECTUV: number;
  50971. CLEARCOAT_TINT: boolean;
  50972. CLEARCOAT_TINT_TEXTURE: boolean;
  50973. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50974. /** @hidden */
  50975. _areTexturesDirty: boolean;
  50976. }
  50977. /**
  50978. * Define the code related to the clear coat parameters of the pbr material.
  50979. */
  50980. export class PBRClearCoatConfiguration {
  50981. /**
  50982. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50983. * The default fits with a polyurethane material.
  50984. */
  50985. private static readonly _DefaultIndexOfRefraction;
  50986. private _isEnabled;
  50987. /**
  50988. * Defines if the clear coat is enabled in the material.
  50989. */
  50990. isEnabled: boolean;
  50991. /**
  50992. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50993. */
  50994. intensity: number;
  50995. /**
  50996. * Defines the clear coat layer roughness.
  50997. */
  50998. roughness: number;
  50999. private _indexOfRefraction;
  51000. /**
  51001. * Defines the index of refraction of the clear coat.
  51002. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51003. * The default fits with a polyurethane material.
  51004. * Changing the default value is more performance intensive.
  51005. */
  51006. indexOfRefraction: number;
  51007. private _texture;
  51008. /**
  51009. * Stores the clear coat values in a texture.
  51010. */
  51011. texture: Nullable<BaseTexture>;
  51012. private _bumpTexture;
  51013. /**
  51014. * Define the clear coat specific bump texture.
  51015. */
  51016. bumpTexture: Nullable<BaseTexture>;
  51017. private _isTintEnabled;
  51018. /**
  51019. * Defines if the clear coat tint is enabled in the material.
  51020. */
  51021. isTintEnabled: boolean;
  51022. /**
  51023. * Defines the clear coat tint of the material.
  51024. * This is only use if tint is enabled
  51025. */
  51026. tintColor: Color3;
  51027. /**
  51028. * Defines the distance at which the tint color should be found in the
  51029. * clear coat media.
  51030. * This is only use if tint is enabled
  51031. */
  51032. tintColorAtDistance: number;
  51033. /**
  51034. * Defines the clear coat layer thickness.
  51035. * This is only use if tint is enabled
  51036. */
  51037. tintThickness: number;
  51038. private _tintTexture;
  51039. /**
  51040. * Stores the clear tint values in a texture.
  51041. * rgb is tint
  51042. * a is a thickness factor
  51043. */
  51044. tintTexture: Nullable<BaseTexture>;
  51045. /** @hidden */
  51046. private _internalMarkAllSubMeshesAsTexturesDirty;
  51047. /** @hidden */
  51048. _markAllSubMeshesAsTexturesDirty(): void;
  51049. /**
  51050. * Instantiate a new istance of clear coat configuration.
  51051. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51052. */
  51053. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51054. /**
  51055. * Gets wehter the submesh is ready to be used or not.
  51056. * @param defines the list of "defines" to update.
  51057. * @param scene defines the scene the material belongs to.
  51058. * @param engine defines the engine the material belongs to.
  51059. * @param disableBumpMap defines wether the material disables bump or not.
  51060. * @returns - boolean indicating that the submesh is ready or not.
  51061. */
  51062. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  51063. /**
  51064. * Checks to see if a texture is used in the material.
  51065. * @param defines the list of "defines" to update.
  51066. * @param scene defines the scene to the material belongs to.
  51067. */
  51068. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  51069. /**
  51070. * Binds the material data.
  51071. * @param uniformBuffer defines the Uniform buffer to fill in.
  51072. * @param scene defines the scene the material belongs to.
  51073. * @param engine defines the engine the material belongs to.
  51074. * @param disableBumpMap defines wether the material disables bump or not.
  51075. * @param isFrozen defines wether the material is frozen or not.
  51076. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51077. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51078. */
  51079. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  51080. /**
  51081. * Checks to see if a texture is used in the material.
  51082. * @param texture - Base texture to use.
  51083. * @returns - Boolean specifying if a texture is used in the material.
  51084. */
  51085. hasTexture(texture: BaseTexture): boolean;
  51086. /**
  51087. * Returns an array of the actively used textures.
  51088. * @param activeTextures Array of BaseTextures
  51089. */
  51090. getActiveTextures(activeTextures: BaseTexture[]): void;
  51091. /**
  51092. * Returns the animatable textures.
  51093. * @param animatables Array of animatable textures.
  51094. */
  51095. getAnimatables(animatables: IAnimatable[]): void;
  51096. /**
  51097. * Disposes the resources of the material.
  51098. * @param forceDisposeTextures - Forces the disposal of all textures.
  51099. */
  51100. dispose(forceDisposeTextures?: boolean): void;
  51101. /**
  51102. * Get the current class name of the texture useful for serialization or dynamic coding.
  51103. * @returns "PBRClearCoatConfiguration"
  51104. */
  51105. getClassName(): string;
  51106. /**
  51107. * Add fallbacks to the effect fallbacks list.
  51108. * @param defines defines the Base texture to use.
  51109. * @param fallbacks defines the current fallback list.
  51110. * @param currentRank defines the current fallback rank.
  51111. * @returns the new fallback rank.
  51112. */
  51113. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51114. /**
  51115. * Add the required uniforms to the current list.
  51116. * @param uniforms defines the current uniform list.
  51117. */
  51118. static AddUniforms(uniforms: string[]): void;
  51119. /**
  51120. * Add the required samplers to the current list.
  51121. * @param samplers defines the current sampler list.
  51122. */
  51123. static AddSamplers(samplers: string[]): void;
  51124. /**
  51125. * Add the required uniforms to the current buffer.
  51126. * @param uniformBuffer defines the current uniform buffer.
  51127. */
  51128. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51129. /**
  51130. * Makes a duplicate of the current configuration into another one.
  51131. * @param clearCoatConfiguration define the config where to copy the info
  51132. */
  51133. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51134. /**
  51135. * Serializes this clear coat configuration.
  51136. * @returns - An object with the serialized config.
  51137. */
  51138. serialize(): any;
  51139. /**
  51140. * Parses a anisotropy Configuration from a serialized object.
  51141. * @param source - Serialized object.
  51142. * @param scene Defines the scene we are parsing for
  51143. * @param rootUrl Defines the rootUrl to load from
  51144. */
  51145. parse(source: any, scene: Scene, rootUrl: string): void;
  51146. }
  51147. }
  51148. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51149. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51151. import { Vector2 } from "babylonjs/Maths/math.vector";
  51152. import { Scene } from "babylonjs/scene";
  51153. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51154. import { Nullable } from "babylonjs/types";
  51155. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51156. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51157. /**
  51158. * @hidden
  51159. */
  51160. export interface IMaterialAnisotropicDefines {
  51161. ANISOTROPIC: boolean;
  51162. ANISOTROPIC_TEXTURE: boolean;
  51163. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51164. MAINUV1: boolean;
  51165. _areTexturesDirty: boolean;
  51166. _needUVs: boolean;
  51167. }
  51168. /**
  51169. * Define the code related to the anisotropic parameters of the pbr material.
  51170. */
  51171. export class PBRAnisotropicConfiguration {
  51172. private _isEnabled;
  51173. /**
  51174. * Defines if the anisotropy is enabled in the material.
  51175. */
  51176. isEnabled: boolean;
  51177. /**
  51178. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51179. */
  51180. intensity: number;
  51181. /**
  51182. * Defines if the effect is along the tangents, bitangents or in between.
  51183. * By default, the effect is "strectching" the highlights along the tangents.
  51184. */
  51185. direction: Vector2;
  51186. private _texture;
  51187. /**
  51188. * Stores the anisotropy values in a texture.
  51189. * rg is direction (like normal from -1 to 1)
  51190. * b is a intensity
  51191. */
  51192. texture: Nullable<BaseTexture>;
  51193. /** @hidden */
  51194. private _internalMarkAllSubMeshesAsTexturesDirty;
  51195. /** @hidden */
  51196. _markAllSubMeshesAsTexturesDirty(): void;
  51197. /**
  51198. * Instantiate a new istance of anisotropy configuration.
  51199. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51200. */
  51201. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51202. /**
  51203. * Specifies that the submesh is ready to be used.
  51204. * @param defines the list of "defines" to update.
  51205. * @param scene defines the scene the material belongs to.
  51206. * @returns - boolean indicating that the submesh is ready or not.
  51207. */
  51208. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  51209. /**
  51210. * Checks to see if a texture is used in the material.
  51211. * @param defines the list of "defines" to update.
  51212. * @param mesh the mesh we are preparing the defines for.
  51213. * @param scene defines the scene the material belongs to.
  51214. */
  51215. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  51216. /**
  51217. * Binds the material data.
  51218. * @param uniformBuffer defines the Uniform buffer to fill in.
  51219. * @param scene defines the scene the material belongs to.
  51220. * @param isFrozen defines wether the material is frozen or not.
  51221. */
  51222. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51223. /**
  51224. * Checks to see if a texture is used in the material.
  51225. * @param texture - Base texture to use.
  51226. * @returns - Boolean specifying if a texture is used in the material.
  51227. */
  51228. hasTexture(texture: BaseTexture): boolean;
  51229. /**
  51230. * Returns an array of the actively used textures.
  51231. * @param activeTextures Array of BaseTextures
  51232. */
  51233. getActiveTextures(activeTextures: BaseTexture[]): void;
  51234. /**
  51235. * Returns the animatable textures.
  51236. * @param animatables Array of animatable textures.
  51237. */
  51238. getAnimatables(animatables: IAnimatable[]): void;
  51239. /**
  51240. * Disposes the resources of the material.
  51241. * @param forceDisposeTextures - Forces the disposal of all textures.
  51242. */
  51243. dispose(forceDisposeTextures?: boolean): void;
  51244. /**
  51245. * Get the current class name of the texture useful for serialization or dynamic coding.
  51246. * @returns "PBRAnisotropicConfiguration"
  51247. */
  51248. getClassName(): string;
  51249. /**
  51250. * Add fallbacks to the effect fallbacks list.
  51251. * @param defines defines the Base texture to use.
  51252. * @param fallbacks defines the current fallback list.
  51253. * @param currentRank defines the current fallback rank.
  51254. * @returns the new fallback rank.
  51255. */
  51256. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51257. /**
  51258. * Add the required uniforms to the current list.
  51259. * @param uniforms defines the current uniform list.
  51260. */
  51261. static AddUniforms(uniforms: string[]): void;
  51262. /**
  51263. * Add the required uniforms to the current buffer.
  51264. * @param uniformBuffer defines the current uniform buffer.
  51265. */
  51266. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51267. /**
  51268. * Add the required samplers to the current list.
  51269. * @param samplers defines the current sampler list.
  51270. */
  51271. static AddSamplers(samplers: string[]): void;
  51272. /**
  51273. * Makes a duplicate of the current configuration into another one.
  51274. * @param anisotropicConfiguration define the config where to copy the info
  51275. */
  51276. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  51277. /**
  51278. * Serializes this anisotropy configuration.
  51279. * @returns - An object with the serialized config.
  51280. */
  51281. serialize(): any;
  51282. /**
  51283. * Parses a anisotropy Configuration from a serialized object.
  51284. * @param source - Serialized object.
  51285. * @param scene Defines the scene we are parsing for
  51286. * @param rootUrl Defines the rootUrl to load from
  51287. */
  51288. parse(source: any, scene: Scene, rootUrl: string): void;
  51289. }
  51290. }
  51291. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  51292. import { Scene } from "babylonjs/scene";
  51293. /**
  51294. * @hidden
  51295. */
  51296. export interface IMaterialBRDFDefines {
  51297. BRDF_V_HEIGHT_CORRELATED: boolean;
  51298. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51299. SPHERICAL_HARMONICS: boolean;
  51300. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51301. /** @hidden */
  51302. _areMiscDirty: boolean;
  51303. }
  51304. /**
  51305. * Define the code related to the BRDF parameters of the pbr material.
  51306. */
  51307. export class PBRBRDFConfiguration {
  51308. /**
  51309. * Default value used for the energy conservation.
  51310. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51311. */
  51312. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  51313. /**
  51314. * Default value used for the Smith Visibility Height Correlated mode.
  51315. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51316. */
  51317. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  51318. /**
  51319. * Default value used for the IBL diffuse part.
  51320. * This can help switching back to the polynomials mode globally which is a tiny bit
  51321. * less GPU intensive at the drawback of a lower quality.
  51322. */
  51323. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  51324. /**
  51325. * Default value used for activating energy conservation for the specular workflow.
  51326. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51327. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51328. */
  51329. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  51330. private _useEnergyConservation;
  51331. /**
  51332. * Defines if the material uses energy conservation.
  51333. */
  51334. useEnergyConservation: boolean;
  51335. private _useSmithVisibilityHeightCorrelated;
  51336. /**
  51337. * LEGACY Mode set to false
  51338. * Defines if the material uses height smith correlated visibility term.
  51339. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51340. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51341. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51342. * Not relying on height correlated will also disable energy conservation.
  51343. */
  51344. useSmithVisibilityHeightCorrelated: boolean;
  51345. private _useSphericalHarmonics;
  51346. /**
  51347. * LEGACY Mode set to false
  51348. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  51349. * diffuse part of the IBL.
  51350. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  51351. * to the ground truth.
  51352. */
  51353. useSphericalHarmonics: boolean;
  51354. private _useSpecularGlossinessInputEnergyConservation;
  51355. /**
  51356. * Defines if the material uses energy conservation, when the specular workflow is active.
  51357. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51358. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51359. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  51360. */
  51361. useSpecularGlossinessInputEnergyConservation: boolean;
  51362. /** @hidden */
  51363. private _internalMarkAllSubMeshesAsMiscDirty;
  51364. /** @hidden */
  51365. _markAllSubMeshesAsMiscDirty(): void;
  51366. /**
  51367. * Instantiate a new istance of clear coat configuration.
  51368. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51369. */
  51370. constructor(markAllSubMeshesAsMiscDirty: () => void);
  51371. /**
  51372. * Checks to see if a texture is used in the material.
  51373. * @param defines the list of "defines" to update.
  51374. */
  51375. prepareDefines(defines: IMaterialBRDFDefines): void;
  51376. /**
  51377. * Get the current class name of the texture useful for serialization or dynamic coding.
  51378. * @returns "PBRClearCoatConfiguration"
  51379. */
  51380. getClassName(): string;
  51381. /**
  51382. * Makes a duplicate of the current configuration into another one.
  51383. * @param brdfConfiguration define the config where to copy the info
  51384. */
  51385. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51386. /**
  51387. * Serializes this BRDF configuration.
  51388. * @returns - An object with the serialized config.
  51389. */
  51390. serialize(): any;
  51391. /**
  51392. * Parses a anisotropy Configuration from a serialized object.
  51393. * @param source - Serialized object.
  51394. * @param scene Defines the scene we are parsing for
  51395. * @param rootUrl Defines the rootUrl to load from
  51396. */
  51397. parse(source: any, scene: Scene, rootUrl: string): void;
  51398. }
  51399. }
  51400. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  51401. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51402. import { Color3 } from "babylonjs/Maths/math.color";
  51403. import { Scene } from "babylonjs/scene";
  51404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51405. import { Nullable } from "babylonjs/types";
  51406. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51407. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51408. /**
  51409. * @hidden
  51410. */
  51411. export interface IMaterialSheenDefines {
  51412. SHEEN: boolean;
  51413. SHEEN_TEXTURE: boolean;
  51414. SHEEN_TEXTUREDIRECTUV: number;
  51415. SHEEN_LINKWITHALBEDO: boolean;
  51416. /** @hidden */
  51417. _areTexturesDirty: boolean;
  51418. }
  51419. /**
  51420. * Define the code related to the Sheen parameters of the pbr material.
  51421. */
  51422. export class PBRSheenConfiguration {
  51423. private _isEnabled;
  51424. /**
  51425. * Defines if the material uses sheen.
  51426. */
  51427. isEnabled: boolean;
  51428. private _linkSheenWithAlbedo;
  51429. /**
  51430. * Defines if the sheen is linked to the sheen color.
  51431. */
  51432. linkSheenWithAlbedo: boolean;
  51433. /**
  51434. * Defines the sheen intensity.
  51435. */
  51436. intensity: number;
  51437. /**
  51438. * Defines the sheen color.
  51439. */
  51440. color: Color3;
  51441. private _texture;
  51442. /**
  51443. * Stores the sheen tint values in a texture.
  51444. * rgb is tint
  51445. * a is a intensity
  51446. */
  51447. texture: Nullable<BaseTexture>;
  51448. /** @hidden */
  51449. private _internalMarkAllSubMeshesAsTexturesDirty;
  51450. /** @hidden */
  51451. _markAllSubMeshesAsTexturesDirty(): void;
  51452. /**
  51453. * Instantiate a new istance of clear coat configuration.
  51454. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51455. */
  51456. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51457. /**
  51458. * Specifies that the submesh is ready to be used.
  51459. * @param defines the list of "defines" to update.
  51460. * @param scene defines the scene the material belongs to.
  51461. * @returns - boolean indicating that the submesh is ready or not.
  51462. */
  51463. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51464. /**
  51465. * Checks to see if a texture is used in the material.
  51466. * @param defines the list of "defines" to update.
  51467. * @param scene defines the scene the material belongs to.
  51468. */
  51469. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51470. /**
  51471. * Binds the material data.
  51472. * @param uniformBuffer defines the Uniform buffer to fill in.
  51473. * @param scene defines the scene the material belongs to.
  51474. * @param isFrozen defines wether the material is frozen or not.
  51475. */
  51476. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51477. /**
  51478. * Checks to see if a texture is used in the material.
  51479. * @param texture - Base texture to use.
  51480. * @returns - Boolean specifying if a texture is used in the material.
  51481. */
  51482. hasTexture(texture: BaseTexture): boolean;
  51483. /**
  51484. * Returns an array of the actively used textures.
  51485. * @param activeTextures Array of BaseTextures
  51486. */
  51487. getActiveTextures(activeTextures: BaseTexture[]): void;
  51488. /**
  51489. * Returns the animatable textures.
  51490. * @param animatables Array of animatable textures.
  51491. */
  51492. getAnimatables(animatables: IAnimatable[]): void;
  51493. /**
  51494. * Disposes the resources of the material.
  51495. * @param forceDisposeTextures - Forces the disposal of all textures.
  51496. */
  51497. dispose(forceDisposeTextures?: boolean): void;
  51498. /**
  51499. * Get the current class name of the texture useful for serialization or dynamic coding.
  51500. * @returns "PBRSheenConfiguration"
  51501. */
  51502. getClassName(): string;
  51503. /**
  51504. * Add fallbacks to the effect fallbacks list.
  51505. * @param defines defines the Base texture to use.
  51506. * @param fallbacks defines the current fallback list.
  51507. * @param currentRank defines the current fallback rank.
  51508. * @returns the new fallback rank.
  51509. */
  51510. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51511. /**
  51512. * Add the required uniforms to the current list.
  51513. * @param uniforms defines the current uniform list.
  51514. */
  51515. static AddUniforms(uniforms: string[]): void;
  51516. /**
  51517. * Add the required uniforms to the current buffer.
  51518. * @param uniformBuffer defines the current uniform buffer.
  51519. */
  51520. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51521. /**
  51522. * Add the required samplers to the current list.
  51523. * @param samplers defines the current sampler list.
  51524. */
  51525. static AddSamplers(samplers: string[]): void;
  51526. /**
  51527. * Makes a duplicate of the current configuration into another one.
  51528. * @param sheenConfiguration define the config where to copy the info
  51529. */
  51530. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51531. /**
  51532. * Serializes this BRDF configuration.
  51533. * @returns - An object with the serialized config.
  51534. */
  51535. serialize(): any;
  51536. /**
  51537. * Parses a anisotropy Configuration from a serialized object.
  51538. * @param source - Serialized object.
  51539. * @param scene Defines the scene we are parsing for
  51540. * @param rootUrl Defines the rootUrl to load from
  51541. */
  51542. parse(source: any, scene: Scene, rootUrl: string): void;
  51543. }
  51544. }
  51545. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  51546. import { Nullable } from "babylonjs/types";
  51547. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51548. import { Color3 } from "babylonjs/Maths/math.color";
  51549. import { SmartArray } from "babylonjs/Misc/smartArray";
  51550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51551. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51552. import { Effect } from "babylonjs/Materials/effect";
  51553. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51554. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51555. import { Engine } from "babylonjs/Engines/engine";
  51556. import { Scene } from "babylonjs/scene";
  51557. /**
  51558. * @hidden
  51559. */
  51560. export interface IMaterialSubSurfaceDefines {
  51561. SUBSURFACE: boolean;
  51562. SS_REFRACTION: boolean;
  51563. SS_TRANSLUCENCY: boolean;
  51564. SS_SCATERRING: boolean;
  51565. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51566. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51567. SS_REFRACTIONMAP_3D: boolean;
  51568. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51569. SS_LODINREFRACTIONALPHA: boolean;
  51570. SS_GAMMAREFRACTION: boolean;
  51571. SS_RGBDREFRACTION: boolean;
  51572. SS_LINEARSPECULARREFRACTION: boolean;
  51573. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51574. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51575. /** @hidden */
  51576. _areTexturesDirty: boolean;
  51577. }
  51578. /**
  51579. * Define the code related to the sub surface parameters of the pbr material.
  51580. */
  51581. export class PBRSubSurfaceConfiguration {
  51582. private _isRefractionEnabled;
  51583. /**
  51584. * Defines if the refraction is enabled in the material.
  51585. */
  51586. isRefractionEnabled: boolean;
  51587. private _isTranslucencyEnabled;
  51588. /**
  51589. * Defines if the translucency is enabled in the material.
  51590. */
  51591. isTranslucencyEnabled: boolean;
  51592. private _isScatteringEnabled;
  51593. /**
  51594. * Defines the refraction intensity of the material.
  51595. * The refraction when enabled replaces the Diffuse part of the material.
  51596. * The intensity helps transitionning between diffuse and refraction.
  51597. */
  51598. refractionIntensity: number;
  51599. /**
  51600. * Defines the translucency intensity of the material.
  51601. * When translucency has been enabled, this defines how much of the "translucency"
  51602. * is addded to the diffuse part of the material.
  51603. */
  51604. translucencyIntensity: number;
  51605. /**
  51606. * Defines the scattering intensity of the material.
  51607. * When scattering has been enabled, this defines how much of the "scattered light"
  51608. * is addded to the diffuse part of the material.
  51609. */
  51610. scatteringIntensity: number;
  51611. private _thicknessTexture;
  51612. /**
  51613. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51614. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51615. * 0 would mean minimumThickness
  51616. * 1 would mean maximumThickness
  51617. * The other channels might be use as a mask to vary the different effects intensity.
  51618. */
  51619. thicknessTexture: Nullable<BaseTexture>;
  51620. private _refractionTexture;
  51621. /**
  51622. * Defines the texture to use for refraction.
  51623. */
  51624. refractionTexture: Nullable<BaseTexture>;
  51625. private _indexOfRefraction;
  51626. /**
  51627. * Defines the index of refraction used in the material.
  51628. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51629. */
  51630. indexOfRefraction: number;
  51631. private _invertRefractionY;
  51632. /**
  51633. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51634. */
  51635. invertRefractionY: boolean;
  51636. private _linkRefractionWithTransparency;
  51637. /**
  51638. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51639. * Materials half opaque for instance using refraction could benefit from this control.
  51640. */
  51641. linkRefractionWithTransparency: boolean;
  51642. /**
  51643. * Defines the minimum thickness stored in the thickness map.
  51644. * If no thickness map is defined, this value will be used to simulate thickness.
  51645. */
  51646. minimumThickness: number;
  51647. /**
  51648. * Defines the maximum thickness stored in the thickness map.
  51649. */
  51650. maximumThickness: number;
  51651. /**
  51652. * Defines the volume tint of the material.
  51653. * This is used for both translucency and scattering.
  51654. */
  51655. tintColor: Color3;
  51656. /**
  51657. * Defines the distance at which the tint color should be found in the media.
  51658. * This is used for refraction only.
  51659. */
  51660. tintColorAtDistance: number;
  51661. /**
  51662. * Defines how far each channel transmit through the media.
  51663. * It is defined as a color to simplify it selection.
  51664. */
  51665. diffusionDistance: Color3;
  51666. private _useMaskFromThicknessTexture;
  51667. /**
  51668. * Stores the intensity of the different subsurface effects in the thickness texture.
  51669. * * the green channel is the translucency intensity.
  51670. * * the blue channel is the scattering intensity.
  51671. * * the alpha channel is the refraction intensity.
  51672. */
  51673. useMaskFromThicknessTexture: boolean;
  51674. /** @hidden */
  51675. private _internalMarkAllSubMeshesAsTexturesDirty;
  51676. /** @hidden */
  51677. _markAllSubMeshesAsTexturesDirty(): void;
  51678. /**
  51679. * Instantiate a new istance of sub surface configuration.
  51680. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51681. */
  51682. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51683. /**
  51684. * Gets wehter the submesh is ready to be used or not.
  51685. * @param defines the list of "defines" to update.
  51686. * @param scene defines the scene the material belongs to.
  51687. * @returns - boolean indicating that the submesh is ready or not.
  51688. */
  51689. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51690. /**
  51691. * Checks to see if a texture is used in the material.
  51692. * @param defines the list of "defines" to update.
  51693. * @param scene defines the scene to the material belongs to.
  51694. */
  51695. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51696. /**
  51697. * Binds the material data.
  51698. * @param uniformBuffer defines the Uniform buffer to fill in.
  51699. * @param scene defines the scene the material belongs to.
  51700. * @param engine defines the engine the material belongs to.
  51701. * @param isFrozen defines wether the material is frozen or not.
  51702. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51703. */
  51704. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51705. /**
  51706. * Unbinds the material from the mesh.
  51707. * @param activeEffect defines the effect that should be unbound from.
  51708. * @returns true if unbound, otherwise false
  51709. */
  51710. unbind(activeEffect: Effect): boolean;
  51711. /**
  51712. * Returns the texture used for refraction or null if none is used.
  51713. * @param scene defines the scene the material belongs to.
  51714. * @returns - Refraction texture if present. If no refraction texture and refraction
  51715. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51716. */
  51717. private _getRefractionTexture;
  51718. /**
  51719. * Returns true if alpha blending should be disabled.
  51720. */
  51721. get disableAlphaBlending(): boolean;
  51722. /**
  51723. * Fills the list of render target textures.
  51724. * @param renderTargets the list of render targets to update
  51725. */
  51726. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51727. /**
  51728. * Checks to see if a texture is used in the material.
  51729. * @param texture - Base texture to use.
  51730. * @returns - Boolean specifying if a texture is used in the material.
  51731. */
  51732. hasTexture(texture: BaseTexture): boolean;
  51733. /**
  51734. * Gets a boolean indicating that current material needs to register RTT
  51735. * @returns true if this uses a render target otherwise false.
  51736. */
  51737. hasRenderTargetTextures(): boolean;
  51738. /**
  51739. * Returns an array of the actively used textures.
  51740. * @param activeTextures Array of BaseTextures
  51741. */
  51742. getActiveTextures(activeTextures: BaseTexture[]): void;
  51743. /**
  51744. * Returns the animatable textures.
  51745. * @param animatables Array of animatable textures.
  51746. */
  51747. getAnimatables(animatables: IAnimatable[]): void;
  51748. /**
  51749. * Disposes the resources of the material.
  51750. * @param forceDisposeTextures - Forces the disposal of all textures.
  51751. */
  51752. dispose(forceDisposeTextures?: boolean): void;
  51753. /**
  51754. * Get the current class name of the texture useful for serialization or dynamic coding.
  51755. * @returns "PBRSubSurfaceConfiguration"
  51756. */
  51757. getClassName(): string;
  51758. /**
  51759. * Add fallbacks to the effect fallbacks list.
  51760. * @param defines defines the Base texture to use.
  51761. * @param fallbacks defines the current fallback list.
  51762. * @param currentRank defines the current fallback rank.
  51763. * @returns the new fallback rank.
  51764. */
  51765. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51766. /**
  51767. * Add the required uniforms to the current list.
  51768. * @param uniforms defines the current uniform list.
  51769. */
  51770. static AddUniforms(uniforms: string[]): void;
  51771. /**
  51772. * Add the required samplers to the current list.
  51773. * @param samplers defines the current sampler list.
  51774. */
  51775. static AddSamplers(samplers: string[]): void;
  51776. /**
  51777. * Add the required uniforms to the current buffer.
  51778. * @param uniformBuffer defines the current uniform buffer.
  51779. */
  51780. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51781. /**
  51782. * Makes a duplicate of the current configuration into another one.
  51783. * @param configuration define the config where to copy the info
  51784. */
  51785. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51786. /**
  51787. * Serializes this Sub Surface configuration.
  51788. * @returns - An object with the serialized config.
  51789. */
  51790. serialize(): any;
  51791. /**
  51792. * Parses a anisotropy Configuration from a serialized object.
  51793. * @param source - Serialized object.
  51794. * @param scene Defines the scene we are parsing for
  51795. * @param rootUrl Defines the rootUrl to load from
  51796. */
  51797. parse(source: any, scene: Scene, rootUrl: string): void;
  51798. }
  51799. }
  51800. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  51801. /** @hidden */
  51802. export var pbrFragmentDeclaration: {
  51803. name: string;
  51804. shader: string;
  51805. };
  51806. }
  51807. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  51808. /** @hidden */
  51809. export var pbrUboDeclaration: {
  51810. name: string;
  51811. shader: string;
  51812. };
  51813. }
  51814. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  51815. /** @hidden */
  51816. export var pbrFragmentExtraDeclaration: {
  51817. name: string;
  51818. shader: string;
  51819. };
  51820. }
  51821. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  51822. /** @hidden */
  51823. export var pbrFragmentSamplersDeclaration: {
  51824. name: string;
  51825. shader: string;
  51826. };
  51827. }
  51828. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  51829. /** @hidden */
  51830. export var pbrHelperFunctions: {
  51831. name: string;
  51832. shader: string;
  51833. };
  51834. }
  51835. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  51836. /** @hidden */
  51837. export var harmonicsFunctions: {
  51838. name: string;
  51839. shader: string;
  51840. };
  51841. }
  51842. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  51843. /** @hidden */
  51844. export var pbrDirectLightingSetupFunctions: {
  51845. name: string;
  51846. shader: string;
  51847. };
  51848. }
  51849. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  51850. /** @hidden */
  51851. export var pbrDirectLightingFalloffFunctions: {
  51852. name: string;
  51853. shader: string;
  51854. };
  51855. }
  51856. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  51857. /** @hidden */
  51858. export var pbrBRDFFunctions: {
  51859. name: string;
  51860. shader: string;
  51861. };
  51862. }
  51863. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  51864. /** @hidden */
  51865. export var pbrDirectLightingFunctions: {
  51866. name: string;
  51867. shader: string;
  51868. };
  51869. }
  51870. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  51871. /** @hidden */
  51872. export var pbrIBLFunctions: {
  51873. name: string;
  51874. shader: string;
  51875. };
  51876. }
  51877. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  51878. /** @hidden */
  51879. export var pbrDebug: {
  51880. name: string;
  51881. shader: string;
  51882. };
  51883. }
  51884. declare module "babylonjs/Shaders/pbr.fragment" {
  51885. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  51886. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51887. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  51888. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51889. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51890. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  51891. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51892. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51893. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51894. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51895. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51896. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  51897. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51898. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51899. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51900. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  51901. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  51902. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  51903. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  51904. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  51905. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  51906. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51907. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51908. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  51909. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  51910. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51911. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  51912. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51913. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  51914. /** @hidden */
  51915. export var pbrPixelShader: {
  51916. name: string;
  51917. shader: string;
  51918. };
  51919. }
  51920. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  51921. /** @hidden */
  51922. export var pbrVertexDeclaration: {
  51923. name: string;
  51924. shader: string;
  51925. };
  51926. }
  51927. declare module "babylonjs/Shaders/pbr.vertex" {
  51928. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  51929. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51930. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51931. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51932. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51933. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51934. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  51935. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51936. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51937. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51938. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51939. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51940. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51941. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51943. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51944. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51945. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  51946. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51947. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51948. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51949. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  51950. /** @hidden */
  51951. export var pbrVertexShader: {
  51952. name: string;
  51953. shader: string;
  51954. };
  51955. }
  51956. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  51957. import { Nullable } from "babylonjs/types";
  51958. import { Scene } from "babylonjs/scene";
  51959. import { Matrix } from "babylonjs/Maths/math.vector";
  51960. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51962. import { Mesh } from "babylonjs/Meshes/mesh";
  51963. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  51964. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  51965. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  51966. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  51967. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  51968. import { Color3 } from "babylonjs/Maths/math.color";
  51969. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  51970. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  51971. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  51972. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51973. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51974. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51975. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  51976. import "babylonjs/Shaders/pbr.fragment";
  51977. import "babylonjs/Shaders/pbr.vertex";
  51978. /**
  51979. * Manages the defines for the PBR Material.
  51980. * @hidden
  51981. */
  51982. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51983. PBR: boolean;
  51984. MAINUV1: boolean;
  51985. MAINUV2: boolean;
  51986. UV1: boolean;
  51987. UV2: boolean;
  51988. ALBEDO: boolean;
  51989. ALBEDODIRECTUV: number;
  51990. VERTEXCOLOR: boolean;
  51991. AMBIENT: boolean;
  51992. AMBIENTDIRECTUV: number;
  51993. AMBIENTINGRAYSCALE: boolean;
  51994. OPACITY: boolean;
  51995. VERTEXALPHA: boolean;
  51996. OPACITYDIRECTUV: number;
  51997. OPACITYRGB: boolean;
  51998. ALPHATEST: boolean;
  51999. DEPTHPREPASS: boolean;
  52000. ALPHABLEND: boolean;
  52001. ALPHAFROMALBEDO: boolean;
  52002. ALPHATESTVALUE: string;
  52003. SPECULAROVERALPHA: boolean;
  52004. RADIANCEOVERALPHA: boolean;
  52005. ALPHAFRESNEL: boolean;
  52006. LINEARALPHAFRESNEL: boolean;
  52007. PREMULTIPLYALPHA: boolean;
  52008. EMISSIVE: boolean;
  52009. EMISSIVEDIRECTUV: number;
  52010. REFLECTIVITY: boolean;
  52011. REFLECTIVITYDIRECTUV: number;
  52012. SPECULARTERM: boolean;
  52013. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52014. MICROSURFACEAUTOMATIC: boolean;
  52015. LODBASEDMICROSFURACE: boolean;
  52016. MICROSURFACEMAP: boolean;
  52017. MICROSURFACEMAPDIRECTUV: number;
  52018. METALLICWORKFLOW: boolean;
  52019. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52020. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52021. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52022. AOSTOREINMETALMAPRED: boolean;
  52023. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52024. ENVIRONMENTBRDF: boolean;
  52025. ENVIRONMENTBRDF_RGBD: boolean;
  52026. NORMAL: boolean;
  52027. TANGENT: boolean;
  52028. BUMP: boolean;
  52029. BUMPDIRECTUV: number;
  52030. OBJECTSPACE_NORMALMAP: boolean;
  52031. PARALLAX: boolean;
  52032. PARALLAXOCCLUSION: boolean;
  52033. NORMALXYSCALE: boolean;
  52034. LIGHTMAP: boolean;
  52035. LIGHTMAPDIRECTUV: number;
  52036. USELIGHTMAPASSHADOWMAP: boolean;
  52037. GAMMALIGHTMAP: boolean;
  52038. RGBDLIGHTMAP: boolean;
  52039. REFLECTION: boolean;
  52040. REFLECTIONMAP_3D: boolean;
  52041. REFLECTIONMAP_SPHERICAL: boolean;
  52042. REFLECTIONMAP_PLANAR: boolean;
  52043. REFLECTIONMAP_CUBIC: boolean;
  52044. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  52045. REFLECTIONMAP_PROJECTION: boolean;
  52046. REFLECTIONMAP_SKYBOX: boolean;
  52047. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  52048. REFLECTIONMAP_EXPLICIT: boolean;
  52049. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  52050. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  52051. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  52052. INVERTCUBICMAP: boolean;
  52053. USESPHERICALFROMREFLECTIONMAP: boolean;
  52054. USEIRRADIANCEMAP: boolean;
  52055. SPHERICAL_HARMONICS: boolean;
  52056. USESPHERICALINVERTEX: boolean;
  52057. REFLECTIONMAP_OPPOSITEZ: boolean;
  52058. LODINREFLECTIONALPHA: boolean;
  52059. GAMMAREFLECTION: boolean;
  52060. RGBDREFLECTION: boolean;
  52061. LINEARSPECULARREFLECTION: boolean;
  52062. RADIANCEOCCLUSION: boolean;
  52063. HORIZONOCCLUSION: boolean;
  52064. INSTANCES: boolean;
  52065. NUM_BONE_INFLUENCERS: number;
  52066. BonesPerMesh: number;
  52067. BONETEXTURE: boolean;
  52068. NONUNIFORMSCALING: boolean;
  52069. MORPHTARGETS: boolean;
  52070. MORPHTARGETS_NORMAL: boolean;
  52071. MORPHTARGETS_TANGENT: boolean;
  52072. MORPHTARGETS_UV: boolean;
  52073. NUM_MORPH_INFLUENCERS: number;
  52074. IMAGEPROCESSING: boolean;
  52075. VIGNETTE: boolean;
  52076. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52077. VIGNETTEBLENDMODEOPAQUE: boolean;
  52078. TONEMAPPING: boolean;
  52079. TONEMAPPING_ACES: boolean;
  52080. CONTRAST: boolean;
  52081. COLORCURVES: boolean;
  52082. COLORGRADING: boolean;
  52083. COLORGRADING3D: boolean;
  52084. SAMPLER3DGREENDEPTH: boolean;
  52085. SAMPLER3DBGRMAP: boolean;
  52086. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52087. EXPOSURE: boolean;
  52088. MULTIVIEW: boolean;
  52089. USEPHYSICALLIGHTFALLOFF: boolean;
  52090. USEGLTFLIGHTFALLOFF: boolean;
  52091. TWOSIDEDLIGHTING: boolean;
  52092. SHADOWFLOAT: boolean;
  52093. CLIPPLANE: boolean;
  52094. CLIPPLANE2: boolean;
  52095. CLIPPLANE3: boolean;
  52096. CLIPPLANE4: boolean;
  52097. CLIPPLANE5: boolean;
  52098. CLIPPLANE6: boolean;
  52099. POINTSIZE: boolean;
  52100. FOG: boolean;
  52101. LOGARITHMICDEPTH: boolean;
  52102. FORCENORMALFORWARD: boolean;
  52103. SPECULARAA: boolean;
  52104. CLEARCOAT: boolean;
  52105. CLEARCOAT_DEFAULTIOR: boolean;
  52106. CLEARCOAT_TEXTURE: boolean;
  52107. CLEARCOAT_TEXTUREDIRECTUV: number;
  52108. CLEARCOAT_BUMP: boolean;
  52109. CLEARCOAT_BUMPDIRECTUV: number;
  52110. CLEARCOAT_TINT: boolean;
  52111. CLEARCOAT_TINT_TEXTURE: boolean;
  52112. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52113. ANISOTROPIC: boolean;
  52114. ANISOTROPIC_TEXTURE: boolean;
  52115. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52116. BRDF_V_HEIGHT_CORRELATED: boolean;
  52117. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52118. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52119. SHEEN: boolean;
  52120. SHEEN_TEXTURE: boolean;
  52121. SHEEN_TEXTUREDIRECTUV: number;
  52122. SHEEN_LINKWITHALBEDO: boolean;
  52123. SUBSURFACE: boolean;
  52124. SS_REFRACTION: boolean;
  52125. SS_TRANSLUCENCY: boolean;
  52126. SS_SCATERRING: boolean;
  52127. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52128. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52129. SS_REFRACTIONMAP_3D: boolean;
  52130. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52131. SS_LODINREFRACTIONALPHA: boolean;
  52132. SS_GAMMAREFRACTION: boolean;
  52133. SS_RGBDREFRACTION: boolean;
  52134. SS_LINEARSPECULARREFRACTION: boolean;
  52135. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52136. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52137. UNLIT: boolean;
  52138. DEBUGMODE: number;
  52139. /**
  52140. * Initializes the PBR Material defines.
  52141. */
  52142. constructor();
  52143. /**
  52144. * Resets the PBR Material defines.
  52145. */
  52146. reset(): void;
  52147. }
  52148. /**
  52149. * The Physically based material base class of BJS.
  52150. *
  52151. * This offers the main features of a standard PBR material.
  52152. * For more information, please refer to the documentation :
  52153. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52154. */
  52155. export abstract class PBRBaseMaterial extends PushMaterial {
  52156. /**
  52157. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52158. */
  52159. static readonly PBRMATERIAL_OPAQUE: number;
  52160. /**
  52161. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52162. */
  52163. static readonly PBRMATERIAL_ALPHATEST: number;
  52164. /**
  52165. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52166. */
  52167. static readonly PBRMATERIAL_ALPHABLEND: number;
  52168. /**
  52169. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52170. * They are also discarded below the alpha cutoff threshold to improve performances.
  52171. */
  52172. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52173. /**
  52174. * Defines the default value of how much AO map is occluding the analytical lights
  52175. * (point spot...).
  52176. */
  52177. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52178. /**
  52179. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52180. */
  52181. static readonly LIGHTFALLOFF_PHYSICAL: number;
  52182. /**
  52183. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52184. * to enhance interoperability with other engines.
  52185. */
  52186. static readonly LIGHTFALLOFF_GLTF: number;
  52187. /**
  52188. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52189. * to enhance interoperability with other materials.
  52190. */
  52191. static readonly LIGHTFALLOFF_STANDARD: number;
  52192. /**
  52193. * Intensity of the direct lights e.g. the four lights available in your scene.
  52194. * This impacts both the direct diffuse and specular highlights.
  52195. */
  52196. protected _directIntensity: number;
  52197. /**
  52198. * Intensity of the emissive part of the material.
  52199. * This helps controlling the emissive effect without modifying the emissive color.
  52200. */
  52201. protected _emissiveIntensity: number;
  52202. /**
  52203. * Intensity of the environment e.g. how much the environment will light the object
  52204. * either through harmonics for rough material or through the refelction for shiny ones.
  52205. */
  52206. protected _environmentIntensity: number;
  52207. /**
  52208. * This is a special control allowing the reduction of the specular highlights coming from the
  52209. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52210. */
  52211. protected _specularIntensity: number;
  52212. /**
  52213. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52214. */
  52215. private _lightingInfos;
  52216. /**
  52217. * Debug Control allowing disabling the bump map on this material.
  52218. */
  52219. protected _disableBumpMap: boolean;
  52220. /**
  52221. * AKA Diffuse Texture in standard nomenclature.
  52222. */
  52223. protected _albedoTexture: Nullable<BaseTexture>;
  52224. /**
  52225. * AKA Occlusion Texture in other nomenclature.
  52226. */
  52227. protected _ambientTexture: Nullable<BaseTexture>;
  52228. /**
  52229. * AKA Occlusion Texture Intensity in other nomenclature.
  52230. */
  52231. protected _ambientTextureStrength: number;
  52232. /**
  52233. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52234. * 1 means it completely occludes it
  52235. * 0 mean it has no impact
  52236. */
  52237. protected _ambientTextureImpactOnAnalyticalLights: number;
  52238. /**
  52239. * Stores the alpha values in a texture.
  52240. */
  52241. protected _opacityTexture: Nullable<BaseTexture>;
  52242. /**
  52243. * Stores the reflection values in a texture.
  52244. */
  52245. protected _reflectionTexture: Nullable<BaseTexture>;
  52246. /**
  52247. * Stores the emissive values in a texture.
  52248. */
  52249. protected _emissiveTexture: Nullable<BaseTexture>;
  52250. /**
  52251. * AKA Specular texture in other nomenclature.
  52252. */
  52253. protected _reflectivityTexture: Nullable<BaseTexture>;
  52254. /**
  52255. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52256. */
  52257. protected _metallicTexture: Nullable<BaseTexture>;
  52258. /**
  52259. * Specifies the metallic scalar of the metallic/roughness workflow.
  52260. * Can also be used to scale the metalness values of the metallic texture.
  52261. */
  52262. protected _metallic: Nullable<number>;
  52263. /**
  52264. * Specifies the roughness scalar of the metallic/roughness workflow.
  52265. * Can also be used to scale the roughness values of the metallic texture.
  52266. */
  52267. protected _roughness: Nullable<number>;
  52268. /**
  52269. * Specifies the an F0 factor to help configuring the material F0.
  52270. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52271. * to 0.5 the previously hard coded value stays the same.
  52272. * Can also be used to scale the F0 values of the metallic texture.
  52273. */
  52274. protected _metallicF0Factor: number;
  52275. /**
  52276. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52277. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52278. * your expectation as it multiplies with the texture data.
  52279. */
  52280. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52281. /**
  52282. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52283. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52284. */
  52285. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52286. /**
  52287. * Stores surface normal data used to displace a mesh in a texture.
  52288. */
  52289. protected _bumpTexture: Nullable<BaseTexture>;
  52290. /**
  52291. * Stores the pre-calculated light information of a mesh in a texture.
  52292. */
  52293. protected _lightmapTexture: Nullable<BaseTexture>;
  52294. /**
  52295. * The color of a material in ambient lighting.
  52296. */
  52297. protected _ambientColor: Color3;
  52298. /**
  52299. * AKA Diffuse Color in other nomenclature.
  52300. */
  52301. protected _albedoColor: Color3;
  52302. /**
  52303. * AKA Specular Color in other nomenclature.
  52304. */
  52305. protected _reflectivityColor: Color3;
  52306. /**
  52307. * The color applied when light is reflected from a material.
  52308. */
  52309. protected _reflectionColor: Color3;
  52310. /**
  52311. * The color applied when light is emitted from a material.
  52312. */
  52313. protected _emissiveColor: Color3;
  52314. /**
  52315. * AKA Glossiness in other nomenclature.
  52316. */
  52317. protected _microSurface: number;
  52318. /**
  52319. * Specifies that the material will use the light map as a show map.
  52320. */
  52321. protected _useLightmapAsShadowmap: boolean;
  52322. /**
  52323. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52324. * makes the reflect vector face the model (under horizon).
  52325. */
  52326. protected _useHorizonOcclusion: boolean;
  52327. /**
  52328. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52329. * too much the area relying on ambient texture to define their ambient occlusion.
  52330. */
  52331. protected _useRadianceOcclusion: boolean;
  52332. /**
  52333. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52334. */
  52335. protected _useAlphaFromAlbedoTexture: boolean;
  52336. /**
  52337. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52338. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52339. */
  52340. protected _useSpecularOverAlpha: boolean;
  52341. /**
  52342. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52343. */
  52344. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52345. /**
  52346. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52347. */
  52348. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52349. /**
  52350. * Specifies if the metallic texture contains the roughness information in its green channel.
  52351. */
  52352. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52353. /**
  52354. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52355. */
  52356. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52357. /**
  52358. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52359. */
  52360. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52361. /**
  52362. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52363. */
  52364. protected _useAmbientInGrayScale: boolean;
  52365. /**
  52366. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52367. * The material will try to infer what glossiness each pixel should be.
  52368. */
  52369. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52370. /**
  52371. * Defines the falloff type used in this material.
  52372. * It by default is Physical.
  52373. */
  52374. protected _lightFalloff: number;
  52375. /**
  52376. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52377. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52378. */
  52379. protected _useRadianceOverAlpha: boolean;
  52380. /**
  52381. * Allows using an object space normal map (instead of tangent space).
  52382. */
  52383. protected _useObjectSpaceNormalMap: boolean;
  52384. /**
  52385. * Allows using the bump map in parallax mode.
  52386. */
  52387. protected _useParallax: boolean;
  52388. /**
  52389. * Allows using the bump map in parallax occlusion mode.
  52390. */
  52391. protected _useParallaxOcclusion: boolean;
  52392. /**
  52393. * Controls the scale bias of the parallax mode.
  52394. */
  52395. protected _parallaxScaleBias: number;
  52396. /**
  52397. * If sets to true, disables all the lights affecting the material.
  52398. */
  52399. protected _disableLighting: boolean;
  52400. /**
  52401. * Number of Simultaneous lights allowed on the material.
  52402. */
  52403. protected _maxSimultaneousLights: number;
  52404. /**
  52405. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52406. */
  52407. protected _invertNormalMapX: boolean;
  52408. /**
  52409. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52410. */
  52411. protected _invertNormalMapY: boolean;
  52412. /**
  52413. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52414. */
  52415. protected _twoSidedLighting: boolean;
  52416. /**
  52417. * Defines the alpha limits in alpha test mode.
  52418. */
  52419. protected _alphaCutOff: number;
  52420. /**
  52421. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52422. */
  52423. protected _forceAlphaTest: boolean;
  52424. /**
  52425. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52426. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52427. */
  52428. protected _useAlphaFresnel: boolean;
  52429. /**
  52430. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52431. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52432. */
  52433. protected _useLinearAlphaFresnel: boolean;
  52434. /**
  52435. * The transparency mode of the material.
  52436. */
  52437. protected _transparencyMode: Nullable<number>;
  52438. /**
  52439. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52440. * from cos thetav and roughness:
  52441. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52442. */
  52443. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52444. /**
  52445. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52446. */
  52447. protected _forceIrradianceInFragment: boolean;
  52448. /**
  52449. * Force normal to face away from face.
  52450. */
  52451. protected _forceNormalForward: boolean;
  52452. /**
  52453. * Enables specular anti aliasing in the PBR shader.
  52454. * It will both interacts on the Geometry for analytical and IBL lighting.
  52455. * It also prefilter the roughness map based on the bump values.
  52456. */
  52457. protected _enableSpecularAntiAliasing: boolean;
  52458. /**
  52459. * Default configuration related to image processing available in the PBR Material.
  52460. */
  52461. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52462. /**
  52463. * Keep track of the image processing observer to allow dispose and replace.
  52464. */
  52465. private _imageProcessingObserver;
  52466. /**
  52467. * Attaches a new image processing configuration to the PBR Material.
  52468. * @param configuration
  52469. */
  52470. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52471. /**
  52472. * Stores the available render targets.
  52473. */
  52474. private _renderTargets;
  52475. /**
  52476. * Sets the global ambient color for the material used in lighting calculations.
  52477. */
  52478. private _globalAmbientColor;
  52479. /**
  52480. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52481. */
  52482. private _useLogarithmicDepth;
  52483. /**
  52484. * If set to true, no lighting calculations will be applied.
  52485. */
  52486. private _unlit;
  52487. private _debugMode;
  52488. /**
  52489. * @hidden
  52490. * This is reserved for the inspector.
  52491. * Defines the material debug mode.
  52492. * It helps seeing only some components of the material while troubleshooting.
  52493. */
  52494. debugMode: number;
  52495. /**
  52496. * @hidden
  52497. * This is reserved for the inspector.
  52498. * Specify from where on screen the debug mode should start.
  52499. * The value goes from -1 (full screen) to 1 (not visible)
  52500. * It helps with side by side comparison against the final render
  52501. * This defaults to -1
  52502. */
  52503. private debugLimit;
  52504. /**
  52505. * @hidden
  52506. * This is reserved for the inspector.
  52507. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52508. * You can use the factor to better multiply the final value.
  52509. */
  52510. private debugFactor;
  52511. /**
  52512. * Defines the clear coat layer parameters for the material.
  52513. */
  52514. readonly clearCoat: PBRClearCoatConfiguration;
  52515. /**
  52516. * Defines the anisotropic parameters for the material.
  52517. */
  52518. readonly anisotropy: PBRAnisotropicConfiguration;
  52519. /**
  52520. * Defines the BRDF parameters for the material.
  52521. */
  52522. readonly brdf: PBRBRDFConfiguration;
  52523. /**
  52524. * Defines the Sheen parameters for the material.
  52525. */
  52526. readonly sheen: PBRSheenConfiguration;
  52527. /**
  52528. * Defines the SubSurface parameters for the material.
  52529. */
  52530. readonly subSurface: PBRSubSurfaceConfiguration;
  52531. /**
  52532. * Custom callback helping to override the default shader used in the material.
  52533. */
  52534. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  52535. protected _rebuildInParallel: boolean;
  52536. /**
  52537. * Instantiates a new PBRMaterial instance.
  52538. *
  52539. * @param name The material name
  52540. * @param scene The scene the material will be use in.
  52541. */
  52542. constructor(name: string, scene: Scene);
  52543. /**
  52544. * Gets a boolean indicating that current material needs to register RTT
  52545. */
  52546. get hasRenderTargetTextures(): boolean;
  52547. /**
  52548. * Gets the name of the material class.
  52549. */
  52550. getClassName(): string;
  52551. /**
  52552. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52553. */
  52554. get useLogarithmicDepth(): boolean;
  52555. /**
  52556. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52557. */
  52558. set useLogarithmicDepth(value: boolean);
  52559. /**
  52560. * Gets the current transparency mode.
  52561. */
  52562. get transparencyMode(): Nullable<number>;
  52563. /**
  52564. * Sets the transparency mode of the material.
  52565. *
  52566. * | Value | Type | Description |
  52567. * | ----- | ----------------------------------- | ----------- |
  52568. * | 0 | OPAQUE | |
  52569. * | 1 | ALPHATEST | |
  52570. * | 2 | ALPHABLEND | |
  52571. * | 3 | ALPHATESTANDBLEND | |
  52572. *
  52573. */
  52574. set transparencyMode(value: Nullable<number>);
  52575. /**
  52576. * Returns true if alpha blending should be disabled.
  52577. */
  52578. private get _disableAlphaBlending();
  52579. /**
  52580. * Specifies whether or not this material should be rendered in alpha blend mode.
  52581. */
  52582. needAlphaBlending(): boolean;
  52583. /**
  52584. * Specifies if the mesh will require alpha blending.
  52585. * @param mesh - BJS mesh.
  52586. */
  52587. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  52588. /**
  52589. * Specifies whether or not this material should be rendered in alpha test mode.
  52590. */
  52591. needAlphaTesting(): boolean;
  52592. /**
  52593. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52594. */
  52595. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52596. /**
  52597. * Gets the texture used for the alpha test.
  52598. */
  52599. getAlphaTestTexture(): Nullable<BaseTexture>;
  52600. /**
  52601. * Specifies that the submesh is ready to be used.
  52602. * @param mesh - BJS mesh.
  52603. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52604. * @param useInstances - Specifies that instances should be used.
  52605. * @returns - boolean indicating that the submesh is ready or not.
  52606. */
  52607. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52608. /**
  52609. * Specifies if the material uses metallic roughness workflow.
  52610. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52611. */
  52612. isMetallicWorkflow(): boolean;
  52613. private _prepareEffect;
  52614. private _prepareDefines;
  52615. /**
  52616. * Force shader compilation
  52617. */
  52618. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52619. /**
  52620. * Initializes the uniform buffer layout for the shader.
  52621. */
  52622. buildUniformLayout(): void;
  52623. /**
  52624. * Unbinds the material from the mesh
  52625. */
  52626. unbind(): void;
  52627. /**
  52628. * Binds the submesh data.
  52629. * @param world - The world matrix.
  52630. * @param mesh - The BJS mesh.
  52631. * @param subMesh - A submesh of the BJS mesh.
  52632. */
  52633. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52634. /**
  52635. * Returns the animatable textures.
  52636. * @returns - Array of animatable textures.
  52637. */
  52638. getAnimatables(): IAnimatable[];
  52639. /**
  52640. * Returns the texture used for reflections.
  52641. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52642. */
  52643. private _getReflectionTexture;
  52644. /**
  52645. * Returns an array of the actively used textures.
  52646. * @returns - Array of BaseTextures
  52647. */
  52648. getActiveTextures(): BaseTexture[];
  52649. /**
  52650. * Checks to see if a texture is used in the material.
  52651. * @param texture - Base texture to use.
  52652. * @returns - Boolean specifying if a texture is used in the material.
  52653. */
  52654. hasTexture(texture: BaseTexture): boolean;
  52655. /**
  52656. * Disposes the resources of the material.
  52657. * @param forceDisposeEffect - Forces the disposal of effects.
  52658. * @param forceDisposeTextures - Forces the disposal of all textures.
  52659. */
  52660. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52661. }
  52662. }
  52663. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  52664. import { Nullable } from "babylonjs/types";
  52665. import { Scene } from "babylonjs/scene";
  52666. import { Color3 } from "babylonjs/Maths/math.color";
  52667. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  52668. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  52669. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52670. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52671. /**
  52672. * The Physically based material of BJS.
  52673. *
  52674. * This offers the main features of a standard PBR material.
  52675. * For more information, please refer to the documentation :
  52676. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52677. */
  52678. export class PBRMaterial extends PBRBaseMaterial {
  52679. /**
  52680. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52681. */
  52682. static readonly PBRMATERIAL_OPAQUE: number;
  52683. /**
  52684. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52685. */
  52686. static readonly PBRMATERIAL_ALPHATEST: number;
  52687. /**
  52688. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52689. */
  52690. static readonly PBRMATERIAL_ALPHABLEND: number;
  52691. /**
  52692. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52693. * They are also discarded below the alpha cutoff threshold to improve performances.
  52694. */
  52695. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52696. /**
  52697. * Defines the default value of how much AO map is occluding the analytical lights
  52698. * (point spot...).
  52699. */
  52700. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52701. /**
  52702. * Intensity of the direct lights e.g. the four lights available in your scene.
  52703. * This impacts both the direct diffuse and specular highlights.
  52704. */
  52705. directIntensity: number;
  52706. /**
  52707. * Intensity of the emissive part of the material.
  52708. * This helps controlling the emissive effect without modifying the emissive color.
  52709. */
  52710. emissiveIntensity: number;
  52711. /**
  52712. * Intensity of the environment e.g. how much the environment will light the object
  52713. * either through harmonics for rough material or through the refelction for shiny ones.
  52714. */
  52715. environmentIntensity: number;
  52716. /**
  52717. * This is a special control allowing the reduction of the specular highlights coming from the
  52718. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52719. */
  52720. specularIntensity: number;
  52721. /**
  52722. * Debug Control allowing disabling the bump map on this material.
  52723. */
  52724. disableBumpMap: boolean;
  52725. /**
  52726. * AKA Diffuse Texture in standard nomenclature.
  52727. */
  52728. albedoTexture: BaseTexture;
  52729. /**
  52730. * AKA Occlusion Texture in other nomenclature.
  52731. */
  52732. ambientTexture: BaseTexture;
  52733. /**
  52734. * AKA Occlusion Texture Intensity in other nomenclature.
  52735. */
  52736. ambientTextureStrength: number;
  52737. /**
  52738. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52739. * 1 means it completely occludes it
  52740. * 0 mean it has no impact
  52741. */
  52742. ambientTextureImpactOnAnalyticalLights: number;
  52743. /**
  52744. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52745. */
  52746. opacityTexture: BaseTexture;
  52747. /**
  52748. * Stores the reflection values in a texture.
  52749. */
  52750. reflectionTexture: Nullable<BaseTexture>;
  52751. /**
  52752. * Stores the emissive values in a texture.
  52753. */
  52754. emissiveTexture: BaseTexture;
  52755. /**
  52756. * AKA Specular texture in other nomenclature.
  52757. */
  52758. reflectivityTexture: BaseTexture;
  52759. /**
  52760. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52761. */
  52762. metallicTexture: BaseTexture;
  52763. /**
  52764. * Specifies the metallic scalar of the metallic/roughness workflow.
  52765. * Can also be used to scale the metalness values of the metallic texture.
  52766. */
  52767. metallic: Nullable<number>;
  52768. /**
  52769. * Specifies the roughness scalar of the metallic/roughness workflow.
  52770. * Can also be used to scale the roughness values of the metallic texture.
  52771. */
  52772. roughness: Nullable<number>;
  52773. /**
  52774. * Specifies the an F0 factor to help configuring the material F0.
  52775. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52776. * to 0.5 the previously hard coded value stays the same.
  52777. * Can also be used to scale the F0 values of the metallic texture.
  52778. */
  52779. metallicF0Factor: number;
  52780. /**
  52781. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52782. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52783. * your expectation as it multiplies with the texture data.
  52784. */
  52785. useMetallicF0FactorFromMetallicTexture: boolean;
  52786. /**
  52787. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52788. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52789. */
  52790. microSurfaceTexture: BaseTexture;
  52791. /**
  52792. * Stores surface normal data used to displace a mesh in a texture.
  52793. */
  52794. bumpTexture: BaseTexture;
  52795. /**
  52796. * Stores the pre-calculated light information of a mesh in a texture.
  52797. */
  52798. lightmapTexture: BaseTexture;
  52799. /**
  52800. * Stores the refracted light information in a texture.
  52801. */
  52802. get refractionTexture(): Nullable<BaseTexture>;
  52803. set refractionTexture(value: Nullable<BaseTexture>);
  52804. /**
  52805. * The color of a material in ambient lighting.
  52806. */
  52807. ambientColor: Color3;
  52808. /**
  52809. * AKA Diffuse Color in other nomenclature.
  52810. */
  52811. albedoColor: Color3;
  52812. /**
  52813. * AKA Specular Color in other nomenclature.
  52814. */
  52815. reflectivityColor: Color3;
  52816. /**
  52817. * The color reflected from the material.
  52818. */
  52819. reflectionColor: Color3;
  52820. /**
  52821. * The color emitted from the material.
  52822. */
  52823. emissiveColor: Color3;
  52824. /**
  52825. * AKA Glossiness in other nomenclature.
  52826. */
  52827. microSurface: number;
  52828. /**
  52829. * source material index of refraction (IOR)' / 'destination material IOR.
  52830. */
  52831. get indexOfRefraction(): number;
  52832. set indexOfRefraction(value: number);
  52833. /**
  52834. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52835. */
  52836. get invertRefractionY(): boolean;
  52837. set invertRefractionY(value: boolean);
  52838. /**
  52839. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52840. * Materials half opaque for instance using refraction could benefit from this control.
  52841. */
  52842. get linkRefractionWithTransparency(): boolean;
  52843. set linkRefractionWithTransparency(value: boolean);
  52844. /**
  52845. * If true, the light map contains occlusion information instead of lighting info.
  52846. */
  52847. useLightmapAsShadowmap: boolean;
  52848. /**
  52849. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52850. */
  52851. useAlphaFromAlbedoTexture: boolean;
  52852. /**
  52853. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52854. */
  52855. forceAlphaTest: boolean;
  52856. /**
  52857. * Defines the alpha limits in alpha test mode.
  52858. */
  52859. alphaCutOff: number;
  52860. /**
  52861. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52862. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52863. */
  52864. useSpecularOverAlpha: boolean;
  52865. /**
  52866. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52867. */
  52868. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52869. /**
  52870. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52871. */
  52872. useRoughnessFromMetallicTextureAlpha: boolean;
  52873. /**
  52874. * Specifies if the metallic texture contains the roughness information in its green channel.
  52875. */
  52876. useRoughnessFromMetallicTextureGreen: boolean;
  52877. /**
  52878. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52879. */
  52880. useMetallnessFromMetallicTextureBlue: boolean;
  52881. /**
  52882. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52883. */
  52884. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52885. /**
  52886. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52887. */
  52888. useAmbientInGrayScale: boolean;
  52889. /**
  52890. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52891. * The material will try to infer what glossiness each pixel should be.
  52892. */
  52893. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52894. /**
  52895. * BJS is using an harcoded light falloff based on a manually sets up range.
  52896. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52897. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52898. */
  52899. get usePhysicalLightFalloff(): boolean;
  52900. /**
  52901. * BJS is using an harcoded light falloff based on a manually sets up range.
  52902. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52903. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52904. */
  52905. set usePhysicalLightFalloff(value: boolean);
  52906. /**
  52907. * In order to support the falloff compatibility with gltf, a special mode has been added
  52908. * to reproduce the gltf light falloff.
  52909. */
  52910. get useGLTFLightFalloff(): boolean;
  52911. /**
  52912. * In order to support the falloff compatibility with gltf, a special mode has been added
  52913. * to reproduce the gltf light falloff.
  52914. */
  52915. set useGLTFLightFalloff(value: boolean);
  52916. /**
  52917. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52918. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52919. */
  52920. useRadianceOverAlpha: boolean;
  52921. /**
  52922. * Allows using an object space normal map (instead of tangent space).
  52923. */
  52924. useObjectSpaceNormalMap: boolean;
  52925. /**
  52926. * Allows using the bump map in parallax mode.
  52927. */
  52928. useParallax: boolean;
  52929. /**
  52930. * Allows using the bump map in parallax occlusion mode.
  52931. */
  52932. useParallaxOcclusion: boolean;
  52933. /**
  52934. * Controls the scale bias of the parallax mode.
  52935. */
  52936. parallaxScaleBias: number;
  52937. /**
  52938. * If sets to true, disables all the lights affecting the material.
  52939. */
  52940. disableLighting: boolean;
  52941. /**
  52942. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52943. */
  52944. forceIrradianceInFragment: boolean;
  52945. /**
  52946. * Number of Simultaneous lights allowed on the material.
  52947. */
  52948. maxSimultaneousLights: number;
  52949. /**
  52950. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52951. */
  52952. invertNormalMapX: boolean;
  52953. /**
  52954. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52955. */
  52956. invertNormalMapY: boolean;
  52957. /**
  52958. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52959. */
  52960. twoSidedLighting: boolean;
  52961. /**
  52962. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52963. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52964. */
  52965. useAlphaFresnel: boolean;
  52966. /**
  52967. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52968. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52969. */
  52970. useLinearAlphaFresnel: boolean;
  52971. /**
  52972. * Let user defines the brdf lookup texture used for IBL.
  52973. * A default 8bit version is embedded but you could point at :
  52974. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52975. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52976. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52977. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52978. */
  52979. environmentBRDFTexture: Nullable<BaseTexture>;
  52980. /**
  52981. * Force normal to face away from face.
  52982. */
  52983. forceNormalForward: boolean;
  52984. /**
  52985. * Enables specular anti aliasing in the PBR shader.
  52986. * It will both interacts on the Geometry for analytical and IBL lighting.
  52987. * It also prefilter the roughness map based on the bump values.
  52988. */
  52989. enableSpecularAntiAliasing: boolean;
  52990. /**
  52991. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52992. * makes the reflect vector face the model (under horizon).
  52993. */
  52994. useHorizonOcclusion: boolean;
  52995. /**
  52996. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52997. * too much the area relying on ambient texture to define their ambient occlusion.
  52998. */
  52999. useRadianceOcclusion: boolean;
  53000. /**
  53001. * If set to true, no lighting calculations will be applied.
  53002. */
  53003. unlit: boolean;
  53004. /**
  53005. * Gets the image processing configuration used either in this material.
  53006. */
  53007. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53008. /**
  53009. * Sets the Default image processing configuration used either in the this material.
  53010. *
  53011. * If sets to null, the scene one is in use.
  53012. */
  53013. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53014. /**
  53015. * Gets wether the color curves effect is enabled.
  53016. */
  53017. get cameraColorCurvesEnabled(): boolean;
  53018. /**
  53019. * Sets wether the color curves effect is enabled.
  53020. */
  53021. set cameraColorCurvesEnabled(value: boolean);
  53022. /**
  53023. * Gets wether the color grading effect is enabled.
  53024. */
  53025. get cameraColorGradingEnabled(): boolean;
  53026. /**
  53027. * Gets wether the color grading effect is enabled.
  53028. */
  53029. set cameraColorGradingEnabled(value: boolean);
  53030. /**
  53031. * Gets wether tonemapping is enabled or not.
  53032. */
  53033. get cameraToneMappingEnabled(): boolean;
  53034. /**
  53035. * Sets wether tonemapping is enabled or not
  53036. */
  53037. set cameraToneMappingEnabled(value: boolean);
  53038. /**
  53039. * The camera exposure used on this material.
  53040. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53041. * This corresponds to a photographic exposure.
  53042. */
  53043. get cameraExposure(): number;
  53044. /**
  53045. * The camera exposure used on this material.
  53046. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53047. * This corresponds to a photographic exposure.
  53048. */
  53049. set cameraExposure(value: number);
  53050. /**
  53051. * Gets The camera contrast used on this material.
  53052. */
  53053. get cameraContrast(): number;
  53054. /**
  53055. * Sets The camera contrast used on this material.
  53056. */
  53057. set cameraContrast(value: number);
  53058. /**
  53059. * Gets the Color Grading 2D Lookup Texture.
  53060. */
  53061. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53062. /**
  53063. * Sets the Color Grading 2D Lookup Texture.
  53064. */
  53065. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53066. /**
  53067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53069. * 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;
  53070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53071. */
  53072. get cameraColorCurves(): Nullable<ColorCurves>;
  53073. /**
  53074. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53075. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53076. * 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;
  53077. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53078. */
  53079. set cameraColorCurves(value: Nullable<ColorCurves>);
  53080. /**
  53081. * Instantiates a new PBRMaterial instance.
  53082. *
  53083. * @param name The material name
  53084. * @param scene The scene the material will be use in.
  53085. */
  53086. constructor(name: string, scene: Scene);
  53087. /**
  53088. * Returns the name of this material class.
  53089. */
  53090. getClassName(): string;
  53091. /**
  53092. * Makes a duplicate of the current material.
  53093. * @param name - name to use for the new material.
  53094. */
  53095. clone(name: string): PBRMaterial;
  53096. /**
  53097. * Serializes this PBR Material.
  53098. * @returns - An object with the serialized material.
  53099. */
  53100. serialize(): any;
  53101. /**
  53102. * Parses a PBR Material from a serialized object.
  53103. * @param source - Serialized object.
  53104. * @param scene - BJS scene instance.
  53105. * @param rootUrl - url for the scene object
  53106. * @returns - PBRMaterial
  53107. */
  53108. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53109. }
  53110. }
  53111. declare module "babylonjs/Misc/dds" {
  53112. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53113. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53114. import { Nullable } from "babylonjs/types";
  53115. import { Scene } from "babylonjs/scene";
  53116. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53117. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53118. /**
  53119. * Direct draw surface info
  53120. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53121. */
  53122. export interface DDSInfo {
  53123. /**
  53124. * Width of the texture
  53125. */
  53126. width: number;
  53127. /**
  53128. * Width of the texture
  53129. */
  53130. height: number;
  53131. /**
  53132. * Number of Mipmaps for the texture
  53133. * @see https://en.wikipedia.org/wiki/Mipmap
  53134. */
  53135. mipmapCount: number;
  53136. /**
  53137. * If the textures format is a known fourCC format
  53138. * @see https://www.fourcc.org/
  53139. */
  53140. isFourCC: boolean;
  53141. /**
  53142. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53143. */
  53144. isRGB: boolean;
  53145. /**
  53146. * If the texture is a lumincance format
  53147. */
  53148. isLuminance: boolean;
  53149. /**
  53150. * If this is a cube texture
  53151. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53152. */
  53153. isCube: boolean;
  53154. /**
  53155. * If the texture is a compressed format eg. FOURCC_DXT1
  53156. */
  53157. isCompressed: boolean;
  53158. /**
  53159. * The dxgiFormat of the texture
  53160. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  53161. */
  53162. dxgiFormat: number;
  53163. /**
  53164. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  53165. */
  53166. textureType: number;
  53167. /**
  53168. * Sphericle polynomial created for the dds texture
  53169. */
  53170. sphericalPolynomial?: SphericalPolynomial;
  53171. }
  53172. /**
  53173. * Class used to provide DDS decompression tools
  53174. */
  53175. export class DDSTools {
  53176. /**
  53177. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  53178. */
  53179. static StoreLODInAlphaChannel: boolean;
  53180. /**
  53181. * Gets DDS information from an array buffer
  53182. * @param arrayBuffer defines the array buffer to read data from
  53183. * @returns the DDS information
  53184. */
  53185. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  53186. private static _FloatView;
  53187. private static _Int32View;
  53188. private static _ToHalfFloat;
  53189. private static _FromHalfFloat;
  53190. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  53191. private static _GetHalfFloatRGBAArrayBuffer;
  53192. private static _GetFloatRGBAArrayBuffer;
  53193. private static _GetFloatAsUIntRGBAArrayBuffer;
  53194. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  53195. private static _GetRGBAArrayBuffer;
  53196. private static _ExtractLongWordOrder;
  53197. private static _GetRGBArrayBuffer;
  53198. private static _GetLuminanceArrayBuffer;
  53199. /**
  53200. * Uploads DDS Levels to a Babylon Texture
  53201. * @hidden
  53202. */
  53203. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  53204. }
  53205. module "babylonjs/Engines/thinEngine" {
  53206. interface ThinEngine {
  53207. /**
  53208. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  53209. * @param rootUrl defines the url where the file to load is located
  53210. * @param scene defines the current scene
  53211. * @param lodScale defines scale to apply to the mip map selection
  53212. * @param lodOffset defines offset to apply to the mip map selection
  53213. * @param onLoad defines an optional callback raised when the texture is loaded
  53214. * @param onError defines an optional callback raised if there is an issue to load the texture
  53215. * @param format defines the format of the data
  53216. * @param forcedExtension defines the extension to use to pick the right loader
  53217. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  53218. * @returns the cube texture as an InternalTexture
  53219. */
  53220. 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;
  53221. }
  53222. }
  53223. }
  53224. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  53225. import { Nullable } from "babylonjs/types";
  53226. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53227. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53228. /**
  53229. * Implementation of the DDS Texture Loader.
  53230. * @hidden
  53231. */
  53232. export class _DDSTextureLoader implements IInternalTextureLoader {
  53233. /**
  53234. * Defines wether the loader supports cascade loading the different faces.
  53235. */
  53236. readonly supportCascades: boolean;
  53237. /**
  53238. * This returns if the loader support the current file information.
  53239. * @param extension defines the file extension of the file being loaded
  53240. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53241. * @param fallback defines the fallback internal texture if any
  53242. * @param isBase64 defines whether the texture is encoded as a base64
  53243. * @param isBuffer defines whether the texture data are stored as a buffer
  53244. * @returns true if the loader can load the specified file
  53245. */
  53246. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53247. /**
  53248. * Transform the url before loading if required.
  53249. * @param rootUrl the url of the texture
  53250. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53251. * @returns the transformed texture
  53252. */
  53253. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53254. /**
  53255. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53256. * @param rootUrl the url of the texture
  53257. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53258. * @returns the fallback texture
  53259. */
  53260. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53261. /**
  53262. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53263. * @param data contains the texture data
  53264. * @param texture defines the BabylonJS internal texture
  53265. * @param createPolynomials will be true if polynomials have been requested
  53266. * @param onLoad defines the callback to trigger once the texture is ready
  53267. * @param onError defines the callback to trigger in case of error
  53268. */
  53269. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53270. /**
  53271. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53272. * @param data contains the texture data
  53273. * @param texture defines the BabylonJS internal texture
  53274. * @param callback defines the method to call once ready to upload
  53275. */
  53276. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53277. }
  53278. }
  53279. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  53280. import { Nullable } from "babylonjs/types";
  53281. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53282. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53283. /**
  53284. * Implementation of the ENV Texture Loader.
  53285. * @hidden
  53286. */
  53287. export class _ENVTextureLoader implements IInternalTextureLoader {
  53288. /**
  53289. * Defines wether the loader supports cascade loading the different faces.
  53290. */
  53291. readonly supportCascades: boolean;
  53292. /**
  53293. * This returns if the loader support the current file information.
  53294. * @param extension defines the file extension of the file being loaded
  53295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53296. * @param fallback defines the fallback internal texture if any
  53297. * @param isBase64 defines whether the texture is encoded as a base64
  53298. * @param isBuffer defines whether the texture data are stored as a buffer
  53299. * @returns true if the loader can load the specified file
  53300. */
  53301. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53302. /**
  53303. * Transform the url before loading if required.
  53304. * @param rootUrl the url of the texture
  53305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53306. * @returns the transformed texture
  53307. */
  53308. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53309. /**
  53310. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53311. * @param rootUrl the url of the texture
  53312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53313. * @returns the fallback texture
  53314. */
  53315. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53316. /**
  53317. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53318. * @param data contains the texture data
  53319. * @param texture defines the BabylonJS internal texture
  53320. * @param createPolynomials will be true if polynomials have been requested
  53321. * @param onLoad defines the callback to trigger once the texture is ready
  53322. * @param onError defines the callback to trigger in case of error
  53323. */
  53324. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53325. /**
  53326. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53327. * @param data contains the texture data
  53328. * @param texture defines the BabylonJS internal texture
  53329. * @param callback defines the method to call once ready to upload
  53330. */
  53331. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53332. }
  53333. }
  53334. declare module "babylonjs/Misc/khronosTextureContainer" {
  53335. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53336. /**
  53337. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53338. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53339. */
  53340. export class KhronosTextureContainer {
  53341. /** contents of the KTX container file */
  53342. arrayBuffer: any;
  53343. private static HEADER_LEN;
  53344. private static COMPRESSED_2D;
  53345. private static COMPRESSED_3D;
  53346. private static TEX_2D;
  53347. private static TEX_3D;
  53348. /**
  53349. * Gets the openGL type
  53350. */
  53351. glType: number;
  53352. /**
  53353. * Gets the openGL type size
  53354. */
  53355. glTypeSize: number;
  53356. /**
  53357. * Gets the openGL format
  53358. */
  53359. glFormat: number;
  53360. /**
  53361. * Gets the openGL internal format
  53362. */
  53363. glInternalFormat: number;
  53364. /**
  53365. * Gets the base internal format
  53366. */
  53367. glBaseInternalFormat: number;
  53368. /**
  53369. * Gets image width in pixel
  53370. */
  53371. pixelWidth: number;
  53372. /**
  53373. * Gets image height in pixel
  53374. */
  53375. pixelHeight: number;
  53376. /**
  53377. * Gets image depth in pixels
  53378. */
  53379. pixelDepth: number;
  53380. /**
  53381. * Gets the number of array elements
  53382. */
  53383. numberOfArrayElements: number;
  53384. /**
  53385. * Gets the number of faces
  53386. */
  53387. numberOfFaces: number;
  53388. /**
  53389. * Gets the number of mipmap levels
  53390. */
  53391. numberOfMipmapLevels: number;
  53392. /**
  53393. * Gets the bytes of key value data
  53394. */
  53395. bytesOfKeyValueData: number;
  53396. /**
  53397. * Gets the load type
  53398. */
  53399. loadType: number;
  53400. /**
  53401. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  53402. */
  53403. isInvalid: boolean;
  53404. /**
  53405. * Creates a new KhronosTextureContainer
  53406. * @param arrayBuffer contents of the KTX container file
  53407. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  53408. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  53409. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  53410. */
  53411. constructor(
  53412. /** contents of the KTX container file */
  53413. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53414. /**
  53415. * Uploads KTX content to a Babylon Texture.
  53416. * It is assumed that the texture has already been created & is currently bound
  53417. * @hidden
  53418. */
  53419. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53420. private _upload2DCompressedLevels;
  53421. }
  53422. }
  53423. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  53424. import { Nullable } from "babylonjs/types";
  53425. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53426. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53427. /**
  53428. * Implementation of the KTX Texture Loader.
  53429. * @hidden
  53430. */
  53431. export class _KTXTextureLoader implements IInternalTextureLoader {
  53432. /**
  53433. * Defines wether the loader supports cascade loading the different faces.
  53434. */
  53435. readonly supportCascades: boolean;
  53436. /**
  53437. * This returns if the loader support the current file information.
  53438. * @param extension defines the file extension of the file being loaded
  53439. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53440. * @param fallback defines the fallback internal texture if any
  53441. * @param isBase64 defines whether the texture is encoded as a base64
  53442. * @param isBuffer defines whether the texture data are stored as a buffer
  53443. * @returns true if the loader can load the specified file
  53444. */
  53445. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53446. /**
  53447. * Transform the url before loading if required.
  53448. * @param rootUrl the url of the texture
  53449. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53450. * @returns the transformed texture
  53451. */
  53452. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53453. /**
  53454. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53455. * @param rootUrl the url of the texture
  53456. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53457. * @returns the fallback texture
  53458. */
  53459. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53460. /**
  53461. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53462. * @param data contains the texture data
  53463. * @param texture defines the BabylonJS internal texture
  53464. * @param createPolynomials will be true if polynomials have been requested
  53465. * @param onLoad defines the callback to trigger once the texture is ready
  53466. * @param onError defines the callback to trigger in case of error
  53467. */
  53468. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53469. /**
  53470. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53471. * @param data contains the texture data
  53472. * @param texture defines the BabylonJS internal texture
  53473. * @param callback defines the method to call once ready to upload
  53474. */
  53475. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53476. }
  53477. }
  53478. declare module "babylonjs/Helpers/sceneHelpers" {
  53479. import { Nullable } from "babylonjs/types";
  53480. import { Mesh } from "babylonjs/Meshes/mesh";
  53481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53482. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  53483. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  53484. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53485. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53486. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53487. import "babylonjs/Meshes/Builders/boxBuilder";
  53488. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  53489. /** @hidden */
  53490. export var _forceSceneHelpersToBundle: boolean;
  53491. module "babylonjs/scene" {
  53492. interface Scene {
  53493. /**
  53494. * Creates a default light for the scene.
  53495. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53496. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53497. */
  53498. createDefaultLight(replace?: boolean): void;
  53499. /**
  53500. * Creates a default camera for the scene.
  53501. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53502. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53503. * @param replace has default false, when true replaces the active camera in the scene
  53504. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53505. */
  53506. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53507. /**
  53508. * Creates a default camera and a default light.
  53509. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53510. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53511. * @param replace has the default false, when true replaces the active camera/light in the scene
  53512. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53513. */
  53514. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53515. /**
  53516. * Creates a new sky box
  53517. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53518. * @param environmentTexture defines the texture to use as environment texture
  53519. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53520. * @param scale defines the overall scale of the skybox
  53521. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53522. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53523. * @returns a new mesh holding the sky box
  53524. */
  53525. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53526. /**
  53527. * Creates a new environment
  53528. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53529. * @param options defines the options you can use to configure the environment
  53530. * @returns the new EnvironmentHelper
  53531. */
  53532. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53533. /**
  53534. * Creates a new VREXperienceHelper
  53535. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53536. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53537. * @returns a new VREXperienceHelper
  53538. */
  53539. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53540. /**
  53541. * Creates a new WebXRDefaultExperience
  53542. * @see http://doc.babylonjs.com/how_to/webxr
  53543. * @param options experience options
  53544. * @returns a promise for a new WebXRDefaultExperience
  53545. */
  53546. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53547. }
  53548. }
  53549. }
  53550. declare module "babylonjs/Helpers/videoDome" {
  53551. import { Scene } from "babylonjs/scene";
  53552. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53553. import { Mesh } from "babylonjs/Meshes/mesh";
  53554. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  53555. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  53556. import "babylonjs/Meshes/Builders/sphereBuilder";
  53557. /**
  53558. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53559. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53560. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53561. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53562. */
  53563. export class VideoDome extends TransformNode {
  53564. /**
  53565. * Define the video source as a Monoscopic panoramic 360 video.
  53566. */
  53567. static readonly MODE_MONOSCOPIC: number;
  53568. /**
  53569. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53570. */
  53571. static readonly MODE_TOPBOTTOM: number;
  53572. /**
  53573. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53574. */
  53575. static readonly MODE_SIDEBYSIDE: number;
  53576. private _halfDome;
  53577. private _useDirectMapping;
  53578. /**
  53579. * The video texture being displayed on the sphere
  53580. */
  53581. protected _videoTexture: VideoTexture;
  53582. /**
  53583. * Gets the video texture being displayed on the sphere
  53584. */
  53585. get videoTexture(): VideoTexture;
  53586. /**
  53587. * The skybox material
  53588. */
  53589. protected _material: BackgroundMaterial;
  53590. /**
  53591. * The surface used for the skybox
  53592. */
  53593. protected _mesh: Mesh;
  53594. /**
  53595. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53596. */
  53597. private _halfDomeMask;
  53598. /**
  53599. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53600. * Also see the options.resolution property.
  53601. */
  53602. get fovMultiplier(): number;
  53603. set fovMultiplier(value: number);
  53604. private _videoMode;
  53605. /**
  53606. * Gets or set the current video mode for the video. It can be:
  53607. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53608. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53609. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53610. */
  53611. get videoMode(): number;
  53612. set videoMode(value: number);
  53613. /**
  53614. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53615. *
  53616. */
  53617. get halfDome(): boolean;
  53618. /**
  53619. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53620. */
  53621. set halfDome(enabled: boolean);
  53622. /**
  53623. * Oberserver used in Stereoscopic VR Mode.
  53624. */
  53625. private _onBeforeCameraRenderObserver;
  53626. /**
  53627. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53628. * @param name Element's name, child elements will append suffixes for their own names.
  53629. * @param urlsOrVideo defines the url(s) or the video element to use
  53630. * @param options An object containing optional or exposed sub element properties
  53631. */
  53632. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53633. resolution?: number;
  53634. clickToPlay?: boolean;
  53635. autoPlay?: boolean;
  53636. loop?: boolean;
  53637. size?: number;
  53638. poster?: string;
  53639. faceForward?: boolean;
  53640. useDirectMapping?: boolean;
  53641. halfDomeMode?: boolean;
  53642. }, scene: Scene);
  53643. private _changeVideoMode;
  53644. /**
  53645. * Releases resources associated with this node.
  53646. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53647. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53648. */
  53649. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53650. }
  53651. }
  53652. declare module "babylonjs/Helpers/index" {
  53653. export * from "babylonjs/Helpers/environmentHelper";
  53654. export * from "babylonjs/Helpers/photoDome";
  53655. export * from "babylonjs/Helpers/sceneHelpers";
  53656. export * from "babylonjs/Helpers/videoDome";
  53657. }
  53658. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  53659. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53660. import { IDisposable } from "babylonjs/scene";
  53661. import { Engine } from "babylonjs/Engines/engine";
  53662. /**
  53663. * This class can be used to get instrumentation data from a Babylon engine
  53664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53665. */
  53666. export class EngineInstrumentation implements IDisposable {
  53667. /**
  53668. * Define the instrumented engine.
  53669. */
  53670. engine: Engine;
  53671. private _captureGPUFrameTime;
  53672. private _gpuFrameTimeToken;
  53673. private _gpuFrameTime;
  53674. private _captureShaderCompilationTime;
  53675. private _shaderCompilationTime;
  53676. private _onBeginFrameObserver;
  53677. private _onEndFrameObserver;
  53678. private _onBeforeShaderCompilationObserver;
  53679. private _onAfterShaderCompilationObserver;
  53680. /**
  53681. * Gets the perf counter used for GPU frame time
  53682. */
  53683. get gpuFrameTimeCounter(): PerfCounter;
  53684. /**
  53685. * Gets the GPU frame time capture status
  53686. */
  53687. get captureGPUFrameTime(): boolean;
  53688. /**
  53689. * Enable or disable the GPU frame time capture
  53690. */
  53691. set captureGPUFrameTime(value: boolean);
  53692. /**
  53693. * Gets the perf counter used for shader compilation time
  53694. */
  53695. get shaderCompilationTimeCounter(): PerfCounter;
  53696. /**
  53697. * Gets the shader compilation time capture status
  53698. */
  53699. get captureShaderCompilationTime(): boolean;
  53700. /**
  53701. * Enable or disable the shader compilation time capture
  53702. */
  53703. set captureShaderCompilationTime(value: boolean);
  53704. /**
  53705. * Instantiates a new engine instrumentation.
  53706. * This class can be used to get instrumentation data from a Babylon engine
  53707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53708. * @param engine Defines the engine to instrument
  53709. */
  53710. constructor(
  53711. /**
  53712. * Define the instrumented engine.
  53713. */
  53714. engine: Engine);
  53715. /**
  53716. * Dispose and release associated resources.
  53717. */
  53718. dispose(): void;
  53719. }
  53720. }
  53721. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  53722. import { Scene, IDisposable } from "babylonjs/scene";
  53723. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53724. /**
  53725. * This class can be used to get instrumentation data from a Babylon engine
  53726. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53727. */
  53728. export class SceneInstrumentation implements IDisposable {
  53729. /**
  53730. * Defines the scene to instrument
  53731. */
  53732. scene: Scene;
  53733. private _captureActiveMeshesEvaluationTime;
  53734. private _activeMeshesEvaluationTime;
  53735. private _captureRenderTargetsRenderTime;
  53736. private _renderTargetsRenderTime;
  53737. private _captureFrameTime;
  53738. private _frameTime;
  53739. private _captureRenderTime;
  53740. private _renderTime;
  53741. private _captureInterFrameTime;
  53742. private _interFrameTime;
  53743. private _captureParticlesRenderTime;
  53744. private _particlesRenderTime;
  53745. private _captureSpritesRenderTime;
  53746. private _spritesRenderTime;
  53747. private _capturePhysicsTime;
  53748. private _physicsTime;
  53749. private _captureAnimationsTime;
  53750. private _animationsTime;
  53751. private _captureCameraRenderTime;
  53752. private _cameraRenderTime;
  53753. private _onBeforeActiveMeshesEvaluationObserver;
  53754. private _onAfterActiveMeshesEvaluationObserver;
  53755. private _onBeforeRenderTargetsRenderObserver;
  53756. private _onAfterRenderTargetsRenderObserver;
  53757. private _onAfterRenderObserver;
  53758. private _onBeforeDrawPhaseObserver;
  53759. private _onAfterDrawPhaseObserver;
  53760. private _onBeforeAnimationsObserver;
  53761. private _onBeforeParticlesRenderingObserver;
  53762. private _onAfterParticlesRenderingObserver;
  53763. private _onBeforeSpritesRenderingObserver;
  53764. private _onAfterSpritesRenderingObserver;
  53765. private _onBeforePhysicsObserver;
  53766. private _onAfterPhysicsObserver;
  53767. private _onAfterAnimationsObserver;
  53768. private _onBeforeCameraRenderObserver;
  53769. private _onAfterCameraRenderObserver;
  53770. /**
  53771. * Gets the perf counter used for active meshes evaluation time
  53772. */
  53773. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53774. /**
  53775. * Gets the active meshes evaluation time capture status
  53776. */
  53777. get captureActiveMeshesEvaluationTime(): boolean;
  53778. /**
  53779. * Enable or disable the active meshes evaluation time capture
  53780. */
  53781. set captureActiveMeshesEvaluationTime(value: boolean);
  53782. /**
  53783. * Gets the perf counter used for render targets render time
  53784. */
  53785. get renderTargetsRenderTimeCounter(): PerfCounter;
  53786. /**
  53787. * Gets the render targets render time capture status
  53788. */
  53789. get captureRenderTargetsRenderTime(): boolean;
  53790. /**
  53791. * Enable or disable the render targets render time capture
  53792. */
  53793. set captureRenderTargetsRenderTime(value: boolean);
  53794. /**
  53795. * Gets the perf counter used for particles render time
  53796. */
  53797. get particlesRenderTimeCounter(): PerfCounter;
  53798. /**
  53799. * Gets the particles render time capture status
  53800. */
  53801. get captureParticlesRenderTime(): boolean;
  53802. /**
  53803. * Enable or disable the particles render time capture
  53804. */
  53805. set captureParticlesRenderTime(value: boolean);
  53806. /**
  53807. * Gets the perf counter used for sprites render time
  53808. */
  53809. get spritesRenderTimeCounter(): PerfCounter;
  53810. /**
  53811. * Gets the sprites render time capture status
  53812. */
  53813. get captureSpritesRenderTime(): boolean;
  53814. /**
  53815. * Enable or disable the sprites render time capture
  53816. */
  53817. set captureSpritesRenderTime(value: boolean);
  53818. /**
  53819. * Gets the perf counter used for physics time
  53820. */
  53821. get physicsTimeCounter(): PerfCounter;
  53822. /**
  53823. * Gets the physics time capture status
  53824. */
  53825. get capturePhysicsTime(): boolean;
  53826. /**
  53827. * Enable or disable the physics time capture
  53828. */
  53829. set capturePhysicsTime(value: boolean);
  53830. /**
  53831. * Gets the perf counter used for animations time
  53832. */
  53833. get animationsTimeCounter(): PerfCounter;
  53834. /**
  53835. * Gets the animations time capture status
  53836. */
  53837. get captureAnimationsTime(): boolean;
  53838. /**
  53839. * Enable or disable the animations time capture
  53840. */
  53841. set captureAnimationsTime(value: boolean);
  53842. /**
  53843. * Gets the perf counter used for frame time capture
  53844. */
  53845. get frameTimeCounter(): PerfCounter;
  53846. /**
  53847. * Gets the frame time capture status
  53848. */
  53849. get captureFrameTime(): boolean;
  53850. /**
  53851. * Enable or disable the frame time capture
  53852. */
  53853. set captureFrameTime(value: boolean);
  53854. /**
  53855. * Gets the perf counter used for inter-frames time capture
  53856. */
  53857. get interFrameTimeCounter(): PerfCounter;
  53858. /**
  53859. * Gets the inter-frames time capture status
  53860. */
  53861. get captureInterFrameTime(): boolean;
  53862. /**
  53863. * Enable or disable the inter-frames time capture
  53864. */
  53865. set captureInterFrameTime(value: boolean);
  53866. /**
  53867. * Gets the perf counter used for render time capture
  53868. */
  53869. get renderTimeCounter(): PerfCounter;
  53870. /**
  53871. * Gets the render time capture status
  53872. */
  53873. get captureRenderTime(): boolean;
  53874. /**
  53875. * Enable or disable the render time capture
  53876. */
  53877. set captureRenderTime(value: boolean);
  53878. /**
  53879. * Gets the perf counter used for camera render time capture
  53880. */
  53881. get cameraRenderTimeCounter(): PerfCounter;
  53882. /**
  53883. * Gets the camera render time capture status
  53884. */
  53885. get captureCameraRenderTime(): boolean;
  53886. /**
  53887. * Enable or disable the camera render time capture
  53888. */
  53889. set captureCameraRenderTime(value: boolean);
  53890. /**
  53891. * Gets the perf counter used for draw calls
  53892. */
  53893. get drawCallsCounter(): PerfCounter;
  53894. /**
  53895. * Instantiates a new scene instrumentation.
  53896. * This class can be used to get instrumentation data from a Babylon engine
  53897. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53898. * @param scene Defines the scene to instrument
  53899. */
  53900. constructor(
  53901. /**
  53902. * Defines the scene to instrument
  53903. */
  53904. scene: Scene);
  53905. /**
  53906. * Dispose and release associated resources.
  53907. */
  53908. dispose(): void;
  53909. }
  53910. }
  53911. declare module "babylonjs/Instrumentation/index" {
  53912. export * from "babylonjs/Instrumentation/engineInstrumentation";
  53913. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  53914. export * from "babylonjs/Instrumentation/timeToken";
  53915. }
  53916. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  53917. /** @hidden */
  53918. export var glowMapGenerationPixelShader: {
  53919. name: string;
  53920. shader: string;
  53921. };
  53922. }
  53923. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  53924. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53925. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53926. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53927. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53928. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53929. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53930. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53931. /** @hidden */
  53932. export var glowMapGenerationVertexShader: {
  53933. name: string;
  53934. shader: string;
  53935. };
  53936. }
  53937. declare module "babylonjs/Layers/effectLayer" {
  53938. import { Observable } from "babylonjs/Misc/observable";
  53939. import { Nullable } from "babylonjs/types";
  53940. import { Camera } from "babylonjs/Cameras/camera";
  53941. import { Scene } from "babylonjs/scene";
  53942. import { ISize } from "babylonjs/Maths/math.size";
  53943. import { Color4 } from "babylonjs/Maths/math.color";
  53944. import { Engine } from "babylonjs/Engines/engine";
  53945. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53947. import { Mesh } from "babylonjs/Meshes/mesh";
  53948. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53950. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53951. import { Effect } from "babylonjs/Materials/effect";
  53952. import { Material } from "babylonjs/Materials/material";
  53953. import "babylonjs/Shaders/glowMapGeneration.fragment";
  53954. import "babylonjs/Shaders/glowMapGeneration.vertex";
  53955. /**
  53956. * Effect layer options. This helps customizing the behaviour
  53957. * of the effect layer.
  53958. */
  53959. export interface IEffectLayerOptions {
  53960. /**
  53961. * Multiplication factor apply to the canvas size to compute the render target size
  53962. * used to generated the objects (the smaller the faster).
  53963. */
  53964. mainTextureRatio: number;
  53965. /**
  53966. * Enforces a fixed size texture to ensure effect stability across devices.
  53967. */
  53968. mainTextureFixedSize?: number;
  53969. /**
  53970. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53971. */
  53972. alphaBlendingMode: number;
  53973. /**
  53974. * The camera attached to the layer.
  53975. */
  53976. camera: Nullable<Camera>;
  53977. /**
  53978. * The rendering group to draw the layer in.
  53979. */
  53980. renderingGroupId: number;
  53981. }
  53982. /**
  53983. * The effect layer Helps adding post process effect blended with the main pass.
  53984. *
  53985. * This can be for instance use to generate glow or higlight effects on the scene.
  53986. *
  53987. * The effect layer class can not be used directly and is intented to inherited from to be
  53988. * customized per effects.
  53989. */
  53990. export abstract class EffectLayer {
  53991. private _vertexBuffers;
  53992. private _indexBuffer;
  53993. private _cachedDefines;
  53994. private _effectLayerMapGenerationEffect;
  53995. private _effectLayerOptions;
  53996. private _mergeEffect;
  53997. protected _scene: Scene;
  53998. protected _engine: Engine;
  53999. protected _maxSize: number;
  54000. protected _mainTextureDesiredSize: ISize;
  54001. protected _mainTexture: RenderTargetTexture;
  54002. protected _shouldRender: boolean;
  54003. protected _postProcesses: PostProcess[];
  54004. protected _textures: BaseTexture[];
  54005. protected _emissiveTextureAndColor: {
  54006. texture: Nullable<BaseTexture>;
  54007. color: Color4;
  54008. };
  54009. /**
  54010. * The name of the layer
  54011. */
  54012. name: string;
  54013. /**
  54014. * The clear color of the texture used to generate the glow map.
  54015. */
  54016. neutralColor: Color4;
  54017. /**
  54018. * Specifies wether the highlight layer is enabled or not.
  54019. */
  54020. isEnabled: boolean;
  54021. /**
  54022. * Gets the camera attached to the layer.
  54023. */
  54024. get camera(): Nullable<Camera>;
  54025. /**
  54026. * Gets the rendering group id the layer should render in.
  54027. */
  54028. get renderingGroupId(): number;
  54029. set renderingGroupId(renderingGroupId: number);
  54030. /**
  54031. * An event triggered when the effect layer has been disposed.
  54032. */
  54033. onDisposeObservable: Observable<EffectLayer>;
  54034. /**
  54035. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54036. */
  54037. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54038. /**
  54039. * An event triggered when the generated texture is being merged in the scene.
  54040. */
  54041. onBeforeComposeObservable: Observable<EffectLayer>;
  54042. /**
  54043. * An event triggered when the mesh is rendered into the effect render target.
  54044. */
  54045. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  54046. /**
  54047. * An event triggered after the mesh has been rendered into the effect render target.
  54048. */
  54049. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  54050. /**
  54051. * An event triggered when the generated texture has been merged in the scene.
  54052. */
  54053. onAfterComposeObservable: Observable<EffectLayer>;
  54054. /**
  54055. * An event triggered when the efffect layer changes its size.
  54056. */
  54057. onSizeChangedObservable: Observable<EffectLayer>;
  54058. /** @hidden */
  54059. static _SceneComponentInitialization: (scene: Scene) => void;
  54060. /**
  54061. * Instantiates a new effect Layer and references it in the scene.
  54062. * @param name The name of the layer
  54063. * @param scene The scene to use the layer in
  54064. */
  54065. constructor(
  54066. /** The Friendly of the effect in the scene */
  54067. name: string, scene: Scene);
  54068. /**
  54069. * Get the effect name of the layer.
  54070. * @return The effect name
  54071. */
  54072. abstract getEffectName(): string;
  54073. /**
  54074. * Checks for the readiness of the element composing the layer.
  54075. * @param subMesh the mesh to check for
  54076. * @param useInstances specify wether or not to use instances to render the mesh
  54077. * @return true if ready otherwise, false
  54078. */
  54079. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54080. /**
  54081. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54082. * @returns true if the effect requires stencil during the main canvas render pass.
  54083. */
  54084. abstract needStencil(): boolean;
  54085. /**
  54086. * Create the merge effect. This is the shader use to blit the information back
  54087. * to the main canvas at the end of the scene rendering.
  54088. * @returns The effect containing the shader used to merge the effect on the main canvas
  54089. */
  54090. protected abstract _createMergeEffect(): Effect;
  54091. /**
  54092. * Creates the render target textures and post processes used in the effect layer.
  54093. */
  54094. protected abstract _createTextureAndPostProcesses(): void;
  54095. /**
  54096. * Implementation specific of rendering the generating effect on the main canvas.
  54097. * @param effect The effect used to render through
  54098. */
  54099. protected abstract _internalRender(effect: Effect): void;
  54100. /**
  54101. * Sets the required values for both the emissive texture and and the main color.
  54102. */
  54103. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54104. /**
  54105. * Free any resources and references associated to a mesh.
  54106. * Internal use
  54107. * @param mesh The mesh to free.
  54108. */
  54109. abstract _disposeMesh(mesh: Mesh): void;
  54110. /**
  54111. * Serializes this layer (Glow or Highlight for example)
  54112. * @returns a serialized layer object
  54113. */
  54114. abstract serialize?(): any;
  54115. /**
  54116. * Initializes the effect layer with the required options.
  54117. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54118. */
  54119. protected _init(options: Partial<IEffectLayerOptions>): void;
  54120. /**
  54121. * Generates the index buffer of the full screen quad blending to the main canvas.
  54122. */
  54123. private _generateIndexBuffer;
  54124. /**
  54125. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54126. */
  54127. private _generateVertexBuffer;
  54128. /**
  54129. * Sets the main texture desired size which is the closest power of two
  54130. * of the engine canvas size.
  54131. */
  54132. private _setMainTextureSize;
  54133. /**
  54134. * Creates the main texture for the effect layer.
  54135. */
  54136. protected _createMainTexture(): void;
  54137. /**
  54138. * Adds specific effects defines.
  54139. * @param defines The defines to add specifics to.
  54140. */
  54141. protected _addCustomEffectDefines(defines: string[]): void;
  54142. /**
  54143. * Checks for the readiness of the element composing the layer.
  54144. * @param subMesh the mesh to check for
  54145. * @param useInstances specify wether or not to use instances to render the mesh
  54146. * @param emissiveTexture the associated emissive texture used to generate the glow
  54147. * @return true if ready otherwise, false
  54148. */
  54149. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54150. /**
  54151. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54152. */
  54153. render(): void;
  54154. /**
  54155. * Determine if a given mesh will be used in the current effect.
  54156. * @param mesh mesh to test
  54157. * @returns true if the mesh will be used
  54158. */
  54159. hasMesh(mesh: AbstractMesh): boolean;
  54160. /**
  54161. * Returns true if the layer contains information to display, otherwise false.
  54162. * @returns true if the glow layer should be rendered
  54163. */
  54164. shouldRender(): boolean;
  54165. /**
  54166. * Returns true if the mesh should render, otherwise false.
  54167. * @param mesh The mesh to render
  54168. * @returns true if it should render otherwise false
  54169. */
  54170. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  54171. /**
  54172. * Returns true if the mesh can be rendered, otherwise false.
  54173. * @param mesh The mesh to render
  54174. * @param material The material used on the mesh
  54175. * @returns true if it can be rendered otherwise false
  54176. */
  54177. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54178. /**
  54179. * Returns true if the mesh should render, otherwise false.
  54180. * @param mesh The mesh to render
  54181. * @returns true if it should render otherwise false
  54182. */
  54183. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  54184. /**
  54185. * Renders the submesh passed in parameter to the generation map.
  54186. */
  54187. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  54188. /**
  54189. * Defines wether the current material of the mesh should be use to render the effect.
  54190. * @param mesh defines the current mesh to render
  54191. */
  54192. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54193. /**
  54194. * Rebuild the required buffers.
  54195. * @hidden Internal use only.
  54196. */
  54197. _rebuild(): void;
  54198. /**
  54199. * Dispose only the render target textures and post process.
  54200. */
  54201. private _disposeTextureAndPostProcesses;
  54202. /**
  54203. * Dispose the highlight layer and free resources.
  54204. */
  54205. dispose(): void;
  54206. /**
  54207. * Gets the class name of the effect layer
  54208. * @returns the string with the class name of the effect layer
  54209. */
  54210. getClassName(): string;
  54211. /**
  54212. * Creates an effect layer from parsed effect layer data
  54213. * @param parsedEffectLayer defines effect layer data
  54214. * @param scene defines the current scene
  54215. * @param rootUrl defines the root URL containing the effect layer information
  54216. * @returns a parsed effect Layer
  54217. */
  54218. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  54219. }
  54220. }
  54221. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  54222. import { Scene } from "babylonjs/scene";
  54223. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54224. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54225. import { AbstractScene } from "babylonjs/abstractScene";
  54226. module "babylonjs/abstractScene" {
  54227. interface AbstractScene {
  54228. /**
  54229. * The list of effect layers (highlights/glow) added to the scene
  54230. * @see http://doc.babylonjs.com/how_to/highlight_layer
  54231. * @see http://doc.babylonjs.com/how_to/glow_layer
  54232. */
  54233. effectLayers: Array<EffectLayer>;
  54234. /**
  54235. * Removes the given effect layer from this scene.
  54236. * @param toRemove defines the effect layer to remove
  54237. * @returns the index of the removed effect layer
  54238. */
  54239. removeEffectLayer(toRemove: EffectLayer): number;
  54240. /**
  54241. * Adds the given effect layer to this scene
  54242. * @param newEffectLayer defines the effect layer to add
  54243. */
  54244. addEffectLayer(newEffectLayer: EffectLayer): void;
  54245. }
  54246. }
  54247. /**
  54248. * Defines the layer scene component responsible to manage any effect layers
  54249. * in a given scene.
  54250. */
  54251. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  54252. /**
  54253. * The component name helpfull to identify the component in the list of scene components.
  54254. */
  54255. readonly name: string;
  54256. /**
  54257. * The scene the component belongs to.
  54258. */
  54259. scene: Scene;
  54260. private _engine;
  54261. private _renderEffects;
  54262. private _needStencil;
  54263. private _previousStencilState;
  54264. /**
  54265. * Creates a new instance of the component for the given scene
  54266. * @param scene Defines the scene to register the component in
  54267. */
  54268. constructor(scene: Scene);
  54269. /**
  54270. * Registers the component in a given scene
  54271. */
  54272. register(): void;
  54273. /**
  54274. * Rebuilds the elements related to this component in case of
  54275. * context lost for instance.
  54276. */
  54277. rebuild(): void;
  54278. /**
  54279. * Serializes the component data to the specified json object
  54280. * @param serializationObject The object to serialize to
  54281. */
  54282. serialize(serializationObject: any): void;
  54283. /**
  54284. * Adds all the elements from the container to the scene
  54285. * @param container the container holding the elements
  54286. */
  54287. addFromContainer(container: AbstractScene): void;
  54288. /**
  54289. * Removes all the elements in the container from the scene
  54290. * @param container contains the elements to remove
  54291. * @param dispose if the removed element should be disposed (default: false)
  54292. */
  54293. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54294. /**
  54295. * Disposes the component and the associated ressources.
  54296. */
  54297. dispose(): void;
  54298. private _isReadyForMesh;
  54299. private _renderMainTexture;
  54300. private _setStencil;
  54301. private _setStencilBack;
  54302. private _draw;
  54303. private _drawCamera;
  54304. private _drawRenderingGroup;
  54305. }
  54306. }
  54307. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  54308. /** @hidden */
  54309. export var glowMapMergePixelShader: {
  54310. name: string;
  54311. shader: string;
  54312. };
  54313. }
  54314. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  54315. /** @hidden */
  54316. export var glowMapMergeVertexShader: {
  54317. name: string;
  54318. shader: string;
  54319. };
  54320. }
  54321. declare module "babylonjs/Layers/glowLayer" {
  54322. import { Nullable } from "babylonjs/types";
  54323. import { Camera } from "babylonjs/Cameras/camera";
  54324. import { Scene } from "babylonjs/scene";
  54325. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54327. import { Mesh } from "babylonjs/Meshes/mesh";
  54328. import { Texture } from "babylonjs/Materials/Textures/texture";
  54329. import { Effect } from "babylonjs/Materials/effect";
  54330. import { Material } from "babylonjs/Materials/material";
  54331. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54332. import { Color4 } from "babylonjs/Maths/math.color";
  54333. import "babylonjs/Shaders/glowMapMerge.fragment";
  54334. import "babylonjs/Shaders/glowMapMerge.vertex";
  54335. import "babylonjs/Layers/effectLayerSceneComponent";
  54336. module "babylonjs/abstractScene" {
  54337. interface AbstractScene {
  54338. /**
  54339. * Return a the first highlight layer of the scene with a given name.
  54340. * @param name The name of the highlight layer to look for.
  54341. * @return The highlight layer if found otherwise null.
  54342. */
  54343. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  54344. }
  54345. }
  54346. /**
  54347. * Glow layer options. This helps customizing the behaviour
  54348. * of the glow layer.
  54349. */
  54350. export interface IGlowLayerOptions {
  54351. /**
  54352. * Multiplication factor apply to the canvas size to compute the render target size
  54353. * used to generated the glowing objects (the smaller the faster).
  54354. */
  54355. mainTextureRatio: number;
  54356. /**
  54357. * Enforces a fixed size texture to ensure resize independant blur.
  54358. */
  54359. mainTextureFixedSize?: number;
  54360. /**
  54361. * How big is the kernel of the blur texture.
  54362. */
  54363. blurKernelSize: number;
  54364. /**
  54365. * The camera attached to the layer.
  54366. */
  54367. camera: Nullable<Camera>;
  54368. /**
  54369. * Enable MSAA by chosing the number of samples.
  54370. */
  54371. mainTextureSamples?: number;
  54372. /**
  54373. * The rendering group to draw the layer in.
  54374. */
  54375. renderingGroupId: number;
  54376. }
  54377. /**
  54378. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  54379. *
  54380. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  54381. *
  54382. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  54383. */
  54384. export class GlowLayer extends EffectLayer {
  54385. /**
  54386. * Effect Name of the layer.
  54387. */
  54388. static readonly EffectName: string;
  54389. /**
  54390. * The default blur kernel size used for the glow.
  54391. */
  54392. static DefaultBlurKernelSize: number;
  54393. /**
  54394. * The default texture size ratio used for the glow.
  54395. */
  54396. static DefaultTextureRatio: number;
  54397. /**
  54398. * Sets the kernel size of the blur.
  54399. */
  54400. set blurKernelSize(value: number);
  54401. /**
  54402. * Gets the kernel size of the blur.
  54403. */
  54404. get blurKernelSize(): number;
  54405. /**
  54406. * Sets the glow intensity.
  54407. */
  54408. set intensity(value: number);
  54409. /**
  54410. * Gets the glow intensity.
  54411. */
  54412. get intensity(): number;
  54413. private _options;
  54414. private _intensity;
  54415. private _horizontalBlurPostprocess1;
  54416. private _verticalBlurPostprocess1;
  54417. private _horizontalBlurPostprocess2;
  54418. private _verticalBlurPostprocess2;
  54419. private _blurTexture1;
  54420. private _blurTexture2;
  54421. private _postProcesses1;
  54422. private _postProcesses2;
  54423. private _includedOnlyMeshes;
  54424. private _excludedMeshes;
  54425. private _meshesUsingTheirOwnMaterials;
  54426. /**
  54427. * Callback used to let the user override the color selection on a per mesh basis
  54428. */
  54429. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  54430. /**
  54431. * Callback used to let the user override the texture selection on a per mesh basis
  54432. */
  54433. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  54434. /**
  54435. * Instantiates a new glow Layer and references it to the scene.
  54436. * @param name The name of the layer
  54437. * @param scene The scene to use the layer in
  54438. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  54439. */
  54440. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  54441. /**
  54442. * Get the effect name of the layer.
  54443. * @return The effect name
  54444. */
  54445. getEffectName(): string;
  54446. /**
  54447. * Create the merge effect. This is the shader use to blit the information back
  54448. * to the main canvas at the end of the scene rendering.
  54449. */
  54450. protected _createMergeEffect(): Effect;
  54451. /**
  54452. * Creates the render target textures and post processes used in the glow layer.
  54453. */
  54454. protected _createTextureAndPostProcesses(): void;
  54455. /**
  54456. * Checks for the readiness of the element composing the layer.
  54457. * @param subMesh the mesh to check for
  54458. * @param useInstances specify wether or not to use instances to render the mesh
  54459. * @param emissiveTexture the associated emissive texture used to generate the glow
  54460. * @return true if ready otherwise, false
  54461. */
  54462. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54463. /**
  54464. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54465. */
  54466. needStencil(): boolean;
  54467. /**
  54468. * Returns true if the mesh can be rendered, otherwise false.
  54469. * @param mesh The mesh to render
  54470. * @param material The material used on the mesh
  54471. * @returns true if it can be rendered otherwise false
  54472. */
  54473. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54474. /**
  54475. * Implementation specific of rendering the generating effect on the main canvas.
  54476. * @param effect The effect used to render through
  54477. */
  54478. protected _internalRender(effect: Effect): void;
  54479. /**
  54480. * Sets the required values for both the emissive texture and and the main color.
  54481. */
  54482. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54483. /**
  54484. * Returns true if the mesh should render, otherwise false.
  54485. * @param mesh The mesh to render
  54486. * @returns true if it should render otherwise false
  54487. */
  54488. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54489. /**
  54490. * Adds specific effects defines.
  54491. * @param defines The defines to add specifics to.
  54492. */
  54493. protected _addCustomEffectDefines(defines: string[]): void;
  54494. /**
  54495. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54496. * @param mesh The mesh to exclude from the glow layer
  54497. */
  54498. addExcludedMesh(mesh: Mesh): void;
  54499. /**
  54500. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54501. * @param mesh The mesh to remove
  54502. */
  54503. removeExcludedMesh(mesh: Mesh): void;
  54504. /**
  54505. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54506. * @param mesh The mesh to include in the glow layer
  54507. */
  54508. addIncludedOnlyMesh(mesh: Mesh): void;
  54509. /**
  54510. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54511. * @param mesh The mesh to remove
  54512. */
  54513. removeIncludedOnlyMesh(mesh: Mesh): void;
  54514. /**
  54515. * Determine if a given mesh will be used in the glow layer
  54516. * @param mesh The mesh to test
  54517. * @returns true if the mesh will be highlighted by the current glow layer
  54518. */
  54519. hasMesh(mesh: AbstractMesh): boolean;
  54520. /**
  54521. * Defines wether the current material of the mesh should be use to render the effect.
  54522. * @param mesh defines the current mesh to render
  54523. */
  54524. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54525. /**
  54526. * Add a mesh to be rendered through its own material and not with emissive only.
  54527. * @param mesh The mesh for which we need to use its material
  54528. */
  54529. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54530. /**
  54531. * Remove a mesh from being rendered through its own material and not with emissive only.
  54532. * @param mesh The mesh for which we need to not use its material
  54533. */
  54534. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54535. /**
  54536. * Free any resources and references associated to a mesh.
  54537. * Internal use
  54538. * @param mesh The mesh to free.
  54539. * @hidden
  54540. */
  54541. _disposeMesh(mesh: Mesh): void;
  54542. /**
  54543. * Gets the class name of the effect layer
  54544. * @returns the string with the class name of the effect layer
  54545. */
  54546. getClassName(): string;
  54547. /**
  54548. * Serializes this glow layer
  54549. * @returns a serialized glow layer object
  54550. */
  54551. serialize(): any;
  54552. /**
  54553. * Creates a Glow Layer from parsed glow layer data
  54554. * @param parsedGlowLayer defines glow layer data
  54555. * @param scene defines the current scene
  54556. * @param rootUrl defines the root URL containing the glow layer information
  54557. * @returns a parsed Glow Layer
  54558. */
  54559. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54560. }
  54561. }
  54562. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  54563. /** @hidden */
  54564. export var glowBlurPostProcessPixelShader: {
  54565. name: string;
  54566. shader: string;
  54567. };
  54568. }
  54569. declare module "babylonjs/Layers/highlightLayer" {
  54570. import { Observable } from "babylonjs/Misc/observable";
  54571. import { Nullable } from "babylonjs/types";
  54572. import { Camera } from "babylonjs/Cameras/camera";
  54573. import { Scene } from "babylonjs/scene";
  54574. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54576. import { Mesh } from "babylonjs/Meshes/mesh";
  54577. import { Effect } from "babylonjs/Materials/effect";
  54578. import { Material } from "babylonjs/Materials/material";
  54579. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54580. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  54581. import "babylonjs/Shaders/glowMapMerge.fragment";
  54582. import "babylonjs/Shaders/glowMapMerge.vertex";
  54583. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  54584. module "babylonjs/abstractScene" {
  54585. interface AbstractScene {
  54586. /**
  54587. * Return a the first highlight layer of the scene with a given name.
  54588. * @param name The name of the highlight layer to look for.
  54589. * @return The highlight layer if found otherwise null.
  54590. */
  54591. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54592. }
  54593. }
  54594. /**
  54595. * Highlight layer options. This helps customizing the behaviour
  54596. * of the highlight layer.
  54597. */
  54598. export interface IHighlightLayerOptions {
  54599. /**
  54600. * Multiplication factor apply to the canvas size to compute the render target size
  54601. * used to generated the glowing objects (the smaller the faster).
  54602. */
  54603. mainTextureRatio: number;
  54604. /**
  54605. * Enforces a fixed size texture to ensure resize independant blur.
  54606. */
  54607. mainTextureFixedSize?: number;
  54608. /**
  54609. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54610. * of the picture to blur (the smaller the faster).
  54611. */
  54612. blurTextureSizeRatio: number;
  54613. /**
  54614. * How big in texel of the blur texture is the vertical blur.
  54615. */
  54616. blurVerticalSize: number;
  54617. /**
  54618. * How big in texel of the blur texture is the horizontal blur.
  54619. */
  54620. blurHorizontalSize: number;
  54621. /**
  54622. * Alpha blending mode used to apply the blur. Default is combine.
  54623. */
  54624. alphaBlendingMode: number;
  54625. /**
  54626. * The camera attached to the layer.
  54627. */
  54628. camera: Nullable<Camera>;
  54629. /**
  54630. * Should we display highlight as a solid stroke?
  54631. */
  54632. isStroke?: boolean;
  54633. /**
  54634. * The rendering group to draw the layer in.
  54635. */
  54636. renderingGroupId: number;
  54637. }
  54638. /**
  54639. * The highlight layer Helps adding a glow effect around a mesh.
  54640. *
  54641. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54642. * glowy meshes to your scene.
  54643. *
  54644. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54645. */
  54646. export class HighlightLayer extends EffectLayer {
  54647. name: string;
  54648. /**
  54649. * Effect Name of the highlight layer.
  54650. */
  54651. static readonly EffectName: string;
  54652. /**
  54653. * The neutral color used during the preparation of the glow effect.
  54654. * This is black by default as the blend operation is a blend operation.
  54655. */
  54656. static NeutralColor: Color4;
  54657. /**
  54658. * Stencil value used for glowing meshes.
  54659. */
  54660. static GlowingMeshStencilReference: number;
  54661. /**
  54662. * Stencil value used for the other meshes in the scene.
  54663. */
  54664. static NormalMeshStencilReference: number;
  54665. /**
  54666. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54667. */
  54668. innerGlow: boolean;
  54669. /**
  54670. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54671. */
  54672. outerGlow: boolean;
  54673. /**
  54674. * Specifies the horizontal size of the blur.
  54675. */
  54676. set blurHorizontalSize(value: number);
  54677. /**
  54678. * Specifies the vertical size of the blur.
  54679. */
  54680. set blurVerticalSize(value: number);
  54681. /**
  54682. * Gets the horizontal size of the blur.
  54683. */
  54684. get blurHorizontalSize(): number;
  54685. /**
  54686. * Gets the vertical size of the blur.
  54687. */
  54688. get blurVerticalSize(): number;
  54689. /**
  54690. * An event triggered when the highlight layer is being blurred.
  54691. */
  54692. onBeforeBlurObservable: Observable<HighlightLayer>;
  54693. /**
  54694. * An event triggered when the highlight layer has been blurred.
  54695. */
  54696. onAfterBlurObservable: Observable<HighlightLayer>;
  54697. private _instanceGlowingMeshStencilReference;
  54698. private _options;
  54699. private _downSamplePostprocess;
  54700. private _horizontalBlurPostprocess;
  54701. private _verticalBlurPostprocess;
  54702. private _blurTexture;
  54703. private _meshes;
  54704. private _excludedMeshes;
  54705. /**
  54706. * Instantiates a new highlight Layer and references it to the scene..
  54707. * @param name The name of the layer
  54708. * @param scene The scene to use the layer in
  54709. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54710. */
  54711. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54712. /**
  54713. * Get the effect name of the layer.
  54714. * @return The effect name
  54715. */
  54716. getEffectName(): string;
  54717. /**
  54718. * Create the merge effect. This is the shader use to blit the information back
  54719. * to the main canvas at the end of the scene rendering.
  54720. */
  54721. protected _createMergeEffect(): Effect;
  54722. /**
  54723. * Creates the render target textures and post processes used in the highlight layer.
  54724. */
  54725. protected _createTextureAndPostProcesses(): void;
  54726. /**
  54727. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54728. */
  54729. needStencil(): boolean;
  54730. /**
  54731. * Checks for the readiness of the element composing the layer.
  54732. * @param subMesh the mesh to check for
  54733. * @param useInstances specify wether or not to use instances to render the mesh
  54734. * @param emissiveTexture the associated emissive texture used to generate the glow
  54735. * @return true if ready otherwise, false
  54736. */
  54737. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54738. /**
  54739. * Implementation specific of rendering the generating effect on the main canvas.
  54740. * @param effect The effect used to render through
  54741. */
  54742. protected _internalRender(effect: Effect): void;
  54743. /**
  54744. * Returns true if the layer contains information to display, otherwise false.
  54745. */
  54746. shouldRender(): boolean;
  54747. /**
  54748. * Returns true if the mesh should render, otherwise false.
  54749. * @param mesh The mesh to render
  54750. * @returns true if it should render otherwise false
  54751. */
  54752. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54753. /**
  54754. * Sets the required values for both the emissive texture and and the main color.
  54755. */
  54756. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54757. /**
  54758. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54759. * @param mesh The mesh to exclude from the highlight layer
  54760. */
  54761. addExcludedMesh(mesh: Mesh): void;
  54762. /**
  54763. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54764. * @param mesh The mesh to highlight
  54765. */
  54766. removeExcludedMesh(mesh: Mesh): void;
  54767. /**
  54768. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54769. * @param mesh mesh to test
  54770. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54771. */
  54772. hasMesh(mesh: AbstractMesh): boolean;
  54773. /**
  54774. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54775. * @param mesh The mesh to highlight
  54776. * @param color The color of the highlight
  54777. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54778. */
  54779. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54780. /**
  54781. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54782. * @param mesh The mesh to highlight
  54783. */
  54784. removeMesh(mesh: Mesh): void;
  54785. /**
  54786. * Force the stencil to the normal expected value for none glowing parts
  54787. */
  54788. private _defaultStencilReference;
  54789. /**
  54790. * Free any resources and references associated to a mesh.
  54791. * Internal use
  54792. * @param mesh The mesh to free.
  54793. * @hidden
  54794. */
  54795. _disposeMesh(mesh: Mesh): void;
  54796. /**
  54797. * Dispose the highlight layer and free resources.
  54798. */
  54799. dispose(): void;
  54800. /**
  54801. * Gets the class name of the effect layer
  54802. * @returns the string with the class name of the effect layer
  54803. */
  54804. getClassName(): string;
  54805. /**
  54806. * Serializes this Highlight layer
  54807. * @returns a serialized Highlight layer object
  54808. */
  54809. serialize(): any;
  54810. /**
  54811. * Creates a Highlight layer from parsed Highlight layer data
  54812. * @param parsedHightlightLayer defines the Highlight layer data
  54813. * @param scene defines the current scene
  54814. * @param rootUrl defines the root URL containing the Highlight layer information
  54815. * @returns a parsed Highlight layer
  54816. */
  54817. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54818. }
  54819. }
  54820. declare module "babylonjs/Layers/layerSceneComponent" {
  54821. import { Scene } from "babylonjs/scene";
  54822. import { ISceneComponent } from "babylonjs/sceneComponent";
  54823. import { Layer } from "babylonjs/Layers/layer";
  54824. import { AbstractScene } from "babylonjs/abstractScene";
  54825. module "babylonjs/abstractScene" {
  54826. interface AbstractScene {
  54827. /**
  54828. * The list of layers (background and foreground) of the scene
  54829. */
  54830. layers: Array<Layer>;
  54831. }
  54832. }
  54833. /**
  54834. * Defines the layer scene component responsible to manage any layers
  54835. * in a given scene.
  54836. */
  54837. export class LayerSceneComponent implements ISceneComponent {
  54838. /**
  54839. * The component name helpfull to identify the component in the list of scene components.
  54840. */
  54841. readonly name: string;
  54842. /**
  54843. * The scene the component belongs to.
  54844. */
  54845. scene: Scene;
  54846. private _engine;
  54847. /**
  54848. * Creates a new instance of the component for the given scene
  54849. * @param scene Defines the scene to register the component in
  54850. */
  54851. constructor(scene: Scene);
  54852. /**
  54853. * Registers the component in a given scene
  54854. */
  54855. register(): void;
  54856. /**
  54857. * Rebuilds the elements related to this component in case of
  54858. * context lost for instance.
  54859. */
  54860. rebuild(): void;
  54861. /**
  54862. * Disposes the component and the associated ressources.
  54863. */
  54864. dispose(): void;
  54865. private _draw;
  54866. private _drawCameraPredicate;
  54867. private _drawCameraBackground;
  54868. private _drawCameraForeground;
  54869. private _drawRenderTargetPredicate;
  54870. private _drawRenderTargetBackground;
  54871. private _drawRenderTargetForeground;
  54872. /**
  54873. * Adds all the elements from the container to the scene
  54874. * @param container the container holding the elements
  54875. */
  54876. addFromContainer(container: AbstractScene): void;
  54877. /**
  54878. * Removes all the elements in the container from the scene
  54879. * @param container contains the elements to remove
  54880. * @param dispose if the removed element should be disposed (default: false)
  54881. */
  54882. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54883. }
  54884. }
  54885. declare module "babylonjs/Shaders/layer.fragment" {
  54886. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54887. /** @hidden */
  54888. export var layerPixelShader: {
  54889. name: string;
  54890. shader: string;
  54891. };
  54892. }
  54893. declare module "babylonjs/Shaders/layer.vertex" {
  54894. /** @hidden */
  54895. export var layerVertexShader: {
  54896. name: string;
  54897. shader: string;
  54898. };
  54899. }
  54900. declare module "babylonjs/Layers/layer" {
  54901. import { Observable } from "babylonjs/Misc/observable";
  54902. import { Nullable } from "babylonjs/types";
  54903. import { Scene } from "babylonjs/scene";
  54904. import { Vector2 } from "babylonjs/Maths/math.vector";
  54905. import { Color4 } from "babylonjs/Maths/math.color";
  54906. import { Texture } from "babylonjs/Materials/Textures/texture";
  54907. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54908. import "babylonjs/Shaders/layer.fragment";
  54909. import "babylonjs/Shaders/layer.vertex";
  54910. /**
  54911. * This represents a full screen 2d layer.
  54912. * This can be useful to display a picture in the background of your scene for instance.
  54913. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54914. */
  54915. export class Layer {
  54916. /**
  54917. * Define the name of the layer.
  54918. */
  54919. name: string;
  54920. /**
  54921. * Define the texture the layer should display.
  54922. */
  54923. texture: Nullable<Texture>;
  54924. /**
  54925. * Is the layer in background or foreground.
  54926. */
  54927. isBackground: boolean;
  54928. /**
  54929. * Define the color of the layer (instead of texture).
  54930. */
  54931. color: Color4;
  54932. /**
  54933. * Define the scale of the layer in order to zoom in out of the texture.
  54934. */
  54935. scale: Vector2;
  54936. /**
  54937. * Define an offset for the layer in order to shift the texture.
  54938. */
  54939. offset: Vector2;
  54940. /**
  54941. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54942. */
  54943. alphaBlendingMode: number;
  54944. /**
  54945. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54946. * Alpha test will not mix with the background color in case of transparency.
  54947. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54948. */
  54949. alphaTest: boolean;
  54950. /**
  54951. * Define a mask to restrict the layer to only some of the scene cameras.
  54952. */
  54953. layerMask: number;
  54954. /**
  54955. * Define the list of render target the layer is visible into.
  54956. */
  54957. renderTargetTextures: RenderTargetTexture[];
  54958. /**
  54959. * Define if the layer is only used in renderTarget or if it also
  54960. * renders in the main frame buffer of the canvas.
  54961. */
  54962. renderOnlyInRenderTargetTextures: boolean;
  54963. private _scene;
  54964. private _vertexBuffers;
  54965. private _indexBuffer;
  54966. private _effect;
  54967. private _previousDefines;
  54968. /**
  54969. * An event triggered when the layer is disposed.
  54970. */
  54971. onDisposeObservable: Observable<Layer>;
  54972. private _onDisposeObserver;
  54973. /**
  54974. * Back compatibility with callback before the onDisposeObservable existed.
  54975. * The set callback will be triggered when the layer has been disposed.
  54976. */
  54977. set onDispose(callback: () => void);
  54978. /**
  54979. * An event triggered before rendering the scene
  54980. */
  54981. onBeforeRenderObservable: Observable<Layer>;
  54982. private _onBeforeRenderObserver;
  54983. /**
  54984. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54985. * The set callback will be triggered just before rendering the layer.
  54986. */
  54987. set onBeforeRender(callback: () => void);
  54988. /**
  54989. * An event triggered after rendering the scene
  54990. */
  54991. onAfterRenderObservable: Observable<Layer>;
  54992. private _onAfterRenderObserver;
  54993. /**
  54994. * Back compatibility with callback before the onAfterRenderObservable existed.
  54995. * The set callback will be triggered just after rendering the layer.
  54996. */
  54997. set onAfterRender(callback: () => void);
  54998. /**
  54999. * Instantiates a new layer.
  55000. * This represents a full screen 2d layer.
  55001. * This can be useful to display a picture in the background of your scene for instance.
  55002. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55003. * @param name Define the name of the layer in the scene
  55004. * @param imgUrl Define the url of the texture to display in the layer
  55005. * @param scene Define the scene the layer belongs to
  55006. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55007. * @param color Defines a color for the layer
  55008. */
  55009. constructor(
  55010. /**
  55011. * Define the name of the layer.
  55012. */
  55013. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55014. private _createIndexBuffer;
  55015. /** @hidden */
  55016. _rebuild(): void;
  55017. /**
  55018. * Renders the layer in the scene.
  55019. */
  55020. render(): void;
  55021. /**
  55022. * Disposes and releases the associated ressources.
  55023. */
  55024. dispose(): void;
  55025. }
  55026. }
  55027. declare module "babylonjs/Layers/index" {
  55028. export * from "babylonjs/Layers/effectLayer";
  55029. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55030. export * from "babylonjs/Layers/glowLayer";
  55031. export * from "babylonjs/Layers/highlightLayer";
  55032. export * from "babylonjs/Layers/layer";
  55033. export * from "babylonjs/Layers/layerSceneComponent";
  55034. }
  55035. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55036. /** @hidden */
  55037. export var lensFlarePixelShader: {
  55038. name: string;
  55039. shader: string;
  55040. };
  55041. }
  55042. declare module "babylonjs/Shaders/lensFlare.vertex" {
  55043. /** @hidden */
  55044. export var lensFlareVertexShader: {
  55045. name: string;
  55046. shader: string;
  55047. };
  55048. }
  55049. declare module "babylonjs/LensFlares/lensFlareSystem" {
  55050. import { Scene } from "babylonjs/scene";
  55051. import { Vector3 } from "babylonjs/Maths/math.vector";
  55052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55053. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  55054. import "babylonjs/Shaders/lensFlare.fragment";
  55055. import "babylonjs/Shaders/lensFlare.vertex";
  55056. import { Viewport } from "babylonjs/Maths/math.viewport";
  55057. /**
  55058. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55059. * It is usually composed of several `lensFlare`.
  55060. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55061. */
  55062. export class LensFlareSystem {
  55063. /**
  55064. * Define the name of the lens flare system
  55065. */
  55066. name: string;
  55067. /**
  55068. * List of lens flares used in this system.
  55069. */
  55070. lensFlares: LensFlare[];
  55071. /**
  55072. * Define a limit from the border the lens flare can be visible.
  55073. */
  55074. borderLimit: number;
  55075. /**
  55076. * Define a viewport border we do not want to see the lens flare in.
  55077. */
  55078. viewportBorder: number;
  55079. /**
  55080. * Define a predicate which could limit the list of meshes able to occlude the effect.
  55081. */
  55082. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55083. /**
  55084. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  55085. */
  55086. layerMask: number;
  55087. /**
  55088. * Define the id of the lens flare system in the scene.
  55089. * (equal to name by default)
  55090. */
  55091. id: string;
  55092. private _scene;
  55093. private _emitter;
  55094. private _vertexBuffers;
  55095. private _indexBuffer;
  55096. private _effect;
  55097. private _positionX;
  55098. private _positionY;
  55099. private _isEnabled;
  55100. /** @hidden */
  55101. static _SceneComponentInitialization: (scene: Scene) => void;
  55102. /**
  55103. * Instantiates a lens flare system.
  55104. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55105. * It is usually composed of several `lensFlare`.
  55106. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55107. * @param name Define the name of the lens flare system in the scene
  55108. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55109. * @param scene Define the scene the lens flare system belongs to
  55110. */
  55111. constructor(
  55112. /**
  55113. * Define the name of the lens flare system
  55114. */
  55115. name: string, emitter: any, scene: Scene);
  55116. /**
  55117. * Define if the lens flare system is enabled.
  55118. */
  55119. get isEnabled(): boolean;
  55120. set isEnabled(value: boolean);
  55121. /**
  55122. * Get the scene the effects belongs to.
  55123. * @returns the scene holding the lens flare system
  55124. */
  55125. getScene(): Scene;
  55126. /**
  55127. * Get the emitter of the lens flare system.
  55128. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55129. * @returns the emitter of the lens flare system
  55130. */
  55131. getEmitter(): any;
  55132. /**
  55133. * Set the emitter of the lens flare system.
  55134. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55135. * @param newEmitter Define the new emitter of the system
  55136. */
  55137. setEmitter(newEmitter: any): void;
  55138. /**
  55139. * Get the lens flare system emitter position.
  55140. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55141. * @returns the position
  55142. */
  55143. getEmitterPosition(): Vector3;
  55144. /**
  55145. * @hidden
  55146. */
  55147. computeEffectivePosition(globalViewport: Viewport): boolean;
  55148. /** @hidden */
  55149. _isVisible(): boolean;
  55150. /**
  55151. * @hidden
  55152. */
  55153. render(): boolean;
  55154. /**
  55155. * Dispose and release the lens flare with its associated resources.
  55156. */
  55157. dispose(): void;
  55158. /**
  55159. * Parse a lens flare system from a JSON repressentation
  55160. * @param parsedLensFlareSystem Define the JSON to parse
  55161. * @param scene Define the scene the parsed system should be instantiated in
  55162. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  55163. * @returns the parsed system
  55164. */
  55165. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  55166. /**
  55167. * Serialize the current Lens Flare System into a JSON representation.
  55168. * @returns the serialized JSON
  55169. */
  55170. serialize(): any;
  55171. }
  55172. }
  55173. declare module "babylonjs/LensFlares/lensFlare" {
  55174. import { Nullable } from "babylonjs/types";
  55175. import { Color3 } from "babylonjs/Maths/math.color";
  55176. import { Texture } from "babylonjs/Materials/Textures/texture";
  55177. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55178. /**
  55179. * This represents one of the lens effect in a `lensFlareSystem`.
  55180. * It controls one of the indiviual texture used in the effect.
  55181. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55182. */
  55183. export class LensFlare {
  55184. /**
  55185. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55186. */
  55187. size: number;
  55188. /**
  55189. * 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.
  55190. */
  55191. position: number;
  55192. /**
  55193. * Define the lens color.
  55194. */
  55195. color: Color3;
  55196. /**
  55197. * Define the lens texture.
  55198. */
  55199. texture: Nullable<Texture>;
  55200. /**
  55201. * Define the alpha mode to render this particular lens.
  55202. */
  55203. alphaMode: number;
  55204. private _system;
  55205. /**
  55206. * Creates a new Lens Flare.
  55207. * This represents one of the lens effect in a `lensFlareSystem`.
  55208. * It controls one of the indiviual texture used in the effect.
  55209. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55210. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  55211. * @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.
  55212. * @param color Define the lens color
  55213. * @param imgUrl Define the lens texture url
  55214. * @param system Define the `lensFlareSystem` this flare is part of
  55215. * @returns The newly created Lens Flare
  55216. */
  55217. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  55218. /**
  55219. * Instantiates a new Lens Flare.
  55220. * This represents one of the lens effect in a `lensFlareSystem`.
  55221. * It controls one of the indiviual texture used in the effect.
  55222. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55223. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  55224. * @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.
  55225. * @param color Define the lens color
  55226. * @param imgUrl Define the lens texture url
  55227. * @param system Define the `lensFlareSystem` this flare is part of
  55228. */
  55229. constructor(
  55230. /**
  55231. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55232. */
  55233. size: number,
  55234. /**
  55235. * 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.
  55236. */
  55237. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  55238. /**
  55239. * Dispose and release the lens flare with its associated resources.
  55240. */
  55241. dispose(): void;
  55242. }
  55243. }
  55244. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  55245. import { Nullable } from "babylonjs/types";
  55246. import { Scene } from "babylonjs/scene";
  55247. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55248. import { AbstractScene } from "babylonjs/abstractScene";
  55249. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55250. module "babylonjs/abstractScene" {
  55251. interface AbstractScene {
  55252. /**
  55253. * The list of lens flare system added to the scene
  55254. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55255. */
  55256. lensFlareSystems: Array<LensFlareSystem>;
  55257. /**
  55258. * Removes the given lens flare system from this scene.
  55259. * @param toRemove The lens flare system to remove
  55260. * @returns The index of the removed lens flare system
  55261. */
  55262. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  55263. /**
  55264. * Adds the given lens flare system to this scene
  55265. * @param newLensFlareSystem The lens flare system to add
  55266. */
  55267. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  55268. /**
  55269. * Gets a lens flare system using its name
  55270. * @param name defines the name to look for
  55271. * @returns the lens flare system or null if not found
  55272. */
  55273. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  55274. /**
  55275. * Gets a lens flare system using its id
  55276. * @param id defines the id to look for
  55277. * @returns the lens flare system or null if not found
  55278. */
  55279. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  55280. }
  55281. }
  55282. /**
  55283. * Defines the lens flare scene component responsible to manage any lens flares
  55284. * in a given scene.
  55285. */
  55286. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  55287. /**
  55288. * The component name helpfull to identify the component in the list of scene components.
  55289. */
  55290. readonly name: string;
  55291. /**
  55292. * The scene the component belongs to.
  55293. */
  55294. scene: Scene;
  55295. /**
  55296. * Creates a new instance of the component for the given scene
  55297. * @param scene Defines the scene to register the component in
  55298. */
  55299. constructor(scene: Scene);
  55300. /**
  55301. * Registers the component in a given scene
  55302. */
  55303. register(): void;
  55304. /**
  55305. * Rebuilds the elements related to this component in case of
  55306. * context lost for instance.
  55307. */
  55308. rebuild(): void;
  55309. /**
  55310. * Adds all the elements from the container to the scene
  55311. * @param container the container holding the elements
  55312. */
  55313. addFromContainer(container: AbstractScene): void;
  55314. /**
  55315. * Removes all the elements in the container from the scene
  55316. * @param container contains the elements to remove
  55317. * @param dispose if the removed element should be disposed (default: false)
  55318. */
  55319. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55320. /**
  55321. * Serializes the component data to the specified json object
  55322. * @param serializationObject The object to serialize to
  55323. */
  55324. serialize(serializationObject: any): void;
  55325. /**
  55326. * Disposes the component and the associated ressources.
  55327. */
  55328. dispose(): void;
  55329. private _draw;
  55330. }
  55331. }
  55332. declare module "babylonjs/LensFlares/index" {
  55333. export * from "babylonjs/LensFlares/lensFlare";
  55334. export * from "babylonjs/LensFlares/lensFlareSystem";
  55335. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  55336. }
  55337. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  55338. import { Scene } from "babylonjs/scene";
  55339. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55340. import { AbstractScene } from "babylonjs/abstractScene";
  55341. /**
  55342. * Defines the shadow generator component responsible to manage any shadow generators
  55343. * in a given scene.
  55344. */
  55345. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55346. /**
  55347. * The component name helpfull to identify the component in the list of scene components.
  55348. */
  55349. readonly name: string;
  55350. /**
  55351. * The scene the component belongs to.
  55352. */
  55353. scene: Scene;
  55354. /**
  55355. * Creates a new instance of the component for the given scene
  55356. * @param scene Defines the scene to register the component in
  55357. */
  55358. constructor(scene: Scene);
  55359. /**
  55360. * Registers the component in a given scene
  55361. */
  55362. register(): void;
  55363. /**
  55364. * Rebuilds the elements related to this component in case of
  55365. * context lost for instance.
  55366. */
  55367. rebuild(): void;
  55368. /**
  55369. * Serializes the component data to the specified json object
  55370. * @param serializationObject The object to serialize to
  55371. */
  55372. serialize(serializationObject: any): void;
  55373. /**
  55374. * Adds all the elements from the container to the scene
  55375. * @param container the container holding the elements
  55376. */
  55377. addFromContainer(container: AbstractScene): void;
  55378. /**
  55379. * Removes all the elements in the container from the scene
  55380. * @param container contains the elements to remove
  55381. * @param dispose if the removed element should be disposed (default: false)
  55382. */
  55383. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55384. /**
  55385. * Rebuilds the elements related to this component in case of
  55386. * context lost for instance.
  55387. */
  55388. dispose(): void;
  55389. private _gatherRenderTargets;
  55390. }
  55391. }
  55392. declare module "babylonjs/Lights/Shadows/index" {
  55393. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  55394. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  55395. }
  55396. declare module "babylonjs/Lights/pointLight" {
  55397. import { Scene } from "babylonjs/scene";
  55398. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55400. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55401. import { Effect } from "babylonjs/Materials/effect";
  55402. /**
  55403. * A point light is a light defined by an unique point in world space.
  55404. * The light is emitted in every direction from this point.
  55405. * A good example of a point light is a standard light bulb.
  55406. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55407. */
  55408. export class PointLight extends ShadowLight {
  55409. private _shadowAngle;
  55410. /**
  55411. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55412. * This specifies what angle the shadow will use to be created.
  55413. *
  55414. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55415. */
  55416. get shadowAngle(): number;
  55417. /**
  55418. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55419. * This specifies what angle the shadow will use to be created.
  55420. *
  55421. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55422. */
  55423. set shadowAngle(value: number);
  55424. /**
  55425. * Gets the direction if it has been set.
  55426. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55427. */
  55428. get direction(): Vector3;
  55429. /**
  55430. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55431. */
  55432. set direction(value: Vector3);
  55433. /**
  55434. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55435. * A PointLight emits the light in every direction.
  55436. * It can cast shadows.
  55437. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55438. * ```javascript
  55439. * var pointLight = new PointLight("pl", camera.position, scene);
  55440. * ```
  55441. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55442. * @param name The light friendly name
  55443. * @param position The position of the point light in the scene
  55444. * @param scene The scene the lights belongs to
  55445. */
  55446. constructor(name: string, position: Vector3, scene: Scene);
  55447. /**
  55448. * Returns the string "PointLight"
  55449. * @returns the class name
  55450. */
  55451. getClassName(): string;
  55452. /**
  55453. * Returns the integer 0.
  55454. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55455. */
  55456. getTypeID(): number;
  55457. /**
  55458. * Specifies wether or not the shadowmap should be a cube texture.
  55459. * @returns true if the shadowmap needs to be a cube texture.
  55460. */
  55461. needCube(): boolean;
  55462. /**
  55463. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55464. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55465. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55466. */
  55467. getShadowDirection(faceIndex?: number): Vector3;
  55468. /**
  55469. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55470. * - fov = PI / 2
  55471. * - aspect ratio : 1.0
  55472. * - z-near and far equal to the active camera minZ and maxZ.
  55473. * Returns the PointLight.
  55474. */
  55475. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55476. protected _buildUniformLayout(): void;
  55477. /**
  55478. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55479. * @param effect The effect to update
  55480. * @param lightIndex The index of the light in the effect to update
  55481. * @returns The point light
  55482. */
  55483. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55484. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55485. /**
  55486. * Prepares the list of defines specific to the light type.
  55487. * @param defines the list of defines
  55488. * @param lightIndex defines the index of the light for the effect
  55489. */
  55490. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55491. }
  55492. }
  55493. declare module "babylonjs/Lights/index" {
  55494. export * from "babylonjs/Lights/light";
  55495. export * from "babylonjs/Lights/shadowLight";
  55496. export * from "babylonjs/Lights/Shadows/index";
  55497. export * from "babylonjs/Lights/directionalLight";
  55498. export * from "babylonjs/Lights/hemisphericLight";
  55499. export * from "babylonjs/Lights/pointLight";
  55500. export * from "babylonjs/Lights/spotLight";
  55501. }
  55502. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  55503. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55504. /**
  55505. * Header information of HDR texture files.
  55506. */
  55507. export interface HDRInfo {
  55508. /**
  55509. * The height of the texture in pixels.
  55510. */
  55511. height: number;
  55512. /**
  55513. * The width of the texture in pixels.
  55514. */
  55515. width: number;
  55516. /**
  55517. * The index of the beginning of the data in the binary file.
  55518. */
  55519. dataPosition: number;
  55520. }
  55521. /**
  55522. * This groups tools to convert HDR texture to native colors array.
  55523. */
  55524. export class HDRTools {
  55525. private static Ldexp;
  55526. private static Rgbe2float;
  55527. private static readStringLine;
  55528. /**
  55529. * Reads header information from an RGBE texture stored in a native array.
  55530. * More information on this format are available here:
  55531. * https://en.wikipedia.org/wiki/RGBE_image_format
  55532. *
  55533. * @param uint8array The binary file stored in native array.
  55534. * @return The header information.
  55535. */
  55536. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55537. /**
  55538. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55539. * This RGBE texture needs to store the information as a panorama.
  55540. *
  55541. * More information on this format are available here:
  55542. * https://en.wikipedia.org/wiki/RGBE_image_format
  55543. *
  55544. * @param buffer The binary file stored in an array buffer.
  55545. * @param size The expected size of the extracted cubemap.
  55546. * @return The Cube Map information.
  55547. */
  55548. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55549. /**
  55550. * Returns the pixels data extracted from an RGBE texture.
  55551. * This pixels will be stored left to right up to down in the R G B order in one array.
  55552. *
  55553. * More information on this format are available here:
  55554. * https://en.wikipedia.org/wiki/RGBE_image_format
  55555. *
  55556. * @param uint8array The binary file stored in an array buffer.
  55557. * @param hdrInfo The header information of the file.
  55558. * @return The pixels data in RGB right to left up to down order.
  55559. */
  55560. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55561. private static RGBE_ReadPixels_RLE;
  55562. }
  55563. }
  55564. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  55565. import { Nullable } from "babylonjs/types";
  55566. import { Scene } from "babylonjs/scene";
  55567. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55568. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55569. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55570. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  55571. /**
  55572. * This represents a texture coming from an HDR input.
  55573. *
  55574. * The only supported format is currently panorama picture stored in RGBE format.
  55575. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55576. */
  55577. export class HDRCubeTexture extends BaseTexture {
  55578. private static _facesMapping;
  55579. private _generateHarmonics;
  55580. private _noMipmap;
  55581. private _textureMatrix;
  55582. private _size;
  55583. private _onLoad;
  55584. private _onError;
  55585. /**
  55586. * The texture URL.
  55587. */
  55588. url: string;
  55589. /**
  55590. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55591. */
  55592. coordinatesMode: number;
  55593. protected _isBlocking: boolean;
  55594. /**
  55595. * Sets wether or not the texture is blocking during loading.
  55596. */
  55597. set isBlocking(value: boolean);
  55598. /**
  55599. * Gets wether or not the texture is blocking during loading.
  55600. */
  55601. get isBlocking(): boolean;
  55602. protected _rotationY: number;
  55603. /**
  55604. * Sets texture matrix rotation angle around Y axis in radians.
  55605. */
  55606. set rotationY(value: number);
  55607. /**
  55608. * Gets texture matrix rotation angle around Y axis radians.
  55609. */
  55610. get rotationY(): number;
  55611. /**
  55612. * Gets or sets the center of the bounding box associated with the cube texture
  55613. * It must define where the camera used to render the texture was set
  55614. */
  55615. boundingBoxPosition: Vector3;
  55616. private _boundingBoxSize;
  55617. /**
  55618. * Gets or sets the size of the bounding box associated with the cube texture
  55619. * When defined, the cubemap will switch to local mode
  55620. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55621. * @example https://www.babylonjs-playground.com/#RNASML
  55622. */
  55623. set boundingBoxSize(value: Vector3);
  55624. get boundingBoxSize(): Vector3;
  55625. /**
  55626. * Instantiates an HDRTexture from the following parameters.
  55627. *
  55628. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55629. * @param scene The scene the texture will be used in
  55630. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55631. * @param noMipmap Forces to not generate the mipmap if true
  55632. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55633. * @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)
  55634. * @param reserved Reserved flag for internal use.
  55635. */
  55636. 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>);
  55637. /**
  55638. * Get the current class name of the texture useful for serialization or dynamic coding.
  55639. * @returns "HDRCubeTexture"
  55640. */
  55641. getClassName(): string;
  55642. /**
  55643. * Occurs when the file is raw .hdr file.
  55644. */
  55645. private loadTexture;
  55646. clone(): HDRCubeTexture;
  55647. delayLoad(): void;
  55648. /**
  55649. * Get the texture reflection matrix used to rotate/transform the reflection.
  55650. * @returns the reflection matrix
  55651. */
  55652. getReflectionTextureMatrix(): Matrix;
  55653. /**
  55654. * Set the texture reflection matrix used to rotate/transform the reflection.
  55655. * @param value Define the reflection matrix to set
  55656. */
  55657. setReflectionTextureMatrix(value: Matrix): void;
  55658. /**
  55659. * Parses a JSON representation of an HDR Texture in order to create the texture
  55660. * @param parsedTexture Define the JSON representation
  55661. * @param scene Define the scene the texture should be created in
  55662. * @param rootUrl Define the root url in case we need to load relative dependencies
  55663. * @returns the newly created texture after parsing
  55664. */
  55665. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55666. serialize(): any;
  55667. }
  55668. }
  55669. declare module "babylonjs/Physics/physicsEngine" {
  55670. import { Nullable } from "babylonjs/types";
  55671. import { Vector3 } from "babylonjs/Maths/math.vector";
  55672. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  55673. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  55674. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  55675. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55676. /**
  55677. * Class used to control physics engine
  55678. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55679. */
  55680. export class PhysicsEngine implements IPhysicsEngine {
  55681. private _physicsPlugin;
  55682. /**
  55683. * Global value used to control the smallest number supported by the simulation
  55684. */
  55685. static Epsilon: number;
  55686. private _impostors;
  55687. private _joints;
  55688. private _subTimeStep;
  55689. /**
  55690. * Gets the gravity vector used by the simulation
  55691. */
  55692. gravity: Vector3;
  55693. /**
  55694. * Factory used to create the default physics plugin.
  55695. * @returns The default physics plugin
  55696. */
  55697. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55698. /**
  55699. * Creates a new Physics Engine
  55700. * @param gravity defines the gravity vector used by the simulation
  55701. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55702. */
  55703. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55704. /**
  55705. * Sets the gravity vector used by the simulation
  55706. * @param gravity defines the gravity vector to use
  55707. */
  55708. setGravity(gravity: Vector3): void;
  55709. /**
  55710. * Set the time step of the physics engine.
  55711. * Default is 1/60.
  55712. * To slow it down, enter 1/600 for example.
  55713. * To speed it up, 1/30
  55714. * @param newTimeStep defines the new timestep to apply to this world.
  55715. */
  55716. setTimeStep(newTimeStep?: number): void;
  55717. /**
  55718. * Get the time step of the physics engine.
  55719. * @returns the current time step
  55720. */
  55721. getTimeStep(): number;
  55722. /**
  55723. * Set the sub time step of the physics engine.
  55724. * Default is 0 meaning there is no sub steps
  55725. * To increase physics resolution precision, set a small value (like 1 ms)
  55726. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55727. */
  55728. setSubTimeStep(subTimeStep?: number): void;
  55729. /**
  55730. * Get the sub time step of the physics engine.
  55731. * @returns the current sub time step
  55732. */
  55733. getSubTimeStep(): number;
  55734. /**
  55735. * Release all resources
  55736. */
  55737. dispose(): void;
  55738. /**
  55739. * Gets the name of the current physics plugin
  55740. * @returns the name of the plugin
  55741. */
  55742. getPhysicsPluginName(): string;
  55743. /**
  55744. * Adding a new impostor for the impostor tracking.
  55745. * This will be done by the impostor itself.
  55746. * @param impostor the impostor to add
  55747. */
  55748. addImpostor(impostor: PhysicsImpostor): void;
  55749. /**
  55750. * Remove an impostor from the engine.
  55751. * This impostor and its mesh will not longer be updated by the physics engine.
  55752. * @param impostor the impostor to remove
  55753. */
  55754. removeImpostor(impostor: PhysicsImpostor): void;
  55755. /**
  55756. * Add a joint to the physics engine
  55757. * @param mainImpostor defines the main impostor to which the joint is added.
  55758. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55759. * @param joint defines the joint that will connect both impostors.
  55760. */
  55761. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55762. /**
  55763. * Removes a joint from the simulation
  55764. * @param mainImpostor defines the impostor used with the joint
  55765. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55766. * @param joint defines the joint to remove
  55767. */
  55768. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55769. /**
  55770. * Called by the scene. No need to call it.
  55771. * @param delta defines the timespam between frames
  55772. */
  55773. _step(delta: number): void;
  55774. /**
  55775. * Gets the current plugin used to run the simulation
  55776. * @returns current plugin
  55777. */
  55778. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55779. /**
  55780. * Gets the list of physic impostors
  55781. * @returns an array of PhysicsImpostor
  55782. */
  55783. getImpostors(): Array<PhysicsImpostor>;
  55784. /**
  55785. * Gets the impostor for a physics enabled object
  55786. * @param object defines the object impersonated by the impostor
  55787. * @returns the PhysicsImpostor or null if not found
  55788. */
  55789. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55790. /**
  55791. * Gets the impostor for a physics body object
  55792. * @param body defines physics body used by the impostor
  55793. * @returns the PhysicsImpostor or null if not found
  55794. */
  55795. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55796. /**
  55797. * Does a raycast in the physics world
  55798. * @param from when should the ray start?
  55799. * @param to when should the ray end?
  55800. * @returns PhysicsRaycastResult
  55801. */
  55802. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55803. }
  55804. }
  55805. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  55806. import { Nullable } from "babylonjs/types";
  55807. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55809. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55810. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55811. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55812. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55813. /** @hidden */
  55814. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55815. private _useDeltaForWorldStep;
  55816. world: any;
  55817. name: string;
  55818. private _physicsMaterials;
  55819. private _fixedTimeStep;
  55820. private _cannonRaycastResult;
  55821. private _raycastResult;
  55822. private _physicsBodysToRemoveAfterStep;
  55823. BJSCANNON: any;
  55824. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55825. setGravity(gravity: Vector3): void;
  55826. setTimeStep(timeStep: number): void;
  55827. getTimeStep(): number;
  55828. executeStep(delta: number): void;
  55829. private _removeMarkedPhysicsBodiesFromWorld;
  55830. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55831. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55832. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55833. private _processChildMeshes;
  55834. removePhysicsBody(impostor: PhysicsImpostor): void;
  55835. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55836. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55837. private _addMaterial;
  55838. private _checkWithEpsilon;
  55839. private _createShape;
  55840. private _createHeightmap;
  55841. private _minus90X;
  55842. private _plus90X;
  55843. private _tmpPosition;
  55844. private _tmpDeltaPosition;
  55845. private _tmpUnityRotation;
  55846. private _updatePhysicsBodyTransformation;
  55847. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55848. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55849. isSupported(): boolean;
  55850. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55851. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55852. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55853. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55854. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55855. getBodyMass(impostor: PhysicsImpostor): number;
  55856. getBodyFriction(impostor: PhysicsImpostor): number;
  55857. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55858. getBodyRestitution(impostor: PhysicsImpostor): number;
  55859. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55860. sleepBody(impostor: PhysicsImpostor): void;
  55861. wakeUpBody(impostor: PhysicsImpostor): void;
  55862. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55863. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55864. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55865. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55866. getRadius(impostor: PhysicsImpostor): number;
  55867. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55868. dispose(): void;
  55869. private _extendNamespace;
  55870. /**
  55871. * Does a raycast in the physics world
  55872. * @param from when should the ray start?
  55873. * @param to when should the ray end?
  55874. * @returns PhysicsRaycastResult
  55875. */
  55876. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55877. }
  55878. }
  55879. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  55880. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55881. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55882. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55884. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55885. import { Nullable } from "babylonjs/types";
  55886. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55887. /** @hidden */
  55888. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55889. world: any;
  55890. name: string;
  55891. BJSOIMO: any;
  55892. private _raycastResult;
  55893. constructor(iterations?: number, oimoInjection?: any);
  55894. setGravity(gravity: Vector3): void;
  55895. setTimeStep(timeStep: number): void;
  55896. getTimeStep(): number;
  55897. private _tmpImpostorsArray;
  55898. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55899. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55900. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55901. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55902. private _tmpPositionVector;
  55903. removePhysicsBody(impostor: PhysicsImpostor): void;
  55904. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55905. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55906. isSupported(): boolean;
  55907. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55908. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55909. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55910. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55911. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55912. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55913. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55914. getBodyMass(impostor: PhysicsImpostor): number;
  55915. getBodyFriction(impostor: PhysicsImpostor): number;
  55916. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55917. getBodyRestitution(impostor: PhysicsImpostor): number;
  55918. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55919. sleepBody(impostor: PhysicsImpostor): void;
  55920. wakeUpBody(impostor: PhysicsImpostor): void;
  55921. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55922. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55923. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55924. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55925. getRadius(impostor: PhysicsImpostor): number;
  55926. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55927. dispose(): void;
  55928. /**
  55929. * Does a raycast in the physics world
  55930. * @param from when should the ray start?
  55931. * @param to when should the ray end?
  55932. * @returns PhysicsRaycastResult
  55933. */
  55934. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55935. }
  55936. }
  55937. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  55938. import { Nullable } from "babylonjs/types";
  55939. import { Scene } from "babylonjs/scene";
  55940. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  55941. import { Color4 } from "babylonjs/Maths/math.color";
  55942. import { Mesh } from "babylonjs/Meshes/mesh";
  55943. /**
  55944. * Class containing static functions to help procedurally build meshes
  55945. */
  55946. export class RibbonBuilder {
  55947. /**
  55948. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55949. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55950. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55951. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55952. * * 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
  55953. * * 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
  55954. * * 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
  55955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55957. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55958. * * 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
  55959. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55960. * * 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
  55961. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55963. * @param name defines the name of the mesh
  55964. * @param options defines the options used to create the mesh
  55965. * @param scene defines the hosting scene
  55966. * @returns the ribbon mesh
  55967. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55968. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55969. */
  55970. static CreateRibbon(name: string, options: {
  55971. pathArray: Vector3[][];
  55972. closeArray?: boolean;
  55973. closePath?: boolean;
  55974. offset?: number;
  55975. updatable?: boolean;
  55976. sideOrientation?: number;
  55977. frontUVs?: Vector4;
  55978. backUVs?: Vector4;
  55979. instance?: Mesh;
  55980. invertUV?: boolean;
  55981. uvs?: Vector2[];
  55982. colors?: Color4[];
  55983. }, scene?: Nullable<Scene>): Mesh;
  55984. }
  55985. }
  55986. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  55987. import { Nullable } from "babylonjs/types";
  55988. import { Scene } from "babylonjs/scene";
  55989. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  55990. import { Mesh } from "babylonjs/Meshes/mesh";
  55991. /**
  55992. * Class containing static functions to help procedurally build meshes
  55993. */
  55994. export class ShapeBuilder {
  55995. /**
  55996. * 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.
  55997. * * 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.
  55998. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55999. * * 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.
  56000. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56001. * * 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
  56002. * * 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
  56003. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56008. * @param name defines the name of the mesh
  56009. * @param options defines the options used to create the mesh
  56010. * @param scene defines the hosting scene
  56011. * @returns the extruded shape mesh
  56012. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56013. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56014. */
  56015. static ExtrudeShape(name: string, options: {
  56016. shape: Vector3[];
  56017. path: Vector3[];
  56018. scale?: number;
  56019. rotation?: number;
  56020. cap?: number;
  56021. updatable?: boolean;
  56022. sideOrientation?: number;
  56023. frontUVs?: Vector4;
  56024. backUVs?: Vector4;
  56025. instance?: Mesh;
  56026. invertUV?: boolean;
  56027. }, scene?: Nullable<Scene>): Mesh;
  56028. /**
  56029. * Creates an custom extruded shape mesh.
  56030. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56031. * * 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.
  56032. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56033. * * 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
  56034. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56035. * * 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
  56036. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56037. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56038. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56039. * * 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
  56040. * * 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
  56041. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56043. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56044. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56046. * @param name defines the name of the mesh
  56047. * @param options defines the options used to create the mesh
  56048. * @param scene defines the hosting scene
  56049. * @returns the custom extruded shape mesh
  56050. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56051. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56053. */
  56054. static ExtrudeShapeCustom(name: string, options: {
  56055. shape: Vector3[];
  56056. path: Vector3[];
  56057. scaleFunction?: any;
  56058. rotationFunction?: any;
  56059. ribbonCloseArray?: boolean;
  56060. ribbonClosePath?: boolean;
  56061. cap?: number;
  56062. updatable?: boolean;
  56063. sideOrientation?: number;
  56064. frontUVs?: Vector4;
  56065. backUVs?: Vector4;
  56066. instance?: Mesh;
  56067. invertUV?: boolean;
  56068. }, scene?: Nullable<Scene>): Mesh;
  56069. private static _ExtrudeShapeGeneric;
  56070. }
  56071. }
  56072. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  56073. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  56074. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56075. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56076. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56077. import { Nullable } from "babylonjs/types";
  56078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56079. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56080. /**
  56081. * AmmoJS Physics plugin
  56082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  56083. * @see https://github.com/kripken/ammo.js/
  56084. */
  56085. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  56086. private _useDeltaForWorldStep;
  56087. /**
  56088. * Reference to the Ammo library
  56089. */
  56090. bjsAMMO: any;
  56091. /**
  56092. * Created ammoJS world which physics bodies are added to
  56093. */
  56094. world: any;
  56095. /**
  56096. * Name of the plugin
  56097. */
  56098. name: string;
  56099. private _timeStep;
  56100. private _fixedTimeStep;
  56101. private _maxSteps;
  56102. private _tmpQuaternion;
  56103. private _tmpAmmoTransform;
  56104. private _tmpAmmoQuaternion;
  56105. private _tmpAmmoConcreteContactResultCallback;
  56106. private _collisionConfiguration;
  56107. private _dispatcher;
  56108. private _overlappingPairCache;
  56109. private _solver;
  56110. private _softBodySolver;
  56111. private _tmpAmmoVectorA;
  56112. private _tmpAmmoVectorB;
  56113. private _tmpAmmoVectorC;
  56114. private _tmpAmmoVectorD;
  56115. private _tmpContactCallbackResult;
  56116. private _tmpAmmoVectorRCA;
  56117. private _tmpAmmoVectorRCB;
  56118. private _raycastResult;
  56119. private static readonly DISABLE_COLLISION_FLAG;
  56120. private static readonly KINEMATIC_FLAG;
  56121. private static readonly DISABLE_DEACTIVATION_FLAG;
  56122. /**
  56123. * Initializes the ammoJS plugin
  56124. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56125. * @param ammoInjection can be used to inject your own ammo reference
  56126. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56127. */
  56128. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56129. /**
  56130. * Sets the gravity of the physics world (m/(s^2))
  56131. * @param gravity Gravity to set
  56132. */
  56133. setGravity(gravity: Vector3): void;
  56134. /**
  56135. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56136. * @param timeStep timestep to use in seconds
  56137. */
  56138. setTimeStep(timeStep: number): void;
  56139. /**
  56140. * 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)
  56141. * @param fixedTimeStep fixedTimeStep to use in seconds
  56142. */
  56143. setFixedTimeStep(fixedTimeStep: number): void;
  56144. /**
  56145. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56146. * @param maxSteps the maximum number of steps by the physics engine per frame
  56147. */
  56148. setMaxSteps(maxSteps: number): void;
  56149. /**
  56150. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56151. * @returns the current timestep in seconds
  56152. */
  56153. getTimeStep(): number;
  56154. /**
  56155. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56156. */
  56157. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56158. private _isImpostorInContact;
  56159. private _isImpostorPairInContact;
  56160. private _stepSimulation;
  56161. /**
  56162. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56163. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56164. * After the step the babylon meshes are set to the position of the physics imposters
  56165. * @param delta amount of time to step forward
  56166. * @param impostors array of imposters to update before/after the step
  56167. */
  56168. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56169. /**
  56170. * Update babylon mesh to match physics world object
  56171. * @param impostor imposter to match
  56172. */
  56173. private _afterSoftStep;
  56174. /**
  56175. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56176. * @param impostor imposter to match
  56177. */
  56178. private _ropeStep;
  56179. /**
  56180. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56181. * @param impostor imposter to match
  56182. */
  56183. private _softbodyOrClothStep;
  56184. private _tmpVector;
  56185. private _tmpMatrix;
  56186. /**
  56187. * Applies an impulse on the imposter
  56188. * @param impostor imposter to apply impulse to
  56189. * @param force amount of force to be applied to the imposter
  56190. * @param contactPoint the location to apply the impulse on the imposter
  56191. */
  56192. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56193. /**
  56194. * Applies a force on the imposter
  56195. * @param impostor imposter to apply force
  56196. * @param force amount of force to be applied to the imposter
  56197. * @param contactPoint the location to apply the force on the imposter
  56198. */
  56199. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56200. /**
  56201. * Creates a physics body using the plugin
  56202. * @param impostor the imposter to create the physics body on
  56203. */
  56204. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56205. /**
  56206. * Removes the physics body from the imposter and disposes of the body's memory
  56207. * @param impostor imposter to remove the physics body from
  56208. */
  56209. removePhysicsBody(impostor: PhysicsImpostor): void;
  56210. /**
  56211. * Generates a joint
  56212. * @param impostorJoint the imposter joint to create the joint with
  56213. */
  56214. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56215. /**
  56216. * Removes a joint
  56217. * @param impostorJoint the imposter joint to remove the joint from
  56218. */
  56219. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56220. private _addMeshVerts;
  56221. /**
  56222. * Initialise the soft body vertices to match its object's (mesh) vertices
  56223. * Softbody vertices (nodes) are in world space and to match this
  56224. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56225. * @param impostor to create the softbody for
  56226. */
  56227. private _softVertexData;
  56228. /**
  56229. * Create an impostor's soft body
  56230. * @param impostor to create the softbody for
  56231. */
  56232. private _createSoftbody;
  56233. /**
  56234. * Create cloth for an impostor
  56235. * @param impostor to create the softbody for
  56236. */
  56237. private _createCloth;
  56238. /**
  56239. * Create rope for an impostor
  56240. * @param impostor to create the softbody for
  56241. */
  56242. private _createRope;
  56243. /**
  56244. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56245. * @param impostor to create the custom physics shape for
  56246. */
  56247. private _createCustom;
  56248. private _addHullVerts;
  56249. private _createShape;
  56250. /**
  56251. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56252. * @param impostor imposter containing the physics body and babylon object
  56253. */
  56254. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56255. /**
  56256. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56257. * @param impostor imposter containing the physics body and babylon object
  56258. * @param newPosition new position
  56259. * @param newRotation new rotation
  56260. */
  56261. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56262. /**
  56263. * If this plugin is supported
  56264. * @returns true if its supported
  56265. */
  56266. isSupported(): boolean;
  56267. /**
  56268. * Sets the linear velocity of the physics body
  56269. * @param impostor imposter to set the velocity on
  56270. * @param velocity velocity to set
  56271. */
  56272. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56273. /**
  56274. * Sets the angular velocity of the physics body
  56275. * @param impostor imposter to set the velocity on
  56276. * @param velocity velocity to set
  56277. */
  56278. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56279. /**
  56280. * gets the linear velocity
  56281. * @param impostor imposter to get linear velocity from
  56282. * @returns linear velocity
  56283. */
  56284. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56285. /**
  56286. * gets the angular velocity
  56287. * @param impostor imposter to get angular velocity from
  56288. * @returns angular velocity
  56289. */
  56290. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56291. /**
  56292. * Sets the mass of physics body
  56293. * @param impostor imposter to set the mass on
  56294. * @param mass mass to set
  56295. */
  56296. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56297. /**
  56298. * Gets the mass of the physics body
  56299. * @param impostor imposter to get the mass from
  56300. * @returns mass
  56301. */
  56302. getBodyMass(impostor: PhysicsImpostor): number;
  56303. /**
  56304. * Gets friction of the impostor
  56305. * @param impostor impostor to get friction from
  56306. * @returns friction value
  56307. */
  56308. getBodyFriction(impostor: PhysicsImpostor): number;
  56309. /**
  56310. * Sets friction of the impostor
  56311. * @param impostor impostor to set friction on
  56312. * @param friction friction value
  56313. */
  56314. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56315. /**
  56316. * Gets restitution of the impostor
  56317. * @param impostor impostor to get restitution from
  56318. * @returns restitution value
  56319. */
  56320. getBodyRestitution(impostor: PhysicsImpostor): number;
  56321. /**
  56322. * Sets resitution of the impostor
  56323. * @param impostor impostor to set resitution on
  56324. * @param restitution resitution value
  56325. */
  56326. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56327. /**
  56328. * Gets pressure inside the impostor
  56329. * @param impostor impostor to get pressure from
  56330. * @returns pressure value
  56331. */
  56332. getBodyPressure(impostor: PhysicsImpostor): number;
  56333. /**
  56334. * Sets pressure inside a soft body impostor
  56335. * Cloth and rope must remain 0 pressure
  56336. * @param impostor impostor to set pressure on
  56337. * @param pressure pressure value
  56338. */
  56339. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56340. /**
  56341. * Gets stiffness of the impostor
  56342. * @param impostor impostor to get stiffness from
  56343. * @returns pressure value
  56344. */
  56345. getBodyStiffness(impostor: PhysicsImpostor): number;
  56346. /**
  56347. * Sets stiffness of the impostor
  56348. * @param impostor impostor to set stiffness on
  56349. * @param stiffness stiffness value from 0 to 1
  56350. */
  56351. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56352. /**
  56353. * Gets velocityIterations of the impostor
  56354. * @param impostor impostor to get velocity iterations from
  56355. * @returns velocityIterations value
  56356. */
  56357. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56358. /**
  56359. * Sets velocityIterations of the impostor
  56360. * @param impostor impostor to set velocity iterations on
  56361. * @param velocityIterations velocityIterations value
  56362. */
  56363. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56364. /**
  56365. * Gets positionIterations of the impostor
  56366. * @param impostor impostor to get position iterations from
  56367. * @returns positionIterations value
  56368. */
  56369. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56370. /**
  56371. * Sets positionIterations of the impostor
  56372. * @param impostor impostor to set position on
  56373. * @param positionIterations positionIterations value
  56374. */
  56375. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56376. /**
  56377. * Append an anchor to a cloth object
  56378. * @param impostor is the cloth impostor to add anchor to
  56379. * @param otherImpostor is the rigid impostor to anchor to
  56380. * @param width ratio across width from 0 to 1
  56381. * @param height ratio up height from 0 to 1
  56382. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56383. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56384. */
  56385. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56386. /**
  56387. * Append an hook to a rope object
  56388. * @param impostor is the rope impostor to add hook to
  56389. * @param otherImpostor is the rigid impostor to hook to
  56390. * @param length ratio along the rope from 0 to 1
  56391. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56392. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56393. */
  56394. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56395. /**
  56396. * Sleeps the physics body and stops it from being active
  56397. * @param impostor impostor to sleep
  56398. */
  56399. sleepBody(impostor: PhysicsImpostor): void;
  56400. /**
  56401. * Activates the physics body
  56402. * @param impostor impostor to activate
  56403. */
  56404. wakeUpBody(impostor: PhysicsImpostor): void;
  56405. /**
  56406. * Updates the distance parameters of the joint
  56407. * @param joint joint to update
  56408. * @param maxDistance maximum distance of the joint
  56409. * @param minDistance minimum distance of the joint
  56410. */
  56411. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56412. /**
  56413. * Sets a motor on the joint
  56414. * @param joint joint to set motor on
  56415. * @param speed speed of the motor
  56416. * @param maxForce maximum force of the motor
  56417. * @param motorIndex index of the motor
  56418. */
  56419. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56420. /**
  56421. * Sets the motors limit
  56422. * @param joint joint to set limit on
  56423. * @param upperLimit upper limit
  56424. * @param lowerLimit lower limit
  56425. */
  56426. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56427. /**
  56428. * Syncs the position and rotation of a mesh with the impostor
  56429. * @param mesh mesh to sync
  56430. * @param impostor impostor to update the mesh with
  56431. */
  56432. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56433. /**
  56434. * Gets the radius of the impostor
  56435. * @param impostor impostor to get radius from
  56436. * @returns the radius
  56437. */
  56438. getRadius(impostor: PhysicsImpostor): number;
  56439. /**
  56440. * Gets the box size of the impostor
  56441. * @param impostor impostor to get box size from
  56442. * @param result the resulting box size
  56443. */
  56444. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56445. /**
  56446. * Disposes of the impostor
  56447. */
  56448. dispose(): void;
  56449. /**
  56450. * Does a raycast in the physics world
  56451. * @param from when should the ray start?
  56452. * @param to when should the ray end?
  56453. * @returns PhysicsRaycastResult
  56454. */
  56455. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56456. }
  56457. }
  56458. declare module "babylonjs/Probes/reflectionProbe" {
  56459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56460. import { Vector3 } from "babylonjs/Maths/math.vector";
  56461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56462. import { Nullable } from "babylonjs/types";
  56463. import { Scene } from "babylonjs/scene";
  56464. module "babylonjs/abstractScene" {
  56465. interface AbstractScene {
  56466. /**
  56467. * The list of reflection probes added to the scene
  56468. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56469. */
  56470. reflectionProbes: Array<ReflectionProbe>;
  56471. /**
  56472. * Removes the given reflection probe from this scene.
  56473. * @param toRemove The reflection probe to remove
  56474. * @returns The index of the removed reflection probe
  56475. */
  56476. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56477. /**
  56478. * Adds the given reflection probe to this scene.
  56479. * @param newReflectionProbe The reflection probe to add
  56480. */
  56481. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56482. }
  56483. }
  56484. /**
  56485. * Class used to generate realtime reflection / refraction cube textures
  56486. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56487. */
  56488. export class ReflectionProbe {
  56489. /** defines the name of the probe */
  56490. name: string;
  56491. private _scene;
  56492. private _renderTargetTexture;
  56493. private _projectionMatrix;
  56494. private _viewMatrix;
  56495. private _target;
  56496. private _add;
  56497. private _attachedMesh;
  56498. private _invertYAxis;
  56499. /** Gets or sets probe position (center of the cube map) */
  56500. position: Vector3;
  56501. /**
  56502. * Creates a new reflection probe
  56503. * @param name defines the name of the probe
  56504. * @param size defines the texture resolution (for each face)
  56505. * @param scene defines the hosting scene
  56506. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56507. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56508. */
  56509. constructor(
  56510. /** defines the name of the probe */
  56511. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56512. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56513. get samples(): number;
  56514. set samples(value: number);
  56515. /** Gets or sets the refresh rate to use (on every frame by default) */
  56516. get refreshRate(): number;
  56517. set refreshRate(value: number);
  56518. /**
  56519. * Gets the hosting scene
  56520. * @returns a Scene
  56521. */
  56522. getScene(): Scene;
  56523. /** Gets the internal CubeTexture used to render to */
  56524. get cubeTexture(): RenderTargetTexture;
  56525. /** Gets the list of meshes to render */
  56526. get renderList(): Nullable<AbstractMesh[]>;
  56527. /**
  56528. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56529. * @param mesh defines the mesh to attach to
  56530. */
  56531. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56532. /**
  56533. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56534. * @param renderingGroupId The rendering group id corresponding to its index
  56535. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56536. */
  56537. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56538. /**
  56539. * Clean all associated resources
  56540. */
  56541. dispose(): void;
  56542. /**
  56543. * Converts the reflection probe information to a readable string for debug purpose.
  56544. * @param fullDetails Supports for multiple levels of logging within scene loading
  56545. * @returns the human readable reflection probe info
  56546. */
  56547. toString(fullDetails?: boolean): string;
  56548. /**
  56549. * Get the class name of the relfection probe.
  56550. * @returns "ReflectionProbe"
  56551. */
  56552. getClassName(): string;
  56553. /**
  56554. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56555. * @returns The JSON representation of the texture
  56556. */
  56557. serialize(): any;
  56558. /**
  56559. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56560. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56561. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56562. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56563. * @returns The parsed reflection probe if successful
  56564. */
  56565. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56566. }
  56567. }
  56568. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  56569. /** @hidden */
  56570. export var _BabylonLoaderRegistered: boolean;
  56571. /**
  56572. * Helps setting up some configuration for the babylon file loader.
  56573. */
  56574. export class BabylonFileLoaderConfiguration {
  56575. /**
  56576. * The loader does not allow injecting custom physix engine into the plugins.
  56577. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56578. * So you could set this variable to your engine import to make it work.
  56579. */
  56580. static LoaderInjectedPhysicsEngine: any;
  56581. }
  56582. }
  56583. declare module "babylonjs/Loading/Plugins/index" {
  56584. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  56585. }
  56586. declare module "babylonjs/Loading/index" {
  56587. export * from "babylonjs/Loading/loadingScreen";
  56588. export * from "babylonjs/Loading/Plugins/index";
  56589. export * from "babylonjs/Loading/sceneLoader";
  56590. export * from "babylonjs/Loading/sceneLoaderFlags";
  56591. }
  56592. declare module "babylonjs/Materials/Background/index" {
  56593. export * from "babylonjs/Materials/Background/backgroundMaterial";
  56594. }
  56595. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  56596. import { Scene } from "babylonjs/scene";
  56597. import { Color3 } from "babylonjs/Maths/math.color";
  56598. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56600. /**
  56601. * The Physically based simple base material of BJS.
  56602. *
  56603. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56604. * It is used as the base class for both the specGloss and metalRough conventions.
  56605. */
  56606. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56607. /**
  56608. * Number of Simultaneous lights allowed on the material.
  56609. */
  56610. maxSimultaneousLights: number;
  56611. /**
  56612. * If sets to true, disables all the lights affecting the material.
  56613. */
  56614. disableLighting: boolean;
  56615. /**
  56616. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56617. */
  56618. environmentTexture: BaseTexture;
  56619. /**
  56620. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56621. */
  56622. invertNormalMapX: boolean;
  56623. /**
  56624. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56625. */
  56626. invertNormalMapY: boolean;
  56627. /**
  56628. * Normal map used in the model.
  56629. */
  56630. normalTexture: BaseTexture;
  56631. /**
  56632. * Emissivie color used to self-illuminate the model.
  56633. */
  56634. emissiveColor: Color3;
  56635. /**
  56636. * Emissivie texture used to self-illuminate the model.
  56637. */
  56638. emissiveTexture: BaseTexture;
  56639. /**
  56640. * Occlusion Channel Strenght.
  56641. */
  56642. occlusionStrength: number;
  56643. /**
  56644. * Occlusion Texture of the material (adding extra occlusion effects).
  56645. */
  56646. occlusionTexture: BaseTexture;
  56647. /**
  56648. * Defines the alpha limits in alpha test mode.
  56649. */
  56650. alphaCutOff: number;
  56651. /**
  56652. * Gets the current double sided mode.
  56653. */
  56654. get doubleSided(): boolean;
  56655. /**
  56656. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56657. */
  56658. set doubleSided(value: boolean);
  56659. /**
  56660. * Stores the pre-calculated light information of a mesh in a texture.
  56661. */
  56662. lightmapTexture: BaseTexture;
  56663. /**
  56664. * If true, the light map contains occlusion information instead of lighting info.
  56665. */
  56666. useLightmapAsShadowmap: boolean;
  56667. /**
  56668. * Instantiates a new PBRMaterial instance.
  56669. *
  56670. * @param name The material name
  56671. * @param scene The scene the material will be use in.
  56672. */
  56673. constructor(name: string, scene: Scene);
  56674. getClassName(): string;
  56675. }
  56676. }
  56677. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  56678. import { Scene } from "babylonjs/scene";
  56679. import { Color3 } from "babylonjs/Maths/math.color";
  56680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56681. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56682. /**
  56683. * The PBR material of BJS following the metal roughness convention.
  56684. *
  56685. * This fits to the PBR convention in the GLTF definition:
  56686. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56687. */
  56688. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56689. /**
  56690. * The base color has two different interpretations depending on the value of metalness.
  56691. * When the material is a metal, the base color is the specific measured reflectance value
  56692. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56693. * of the material.
  56694. */
  56695. baseColor: Color3;
  56696. /**
  56697. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56698. * well as opacity information in the alpha channel.
  56699. */
  56700. baseTexture: BaseTexture;
  56701. /**
  56702. * Specifies the metallic scalar value of the material.
  56703. * Can also be used to scale the metalness values of the metallic texture.
  56704. */
  56705. metallic: number;
  56706. /**
  56707. * Specifies the roughness scalar value of the material.
  56708. * Can also be used to scale the roughness values of the metallic texture.
  56709. */
  56710. roughness: number;
  56711. /**
  56712. * Texture containing both the metallic value in the B channel and the
  56713. * roughness value in the G channel to keep better precision.
  56714. */
  56715. metallicRoughnessTexture: BaseTexture;
  56716. /**
  56717. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56718. *
  56719. * @param name The material name
  56720. * @param scene The scene the material will be use in.
  56721. */
  56722. constructor(name: string, scene: Scene);
  56723. /**
  56724. * Return the currrent class name of the material.
  56725. */
  56726. getClassName(): string;
  56727. /**
  56728. * Makes a duplicate of the current material.
  56729. * @param name - name to use for the new material.
  56730. */
  56731. clone(name: string): PBRMetallicRoughnessMaterial;
  56732. /**
  56733. * Serialize the material to a parsable JSON object.
  56734. */
  56735. serialize(): any;
  56736. /**
  56737. * Parses a JSON object correponding to the serialize function.
  56738. */
  56739. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56740. }
  56741. }
  56742. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  56743. import { Scene } from "babylonjs/scene";
  56744. import { Color3 } from "babylonjs/Maths/math.color";
  56745. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56746. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56747. /**
  56748. * The PBR material of BJS following the specular glossiness convention.
  56749. *
  56750. * This fits to the PBR convention in the GLTF definition:
  56751. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56752. */
  56753. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56754. /**
  56755. * Specifies the diffuse color of the material.
  56756. */
  56757. diffuseColor: Color3;
  56758. /**
  56759. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56760. * channel.
  56761. */
  56762. diffuseTexture: BaseTexture;
  56763. /**
  56764. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56765. */
  56766. specularColor: Color3;
  56767. /**
  56768. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56769. */
  56770. glossiness: number;
  56771. /**
  56772. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56773. */
  56774. specularGlossinessTexture: BaseTexture;
  56775. /**
  56776. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56777. *
  56778. * @param name The material name
  56779. * @param scene The scene the material will be use in.
  56780. */
  56781. constructor(name: string, scene: Scene);
  56782. /**
  56783. * Return the currrent class name of the material.
  56784. */
  56785. getClassName(): string;
  56786. /**
  56787. * Makes a duplicate of the current material.
  56788. * @param name - name to use for the new material.
  56789. */
  56790. clone(name: string): PBRSpecularGlossinessMaterial;
  56791. /**
  56792. * Serialize the material to a parsable JSON object.
  56793. */
  56794. serialize(): any;
  56795. /**
  56796. * Parses a JSON object correponding to the serialize function.
  56797. */
  56798. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56799. }
  56800. }
  56801. declare module "babylonjs/Materials/PBR/index" {
  56802. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56803. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56804. export * from "babylonjs/Materials/PBR/pbrMaterial";
  56805. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  56806. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  56807. }
  56808. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  56809. import { Nullable } from "babylonjs/types";
  56810. import { Scene } from "babylonjs/scene";
  56811. import { Matrix } from "babylonjs/Maths/math.vector";
  56812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56813. /**
  56814. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56815. * It can help converting any input color in a desired output one. This can then be used to create effects
  56816. * from sepia, black and white to sixties or futuristic rendering...
  56817. *
  56818. * The only supported format is currently 3dl.
  56819. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56820. */
  56821. export class ColorGradingTexture extends BaseTexture {
  56822. /**
  56823. * The current texture matrix. (will always be identity in color grading texture)
  56824. */
  56825. private _textureMatrix;
  56826. /**
  56827. * The texture URL.
  56828. */
  56829. url: string;
  56830. /**
  56831. * Empty line regex stored for GC.
  56832. */
  56833. private static _noneEmptyLineRegex;
  56834. private _engine;
  56835. /**
  56836. * Instantiates a ColorGradingTexture from the following parameters.
  56837. *
  56838. * @param url The location of the color gradind data (currently only supporting 3dl)
  56839. * @param scene The scene the texture will be used in
  56840. */
  56841. constructor(url: string, scene: Scene);
  56842. /**
  56843. * Returns the texture matrix used in most of the material.
  56844. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56845. */
  56846. getTextureMatrix(): Matrix;
  56847. /**
  56848. * Occurs when the file being loaded is a .3dl LUT file.
  56849. */
  56850. private load3dlTexture;
  56851. /**
  56852. * Starts the loading process of the texture.
  56853. */
  56854. private loadTexture;
  56855. /**
  56856. * Clones the color gradind texture.
  56857. */
  56858. clone(): ColorGradingTexture;
  56859. /**
  56860. * Called during delayed load for textures.
  56861. */
  56862. delayLoad(): void;
  56863. /**
  56864. * Parses a color grading texture serialized by Babylon.
  56865. * @param parsedTexture The texture information being parsedTexture
  56866. * @param scene The scene to load the texture in
  56867. * @param rootUrl The root url of the data assets to load
  56868. * @return A color gradind texture
  56869. */
  56870. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56871. /**
  56872. * Serializes the LUT texture to json format.
  56873. */
  56874. serialize(): any;
  56875. }
  56876. }
  56877. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  56878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56879. import { Scene } from "babylonjs/scene";
  56880. import { Nullable } from "babylonjs/types";
  56881. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56882. /**
  56883. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56884. */
  56885. export class EquiRectangularCubeTexture extends BaseTexture {
  56886. /** The six faces of the cube. */
  56887. private static _FacesMapping;
  56888. private _noMipmap;
  56889. private _onLoad;
  56890. private _onError;
  56891. /** The size of the cubemap. */
  56892. private _size;
  56893. /** The buffer of the image. */
  56894. private _buffer;
  56895. /** The width of the input image. */
  56896. private _width;
  56897. /** The height of the input image. */
  56898. private _height;
  56899. /** The URL to the image. */
  56900. url: string;
  56901. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56902. coordinatesMode: number;
  56903. /**
  56904. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56905. * @param url The location of the image
  56906. * @param scene The scene the texture will be used in
  56907. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56908. * @param noMipmap Forces to not generate the mipmap if true
  56909. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56910. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56911. * @param onLoad — defines a callback called when texture is loaded
  56912. * @param onError — defines a callback called if there is an error
  56913. */
  56914. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56915. /**
  56916. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56917. */
  56918. private loadImage;
  56919. /**
  56920. * Convert the image buffer into a cubemap and create a CubeTexture.
  56921. */
  56922. private loadTexture;
  56923. /**
  56924. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56925. * @param buffer The ArrayBuffer that should be converted.
  56926. * @returns The buffer as Float32Array.
  56927. */
  56928. private getFloat32ArrayFromArrayBuffer;
  56929. /**
  56930. * Get the current class name of the texture useful for serialization or dynamic coding.
  56931. * @returns "EquiRectangularCubeTexture"
  56932. */
  56933. getClassName(): string;
  56934. /**
  56935. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56936. * @returns A clone of the current EquiRectangularCubeTexture.
  56937. */
  56938. clone(): EquiRectangularCubeTexture;
  56939. }
  56940. }
  56941. declare module "babylonjs/Misc/tga" {
  56942. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56943. /**
  56944. * Based on jsTGALoader - Javascript loader for TGA file
  56945. * By Vincent Thibault
  56946. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56947. */
  56948. export class TGATools {
  56949. private static _TYPE_INDEXED;
  56950. private static _TYPE_RGB;
  56951. private static _TYPE_GREY;
  56952. private static _TYPE_RLE_INDEXED;
  56953. private static _TYPE_RLE_RGB;
  56954. private static _TYPE_RLE_GREY;
  56955. private static _ORIGIN_MASK;
  56956. private static _ORIGIN_SHIFT;
  56957. private static _ORIGIN_BL;
  56958. private static _ORIGIN_BR;
  56959. private static _ORIGIN_UL;
  56960. private static _ORIGIN_UR;
  56961. /**
  56962. * Gets the header of a TGA file
  56963. * @param data defines the TGA data
  56964. * @returns the header
  56965. */
  56966. static GetTGAHeader(data: Uint8Array): any;
  56967. /**
  56968. * Uploads TGA content to a Babylon Texture
  56969. * @hidden
  56970. */
  56971. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56972. /** @hidden */
  56973. 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;
  56974. /** @hidden */
  56975. 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;
  56976. /** @hidden */
  56977. 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;
  56978. /** @hidden */
  56979. 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;
  56980. /** @hidden */
  56981. 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;
  56982. /** @hidden */
  56983. 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;
  56984. }
  56985. }
  56986. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  56987. import { Nullable } from "babylonjs/types";
  56988. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56989. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  56990. /**
  56991. * Implementation of the TGA Texture Loader.
  56992. * @hidden
  56993. */
  56994. export class _TGATextureLoader implements IInternalTextureLoader {
  56995. /**
  56996. * Defines wether the loader supports cascade loading the different faces.
  56997. */
  56998. readonly supportCascades: boolean;
  56999. /**
  57000. * This returns if the loader support the current file information.
  57001. * @param extension defines the file extension of the file being loaded
  57002. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57003. * @param fallback defines the fallback internal texture if any
  57004. * @param isBase64 defines whether the texture is encoded as a base64
  57005. * @param isBuffer defines whether the texture data are stored as a buffer
  57006. * @returns true if the loader can load the specified file
  57007. */
  57008. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57009. /**
  57010. * Transform the url before loading if required.
  57011. * @param rootUrl the url of the texture
  57012. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57013. * @returns the transformed texture
  57014. */
  57015. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57016. /**
  57017. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57018. * @param rootUrl the url of the texture
  57019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57020. * @returns the fallback texture
  57021. */
  57022. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57023. /**
  57024. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  57025. * @param data contains the texture data
  57026. * @param texture defines the BabylonJS internal texture
  57027. * @param createPolynomials will be true if polynomials have been requested
  57028. * @param onLoad defines the callback to trigger once the texture is ready
  57029. * @param onError defines the callback to trigger in case of error
  57030. */
  57031. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57032. /**
  57033. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57034. * @param data contains the texture data
  57035. * @param texture defines the BabylonJS internal texture
  57036. * @param callback defines the method to call once ready to upload
  57037. */
  57038. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57039. }
  57040. }
  57041. declare module "babylonjs/Misc/basis" {
  57042. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57043. /**
  57044. * Info about the .basis files
  57045. */
  57046. class BasisFileInfo {
  57047. /**
  57048. * If the file has alpha
  57049. */
  57050. hasAlpha: boolean;
  57051. /**
  57052. * Info about each image of the basis file
  57053. */
  57054. images: Array<{
  57055. levels: Array<{
  57056. width: number;
  57057. height: number;
  57058. transcodedPixels: ArrayBufferView;
  57059. }>;
  57060. }>;
  57061. }
  57062. /**
  57063. * Result of transcoding a basis file
  57064. */
  57065. class TranscodeResult {
  57066. /**
  57067. * Info about the .basis file
  57068. */
  57069. fileInfo: BasisFileInfo;
  57070. /**
  57071. * Format to use when loading the file
  57072. */
  57073. format: number;
  57074. }
  57075. /**
  57076. * Configuration options for the Basis transcoder
  57077. */
  57078. export class BasisTranscodeConfiguration {
  57079. /**
  57080. * Supported compression formats used to determine the supported output format of the transcoder
  57081. */
  57082. supportedCompressionFormats?: {
  57083. /**
  57084. * etc1 compression format
  57085. */
  57086. etc1?: boolean;
  57087. /**
  57088. * s3tc compression format
  57089. */
  57090. s3tc?: boolean;
  57091. /**
  57092. * pvrtc compression format
  57093. */
  57094. pvrtc?: boolean;
  57095. /**
  57096. * etc2 compression format
  57097. */
  57098. etc2?: boolean;
  57099. };
  57100. /**
  57101. * If mipmap levels should be loaded for transcoded images (Default: true)
  57102. */
  57103. loadMipmapLevels?: boolean;
  57104. /**
  57105. * Index of a single image to load (Default: all images)
  57106. */
  57107. loadSingleImage?: number;
  57108. }
  57109. /**
  57110. * Used to load .Basis files
  57111. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  57112. */
  57113. export class BasisTools {
  57114. private static _IgnoreSupportedFormats;
  57115. /**
  57116. * URL to use when loading the basis transcoder
  57117. */
  57118. static JSModuleURL: string;
  57119. /**
  57120. * URL to use when loading the wasm module for the transcoder
  57121. */
  57122. static WasmModuleURL: string;
  57123. /**
  57124. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  57125. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  57126. * @returns internal format corresponding to the Basis format
  57127. */
  57128. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  57129. private static _WorkerPromise;
  57130. private static _Worker;
  57131. private static _actionId;
  57132. private static _CreateWorkerAsync;
  57133. /**
  57134. * Transcodes a loaded image file to compressed pixel data
  57135. * @param imageData image data to transcode
  57136. * @param config configuration options for the transcoding
  57137. * @returns a promise resulting in the transcoded image
  57138. */
  57139. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57140. /**
  57141. * Loads a texture from the transcode result
  57142. * @param texture texture load to
  57143. * @param transcodeResult the result of transcoding the basis file to load from
  57144. */
  57145. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57146. }
  57147. }
  57148. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  57149. import { Nullable } from "babylonjs/types";
  57150. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57151. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57152. /**
  57153. * Loader for .basis file format
  57154. */
  57155. export class _BasisTextureLoader implements IInternalTextureLoader {
  57156. /**
  57157. * Defines whether the loader supports cascade loading the different faces.
  57158. */
  57159. readonly supportCascades: boolean;
  57160. /**
  57161. * This returns if the loader support the current file information.
  57162. * @param extension defines the file extension of the file being loaded
  57163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57164. * @param fallback defines the fallback internal texture if any
  57165. * @param isBase64 defines whether the texture is encoded as a base64
  57166. * @param isBuffer defines whether the texture data are stored as a buffer
  57167. * @returns true if the loader can load the specified file
  57168. */
  57169. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57170. /**
  57171. * Transform the url before loading if required.
  57172. * @param rootUrl the url of the texture
  57173. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57174. * @returns the transformed texture
  57175. */
  57176. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57177. /**
  57178. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57179. * @param rootUrl the url of the texture
  57180. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57181. * @returns the fallback texture
  57182. */
  57183. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57184. /**
  57185. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  57186. * @param data contains the texture data
  57187. * @param texture defines the BabylonJS internal texture
  57188. * @param createPolynomials will be true if polynomials have been requested
  57189. * @param onLoad defines the callback to trigger once the texture is ready
  57190. * @param onError defines the callback to trigger in case of error
  57191. */
  57192. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57193. /**
  57194. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57195. * @param data contains the texture data
  57196. * @param texture defines the BabylonJS internal texture
  57197. * @param callback defines the method to call once ready to upload
  57198. */
  57199. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57200. }
  57201. }
  57202. declare module "babylonjs/Materials/Textures/Loaders/index" {
  57203. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  57204. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  57205. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  57206. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  57207. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  57208. }
  57209. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  57210. import { Scene } from "babylonjs/scene";
  57211. import { Texture } from "babylonjs/Materials/Textures/texture";
  57212. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57213. /**
  57214. * 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.
  57215. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57216. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57217. */
  57218. export class CustomProceduralTexture extends ProceduralTexture {
  57219. private _animate;
  57220. private _time;
  57221. private _config;
  57222. private _texturePath;
  57223. /**
  57224. * Instantiates a new Custom Procedural Texture.
  57225. * 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.
  57226. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57227. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57228. * @param name Define the name of the texture
  57229. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57230. * @param size Define the size of the texture to create
  57231. * @param scene Define the scene the texture belongs to
  57232. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57233. * @param generateMipMaps Define if the texture should creates mip maps or not
  57234. */
  57235. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57236. private _loadJson;
  57237. /**
  57238. * Is the texture ready to be used ? (rendered at least once)
  57239. * @returns true if ready, otherwise, false.
  57240. */
  57241. isReady(): boolean;
  57242. /**
  57243. * Render the texture to its associated render target.
  57244. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57245. */
  57246. render(useCameraPostProcess?: boolean): void;
  57247. /**
  57248. * Update the list of dependant textures samplers in the shader.
  57249. */
  57250. updateTextures(): void;
  57251. /**
  57252. * Update the uniform values of the procedural texture in the shader.
  57253. */
  57254. updateShaderUniforms(): void;
  57255. /**
  57256. * Define if the texture animates or not.
  57257. */
  57258. get animate(): boolean;
  57259. set animate(value: boolean);
  57260. }
  57261. }
  57262. declare module "babylonjs/Shaders/noise.fragment" {
  57263. /** @hidden */
  57264. export var noisePixelShader: {
  57265. name: string;
  57266. shader: string;
  57267. };
  57268. }
  57269. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  57270. import { Nullable } from "babylonjs/types";
  57271. import { Scene } from "babylonjs/scene";
  57272. import { Texture } from "babylonjs/Materials/Textures/texture";
  57273. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57274. import "babylonjs/Shaders/noise.fragment";
  57275. /**
  57276. * Class used to generate noise procedural textures
  57277. */
  57278. export class NoiseProceduralTexture extends ProceduralTexture {
  57279. private _time;
  57280. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57281. brightness: number;
  57282. /** Defines the number of octaves to process */
  57283. octaves: number;
  57284. /** Defines the level of persistence (0.8 by default) */
  57285. persistence: number;
  57286. /** Gets or sets animation speed factor (default is 1) */
  57287. animationSpeedFactor: number;
  57288. /**
  57289. * Creates a new NoiseProceduralTexture
  57290. * @param name defines the name fo the texture
  57291. * @param size defines the size of the texture (default is 256)
  57292. * @param scene defines the hosting scene
  57293. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57294. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57295. */
  57296. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57297. private _updateShaderUniforms;
  57298. protected _getDefines(): string;
  57299. /** Generate the current state of the procedural texture */
  57300. render(useCameraPostProcess?: boolean): void;
  57301. /**
  57302. * Serializes this noise procedural texture
  57303. * @returns a serialized noise procedural texture object
  57304. */
  57305. serialize(): any;
  57306. /**
  57307. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57308. * @param parsedTexture defines parsed texture data
  57309. * @param scene defines the current scene
  57310. * @param rootUrl defines the root URL containing noise procedural texture information
  57311. * @returns a parsed NoiseProceduralTexture
  57312. */
  57313. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57314. }
  57315. }
  57316. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  57317. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  57318. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  57319. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57320. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  57321. }
  57322. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  57323. import { Nullable } from "babylonjs/types";
  57324. import { Scene } from "babylonjs/scene";
  57325. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57327. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57328. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57329. /**
  57330. * Raw cube texture where the raw buffers are passed in
  57331. */
  57332. export class RawCubeTexture extends CubeTexture {
  57333. /**
  57334. * Creates a cube texture where the raw buffers are passed in.
  57335. * @param scene defines the scene the texture is attached to
  57336. * @param data defines the array of data to use to create each face
  57337. * @param size defines the size of the textures
  57338. * @param format defines the format of the data
  57339. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57340. * @param generateMipMaps defines if the engine should generate the mip levels
  57341. * @param invertY defines if data must be stored with Y axis inverted
  57342. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57343. * @param compression defines the compression used (null by default)
  57344. */
  57345. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57346. /**
  57347. * Updates the raw cube texture.
  57348. * @param data defines the data to store
  57349. * @param format defines the data format
  57350. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57351. * @param invertY defines if data must be stored with Y axis inverted
  57352. * @param compression defines the compression used (null by default)
  57353. * @param level defines which level of the texture to update
  57354. */
  57355. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57356. /**
  57357. * Updates a raw cube texture with RGBD encoded data.
  57358. * @param data defines the array of data [mipmap][face] to use to create each face
  57359. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57360. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57361. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57362. * @returns a promsie that resolves when the operation is complete
  57363. */
  57364. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57365. /**
  57366. * Clones the raw cube texture.
  57367. * @return a new cube texture
  57368. */
  57369. clone(): CubeTexture;
  57370. /** @hidden */
  57371. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57372. }
  57373. }
  57374. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  57375. import { Scene } from "babylonjs/scene";
  57376. import { Texture } from "babylonjs/Materials/Textures/texture";
  57377. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57378. /**
  57379. * Class used to store 3D textures containing user data
  57380. */
  57381. export class RawTexture3D extends Texture {
  57382. /** Gets or sets the texture format to use */
  57383. format: number;
  57384. private _engine;
  57385. /**
  57386. * Create a new RawTexture3D
  57387. * @param data defines the data of the texture
  57388. * @param width defines the width of the texture
  57389. * @param height defines the height of the texture
  57390. * @param depth defines the depth of the texture
  57391. * @param format defines the texture format to use
  57392. * @param scene defines the hosting scene
  57393. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57394. * @param invertY defines if texture must be stored with Y axis inverted
  57395. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57396. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57397. */
  57398. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57399. /** Gets or sets the texture format to use */
  57400. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57401. /**
  57402. * Update the texture with new data
  57403. * @param data defines the data to store in the texture
  57404. */
  57405. update(data: ArrayBufferView): void;
  57406. }
  57407. }
  57408. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  57409. import { Scene } from "babylonjs/scene";
  57410. import { Texture } from "babylonjs/Materials/Textures/texture";
  57411. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57412. /**
  57413. * Class used to store 2D array textures containing user data
  57414. */
  57415. export class RawTexture2DArray extends Texture {
  57416. /** Gets or sets the texture format to use */
  57417. format: number;
  57418. private _engine;
  57419. /**
  57420. * Create a new RawTexture2DArray
  57421. * @param data defines the data of the texture
  57422. * @param width defines the width of the texture
  57423. * @param height defines the height of the texture
  57424. * @param depth defines the number of layers of the texture
  57425. * @param format defines the texture format to use
  57426. * @param scene defines the hosting scene
  57427. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57428. * @param invertY defines if texture must be stored with Y axis inverted
  57429. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57430. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57431. */
  57432. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57433. /** Gets or sets the texture format to use */
  57434. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57435. /**
  57436. * Update the texture with new data
  57437. * @param data defines the data to store in the texture
  57438. */
  57439. update(data: ArrayBufferView): void;
  57440. }
  57441. }
  57442. declare module "babylonjs/Materials/Textures/refractionTexture" {
  57443. import { Scene } from "babylonjs/scene";
  57444. import { Plane } from "babylonjs/Maths/math.plane";
  57445. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57446. /**
  57447. * Creates a refraction texture used by refraction channel of the standard material.
  57448. * It is like a mirror but to see through a material.
  57449. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57450. */
  57451. export class RefractionTexture extends RenderTargetTexture {
  57452. /**
  57453. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57454. * 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.
  57455. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57456. */
  57457. refractionPlane: Plane;
  57458. /**
  57459. * Define how deep under the surface we should see.
  57460. */
  57461. depth: number;
  57462. /**
  57463. * Creates a refraction texture used by refraction channel of the standard material.
  57464. * It is like a mirror but to see through a material.
  57465. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57466. * @param name Define the texture name
  57467. * @param size Define the size of the underlying texture
  57468. * @param scene Define the scene the refraction belongs to
  57469. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57470. */
  57471. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57472. /**
  57473. * Clone the refraction texture.
  57474. * @returns the cloned texture
  57475. */
  57476. clone(): RefractionTexture;
  57477. /**
  57478. * Serialize the texture to a JSON representation you could use in Parse later on
  57479. * @returns the serialized JSON representation
  57480. */
  57481. serialize(): any;
  57482. }
  57483. }
  57484. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  57485. import { Nullable } from "babylonjs/types";
  57486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57487. import { Matrix } from "babylonjs/Maths/math.vector";
  57488. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57489. import "babylonjs/Engines/Extensions/engine.videoTexture";
  57490. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  57491. import { Scene } from "babylonjs/scene";
  57492. /**
  57493. * Defines the options related to the creation of an HtmlElementTexture
  57494. */
  57495. export interface IHtmlElementTextureOptions {
  57496. /**
  57497. * Defines wether mip maps should be created or not.
  57498. */
  57499. generateMipMaps?: boolean;
  57500. /**
  57501. * Defines the sampling mode of the texture.
  57502. */
  57503. samplingMode?: number;
  57504. /**
  57505. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57506. */
  57507. engine: Nullable<ThinEngine>;
  57508. /**
  57509. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57510. */
  57511. scene: Nullable<Scene>;
  57512. }
  57513. /**
  57514. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57515. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57516. * is automatically managed.
  57517. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57518. * in your application.
  57519. *
  57520. * As the update is not automatic, you need to call them manually.
  57521. */
  57522. export class HtmlElementTexture extends BaseTexture {
  57523. /**
  57524. * The texture URL.
  57525. */
  57526. element: HTMLVideoElement | HTMLCanvasElement;
  57527. private static readonly DefaultOptions;
  57528. private _textureMatrix;
  57529. private _engine;
  57530. private _isVideo;
  57531. private _generateMipMaps;
  57532. private _samplingMode;
  57533. /**
  57534. * Instantiates a HtmlElementTexture from the following parameters.
  57535. *
  57536. * @param name Defines the name of the texture
  57537. * @param element Defines the video or canvas the texture is filled with
  57538. * @param options Defines the other none mandatory texture creation options
  57539. */
  57540. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57541. private _createInternalTexture;
  57542. /**
  57543. * Returns the texture matrix used in most of the material.
  57544. */
  57545. getTextureMatrix(): Matrix;
  57546. /**
  57547. * Updates the content of the texture.
  57548. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57549. */
  57550. update(invertY?: Nullable<boolean>): void;
  57551. }
  57552. }
  57553. declare module "babylonjs/Materials/Textures/index" {
  57554. export * from "babylonjs/Materials/Textures/baseTexture";
  57555. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  57556. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  57557. export * from "babylonjs/Materials/Textures/cubeTexture";
  57558. export * from "babylonjs/Materials/Textures/dynamicTexture";
  57559. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57560. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  57561. export * from "babylonjs/Materials/Textures/internalTexture";
  57562. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  57563. export * from "babylonjs/Materials/Textures/Loaders/index";
  57564. export * from "babylonjs/Materials/Textures/mirrorTexture";
  57565. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  57566. export * from "babylonjs/Materials/Textures/Procedurals/index";
  57567. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  57568. export * from "babylonjs/Materials/Textures/rawTexture";
  57569. export * from "babylonjs/Materials/Textures/rawTexture3D";
  57570. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  57571. export * from "babylonjs/Materials/Textures/refractionTexture";
  57572. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  57573. export * from "babylonjs/Materials/Textures/texture";
  57574. export * from "babylonjs/Materials/Textures/videoTexture";
  57575. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  57576. }
  57577. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  57578. /**
  57579. * Enum used to define the target of a block
  57580. */
  57581. export enum NodeMaterialBlockTargets {
  57582. /** Vertex shader */
  57583. Vertex = 1,
  57584. /** Fragment shader */
  57585. Fragment = 2,
  57586. /** Neutral */
  57587. Neutral = 4,
  57588. /** Vertex and Fragment */
  57589. VertexAndFragment = 3
  57590. }
  57591. }
  57592. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  57593. /**
  57594. * Defines the kind of connection point for node based material
  57595. */
  57596. export enum NodeMaterialBlockConnectionPointTypes {
  57597. /** Float */
  57598. Float = 1,
  57599. /** Int */
  57600. Int = 2,
  57601. /** Vector2 */
  57602. Vector2 = 4,
  57603. /** Vector3 */
  57604. Vector3 = 8,
  57605. /** Vector4 */
  57606. Vector4 = 16,
  57607. /** Color3 */
  57608. Color3 = 32,
  57609. /** Color4 */
  57610. Color4 = 64,
  57611. /** Matrix */
  57612. Matrix = 128,
  57613. /** Detect type based on connection */
  57614. AutoDetect = 1024,
  57615. /** Output type that will be defined by input type */
  57616. BasedOnInput = 2048
  57617. }
  57618. }
  57619. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  57620. /**
  57621. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57622. */
  57623. export enum NodeMaterialBlockConnectionPointMode {
  57624. /** Value is an uniform */
  57625. Uniform = 0,
  57626. /** Value is a mesh attribute */
  57627. Attribute = 1,
  57628. /** Value is a varying between vertex and fragment shaders */
  57629. Varying = 2,
  57630. /** Mode is undefined */
  57631. Undefined = 3
  57632. }
  57633. }
  57634. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  57635. /**
  57636. * Enum used to define system values e.g. values automatically provided by the system
  57637. */
  57638. export enum NodeMaterialSystemValues {
  57639. /** World */
  57640. World = 1,
  57641. /** View */
  57642. View = 2,
  57643. /** Projection */
  57644. Projection = 3,
  57645. /** ViewProjection */
  57646. ViewProjection = 4,
  57647. /** WorldView */
  57648. WorldView = 5,
  57649. /** WorldViewProjection */
  57650. WorldViewProjection = 6,
  57651. /** CameraPosition */
  57652. CameraPosition = 7,
  57653. /** Fog Color */
  57654. FogColor = 8,
  57655. /** Delta time */
  57656. DeltaTime = 9
  57657. }
  57658. }
  57659. declare module "babylonjs/Materials/Node/Enums/index" {
  57660. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57661. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57662. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  57663. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57664. }
  57665. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  57666. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57667. /**
  57668. * Root class for all node material optimizers
  57669. */
  57670. export class NodeMaterialOptimizer {
  57671. /**
  57672. * Function used to optimize a NodeMaterial graph
  57673. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57674. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57675. */
  57676. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57677. }
  57678. }
  57679. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  57680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57683. import { Scene } from "babylonjs/scene";
  57684. /**
  57685. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57686. */
  57687. export class TransformBlock extends NodeMaterialBlock {
  57688. /**
  57689. * Defines the value to use to complement W value to transform it to a Vector4
  57690. */
  57691. complementW: number;
  57692. /**
  57693. * Defines the value to use to complement z value to transform it to a Vector4
  57694. */
  57695. complementZ: number;
  57696. /**
  57697. * Creates a new TransformBlock
  57698. * @param name defines the block name
  57699. */
  57700. constructor(name: string);
  57701. /**
  57702. * Gets the current class name
  57703. * @returns the class name
  57704. */
  57705. getClassName(): string;
  57706. /**
  57707. * Gets the vector input
  57708. */
  57709. get vector(): NodeMaterialConnectionPoint;
  57710. /**
  57711. * Gets the output component
  57712. */
  57713. get output(): NodeMaterialConnectionPoint;
  57714. /**
  57715. * Gets the matrix transform input
  57716. */
  57717. get transform(): NodeMaterialConnectionPoint;
  57718. protected _buildBlock(state: NodeMaterialBuildState): this;
  57719. serialize(): any;
  57720. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57721. protected _dumpPropertiesCode(): string;
  57722. }
  57723. }
  57724. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  57725. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57728. /**
  57729. * Block used to output the vertex position
  57730. */
  57731. export class VertexOutputBlock extends NodeMaterialBlock {
  57732. /**
  57733. * Creates a new VertexOutputBlock
  57734. * @param name defines the block name
  57735. */
  57736. constructor(name: string);
  57737. /**
  57738. * Gets the current class name
  57739. * @returns the class name
  57740. */
  57741. getClassName(): string;
  57742. /**
  57743. * Gets the vector input component
  57744. */
  57745. get vector(): NodeMaterialConnectionPoint;
  57746. protected _buildBlock(state: NodeMaterialBuildState): this;
  57747. }
  57748. }
  57749. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  57750. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57751. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57752. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57753. /**
  57754. * Block used to output the final color
  57755. */
  57756. export class FragmentOutputBlock extends NodeMaterialBlock {
  57757. /**
  57758. * Create a new FragmentOutputBlock
  57759. * @param name defines the block name
  57760. */
  57761. constructor(name: string);
  57762. /**
  57763. * Gets the current class name
  57764. * @returns the class name
  57765. */
  57766. getClassName(): string;
  57767. /**
  57768. * Gets the rgba input component
  57769. */
  57770. get rgba(): NodeMaterialConnectionPoint;
  57771. /**
  57772. * Gets the rgb input component
  57773. */
  57774. get rgb(): NodeMaterialConnectionPoint;
  57775. /**
  57776. * Gets the a input component
  57777. */
  57778. get a(): NodeMaterialConnectionPoint;
  57779. protected _buildBlock(state: NodeMaterialBuildState): this;
  57780. }
  57781. }
  57782. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  57783. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57784. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57785. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57788. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57789. import { Effect } from "babylonjs/Materials/effect";
  57790. import { Mesh } from "babylonjs/Meshes/mesh";
  57791. import { Nullable } from "babylonjs/types";
  57792. import { Scene } from "babylonjs/scene";
  57793. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57794. /**
  57795. * Block used to read a reflection texture from a sampler
  57796. */
  57797. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57798. private _define3DName;
  57799. private _defineCubicName;
  57800. private _defineExplicitName;
  57801. private _defineProjectionName;
  57802. private _defineLocalCubicName;
  57803. private _defineSphericalName;
  57804. private _definePlanarName;
  57805. private _defineEquirectangularName;
  57806. private _defineMirroredEquirectangularFixedName;
  57807. private _defineEquirectangularFixedName;
  57808. private _defineSkyboxName;
  57809. private _cubeSamplerName;
  57810. private _2DSamplerName;
  57811. private _positionUVWName;
  57812. private _directionWName;
  57813. private _reflectionCoordsName;
  57814. private _reflection2DCoordsName;
  57815. private _reflectionColorName;
  57816. private _reflectionMatrixName;
  57817. /**
  57818. * Gets or sets the texture associated with the node
  57819. */
  57820. texture: Nullable<BaseTexture>;
  57821. /**
  57822. * Create a new TextureBlock
  57823. * @param name defines the block name
  57824. */
  57825. constructor(name: string);
  57826. /**
  57827. * Gets the current class name
  57828. * @returns the class name
  57829. */
  57830. getClassName(): string;
  57831. /**
  57832. * Gets the world position input component
  57833. */
  57834. get position(): NodeMaterialConnectionPoint;
  57835. /**
  57836. * Gets the world position input component
  57837. */
  57838. get worldPosition(): NodeMaterialConnectionPoint;
  57839. /**
  57840. * Gets the world normal input component
  57841. */
  57842. get worldNormal(): NodeMaterialConnectionPoint;
  57843. /**
  57844. * Gets the world input component
  57845. */
  57846. get world(): NodeMaterialConnectionPoint;
  57847. /**
  57848. * Gets the camera (or eye) position component
  57849. */
  57850. get cameraPosition(): NodeMaterialConnectionPoint;
  57851. /**
  57852. * Gets the view input component
  57853. */
  57854. get view(): NodeMaterialConnectionPoint;
  57855. /**
  57856. * Gets the rgb output component
  57857. */
  57858. get rgb(): NodeMaterialConnectionPoint;
  57859. /**
  57860. * Gets the r output component
  57861. */
  57862. get r(): NodeMaterialConnectionPoint;
  57863. /**
  57864. * Gets the g output component
  57865. */
  57866. get g(): NodeMaterialConnectionPoint;
  57867. /**
  57868. * Gets the b output component
  57869. */
  57870. get b(): NodeMaterialConnectionPoint;
  57871. autoConfigure(material: NodeMaterial): void;
  57872. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57873. isReady(): boolean;
  57874. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57875. private _injectVertexCode;
  57876. private _writeOutput;
  57877. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57878. protected _dumpPropertiesCode(): string;
  57879. serialize(): any;
  57880. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57881. }
  57882. }
  57883. declare module "babylonjs/Materials/Node/nodeMaterial" {
  57884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57885. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57886. import { Scene } from "babylonjs/scene";
  57887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57888. import { Matrix } from "babylonjs/Maths/math.vector";
  57889. import { Mesh } from "babylonjs/Meshes/mesh";
  57890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57891. import { Observable } from "babylonjs/Misc/observable";
  57892. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57893. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57894. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57895. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57896. import { Nullable } from "babylonjs/types";
  57897. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57898. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57899. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57900. /**
  57901. * Interface used to configure the node material editor
  57902. */
  57903. export interface INodeMaterialEditorOptions {
  57904. /** Define the URl to load node editor script */
  57905. editorURL?: string;
  57906. }
  57907. /** @hidden */
  57908. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57909. /** BONES */
  57910. NUM_BONE_INFLUENCERS: number;
  57911. BonesPerMesh: number;
  57912. BONETEXTURE: boolean;
  57913. /** MORPH TARGETS */
  57914. MORPHTARGETS: boolean;
  57915. MORPHTARGETS_NORMAL: boolean;
  57916. MORPHTARGETS_TANGENT: boolean;
  57917. MORPHTARGETS_UV: boolean;
  57918. NUM_MORPH_INFLUENCERS: number;
  57919. /** IMAGE PROCESSING */
  57920. IMAGEPROCESSING: boolean;
  57921. VIGNETTE: boolean;
  57922. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57923. VIGNETTEBLENDMODEOPAQUE: boolean;
  57924. TONEMAPPING: boolean;
  57925. TONEMAPPING_ACES: boolean;
  57926. CONTRAST: boolean;
  57927. EXPOSURE: boolean;
  57928. COLORCURVES: boolean;
  57929. COLORGRADING: boolean;
  57930. COLORGRADING3D: boolean;
  57931. SAMPLER3DGREENDEPTH: boolean;
  57932. SAMPLER3DBGRMAP: boolean;
  57933. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57934. /** MISC. */
  57935. BUMPDIRECTUV: number;
  57936. constructor();
  57937. setValue(name: string, value: boolean): void;
  57938. }
  57939. /**
  57940. * Class used to configure NodeMaterial
  57941. */
  57942. export interface INodeMaterialOptions {
  57943. /**
  57944. * Defines if blocks should emit comments
  57945. */
  57946. emitComments: boolean;
  57947. }
  57948. /**
  57949. * Class used to create a node based material built by assembling shader blocks
  57950. */
  57951. export class NodeMaterial extends PushMaterial {
  57952. private static _BuildIdGenerator;
  57953. private _options;
  57954. private _vertexCompilationState;
  57955. private _fragmentCompilationState;
  57956. private _sharedData;
  57957. private _buildId;
  57958. private _buildWasSuccessful;
  57959. private _cachedWorldViewMatrix;
  57960. private _cachedWorldViewProjectionMatrix;
  57961. private _optimizers;
  57962. private _animationFrame;
  57963. /** Define the URl to load node editor script */
  57964. static EditorURL: string;
  57965. private BJSNODEMATERIALEDITOR;
  57966. /** Get the inspector from bundle or global */
  57967. private _getGlobalNodeMaterialEditor;
  57968. /**
  57969. * Gets or sets data used by visual editor
  57970. * @see https://nme.babylonjs.com
  57971. */
  57972. editorData: any;
  57973. /**
  57974. * 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)
  57975. */
  57976. ignoreAlpha: boolean;
  57977. /**
  57978. * Defines the maximum number of lights that can be used in the material
  57979. */
  57980. maxSimultaneousLights: number;
  57981. /**
  57982. * Observable raised when the material is built
  57983. */
  57984. onBuildObservable: Observable<NodeMaterial>;
  57985. /**
  57986. * Gets or sets the root nodes of the material vertex shader
  57987. */
  57988. _vertexOutputNodes: NodeMaterialBlock[];
  57989. /**
  57990. * Gets or sets the root nodes of the material fragment (pixel) shader
  57991. */
  57992. _fragmentOutputNodes: NodeMaterialBlock[];
  57993. /** Gets or sets options to control the node material overall behavior */
  57994. get options(): INodeMaterialOptions;
  57995. set options(options: INodeMaterialOptions);
  57996. /**
  57997. * Default configuration related to image processing available in the standard Material.
  57998. */
  57999. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58000. /**
  58001. * Gets the image processing configuration used either in this material.
  58002. */
  58003. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58004. /**
  58005. * Sets the Default image processing configuration used either in the this material.
  58006. *
  58007. * If sets to null, the scene one is in use.
  58008. */
  58009. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58010. /**
  58011. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  58012. */
  58013. attachedBlocks: NodeMaterialBlock[];
  58014. /**
  58015. * Create a new node based material
  58016. * @param name defines the material name
  58017. * @param scene defines the hosting scene
  58018. * @param options defines creation option
  58019. */
  58020. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  58021. /**
  58022. * Gets the current class name of the material e.g. "NodeMaterial"
  58023. * @returns the class name
  58024. */
  58025. getClassName(): string;
  58026. /**
  58027. * Keep track of the image processing observer to allow dispose and replace.
  58028. */
  58029. private _imageProcessingObserver;
  58030. /**
  58031. * Attaches a new image processing configuration to the Standard Material.
  58032. * @param configuration
  58033. */
  58034. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58035. /**
  58036. * Get a block by its name
  58037. * @param name defines the name of the block to retrieve
  58038. * @returns the required block or null if not found
  58039. */
  58040. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  58041. /**
  58042. * Get a block by its name
  58043. * @param predicate defines the predicate used to find the good candidate
  58044. * @returns the required block or null if not found
  58045. */
  58046. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  58047. /**
  58048. * Get an input block by its name
  58049. * @param predicate defines the predicate used to find the good candidate
  58050. * @returns the required input block or null if not found
  58051. */
  58052. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  58053. /**
  58054. * Gets the list of input blocks attached to this material
  58055. * @returns an array of InputBlocks
  58056. */
  58057. getInputBlocks(): InputBlock[];
  58058. /**
  58059. * Adds a new optimizer to the list of optimizers
  58060. * @param optimizer defines the optimizers to add
  58061. * @returns the current material
  58062. */
  58063. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58064. /**
  58065. * Remove an optimizer from the list of optimizers
  58066. * @param optimizer defines the optimizers to remove
  58067. * @returns the current material
  58068. */
  58069. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58070. /**
  58071. * Add a new block to the list of output nodes
  58072. * @param node defines the node to add
  58073. * @returns the current material
  58074. */
  58075. addOutputNode(node: NodeMaterialBlock): this;
  58076. /**
  58077. * Remove a block from the list of root nodes
  58078. * @param node defines the node to remove
  58079. * @returns the current material
  58080. */
  58081. removeOutputNode(node: NodeMaterialBlock): this;
  58082. private _addVertexOutputNode;
  58083. private _removeVertexOutputNode;
  58084. private _addFragmentOutputNode;
  58085. private _removeFragmentOutputNode;
  58086. /**
  58087. * Specifies if the material will require alpha blending
  58088. * @returns a boolean specifying if alpha blending is needed
  58089. */
  58090. needAlphaBlending(): boolean;
  58091. /**
  58092. * Specifies if this material should be rendered in alpha test mode
  58093. * @returns a boolean specifying if an alpha test is needed.
  58094. */
  58095. needAlphaTesting(): boolean;
  58096. private _initializeBlock;
  58097. private _resetDualBlocks;
  58098. /**
  58099. * Remove a block from the current node material
  58100. * @param block defines the block to remove
  58101. */
  58102. removeBlock(block: NodeMaterialBlock): void;
  58103. /**
  58104. * Build the material and generates the inner effect
  58105. * @param verbose defines if the build should log activity
  58106. */
  58107. build(verbose?: boolean): void;
  58108. /**
  58109. * Runs an otpimization phase to try to improve the shader code
  58110. */
  58111. optimize(): void;
  58112. private _prepareDefinesForAttributes;
  58113. /**
  58114. * Get if the submesh is ready to be used and all its information available.
  58115. * Child classes can use it to update shaders
  58116. * @param mesh defines the mesh to check
  58117. * @param subMesh defines which submesh to check
  58118. * @param useInstances specifies that instances should be used
  58119. * @returns a boolean indicating that the submesh is ready or not
  58120. */
  58121. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58122. /**
  58123. * Get a string representing the shaders built by the current node graph
  58124. */
  58125. get compiledShaders(): string;
  58126. /**
  58127. * Binds the world matrix to the material
  58128. * @param world defines the world transformation matrix
  58129. */
  58130. bindOnlyWorldMatrix(world: Matrix): void;
  58131. /**
  58132. * Binds the submesh to this material by preparing the effect and shader to draw
  58133. * @param world defines the world transformation matrix
  58134. * @param mesh defines the mesh containing the submesh
  58135. * @param subMesh defines the submesh to bind the material to
  58136. */
  58137. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58138. /**
  58139. * Gets the active textures from the material
  58140. * @returns an array of textures
  58141. */
  58142. getActiveTextures(): BaseTexture[];
  58143. /**
  58144. * Gets the list of texture blocks
  58145. * @returns an array of texture blocks
  58146. */
  58147. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  58148. /**
  58149. * Specifies if the material uses a texture
  58150. * @param texture defines the texture to check against the material
  58151. * @returns a boolean specifying if the material uses the texture
  58152. */
  58153. hasTexture(texture: BaseTexture): boolean;
  58154. /**
  58155. * Disposes the material
  58156. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58157. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58158. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58159. */
  58160. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58161. /** Creates the node editor window. */
  58162. private _createNodeEditor;
  58163. /**
  58164. * Launch the node material editor
  58165. * @param config Define the configuration of the editor
  58166. * @return a promise fulfilled when the node editor is visible
  58167. */
  58168. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58169. /**
  58170. * Clear the current material
  58171. */
  58172. clear(): void;
  58173. /**
  58174. * Clear the current material and set it to a default state
  58175. */
  58176. setToDefault(): void;
  58177. /**
  58178. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58179. * @param url defines the url to load from
  58180. * @returns a promise that will fullfil when the material is fully loaded
  58181. */
  58182. loadAsync(url: string): Promise<void>;
  58183. private _gatherBlocks;
  58184. /**
  58185. * Generate a string containing the code declaration required to create an equivalent of this material
  58186. * @returns a string
  58187. */
  58188. generateCode(): string;
  58189. /**
  58190. * Serializes this material in a JSON representation
  58191. * @returns the serialized material object
  58192. */
  58193. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58194. private _restoreConnections;
  58195. /**
  58196. * Clear the current graph and load a new one from a serialization object
  58197. * @param source defines the JSON representation of the material
  58198. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58199. */
  58200. loadFromSerialization(source: any, rootUrl?: string): void;
  58201. /**
  58202. * Creates a node material from parsed material data
  58203. * @param source defines the JSON representation of the material
  58204. * @param scene defines the hosting scene
  58205. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58206. * @returns a new node material
  58207. */
  58208. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58209. /**
  58210. * Creates a new node material set to default basic configuration
  58211. * @param name defines the name of the material
  58212. * @param scene defines the hosting scene
  58213. * @returns a new NodeMaterial
  58214. */
  58215. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58216. }
  58217. }
  58218. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  58219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58221. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58222. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58224. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58225. import { Effect } from "babylonjs/Materials/effect";
  58226. import { Mesh } from "babylonjs/Meshes/mesh";
  58227. import { Nullable } from "babylonjs/types";
  58228. import { Texture } from "babylonjs/Materials/Textures/texture";
  58229. import { Scene } from "babylonjs/scene";
  58230. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58231. /**
  58232. * Block used to read a texture from a sampler
  58233. */
  58234. export class TextureBlock extends NodeMaterialBlock {
  58235. private _defineName;
  58236. private _linearDefineName;
  58237. private _tempTextureRead;
  58238. private _samplerName;
  58239. private _transformedUVName;
  58240. private _textureTransformName;
  58241. private _textureInfoName;
  58242. private _mainUVName;
  58243. private _mainUVDefineName;
  58244. /**
  58245. * Gets or sets the texture associated with the node
  58246. */
  58247. texture: Nullable<Texture>;
  58248. /**
  58249. * Create a new TextureBlock
  58250. * @param name defines the block name
  58251. */
  58252. constructor(name: string);
  58253. /**
  58254. * Gets the current class name
  58255. * @returns the class name
  58256. */
  58257. getClassName(): string;
  58258. /**
  58259. * Gets the uv input component
  58260. */
  58261. get uv(): NodeMaterialConnectionPoint;
  58262. /**
  58263. * Gets the rgba output component
  58264. */
  58265. get rgba(): NodeMaterialConnectionPoint;
  58266. /**
  58267. * Gets the rgb output component
  58268. */
  58269. get rgb(): NodeMaterialConnectionPoint;
  58270. /**
  58271. * Gets the r output component
  58272. */
  58273. get r(): NodeMaterialConnectionPoint;
  58274. /**
  58275. * Gets the g output component
  58276. */
  58277. get g(): NodeMaterialConnectionPoint;
  58278. /**
  58279. * Gets the b output component
  58280. */
  58281. get b(): NodeMaterialConnectionPoint;
  58282. /**
  58283. * Gets the a output component
  58284. */
  58285. get a(): NodeMaterialConnectionPoint;
  58286. get target(): NodeMaterialBlockTargets;
  58287. autoConfigure(material: NodeMaterial): void;
  58288. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58290. private _getTextureBase;
  58291. isReady(): boolean;
  58292. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58293. private get _isMixed();
  58294. private _injectVertexCode;
  58295. private _writeTextureRead;
  58296. private _writeOutput;
  58297. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58298. protected _dumpPropertiesCode(): string;
  58299. serialize(): any;
  58300. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58301. }
  58302. }
  58303. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  58304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58305. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58306. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58307. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58308. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58309. import { Scene } from "babylonjs/scene";
  58310. /**
  58311. * Class used to store shared data between 2 NodeMaterialBuildState
  58312. */
  58313. export class NodeMaterialBuildStateSharedData {
  58314. /**
  58315. * Gets the list of emitted varyings
  58316. */
  58317. temps: string[];
  58318. /**
  58319. * Gets the list of emitted varyings
  58320. */
  58321. varyings: string[];
  58322. /**
  58323. * Gets the varying declaration string
  58324. */
  58325. varyingDeclaration: string;
  58326. /**
  58327. * Input blocks
  58328. */
  58329. inputBlocks: InputBlock[];
  58330. /**
  58331. * Input blocks
  58332. */
  58333. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58334. /**
  58335. * Bindable blocks (Blocks that need to set data to the effect)
  58336. */
  58337. bindableBlocks: NodeMaterialBlock[];
  58338. /**
  58339. * List of blocks that can provide a compilation fallback
  58340. */
  58341. blocksWithFallbacks: NodeMaterialBlock[];
  58342. /**
  58343. * List of blocks that can provide a define update
  58344. */
  58345. blocksWithDefines: NodeMaterialBlock[];
  58346. /**
  58347. * List of blocks that can provide a repeatable content
  58348. */
  58349. repeatableContentBlocks: NodeMaterialBlock[];
  58350. /**
  58351. * List of blocks that can provide a dynamic list of uniforms
  58352. */
  58353. dynamicUniformBlocks: NodeMaterialBlock[];
  58354. /**
  58355. * List of blocks that can block the isReady function for the material
  58356. */
  58357. blockingBlocks: NodeMaterialBlock[];
  58358. /**
  58359. * Gets the list of animated inputs
  58360. */
  58361. animatedInputs: InputBlock[];
  58362. /**
  58363. * Build Id used to avoid multiple recompilations
  58364. */
  58365. buildId: number;
  58366. /** List of emitted variables */
  58367. variableNames: {
  58368. [key: string]: number;
  58369. };
  58370. /** List of emitted defines */
  58371. defineNames: {
  58372. [key: string]: number;
  58373. };
  58374. /** Should emit comments? */
  58375. emitComments: boolean;
  58376. /** Emit build activity */
  58377. verbose: boolean;
  58378. /** Gets or sets the hosting scene */
  58379. scene: Scene;
  58380. /**
  58381. * Gets the compilation hints emitted at compilation time
  58382. */
  58383. hints: {
  58384. needWorldViewMatrix: boolean;
  58385. needWorldViewProjectionMatrix: boolean;
  58386. needAlphaBlending: boolean;
  58387. needAlphaTesting: boolean;
  58388. };
  58389. /**
  58390. * List of compilation checks
  58391. */
  58392. checks: {
  58393. emitVertex: boolean;
  58394. emitFragment: boolean;
  58395. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58396. };
  58397. /** Creates a new shared data */
  58398. constructor();
  58399. /**
  58400. * Emits console errors and exceptions if there is a failing check
  58401. */
  58402. emitErrors(): void;
  58403. }
  58404. }
  58405. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  58406. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58407. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58408. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  58409. /**
  58410. * Class used to store node based material build state
  58411. */
  58412. export class NodeMaterialBuildState {
  58413. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58414. supportUniformBuffers: boolean;
  58415. /**
  58416. * Gets the list of emitted attributes
  58417. */
  58418. attributes: string[];
  58419. /**
  58420. * Gets the list of emitted uniforms
  58421. */
  58422. uniforms: string[];
  58423. /**
  58424. * Gets the list of emitted constants
  58425. */
  58426. constants: string[];
  58427. /**
  58428. * Gets the list of emitted samplers
  58429. */
  58430. samplers: string[];
  58431. /**
  58432. * Gets the list of emitted functions
  58433. */
  58434. functions: {
  58435. [key: string]: string;
  58436. };
  58437. /**
  58438. * Gets the list of emitted extensions
  58439. */
  58440. extensions: {
  58441. [key: string]: string;
  58442. };
  58443. /**
  58444. * Gets the target of the compilation state
  58445. */
  58446. target: NodeMaterialBlockTargets;
  58447. /**
  58448. * Gets the list of emitted counters
  58449. */
  58450. counters: {
  58451. [key: string]: number;
  58452. };
  58453. /**
  58454. * Shared data between multiple NodeMaterialBuildState instances
  58455. */
  58456. sharedData: NodeMaterialBuildStateSharedData;
  58457. /** @hidden */
  58458. _vertexState: NodeMaterialBuildState;
  58459. /** @hidden */
  58460. _attributeDeclaration: string;
  58461. /** @hidden */
  58462. _uniformDeclaration: string;
  58463. /** @hidden */
  58464. _constantDeclaration: string;
  58465. /** @hidden */
  58466. _samplerDeclaration: string;
  58467. /** @hidden */
  58468. _varyingTransfer: string;
  58469. private _repeatableContentAnchorIndex;
  58470. /** @hidden */
  58471. _builtCompilationString: string;
  58472. /**
  58473. * Gets the emitted compilation strings
  58474. */
  58475. compilationString: string;
  58476. /**
  58477. * Finalize the compilation strings
  58478. * @param state defines the current compilation state
  58479. */
  58480. finalize(state: NodeMaterialBuildState): void;
  58481. /** @hidden */
  58482. get _repeatableContentAnchor(): string;
  58483. /** @hidden */
  58484. _getFreeVariableName(prefix: string): string;
  58485. /** @hidden */
  58486. _getFreeDefineName(prefix: string): string;
  58487. /** @hidden */
  58488. _excludeVariableName(name: string): void;
  58489. /** @hidden */
  58490. _emit2DSampler(name: string): void;
  58491. /** @hidden */
  58492. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58493. /** @hidden */
  58494. _emitExtension(name: string, extension: string): void;
  58495. /** @hidden */
  58496. _emitFunction(name: string, code: string, comments: string): void;
  58497. /** @hidden */
  58498. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58499. replaceStrings?: {
  58500. search: RegExp;
  58501. replace: string;
  58502. }[];
  58503. repeatKey?: string;
  58504. }): string;
  58505. /** @hidden */
  58506. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58507. repeatKey?: string;
  58508. removeAttributes?: boolean;
  58509. removeUniforms?: boolean;
  58510. removeVaryings?: boolean;
  58511. removeIfDef?: boolean;
  58512. replaceStrings?: {
  58513. search: RegExp;
  58514. replace: string;
  58515. }[];
  58516. }, storeKey?: string): void;
  58517. /** @hidden */
  58518. _registerTempVariable(name: string): boolean;
  58519. /** @hidden */
  58520. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58521. /** @hidden */
  58522. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58523. /** @hidden */
  58524. _emitFloat(value: number): string;
  58525. }
  58526. }
  58527. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  58528. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58530. import { Nullable } from "babylonjs/types";
  58531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58532. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58533. import { Effect } from "babylonjs/Materials/effect";
  58534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58535. import { Mesh } from "babylonjs/Meshes/mesh";
  58536. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58537. import { Scene } from "babylonjs/scene";
  58538. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58539. /**
  58540. * Defines a block that can be used inside a node based material
  58541. */
  58542. export class NodeMaterialBlock {
  58543. private _buildId;
  58544. private _buildTarget;
  58545. private _target;
  58546. private _isFinalMerger;
  58547. private _isInput;
  58548. protected _isUnique: boolean;
  58549. /** @hidden */
  58550. _codeVariableName: string;
  58551. /** @hidden */
  58552. _inputs: NodeMaterialConnectionPoint[];
  58553. /** @hidden */
  58554. _outputs: NodeMaterialConnectionPoint[];
  58555. /** @hidden */
  58556. _preparationId: number;
  58557. /**
  58558. * Gets or sets the name of the block
  58559. */
  58560. name: string;
  58561. /**
  58562. * Gets or sets the unique id of the node
  58563. */
  58564. uniqueId: number;
  58565. /**
  58566. * Gets or sets the comments associated with this block
  58567. */
  58568. comments: string;
  58569. /**
  58570. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58571. */
  58572. get isUnique(): boolean;
  58573. /**
  58574. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58575. */
  58576. get isFinalMerger(): boolean;
  58577. /**
  58578. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58579. */
  58580. get isInput(): boolean;
  58581. /**
  58582. * Gets or sets the build Id
  58583. */
  58584. get buildId(): number;
  58585. set buildId(value: number);
  58586. /**
  58587. * Gets or sets the target of the block
  58588. */
  58589. get target(): NodeMaterialBlockTargets;
  58590. set target(value: NodeMaterialBlockTargets);
  58591. /**
  58592. * Gets the list of input points
  58593. */
  58594. get inputs(): NodeMaterialConnectionPoint[];
  58595. /** Gets the list of output points */
  58596. get outputs(): NodeMaterialConnectionPoint[];
  58597. /**
  58598. * Find an input by its name
  58599. * @param name defines the name of the input to look for
  58600. * @returns the input or null if not found
  58601. */
  58602. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58603. /**
  58604. * Find an output by its name
  58605. * @param name defines the name of the outputto look for
  58606. * @returns the output or null if not found
  58607. */
  58608. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58609. /**
  58610. * Creates a new NodeMaterialBlock
  58611. * @param name defines the block name
  58612. * @param target defines the target of that block (Vertex by default)
  58613. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58614. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58615. */
  58616. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58617. /**
  58618. * Initialize the block and prepare the context for build
  58619. * @param state defines the state that will be used for the build
  58620. */
  58621. initialize(state: NodeMaterialBuildState): void;
  58622. /**
  58623. * Bind data to effect. Will only be called for blocks with isBindable === true
  58624. * @param effect defines the effect to bind data to
  58625. * @param nodeMaterial defines the hosting NodeMaterial
  58626. * @param mesh defines the mesh that will be rendered
  58627. */
  58628. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58629. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58630. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58631. protected _writeFloat(value: number): string;
  58632. /**
  58633. * Gets the current class name e.g. "NodeMaterialBlock"
  58634. * @returns the class name
  58635. */
  58636. getClassName(): string;
  58637. /**
  58638. * Register a new input. Must be called inside a block constructor
  58639. * @param name defines the connection point name
  58640. * @param type defines the connection point type
  58641. * @param isOptional defines a boolean indicating that this input can be omitted
  58642. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58643. * @returns the current block
  58644. */
  58645. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58646. /**
  58647. * Register a new output. Must be called inside a block constructor
  58648. * @param name defines the connection point name
  58649. * @param type defines the connection point type
  58650. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58651. * @returns the current block
  58652. */
  58653. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58654. /**
  58655. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58656. * @param forOutput defines an optional connection point to check compatibility with
  58657. * @returns the first available input or null
  58658. */
  58659. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58660. /**
  58661. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58662. * @param forBlock defines an optional block to check compatibility with
  58663. * @returns the first available input or null
  58664. */
  58665. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58666. /**
  58667. * Gets the sibling of the given output
  58668. * @param current defines the current output
  58669. * @returns the next output in the list or null
  58670. */
  58671. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58672. /**
  58673. * Connect current block with another block
  58674. * @param other defines the block to connect with
  58675. * @param options define the various options to help pick the right connections
  58676. * @returns the current block
  58677. */
  58678. connectTo(other: NodeMaterialBlock, options?: {
  58679. input?: string;
  58680. output?: string;
  58681. outputSwizzle?: string;
  58682. }): this | undefined;
  58683. protected _buildBlock(state: NodeMaterialBuildState): void;
  58684. /**
  58685. * Add uniforms, samplers and uniform buffers at compilation time
  58686. * @param state defines the state to update
  58687. * @param nodeMaterial defines the node material requesting the update
  58688. * @param defines defines the material defines to update
  58689. * @param uniformBuffers defines the list of uniform buffer names
  58690. */
  58691. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58692. /**
  58693. * Add potential fallbacks if shader compilation fails
  58694. * @param mesh defines the mesh to be rendered
  58695. * @param fallbacks defines the current prioritized list of fallbacks
  58696. */
  58697. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58698. /**
  58699. * Initialize defines for shader compilation
  58700. * @param mesh defines the mesh to be rendered
  58701. * @param nodeMaterial defines the node material requesting the update
  58702. * @param defines defines the material defines to update
  58703. * @param useInstances specifies that instances should be used
  58704. */
  58705. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58706. /**
  58707. * Update defines for shader compilation
  58708. * @param mesh defines the mesh to be rendered
  58709. * @param nodeMaterial defines the node material requesting the update
  58710. * @param defines defines the material defines to update
  58711. * @param useInstances specifies that instances should be used
  58712. */
  58713. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58714. /**
  58715. * Lets the block try to connect some inputs automatically
  58716. * @param material defines the hosting NodeMaterial
  58717. */
  58718. autoConfigure(material: NodeMaterial): void;
  58719. /**
  58720. * Function called when a block is declared as repeatable content generator
  58721. * @param vertexShaderState defines the current compilation state for the vertex shader
  58722. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58723. * @param mesh defines the mesh to be rendered
  58724. * @param defines defines the material defines to update
  58725. */
  58726. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58727. /**
  58728. * Checks if the block is ready
  58729. * @param mesh defines the mesh to be rendered
  58730. * @param nodeMaterial defines the node material requesting the update
  58731. * @param defines defines the material defines to update
  58732. * @param useInstances specifies that instances should be used
  58733. * @returns true if the block is ready
  58734. */
  58735. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58736. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58737. private _processBuild;
  58738. /**
  58739. * Compile the current node and generate the shader code
  58740. * @param state defines the current compilation state (uniforms, samplers, current string)
  58741. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58742. * @returns true if already built
  58743. */
  58744. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58745. protected _inputRename(name: string): string;
  58746. protected _outputRename(name: string): string;
  58747. protected _dumpPropertiesCode(): string;
  58748. /** @hidden */
  58749. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58750. /** @hidden */
  58751. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58752. /**
  58753. * Clone the current block to a new identical block
  58754. * @param scene defines the hosting scene
  58755. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58756. * @returns a copy of the current block
  58757. */
  58758. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58759. /**
  58760. * Serializes this block in a JSON representation
  58761. * @returns the serialized block object
  58762. */
  58763. serialize(): any;
  58764. /** @hidden */
  58765. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58766. /**
  58767. * Release resources
  58768. */
  58769. dispose(): void;
  58770. }
  58771. }
  58772. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  58773. /**
  58774. * Enum defining the type of animations supported by InputBlock
  58775. */
  58776. export enum AnimatedInputBlockTypes {
  58777. /** No animation */
  58778. None = 0,
  58779. /** Time based animation. Will only work for floats */
  58780. Time = 1
  58781. }
  58782. }
  58783. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  58784. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58785. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58786. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58787. import { Nullable } from "babylonjs/types";
  58788. import { Effect } from "babylonjs/Materials/effect";
  58789. import { Matrix } from "babylonjs/Maths/math.vector";
  58790. import { Scene } from "babylonjs/scene";
  58791. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58793. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58794. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58795. /**
  58796. * Block used to expose an input value
  58797. */
  58798. export class InputBlock extends NodeMaterialBlock {
  58799. private _mode;
  58800. private _associatedVariableName;
  58801. private _storedValue;
  58802. private _valueCallback;
  58803. private _type;
  58804. private _animationType;
  58805. /** Gets or set a value used to limit the range of float values */
  58806. min: number;
  58807. /** Gets or set a value used to limit the range of float values */
  58808. max: number;
  58809. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58810. matrixMode: number;
  58811. /** @hidden */
  58812. _systemValue: Nullable<NodeMaterialSystemValues>;
  58813. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58814. visibleInInspector: boolean;
  58815. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58816. isConstant: boolean;
  58817. /** Gets or sets the group to use to display this block in the Inspector */
  58818. groupInInspector: string;
  58819. /**
  58820. * Gets or sets the connection point type (default is float)
  58821. */
  58822. get type(): NodeMaterialBlockConnectionPointTypes;
  58823. /**
  58824. * Creates a new InputBlock
  58825. * @param name defines the block name
  58826. * @param target defines the target of that block (Vertex by default)
  58827. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58828. */
  58829. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58830. /**
  58831. * Gets the output component
  58832. */
  58833. get output(): NodeMaterialConnectionPoint;
  58834. /**
  58835. * Set the source of this connection point to a vertex attribute
  58836. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58837. * @returns the current connection point
  58838. */
  58839. setAsAttribute(attributeName?: string): InputBlock;
  58840. /**
  58841. * Set the source of this connection point to a system value
  58842. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58843. * @returns the current connection point
  58844. */
  58845. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58846. /**
  58847. * Gets or sets the value of that point.
  58848. * Please note that this value will be ignored if valueCallback is defined
  58849. */
  58850. get value(): any;
  58851. set value(value: any);
  58852. /**
  58853. * Gets or sets a callback used to get the value of that point.
  58854. * Please note that setting this value will force the connection point to ignore the value property
  58855. */
  58856. get valueCallback(): () => any;
  58857. set valueCallback(value: () => any);
  58858. /**
  58859. * Gets or sets the associated variable name in the shader
  58860. */
  58861. get associatedVariableName(): string;
  58862. set associatedVariableName(value: string);
  58863. /** Gets or sets the type of animation applied to the input */
  58864. get animationType(): AnimatedInputBlockTypes;
  58865. set animationType(value: AnimatedInputBlockTypes);
  58866. /**
  58867. * Gets a boolean indicating that this connection point not defined yet
  58868. */
  58869. get isUndefined(): boolean;
  58870. /**
  58871. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58872. * In this case the connection point name must be the name of the uniform to use.
  58873. * Can only be set on inputs
  58874. */
  58875. get isUniform(): boolean;
  58876. set isUniform(value: boolean);
  58877. /**
  58878. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58879. * In this case the connection point name must be the name of the attribute to use
  58880. * Can only be set on inputs
  58881. */
  58882. get isAttribute(): boolean;
  58883. set isAttribute(value: boolean);
  58884. /**
  58885. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58886. * Can only be set on exit points
  58887. */
  58888. get isVarying(): boolean;
  58889. set isVarying(value: boolean);
  58890. /**
  58891. * Gets a boolean indicating that the current connection point is a system value
  58892. */
  58893. get isSystemValue(): boolean;
  58894. /**
  58895. * Gets or sets the current well known value or null if not defined as a system value
  58896. */
  58897. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58898. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58899. /**
  58900. * Gets the current class name
  58901. * @returns the class name
  58902. */
  58903. getClassName(): string;
  58904. /**
  58905. * Animate the input if animationType !== None
  58906. * @param scene defines the rendering scene
  58907. */
  58908. animate(scene: Scene): void;
  58909. private _emitDefine;
  58910. initialize(state: NodeMaterialBuildState): void;
  58911. /**
  58912. * Set the input block to its default value (based on its type)
  58913. */
  58914. setDefaultValue(): void;
  58915. private _emitConstant;
  58916. private _emit;
  58917. /** @hidden */
  58918. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58919. /** @hidden */
  58920. _transmit(effect: Effect, scene: Scene): void;
  58921. protected _buildBlock(state: NodeMaterialBuildState): void;
  58922. protected _dumpPropertiesCode(): string;
  58923. serialize(): any;
  58924. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58925. }
  58926. }
  58927. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  58928. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58929. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58930. import { Nullable } from "babylonjs/types";
  58931. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58932. import { Observable } from "babylonjs/Misc/observable";
  58933. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58934. /**
  58935. * Enum used to define the compatibility state between two connection points
  58936. */
  58937. export enum NodeMaterialConnectionPointCompatibilityStates {
  58938. /** Points are compatibles */
  58939. Compatible = 0,
  58940. /** Points are incompatible because of their types */
  58941. TypeIncompatible = 1,
  58942. /** Points are incompatible because of their targets (vertex vs fragment) */
  58943. TargetIncompatible = 2
  58944. }
  58945. /**
  58946. * Defines the direction of a connection point
  58947. */
  58948. export enum NodeMaterialConnectionPointDirection {
  58949. /** Input */
  58950. Input = 0,
  58951. /** Output */
  58952. Output = 1
  58953. }
  58954. /**
  58955. * Defines a connection point for a block
  58956. */
  58957. export class NodeMaterialConnectionPoint {
  58958. /** @hidden */
  58959. _ownerBlock: NodeMaterialBlock;
  58960. /** @hidden */
  58961. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58962. private _endpoints;
  58963. private _associatedVariableName;
  58964. private _direction;
  58965. /** @hidden */
  58966. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58967. /** @hidden */
  58968. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58969. private _type;
  58970. /** @hidden */
  58971. _enforceAssociatedVariableName: boolean;
  58972. /** Gets the direction of the point */
  58973. get direction(): NodeMaterialConnectionPointDirection;
  58974. /**
  58975. * Gets or sets the additional types supported by this connection point
  58976. */
  58977. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58978. /**
  58979. * Gets or sets the additional types excluded by this connection point
  58980. */
  58981. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58982. /**
  58983. * Observable triggered when this point is connected
  58984. */
  58985. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58986. /**
  58987. * Gets or sets the associated variable name in the shader
  58988. */
  58989. get associatedVariableName(): string;
  58990. set associatedVariableName(value: string);
  58991. /**
  58992. * Gets or sets the connection point type (default is float)
  58993. */
  58994. get type(): NodeMaterialBlockConnectionPointTypes;
  58995. set type(value: NodeMaterialBlockConnectionPointTypes);
  58996. /**
  58997. * Gets or sets the connection point name
  58998. */
  58999. name: string;
  59000. /**
  59001. * Gets or sets a boolean indicating that this connection point can be omitted
  59002. */
  59003. isOptional: boolean;
  59004. /**
  59005. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  59006. */
  59007. define: string;
  59008. /** @hidden */
  59009. _prioritizeVertex: boolean;
  59010. private _target;
  59011. /** Gets or sets the target of that connection point */
  59012. get target(): NodeMaterialBlockTargets;
  59013. set target(value: NodeMaterialBlockTargets);
  59014. /**
  59015. * Gets a boolean indicating that the current point is connected
  59016. */
  59017. get isConnected(): boolean;
  59018. /**
  59019. * Gets a boolean indicating that the current point is connected to an input block
  59020. */
  59021. get isConnectedToInputBlock(): boolean;
  59022. /**
  59023. * Gets a the connected input block (if any)
  59024. */
  59025. get connectInputBlock(): Nullable<InputBlock>;
  59026. /** Get the other side of the connection (if any) */
  59027. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  59028. /** Get the block that owns this connection point */
  59029. get ownerBlock(): NodeMaterialBlock;
  59030. /** Get the block connected on the other side of this connection (if any) */
  59031. get sourceBlock(): Nullable<NodeMaterialBlock>;
  59032. /** Get the block connected on the endpoints of this connection (if any) */
  59033. get connectedBlocks(): Array<NodeMaterialBlock>;
  59034. /** Gets the list of connected endpoints */
  59035. get endpoints(): NodeMaterialConnectionPoint[];
  59036. /** Gets a boolean indicating if that output point is connected to at least one input */
  59037. get hasEndpoints(): boolean;
  59038. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  59039. get isConnectedInVertexShader(): boolean;
  59040. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  59041. get isConnectedInFragmentShader(): boolean;
  59042. /**
  59043. * Creates a new connection point
  59044. * @param name defines the connection point name
  59045. * @param ownerBlock defines the block hosting this connection point
  59046. * @param direction defines the direction of the connection point
  59047. */
  59048. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  59049. /**
  59050. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59051. * @returns the class name
  59052. */
  59053. getClassName(): string;
  59054. /**
  59055. * Gets a boolean indicating if the current point can be connected to another point
  59056. * @param connectionPoint defines the other connection point
  59057. * @returns a boolean
  59058. */
  59059. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  59060. /**
  59061. * Gets a number indicating if the current point can be connected to another point
  59062. * @param connectionPoint defines the other connection point
  59063. * @returns a number defining the compatibility state
  59064. */
  59065. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  59066. /**
  59067. * Connect this point to another connection point
  59068. * @param connectionPoint defines the other connection point
  59069. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  59070. * @returns the current connection point
  59071. */
  59072. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  59073. /**
  59074. * Disconnect this point from one of his endpoint
  59075. * @param endpoint defines the other connection point
  59076. * @returns the current connection point
  59077. */
  59078. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  59079. /**
  59080. * Serializes this point in a JSON representation
  59081. * @returns the serialized point object
  59082. */
  59083. serialize(): any;
  59084. /**
  59085. * Release resources
  59086. */
  59087. dispose(): void;
  59088. }
  59089. }
  59090. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  59091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59092. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59094. import { Mesh } from "babylonjs/Meshes/mesh";
  59095. import { Effect } from "babylonjs/Materials/effect";
  59096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59097. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59098. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59099. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59100. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59101. /**
  59102. * Block used to add support for vertex skinning (bones)
  59103. */
  59104. export class BonesBlock extends NodeMaterialBlock {
  59105. /**
  59106. * Creates a new BonesBlock
  59107. * @param name defines the block name
  59108. */
  59109. constructor(name: string);
  59110. /**
  59111. * Initialize the block and prepare the context for build
  59112. * @param state defines the state that will be used for the build
  59113. */
  59114. initialize(state: NodeMaterialBuildState): void;
  59115. /**
  59116. * Gets the current class name
  59117. * @returns the class name
  59118. */
  59119. getClassName(): string;
  59120. /**
  59121. * Gets the matrix indices input component
  59122. */
  59123. get matricesIndices(): NodeMaterialConnectionPoint;
  59124. /**
  59125. * Gets the matrix weights input component
  59126. */
  59127. get matricesWeights(): NodeMaterialConnectionPoint;
  59128. /**
  59129. * Gets the extra matrix indices input component
  59130. */
  59131. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59132. /**
  59133. * Gets the extra matrix weights input component
  59134. */
  59135. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59136. /**
  59137. * Gets the world input component
  59138. */
  59139. get world(): NodeMaterialConnectionPoint;
  59140. /**
  59141. * Gets the output component
  59142. */
  59143. get output(): NodeMaterialConnectionPoint;
  59144. autoConfigure(material: NodeMaterial): void;
  59145. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59146. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59148. protected _buildBlock(state: NodeMaterialBuildState): this;
  59149. }
  59150. }
  59151. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  59152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59153. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59154. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59156. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59157. /**
  59158. * Block used to add support for instances
  59159. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59160. */
  59161. export class InstancesBlock extends NodeMaterialBlock {
  59162. /**
  59163. * Creates a new InstancesBlock
  59164. * @param name defines the block name
  59165. */
  59166. constructor(name: string);
  59167. /**
  59168. * Gets the current class name
  59169. * @returns the class name
  59170. */
  59171. getClassName(): string;
  59172. /**
  59173. * Gets the first world row input component
  59174. */
  59175. get world0(): NodeMaterialConnectionPoint;
  59176. /**
  59177. * Gets the second world row input component
  59178. */
  59179. get world1(): NodeMaterialConnectionPoint;
  59180. /**
  59181. * Gets the third world row input component
  59182. */
  59183. get world2(): NodeMaterialConnectionPoint;
  59184. /**
  59185. * Gets the forth world row input component
  59186. */
  59187. get world3(): NodeMaterialConnectionPoint;
  59188. /**
  59189. * Gets the world input component
  59190. */
  59191. get world(): NodeMaterialConnectionPoint;
  59192. /**
  59193. * Gets the output component
  59194. */
  59195. get output(): NodeMaterialConnectionPoint;
  59196. autoConfigure(material: NodeMaterial): void;
  59197. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59198. protected _buildBlock(state: NodeMaterialBuildState): this;
  59199. }
  59200. }
  59201. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  59202. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59204. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59206. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59207. import { Effect } from "babylonjs/Materials/effect";
  59208. import { Mesh } from "babylonjs/Meshes/mesh";
  59209. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59210. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59211. /**
  59212. * Block used to add morph targets support to vertex shader
  59213. */
  59214. export class MorphTargetsBlock extends NodeMaterialBlock {
  59215. private _repeatableContentAnchor;
  59216. private _repeatebleContentGenerated;
  59217. /**
  59218. * Create a new MorphTargetsBlock
  59219. * @param name defines the block name
  59220. */
  59221. constructor(name: string);
  59222. /**
  59223. * Gets the current class name
  59224. * @returns the class name
  59225. */
  59226. getClassName(): string;
  59227. /**
  59228. * Gets the position input component
  59229. */
  59230. get position(): NodeMaterialConnectionPoint;
  59231. /**
  59232. * Gets the normal input component
  59233. */
  59234. get normal(): NodeMaterialConnectionPoint;
  59235. /**
  59236. * Gets the tangent input component
  59237. */
  59238. get tangent(): NodeMaterialConnectionPoint;
  59239. /**
  59240. * Gets the tangent input component
  59241. */
  59242. get uv(): NodeMaterialConnectionPoint;
  59243. /**
  59244. * Gets the position output component
  59245. */
  59246. get positionOutput(): NodeMaterialConnectionPoint;
  59247. /**
  59248. * Gets the normal output component
  59249. */
  59250. get normalOutput(): NodeMaterialConnectionPoint;
  59251. /**
  59252. * Gets the tangent output component
  59253. */
  59254. get tangentOutput(): NodeMaterialConnectionPoint;
  59255. /**
  59256. * Gets the tangent output component
  59257. */
  59258. get uvOutput(): NodeMaterialConnectionPoint;
  59259. initialize(state: NodeMaterialBuildState): void;
  59260. autoConfigure(material: NodeMaterial): void;
  59261. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59262. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59263. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59264. protected _buildBlock(state: NodeMaterialBuildState): this;
  59265. }
  59266. }
  59267. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  59268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59271. import { Nullable } from "babylonjs/types";
  59272. import { Scene } from "babylonjs/scene";
  59273. import { Effect } from "babylonjs/Materials/effect";
  59274. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59275. import { Mesh } from "babylonjs/Meshes/mesh";
  59276. import { Light } from "babylonjs/Lights/light";
  59277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59278. /**
  59279. * Block used to get data information from a light
  59280. */
  59281. export class LightInformationBlock extends NodeMaterialBlock {
  59282. private _lightDataUniformName;
  59283. private _lightColorUniformName;
  59284. private _lightTypeDefineName;
  59285. /**
  59286. * Gets or sets the light associated with this block
  59287. */
  59288. light: Nullable<Light>;
  59289. /**
  59290. * Creates a new LightInformationBlock
  59291. * @param name defines the block name
  59292. */
  59293. constructor(name: string);
  59294. /**
  59295. * Gets the current class name
  59296. * @returns the class name
  59297. */
  59298. getClassName(): string;
  59299. /**
  59300. * Gets the world position input component
  59301. */
  59302. get worldPosition(): NodeMaterialConnectionPoint;
  59303. /**
  59304. * Gets the direction output component
  59305. */
  59306. get direction(): NodeMaterialConnectionPoint;
  59307. /**
  59308. * Gets the direction output component
  59309. */
  59310. get color(): NodeMaterialConnectionPoint;
  59311. /**
  59312. * Gets the direction output component
  59313. */
  59314. get intensity(): NodeMaterialConnectionPoint;
  59315. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59316. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59317. protected _buildBlock(state: NodeMaterialBuildState): this;
  59318. serialize(): any;
  59319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59320. }
  59321. }
  59322. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  59323. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  59324. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  59325. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  59326. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  59327. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  59328. }
  59329. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  59330. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59331. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59334. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59335. import { Effect } from "babylonjs/Materials/effect";
  59336. import { Mesh } from "babylonjs/Meshes/mesh";
  59337. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59338. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59339. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59340. /**
  59341. * Block used to add image processing support to fragment shader
  59342. */
  59343. export class ImageProcessingBlock extends NodeMaterialBlock {
  59344. /**
  59345. * Create a new ImageProcessingBlock
  59346. * @param name defines the block name
  59347. */
  59348. constructor(name: string);
  59349. /**
  59350. * Gets the current class name
  59351. * @returns the class name
  59352. */
  59353. getClassName(): string;
  59354. /**
  59355. * Gets the color input component
  59356. */
  59357. get color(): NodeMaterialConnectionPoint;
  59358. /**
  59359. * Gets the output component
  59360. */
  59361. get output(): NodeMaterialConnectionPoint;
  59362. /**
  59363. * Initialize the block and prepare the context for build
  59364. * @param state defines the state that will be used for the build
  59365. */
  59366. initialize(state: NodeMaterialBuildState): void;
  59367. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59369. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59370. protected _buildBlock(state: NodeMaterialBuildState): this;
  59371. }
  59372. }
  59373. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  59374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59376. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59377. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59379. import { Effect } from "babylonjs/Materials/effect";
  59380. import { Mesh } from "babylonjs/Meshes/mesh";
  59381. import { Scene } from "babylonjs/scene";
  59382. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  59383. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  59384. /**
  59385. * Block used to pertub normals based on a normal map
  59386. */
  59387. export class PerturbNormalBlock extends NodeMaterialBlock {
  59388. private _tangentSpaceParameterName;
  59389. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59390. invertX: boolean;
  59391. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59392. invertY: boolean;
  59393. /**
  59394. * Create a new PerturbNormalBlock
  59395. * @param name defines the block name
  59396. */
  59397. constructor(name: string);
  59398. /**
  59399. * Gets the current class name
  59400. * @returns the class name
  59401. */
  59402. getClassName(): string;
  59403. /**
  59404. * Gets the world position input component
  59405. */
  59406. get worldPosition(): NodeMaterialConnectionPoint;
  59407. /**
  59408. * Gets the world normal input component
  59409. */
  59410. get worldNormal(): NodeMaterialConnectionPoint;
  59411. /**
  59412. * Gets the uv input component
  59413. */
  59414. get uv(): NodeMaterialConnectionPoint;
  59415. /**
  59416. * Gets the normal map color input component
  59417. */
  59418. get normalMapColor(): NodeMaterialConnectionPoint;
  59419. /**
  59420. * Gets the strength input component
  59421. */
  59422. get strength(): NodeMaterialConnectionPoint;
  59423. /**
  59424. * Gets the output component
  59425. */
  59426. get output(): NodeMaterialConnectionPoint;
  59427. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59428. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59429. autoConfigure(material: NodeMaterial): void;
  59430. protected _buildBlock(state: NodeMaterialBuildState): this;
  59431. protected _dumpPropertiesCode(): string;
  59432. serialize(): any;
  59433. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59434. }
  59435. }
  59436. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  59437. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59438. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59439. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59440. /**
  59441. * Block used to discard a pixel if a value is smaller than a cutoff
  59442. */
  59443. export class DiscardBlock extends NodeMaterialBlock {
  59444. /**
  59445. * Create a new DiscardBlock
  59446. * @param name defines the block name
  59447. */
  59448. constructor(name: string);
  59449. /**
  59450. * Gets the current class name
  59451. * @returns the class name
  59452. */
  59453. getClassName(): string;
  59454. /**
  59455. * Gets the color input component
  59456. */
  59457. get value(): NodeMaterialConnectionPoint;
  59458. /**
  59459. * Gets the cutoff input component
  59460. */
  59461. get cutoff(): NodeMaterialConnectionPoint;
  59462. protected _buildBlock(state: NodeMaterialBuildState): this;
  59463. }
  59464. }
  59465. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  59466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59469. /**
  59470. * Block used to test if the fragment shader is front facing
  59471. */
  59472. export class FrontFacingBlock extends NodeMaterialBlock {
  59473. /**
  59474. * Creates a new FrontFacingBlock
  59475. * @param name defines the block name
  59476. */
  59477. constructor(name: string);
  59478. /**
  59479. * Gets the current class name
  59480. * @returns the class name
  59481. */
  59482. getClassName(): string;
  59483. /**
  59484. * Gets the output component
  59485. */
  59486. get output(): NodeMaterialConnectionPoint;
  59487. protected _buildBlock(state: NodeMaterialBuildState): this;
  59488. }
  59489. }
  59490. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  59491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59494. /**
  59495. * Block used to get the derivative value on x and y of a given input
  59496. */
  59497. export class DerivativeBlock extends NodeMaterialBlock {
  59498. /**
  59499. * Create a new DerivativeBlock
  59500. * @param name defines the block name
  59501. */
  59502. constructor(name: string);
  59503. /**
  59504. * Gets the current class name
  59505. * @returns the class name
  59506. */
  59507. getClassName(): string;
  59508. /**
  59509. * Gets the input component
  59510. */
  59511. get input(): NodeMaterialConnectionPoint;
  59512. /**
  59513. * Gets the derivative output on x
  59514. */
  59515. get dx(): NodeMaterialConnectionPoint;
  59516. /**
  59517. * Gets the derivative output on y
  59518. */
  59519. get dy(): NodeMaterialConnectionPoint;
  59520. protected _buildBlock(state: NodeMaterialBuildState): this;
  59521. }
  59522. }
  59523. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  59524. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  59525. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  59526. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  59527. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  59528. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  59529. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  59530. }
  59531. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  59532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59534. import { Mesh } from "babylonjs/Meshes/mesh";
  59535. import { Effect } from "babylonjs/Materials/effect";
  59536. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59538. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59539. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59540. /**
  59541. * Block used to add support for scene fog
  59542. */
  59543. export class FogBlock extends NodeMaterialBlock {
  59544. private _fogDistanceName;
  59545. private _fogParameters;
  59546. /**
  59547. * Create a new FogBlock
  59548. * @param name defines the block name
  59549. */
  59550. constructor(name: string);
  59551. /**
  59552. * Gets the current class name
  59553. * @returns the class name
  59554. */
  59555. getClassName(): string;
  59556. /**
  59557. * Gets the world position input component
  59558. */
  59559. get worldPosition(): NodeMaterialConnectionPoint;
  59560. /**
  59561. * Gets the view input component
  59562. */
  59563. get view(): NodeMaterialConnectionPoint;
  59564. /**
  59565. * Gets the color input component
  59566. */
  59567. get input(): NodeMaterialConnectionPoint;
  59568. /**
  59569. * Gets the fog color input component
  59570. */
  59571. get fogColor(): NodeMaterialConnectionPoint;
  59572. /**
  59573. * Gets the output component
  59574. */
  59575. get output(): NodeMaterialConnectionPoint;
  59576. autoConfigure(material: NodeMaterial): void;
  59577. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59578. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59579. protected _buildBlock(state: NodeMaterialBuildState): this;
  59580. }
  59581. }
  59582. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  59583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59587. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59588. import { Effect } from "babylonjs/Materials/effect";
  59589. import { Mesh } from "babylonjs/Meshes/mesh";
  59590. import { Light } from "babylonjs/Lights/light";
  59591. import { Nullable } from "babylonjs/types";
  59592. import { Scene } from "babylonjs/scene";
  59593. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59594. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59595. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59596. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59597. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59598. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59599. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59600. /**
  59601. * Block used to add light in the fragment shader
  59602. */
  59603. export class LightBlock extends NodeMaterialBlock {
  59604. private _lightId;
  59605. /**
  59606. * Gets or sets the light associated with this block
  59607. */
  59608. light: Nullable<Light>;
  59609. /**
  59610. * Create a new LightBlock
  59611. * @param name defines the block name
  59612. */
  59613. constructor(name: string);
  59614. /**
  59615. * Gets the current class name
  59616. * @returns the class name
  59617. */
  59618. getClassName(): string;
  59619. /**
  59620. * Gets the world position input component
  59621. */
  59622. get worldPosition(): NodeMaterialConnectionPoint;
  59623. /**
  59624. * Gets the world normal input component
  59625. */
  59626. get worldNormal(): NodeMaterialConnectionPoint;
  59627. /**
  59628. * Gets the camera (or eye) position component
  59629. */
  59630. get cameraPosition(): NodeMaterialConnectionPoint;
  59631. /**
  59632. * Gets the glossiness component
  59633. */
  59634. get glossiness(): NodeMaterialConnectionPoint;
  59635. /**
  59636. * Gets the glossinness power component
  59637. */
  59638. get glossPower(): NodeMaterialConnectionPoint;
  59639. /**
  59640. * Gets the diffuse color component
  59641. */
  59642. get diffuseColor(): NodeMaterialConnectionPoint;
  59643. /**
  59644. * Gets the specular color component
  59645. */
  59646. get specularColor(): NodeMaterialConnectionPoint;
  59647. /**
  59648. * Gets the diffuse output component
  59649. */
  59650. get diffuseOutput(): NodeMaterialConnectionPoint;
  59651. /**
  59652. * Gets the specular output component
  59653. */
  59654. get specularOutput(): NodeMaterialConnectionPoint;
  59655. /**
  59656. * Gets the shadow output component
  59657. */
  59658. get shadow(): NodeMaterialConnectionPoint;
  59659. autoConfigure(material: NodeMaterial): void;
  59660. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59661. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59662. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59663. private _injectVertexCode;
  59664. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59665. serialize(): any;
  59666. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59667. }
  59668. }
  59669. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  59670. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  59671. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  59672. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59673. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59674. }
  59675. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  59676. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59677. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  59678. }
  59679. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  59680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59683. /**
  59684. * Block used to multiply 2 values
  59685. */
  59686. export class MultiplyBlock extends NodeMaterialBlock {
  59687. /**
  59688. * Creates a new MultiplyBlock
  59689. * @param name defines the block name
  59690. */
  59691. constructor(name: string);
  59692. /**
  59693. * Gets the current class name
  59694. * @returns the class name
  59695. */
  59696. getClassName(): string;
  59697. /**
  59698. * Gets the left operand input component
  59699. */
  59700. get left(): NodeMaterialConnectionPoint;
  59701. /**
  59702. * Gets the right operand input component
  59703. */
  59704. get right(): NodeMaterialConnectionPoint;
  59705. /**
  59706. * Gets the output component
  59707. */
  59708. get output(): NodeMaterialConnectionPoint;
  59709. protected _buildBlock(state: NodeMaterialBuildState): this;
  59710. }
  59711. }
  59712. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  59713. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59714. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59715. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59716. /**
  59717. * Block used to add 2 vectors
  59718. */
  59719. export class AddBlock extends NodeMaterialBlock {
  59720. /**
  59721. * Creates a new AddBlock
  59722. * @param name defines the block name
  59723. */
  59724. constructor(name: string);
  59725. /**
  59726. * Gets the current class name
  59727. * @returns the class name
  59728. */
  59729. getClassName(): string;
  59730. /**
  59731. * Gets the left operand input component
  59732. */
  59733. get left(): NodeMaterialConnectionPoint;
  59734. /**
  59735. * Gets the right operand input component
  59736. */
  59737. get right(): NodeMaterialConnectionPoint;
  59738. /**
  59739. * Gets the output component
  59740. */
  59741. get output(): NodeMaterialConnectionPoint;
  59742. protected _buildBlock(state: NodeMaterialBuildState): this;
  59743. }
  59744. }
  59745. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  59746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59749. /**
  59750. * Block used to scale a vector by a float
  59751. */
  59752. export class ScaleBlock extends NodeMaterialBlock {
  59753. /**
  59754. * Creates a new ScaleBlock
  59755. * @param name defines the block name
  59756. */
  59757. constructor(name: string);
  59758. /**
  59759. * Gets the current class name
  59760. * @returns the class name
  59761. */
  59762. getClassName(): string;
  59763. /**
  59764. * Gets the input component
  59765. */
  59766. get input(): NodeMaterialConnectionPoint;
  59767. /**
  59768. * Gets the factor input component
  59769. */
  59770. get factor(): NodeMaterialConnectionPoint;
  59771. /**
  59772. * Gets the output component
  59773. */
  59774. get output(): NodeMaterialConnectionPoint;
  59775. protected _buildBlock(state: NodeMaterialBuildState): this;
  59776. }
  59777. }
  59778. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  59779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59782. import { Scene } from "babylonjs/scene";
  59783. /**
  59784. * Block used to clamp a float
  59785. */
  59786. export class ClampBlock extends NodeMaterialBlock {
  59787. /** Gets or sets the minimum range */
  59788. minimum: number;
  59789. /** Gets or sets the maximum range */
  59790. maximum: number;
  59791. /**
  59792. * Creates a new ClampBlock
  59793. * @param name defines the block name
  59794. */
  59795. constructor(name: string);
  59796. /**
  59797. * Gets the current class name
  59798. * @returns the class name
  59799. */
  59800. getClassName(): string;
  59801. /**
  59802. * Gets the value input component
  59803. */
  59804. get value(): NodeMaterialConnectionPoint;
  59805. /**
  59806. * Gets the output component
  59807. */
  59808. get output(): NodeMaterialConnectionPoint;
  59809. protected _buildBlock(state: NodeMaterialBuildState): this;
  59810. protected _dumpPropertiesCode(): string;
  59811. serialize(): any;
  59812. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59813. }
  59814. }
  59815. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  59816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59818. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59819. /**
  59820. * Block used to apply a cross product between 2 vectors
  59821. */
  59822. export class CrossBlock extends NodeMaterialBlock {
  59823. /**
  59824. * Creates a new CrossBlock
  59825. * @param name defines the block name
  59826. */
  59827. constructor(name: string);
  59828. /**
  59829. * Gets the current class name
  59830. * @returns the class name
  59831. */
  59832. getClassName(): string;
  59833. /**
  59834. * Gets the left operand input component
  59835. */
  59836. get left(): NodeMaterialConnectionPoint;
  59837. /**
  59838. * Gets the right operand input component
  59839. */
  59840. get right(): NodeMaterialConnectionPoint;
  59841. /**
  59842. * Gets the output component
  59843. */
  59844. get output(): NodeMaterialConnectionPoint;
  59845. protected _buildBlock(state: NodeMaterialBuildState): this;
  59846. }
  59847. }
  59848. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  59849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59852. /**
  59853. * Block used to apply a dot product between 2 vectors
  59854. */
  59855. export class DotBlock extends NodeMaterialBlock {
  59856. /**
  59857. * Creates a new DotBlock
  59858. * @param name defines the block name
  59859. */
  59860. constructor(name: string);
  59861. /**
  59862. * Gets the current class name
  59863. * @returns the class name
  59864. */
  59865. getClassName(): string;
  59866. /**
  59867. * Gets the left operand input component
  59868. */
  59869. get left(): NodeMaterialConnectionPoint;
  59870. /**
  59871. * Gets the right operand input component
  59872. */
  59873. get right(): NodeMaterialConnectionPoint;
  59874. /**
  59875. * Gets the output component
  59876. */
  59877. get output(): NodeMaterialConnectionPoint;
  59878. protected _buildBlock(state: NodeMaterialBuildState): this;
  59879. }
  59880. }
  59881. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  59882. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59883. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59884. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59885. import { Vector2 } from "babylonjs/Maths/math.vector";
  59886. import { Scene } from "babylonjs/scene";
  59887. /**
  59888. * Block used to remap a float from a range to a new one
  59889. */
  59890. export class RemapBlock extends NodeMaterialBlock {
  59891. /**
  59892. * Gets or sets the source range
  59893. */
  59894. sourceRange: Vector2;
  59895. /**
  59896. * Gets or sets the target range
  59897. */
  59898. targetRange: Vector2;
  59899. /**
  59900. * Creates a new RemapBlock
  59901. * @param name defines the block name
  59902. */
  59903. constructor(name: string);
  59904. /**
  59905. * Gets the current class name
  59906. * @returns the class name
  59907. */
  59908. getClassName(): string;
  59909. /**
  59910. * Gets the input component
  59911. */
  59912. get input(): NodeMaterialConnectionPoint;
  59913. /**
  59914. * Gets the source min input component
  59915. */
  59916. get sourceMin(): NodeMaterialConnectionPoint;
  59917. /**
  59918. * Gets the source max input component
  59919. */
  59920. get sourceMax(): NodeMaterialConnectionPoint;
  59921. /**
  59922. * Gets the target min input component
  59923. */
  59924. get targetMin(): NodeMaterialConnectionPoint;
  59925. /**
  59926. * Gets the target max input component
  59927. */
  59928. get targetMax(): NodeMaterialConnectionPoint;
  59929. /**
  59930. * Gets the output component
  59931. */
  59932. get output(): NodeMaterialConnectionPoint;
  59933. protected _buildBlock(state: NodeMaterialBuildState): this;
  59934. protected _dumpPropertiesCode(): string;
  59935. serialize(): any;
  59936. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59937. }
  59938. }
  59939. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  59940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59943. /**
  59944. * Block used to normalize a vector
  59945. */
  59946. export class NormalizeBlock extends NodeMaterialBlock {
  59947. /**
  59948. * Creates a new NormalizeBlock
  59949. * @param name defines the block name
  59950. */
  59951. constructor(name: string);
  59952. /**
  59953. * Gets the current class name
  59954. * @returns the class name
  59955. */
  59956. getClassName(): string;
  59957. /**
  59958. * Gets the input component
  59959. */
  59960. get input(): NodeMaterialConnectionPoint;
  59961. /**
  59962. * Gets the output component
  59963. */
  59964. get output(): NodeMaterialConnectionPoint;
  59965. protected _buildBlock(state: NodeMaterialBuildState): this;
  59966. }
  59967. }
  59968. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  59969. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59970. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59971. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59972. import { Scene } from "babylonjs/scene";
  59973. /**
  59974. * Operations supported by the Trigonometry block
  59975. */
  59976. export enum TrigonometryBlockOperations {
  59977. /** Cos */
  59978. Cos = 0,
  59979. /** Sin */
  59980. Sin = 1,
  59981. /** Abs */
  59982. Abs = 2,
  59983. /** Exp */
  59984. Exp = 3,
  59985. /** Exp2 */
  59986. Exp2 = 4,
  59987. /** Round */
  59988. Round = 5,
  59989. /** Floor */
  59990. Floor = 6,
  59991. /** Ceiling */
  59992. Ceiling = 7,
  59993. /** Square root */
  59994. Sqrt = 8,
  59995. /** Log */
  59996. Log = 9,
  59997. /** Tangent */
  59998. Tan = 10,
  59999. /** Arc tangent */
  60000. ArcTan = 11,
  60001. /** Arc cosinus */
  60002. ArcCos = 12,
  60003. /** Arc sinus */
  60004. ArcSin = 13,
  60005. /** Fraction */
  60006. Fract = 14,
  60007. /** Sign */
  60008. Sign = 15,
  60009. /** To radians (from degrees) */
  60010. Radians = 16,
  60011. /** To degrees (from radians) */
  60012. Degrees = 17
  60013. }
  60014. /**
  60015. * Block used to apply trigonometry operation to floats
  60016. */
  60017. export class TrigonometryBlock extends NodeMaterialBlock {
  60018. /**
  60019. * Gets or sets the operation applied by the block
  60020. */
  60021. operation: TrigonometryBlockOperations;
  60022. /**
  60023. * Creates a new TrigonometryBlock
  60024. * @param name defines the block name
  60025. */
  60026. constructor(name: string);
  60027. /**
  60028. * Gets the current class name
  60029. * @returns the class name
  60030. */
  60031. getClassName(): string;
  60032. /**
  60033. * Gets the input component
  60034. */
  60035. get input(): NodeMaterialConnectionPoint;
  60036. /**
  60037. * Gets the output component
  60038. */
  60039. get output(): NodeMaterialConnectionPoint;
  60040. protected _buildBlock(state: NodeMaterialBuildState): this;
  60041. serialize(): any;
  60042. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60043. protected _dumpPropertiesCode(): string;
  60044. }
  60045. }
  60046. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  60047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60050. /**
  60051. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60052. */
  60053. export class ColorMergerBlock extends NodeMaterialBlock {
  60054. /**
  60055. * Create a new ColorMergerBlock
  60056. * @param name defines the block name
  60057. */
  60058. constructor(name: string);
  60059. /**
  60060. * Gets the current class name
  60061. * @returns the class name
  60062. */
  60063. getClassName(): string;
  60064. /**
  60065. * Gets the rgb component (input)
  60066. */
  60067. get rgbIn(): NodeMaterialConnectionPoint;
  60068. /**
  60069. * Gets the r component (input)
  60070. */
  60071. get r(): NodeMaterialConnectionPoint;
  60072. /**
  60073. * Gets the g component (input)
  60074. */
  60075. get g(): NodeMaterialConnectionPoint;
  60076. /**
  60077. * Gets the b component (input)
  60078. */
  60079. get b(): NodeMaterialConnectionPoint;
  60080. /**
  60081. * Gets the a component (input)
  60082. */
  60083. get a(): NodeMaterialConnectionPoint;
  60084. /**
  60085. * Gets the rgba component (output)
  60086. */
  60087. get rgba(): NodeMaterialConnectionPoint;
  60088. /**
  60089. * Gets the rgb component (output)
  60090. */
  60091. get rgbOut(): NodeMaterialConnectionPoint;
  60092. /**
  60093. * Gets the rgb component (output)
  60094. * @deprecated Please use rgbOut instead.
  60095. */
  60096. get rgb(): NodeMaterialConnectionPoint;
  60097. protected _buildBlock(state: NodeMaterialBuildState): this;
  60098. }
  60099. }
  60100. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60104. /**
  60105. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60106. */
  60107. export class VectorMergerBlock extends NodeMaterialBlock {
  60108. /**
  60109. * Create a new VectorMergerBlock
  60110. * @param name defines the block name
  60111. */
  60112. constructor(name: string);
  60113. /**
  60114. * Gets the current class name
  60115. * @returns the class name
  60116. */
  60117. getClassName(): string;
  60118. /**
  60119. * Gets the xyz component (input)
  60120. */
  60121. get xyzIn(): NodeMaterialConnectionPoint;
  60122. /**
  60123. * Gets the xy component (input)
  60124. */
  60125. get xyIn(): NodeMaterialConnectionPoint;
  60126. /**
  60127. * Gets the x component (input)
  60128. */
  60129. get x(): NodeMaterialConnectionPoint;
  60130. /**
  60131. * Gets the y component (input)
  60132. */
  60133. get y(): NodeMaterialConnectionPoint;
  60134. /**
  60135. * Gets the z component (input)
  60136. */
  60137. get z(): NodeMaterialConnectionPoint;
  60138. /**
  60139. * Gets the w component (input)
  60140. */
  60141. get w(): NodeMaterialConnectionPoint;
  60142. /**
  60143. * Gets the xyzw component (output)
  60144. */
  60145. get xyzw(): NodeMaterialConnectionPoint;
  60146. /**
  60147. * Gets the xyz component (output)
  60148. */
  60149. get xyzOut(): NodeMaterialConnectionPoint;
  60150. /**
  60151. * Gets the xy component (output)
  60152. */
  60153. get xyOut(): NodeMaterialConnectionPoint;
  60154. /**
  60155. * Gets the xy component (output)
  60156. * @deprecated Please use xyOut instead.
  60157. */
  60158. get xy(): NodeMaterialConnectionPoint;
  60159. /**
  60160. * Gets the xyz component (output)
  60161. * @deprecated Please use xyzOut instead.
  60162. */
  60163. get xyz(): NodeMaterialConnectionPoint;
  60164. protected _buildBlock(state: NodeMaterialBuildState): this;
  60165. }
  60166. }
  60167. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  60168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60171. /**
  60172. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60173. */
  60174. export class ColorSplitterBlock extends NodeMaterialBlock {
  60175. /**
  60176. * Create a new ColorSplitterBlock
  60177. * @param name defines the block name
  60178. */
  60179. constructor(name: string);
  60180. /**
  60181. * Gets the current class name
  60182. * @returns the class name
  60183. */
  60184. getClassName(): string;
  60185. /**
  60186. * Gets the rgba component (input)
  60187. */
  60188. get rgba(): NodeMaterialConnectionPoint;
  60189. /**
  60190. * Gets the rgb component (input)
  60191. */
  60192. get rgbIn(): NodeMaterialConnectionPoint;
  60193. /**
  60194. * Gets the rgb component (output)
  60195. */
  60196. get rgbOut(): NodeMaterialConnectionPoint;
  60197. /**
  60198. * Gets the r component (output)
  60199. */
  60200. get r(): NodeMaterialConnectionPoint;
  60201. /**
  60202. * Gets the g component (output)
  60203. */
  60204. get g(): NodeMaterialConnectionPoint;
  60205. /**
  60206. * Gets the b component (output)
  60207. */
  60208. get b(): NodeMaterialConnectionPoint;
  60209. /**
  60210. * Gets the a component (output)
  60211. */
  60212. get a(): NodeMaterialConnectionPoint;
  60213. protected _inputRename(name: string): string;
  60214. protected _outputRename(name: string): string;
  60215. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60216. }
  60217. }
  60218. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  60219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60222. /**
  60223. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60224. */
  60225. export class VectorSplitterBlock extends NodeMaterialBlock {
  60226. /**
  60227. * Create a new VectorSplitterBlock
  60228. * @param name defines the block name
  60229. */
  60230. constructor(name: string);
  60231. /**
  60232. * Gets the current class name
  60233. * @returns the class name
  60234. */
  60235. getClassName(): string;
  60236. /**
  60237. * Gets the xyzw component (input)
  60238. */
  60239. get xyzw(): NodeMaterialConnectionPoint;
  60240. /**
  60241. * Gets the xyz component (input)
  60242. */
  60243. get xyzIn(): NodeMaterialConnectionPoint;
  60244. /**
  60245. * Gets the xy component (input)
  60246. */
  60247. get xyIn(): NodeMaterialConnectionPoint;
  60248. /**
  60249. * Gets the xyz component (output)
  60250. */
  60251. get xyzOut(): NodeMaterialConnectionPoint;
  60252. /**
  60253. * Gets the xy component (output)
  60254. */
  60255. get xyOut(): NodeMaterialConnectionPoint;
  60256. /**
  60257. * Gets the x component (output)
  60258. */
  60259. get x(): NodeMaterialConnectionPoint;
  60260. /**
  60261. * Gets the y component (output)
  60262. */
  60263. get y(): NodeMaterialConnectionPoint;
  60264. /**
  60265. * Gets the z component (output)
  60266. */
  60267. get z(): NodeMaterialConnectionPoint;
  60268. /**
  60269. * Gets the w component (output)
  60270. */
  60271. get w(): NodeMaterialConnectionPoint;
  60272. protected _inputRename(name: string): string;
  60273. protected _outputRename(name: string): string;
  60274. protected _buildBlock(state: NodeMaterialBuildState): this;
  60275. }
  60276. }
  60277. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  60278. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60281. /**
  60282. * Block used to lerp between 2 values
  60283. */
  60284. export class LerpBlock extends NodeMaterialBlock {
  60285. /**
  60286. * Creates a new LerpBlock
  60287. * @param name defines the block name
  60288. */
  60289. constructor(name: string);
  60290. /**
  60291. * Gets the current class name
  60292. * @returns the class name
  60293. */
  60294. getClassName(): string;
  60295. /**
  60296. * Gets the left operand input component
  60297. */
  60298. get left(): NodeMaterialConnectionPoint;
  60299. /**
  60300. * Gets the right operand input component
  60301. */
  60302. get right(): NodeMaterialConnectionPoint;
  60303. /**
  60304. * Gets the gradient operand input component
  60305. */
  60306. get gradient(): NodeMaterialConnectionPoint;
  60307. /**
  60308. * Gets the output component
  60309. */
  60310. get output(): NodeMaterialConnectionPoint;
  60311. protected _buildBlock(state: NodeMaterialBuildState): this;
  60312. }
  60313. }
  60314. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  60315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60318. /**
  60319. * Block used to divide 2 vectors
  60320. */
  60321. export class DivideBlock extends NodeMaterialBlock {
  60322. /**
  60323. * Creates a new DivideBlock
  60324. * @param name defines the block name
  60325. */
  60326. constructor(name: string);
  60327. /**
  60328. * Gets the current class name
  60329. * @returns the class name
  60330. */
  60331. getClassName(): string;
  60332. /**
  60333. * Gets the left operand input component
  60334. */
  60335. get left(): NodeMaterialConnectionPoint;
  60336. /**
  60337. * Gets the right operand input component
  60338. */
  60339. get right(): NodeMaterialConnectionPoint;
  60340. /**
  60341. * Gets the output component
  60342. */
  60343. get output(): NodeMaterialConnectionPoint;
  60344. protected _buildBlock(state: NodeMaterialBuildState): this;
  60345. }
  60346. }
  60347. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  60348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60351. /**
  60352. * Block used to subtract 2 vectors
  60353. */
  60354. export class SubtractBlock extends NodeMaterialBlock {
  60355. /**
  60356. * Creates a new SubtractBlock
  60357. * @param name defines the block name
  60358. */
  60359. constructor(name: string);
  60360. /**
  60361. * Gets the current class name
  60362. * @returns the class name
  60363. */
  60364. getClassName(): string;
  60365. /**
  60366. * Gets the left operand input component
  60367. */
  60368. get left(): NodeMaterialConnectionPoint;
  60369. /**
  60370. * Gets the right operand input component
  60371. */
  60372. get right(): NodeMaterialConnectionPoint;
  60373. /**
  60374. * Gets the output component
  60375. */
  60376. get output(): NodeMaterialConnectionPoint;
  60377. protected _buildBlock(state: NodeMaterialBuildState): this;
  60378. }
  60379. }
  60380. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  60381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60384. /**
  60385. * Block used to step a value
  60386. */
  60387. export class StepBlock extends NodeMaterialBlock {
  60388. /**
  60389. * Creates a new StepBlock
  60390. * @param name defines the block name
  60391. */
  60392. constructor(name: string);
  60393. /**
  60394. * Gets the current class name
  60395. * @returns the class name
  60396. */
  60397. getClassName(): string;
  60398. /**
  60399. * Gets the value operand input component
  60400. */
  60401. get value(): NodeMaterialConnectionPoint;
  60402. /**
  60403. * Gets the edge operand input component
  60404. */
  60405. get edge(): NodeMaterialConnectionPoint;
  60406. /**
  60407. * Gets the output component
  60408. */
  60409. get output(): NodeMaterialConnectionPoint;
  60410. protected _buildBlock(state: NodeMaterialBuildState): this;
  60411. }
  60412. }
  60413. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  60414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60417. /**
  60418. * Block used to get the opposite (1 - x) of a value
  60419. */
  60420. export class OneMinusBlock extends NodeMaterialBlock {
  60421. /**
  60422. * Creates a new OneMinusBlock
  60423. * @param name defines the block name
  60424. */
  60425. constructor(name: string);
  60426. /**
  60427. * Gets the current class name
  60428. * @returns the class name
  60429. */
  60430. getClassName(): string;
  60431. /**
  60432. * Gets the input component
  60433. */
  60434. get input(): NodeMaterialConnectionPoint;
  60435. /**
  60436. * Gets the output component
  60437. */
  60438. get output(): NodeMaterialConnectionPoint;
  60439. protected _buildBlock(state: NodeMaterialBuildState): this;
  60440. }
  60441. }
  60442. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  60443. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60444. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60446. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60447. /**
  60448. * Block used to get the view direction
  60449. */
  60450. export class ViewDirectionBlock extends NodeMaterialBlock {
  60451. /**
  60452. * Creates a new ViewDirectionBlock
  60453. * @param name defines the block name
  60454. */
  60455. constructor(name: string);
  60456. /**
  60457. * Gets the current class name
  60458. * @returns the class name
  60459. */
  60460. getClassName(): string;
  60461. /**
  60462. * Gets the world position component
  60463. */
  60464. get worldPosition(): NodeMaterialConnectionPoint;
  60465. /**
  60466. * Gets the camera position component
  60467. */
  60468. get cameraPosition(): NodeMaterialConnectionPoint;
  60469. /**
  60470. * Gets the output component
  60471. */
  60472. get output(): NodeMaterialConnectionPoint;
  60473. autoConfigure(material: NodeMaterial): void;
  60474. protected _buildBlock(state: NodeMaterialBuildState): this;
  60475. }
  60476. }
  60477. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  60478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60480. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60481. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60482. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  60483. /**
  60484. * Block used to compute fresnel value
  60485. */
  60486. export class FresnelBlock extends NodeMaterialBlock {
  60487. /**
  60488. * Create a new FresnelBlock
  60489. * @param name defines the block name
  60490. */
  60491. constructor(name: string);
  60492. /**
  60493. * Gets the current class name
  60494. * @returns the class name
  60495. */
  60496. getClassName(): string;
  60497. /**
  60498. * Gets the world normal input component
  60499. */
  60500. get worldNormal(): NodeMaterialConnectionPoint;
  60501. /**
  60502. * Gets the view direction input component
  60503. */
  60504. get viewDirection(): NodeMaterialConnectionPoint;
  60505. /**
  60506. * Gets the bias input component
  60507. */
  60508. get bias(): NodeMaterialConnectionPoint;
  60509. /**
  60510. * Gets the camera (or eye) position component
  60511. */
  60512. get power(): NodeMaterialConnectionPoint;
  60513. /**
  60514. * Gets the fresnel output component
  60515. */
  60516. get fresnel(): NodeMaterialConnectionPoint;
  60517. autoConfigure(material: NodeMaterial): void;
  60518. protected _buildBlock(state: NodeMaterialBuildState): this;
  60519. }
  60520. }
  60521. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  60522. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60523. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60524. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60525. /**
  60526. * Block used to get the max of 2 values
  60527. */
  60528. export class MaxBlock extends NodeMaterialBlock {
  60529. /**
  60530. * Creates a new MaxBlock
  60531. * @param name defines the block name
  60532. */
  60533. constructor(name: string);
  60534. /**
  60535. * Gets the current class name
  60536. * @returns the class name
  60537. */
  60538. getClassName(): string;
  60539. /**
  60540. * Gets the left operand input component
  60541. */
  60542. get left(): NodeMaterialConnectionPoint;
  60543. /**
  60544. * Gets the right operand input component
  60545. */
  60546. get right(): NodeMaterialConnectionPoint;
  60547. /**
  60548. * Gets the output component
  60549. */
  60550. get output(): NodeMaterialConnectionPoint;
  60551. protected _buildBlock(state: NodeMaterialBuildState): this;
  60552. }
  60553. }
  60554. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  60555. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60557. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60558. /**
  60559. * Block used to get the min of 2 values
  60560. */
  60561. export class MinBlock extends NodeMaterialBlock {
  60562. /**
  60563. * Creates a new MinBlock
  60564. * @param name defines the block name
  60565. */
  60566. constructor(name: string);
  60567. /**
  60568. * Gets the current class name
  60569. * @returns the class name
  60570. */
  60571. getClassName(): string;
  60572. /**
  60573. * Gets the left operand input component
  60574. */
  60575. get left(): NodeMaterialConnectionPoint;
  60576. /**
  60577. * Gets the right operand input component
  60578. */
  60579. get right(): NodeMaterialConnectionPoint;
  60580. /**
  60581. * Gets the output component
  60582. */
  60583. get output(): NodeMaterialConnectionPoint;
  60584. protected _buildBlock(state: NodeMaterialBuildState): this;
  60585. }
  60586. }
  60587. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  60588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60591. /**
  60592. * Block used to get the distance between 2 values
  60593. */
  60594. export class DistanceBlock extends NodeMaterialBlock {
  60595. /**
  60596. * Creates a new DistanceBlock
  60597. * @param name defines the block name
  60598. */
  60599. constructor(name: string);
  60600. /**
  60601. * Gets the current class name
  60602. * @returns the class name
  60603. */
  60604. getClassName(): string;
  60605. /**
  60606. * Gets the left operand input component
  60607. */
  60608. get left(): NodeMaterialConnectionPoint;
  60609. /**
  60610. * Gets the right operand input component
  60611. */
  60612. get right(): NodeMaterialConnectionPoint;
  60613. /**
  60614. * Gets the output component
  60615. */
  60616. get output(): NodeMaterialConnectionPoint;
  60617. protected _buildBlock(state: NodeMaterialBuildState): this;
  60618. }
  60619. }
  60620. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  60621. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60624. /**
  60625. * Block used to get the length of a vector
  60626. */
  60627. export class LengthBlock extends NodeMaterialBlock {
  60628. /**
  60629. * Creates a new LengthBlock
  60630. * @param name defines the block name
  60631. */
  60632. constructor(name: string);
  60633. /**
  60634. * Gets the current class name
  60635. * @returns the class name
  60636. */
  60637. getClassName(): string;
  60638. /**
  60639. * Gets the value input component
  60640. */
  60641. get value(): NodeMaterialConnectionPoint;
  60642. /**
  60643. * Gets the output component
  60644. */
  60645. get output(): NodeMaterialConnectionPoint;
  60646. protected _buildBlock(state: NodeMaterialBuildState): this;
  60647. }
  60648. }
  60649. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  60650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60653. /**
  60654. * Block used to get negative version of a value (i.e. x * -1)
  60655. */
  60656. export class NegateBlock extends NodeMaterialBlock {
  60657. /**
  60658. * Creates a new NegateBlock
  60659. * @param name defines the block name
  60660. */
  60661. constructor(name: string);
  60662. /**
  60663. * Gets the current class name
  60664. * @returns the class name
  60665. */
  60666. getClassName(): string;
  60667. /**
  60668. * Gets the value input component
  60669. */
  60670. get value(): NodeMaterialConnectionPoint;
  60671. /**
  60672. * Gets the output component
  60673. */
  60674. get output(): NodeMaterialConnectionPoint;
  60675. protected _buildBlock(state: NodeMaterialBuildState): this;
  60676. }
  60677. }
  60678. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  60679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60682. /**
  60683. * Block used to get the value of the first parameter raised to the power of the second
  60684. */
  60685. export class PowBlock extends NodeMaterialBlock {
  60686. /**
  60687. * Creates a new PowBlock
  60688. * @param name defines the block name
  60689. */
  60690. constructor(name: string);
  60691. /**
  60692. * Gets the current class name
  60693. * @returns the class name
  60694. */
  60695. getClassName(): string;
  60696. /**
  60697. * Gets the value operand input component
  60698. */
  60699. get value(): NodeMaterialConnectionPoint;
  60700. /**
  60701. * Gets the power operand input component
  60702. */
  60703. get power(): NodeMaterialConnectionPoint;
  60704. /**
  60705. * Gets the output component
  60706. */
  60707. get output(): NodeMaterialConnectionPoint;
  60708. protected _buildBlock(state: NodeMaterialBuildState): this;
  60709. }
  60710. }
  60711. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  60712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60715. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60716. /**
  60717. * Block used to get a random number
  60718. */
  60719. export class RandomNumberBlock extends NodeMaterialBlock {
  60720. /**
  60721. * Creates a new RandomNumberBlock
  60722. * @param name defines the block name
  60723. */
  60724. constructor(name: string);
  60725. /**
  60726. * Gets the current class name
  60727. * @returns the class name
  60728. */
  60729. getClassName(): string;
  60730. /**
  60731. * Gets the seed input component
  60732. */
  60733. get seed(): NodeMaterialConnectionPoint;
  60734. /**
  60735. * Gets the output component
  60736. */
  60737. get output(): NodeMaterialConnectionPoint;
  60738. protected _buildBlock(state: NodeMaterialBuildState): this;
  60739. }
  60740. }
  60741. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  60742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60745. /**
  60746. * Block used to compute arc tangent of 2 values
  60747. */
  60748. export class ArcTan2Block extends NodeMaterialBlock {
  60749. /**
  60750. * Creates a new ArcTan2Block
  60751. * @param name defines the block name
  60752. */
  60753. constructor(name: string);
  60754. /**
  60755. * Gets the current class name
  60756. * @returns the class name
  60757. */
  60758. getClassName(): string;
  60759. /**
  60760. * Gets the x operand input component
  60761. */
  60762. get x(): NodeMaterialConnectionPoint;
  60763. /**
  60764. * Gets the y operand input component
  60765. */
  60766. get y(): NodeMaterialConnectionPoint;
  60767. /**
  60768. * Gets the output component
  60769. */
  60770. get output(): NodeMaterialConnectionPoint;
  60771. protected _buildBlock(state: NodeMaterialBuildState): this;
  60772. }
  60773. }
  60774. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  60775. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60776. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60777. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60778. /**
  60779. * Block used to smooth step a value
  60780. */
  60781. export class SmoothStepBlock extends NodeMaterialBlock {
  60782. /**
  60783. * Creates a new SmoothStepBlock
  60784. * @param name defines the block name
  60785. */
  60786. constructor(name: string);
  60787. /**
  60788. * Gets the current class name
  60789. * @returns the class name
  60790. */
  60791. getClassName(): string;
  60792. /**
  60793. * Gets the value operand input component
  60794. */
  60795. get value(): NodeMaterialConnectionPoint;
  60796. /**
  60797. * Gets the first edge operand input component
  60798. */
  60799. get edge0(): NodeMaterialConnectionPoint;
  60800. /**
  60801. * Gets the second edge operand input component
  60802. */
  60803. get edge1(): NodeMaterialConnectionPoint;
  60804. /**
  60805. * Gets the output component
  60806. */
  60807. get output(): NodeMaterialConnectionPoint;
  60808. protected _buildBlock(state: NodeMaterialBuildState): this;
  60809. }
  60810. }
  60811. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  60812. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60813. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60814. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60815. /**
  60816. * Block used to get the reciprocal (1 / x) of a value
  60817. */
  60818. export class ReciprocalBlock extends NodeMaterialBlock {
  60819. /**
  60820. * Creates a new ReciprocalBlock
  60821. * @param name defines the block name
  60822. */
  60823. constructor(name: string);
  60824. /**
  60825. * Gets the current class name
  60826. * @returns the class name
  60827. */
  60828. getClassName(): string;
  60829. /**
  60830. * Gets the input component
  60831. */
  60832. get input(): NodeMaterialConnectionPoint;
  60833. /**
  60834. * Gets the output component
  60835. */
  60836. get output(): NodeMaterialConnectionPoint;
  60837. protected _buildBlock(state: NodeMaterialBuildState): this;
  60838. }
  60839. }
  60840. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  60841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60844. /**
  60845. * Block used to replace a color by another one
  60846. */
  60847. export class ReplaceColorBlock extends NodeMaterialBlock {
  60848. /**
  60849. * Creates a new ReplaceColorBlock
  60850. * @param name defines the block name
  60851. */
  60852. constructor(name: string);
  60853. /**
  60854. * Gets the current class name
  60855. * @returns the class name
  60856. */
  60857. getClassName(): string;
  60858. /**
  60859. * Gets the value input component
  60860. */
  60861. get value(): NodeMaterialConnectionPoint;
  60862. /**
  60863. * Gets the reference input component
  60864. */
  60865. get reference(): NodeMaterialConnectionPoint;
  60866. /**
  60867. * Gets the distance input component
  60868. */
  60869. get distance(): NodeMaterialConnectionPoint;
  60870. /**
  60871. * Gets the replacement input component
  60872. */
  60873. get replacement(): NodeMaterialConnectionPoint;
  60874. /**
  60875. * Gets the output component
  60876. */
  60877. get output(): NodeMaterialConnectionPoint;
  60878. protected _buildBlock(state: NodeMaterialBuildState): this;
  60879. }
  60880. }
  60881. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  60882. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60883. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60884. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60885. /**
  60886. * Block used to posterize a value
  60887. * @see https://en.wikipedia.org/wiki/Posterization
  60888. */
  60889. export class PosterizeBlock extends NodeMaterialBlock {
  60890. /**
  60891. * Creates a new PosterizeBlock
  60892. * @param name defines the block name
  60893. */
  60894. constructor(name: string);
  60895. /**
  60896. * Gets the current class name
  60897. * @returns the class name
  60898. */
  60899. getClassName(): string;
  60900. /**
  60901. * Gets the value input component
  60902. */
  60903. get value(): NodeMaterialConnectionPoint;
  60904. /**
  60905. * Gets the steps input component
  60906. */
  60907. get steps(): NodeMaterialConnectionPoint;
  60908. /**
  60909. * Gets the output component
  60910. */
  60911. get output(): NodeMaterialConnectionPoint;
  60912. protected _buildBlock(state: NodeMaterialBuildState): this;
  60913. }
  60914. }
  60915. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  60916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60917. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60919. import { Scene } from "babylonjs/scene";
  60920. /**
  60921. * Operations supported by the Wave block
  60922. */
  60923. export enum WaveBlockKind {
  60924. /** SawTooth */
  60925. SawTooth = 0,
  60926. /** Square */
  60927. Square = 1,
  60928. /** Triangle */
  60929. Triangle = 2
  60930. }
  60931. /**
  60932. * Block used to apply wave operation to floats
  60933. */
  60934. export class WaveBlock extends NodeMaterialBlock {
  60935. /**
  60936. * Gets or sets the kibnd of wave to be applied by the block
  60937. */
  60938. kind: WaveBlockKind;
  60939. /**
  60940. * Creates a new WaveBlock
  60941. * @param name defines the block name
  60942. */
  60943. constructor(name: string);
  60944. /**
  60945. * Gets the current class name
  60946. * @returns the class name
  60947. */
  60948. getClassName(): string;
  60949. /**
  60950. * Gets the input component
  60951. */
  60952. get input(): NodeMaterialConnectionPoint;
  60953. /**
  60954. * Gets the output component
  60955. */
  60956. get output(): NodeMaterialConnectionPoint;
  60957. protected _buildBlock(state: NodeMaterialBuildState): this;
  60958. serialize(): any;
  60959. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60960. }
  60961. }
  60962. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  60963. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60964. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60965. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60966. import { Color3 } from "babylonjs/Maths/math.color";
  60967. import { Scene } from "babylonjs/scene";
  60968. /**
  60969. * Class used to store a color step for the GradientBlock
  60970. */
  60971. export class GradientBlockColorStep {
  60972. /**
  60973. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60974. */
  60975. step: number;
  60976. /**
  60977. * Gets or sets the color associated with this step
  60978. */
  60979. color: Color3;
  60980. /**
  60981. * Creates a new GradientBlockColorStep
  60982. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60983. * @param color defines the color associated with this step
  60984. */
  60985. constructor(
  60986. /**
  60987. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60988. */
  60989. step: number,
  60990. /**
  60991. * Gets or sets the color associated with this step
  60992. */
  60993. color: Color3);
  60994. }
  60995. /**
  60996. * Block used to return a color from a gradient based on an input value between 0 and 1
  60997. */
  60998. export class GradientBlock extends NodeMaterialBlock {
  60999. /**
  61000. * Gets or sets the list of color steps
  61001. */
  61002. colorSteps: GradientBlockColorStep[];
  61003. /**
  61004. * Creates a new GradientBlock
  61005. * @param name defines the block name
  61006. */
  61007. constructor(name: string);
  61008. /**
  61009. * Gets the current class name
  61010. * @returns the class name
  61011. */
  61012. getClassName(): string;
  61013. /**
  61014. * Gets the gradient input component
  61015. */
  61016. get gradient(): NodeMaterialConnectionPoint;
  61017. /**
  61018. * Gets the output component
  61019. */
  61020. get output(): NodeMaterialConnectionPoint;
  61021. private _writeColorConstant;
  61022. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61023. serialize(): any;
  61024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61025. protected _dumpPropertiesCode(): string;
  61026. }
  61027. }
  61028. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  61029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61032. /**
  61033. * Block used to normalize lerp between 2 values
  61034. */
  61035. export class NLerpBlock extends NodeMaterialBlock {
  61036. /**
  61037. * Creates a new NLerpBlock
  61038. * @param name defines the block name
  61039. */
  61040. constructor(name: string);
  61041. /**
  61042. * Gets the current class name
  61043. * @returns the class name
  61044. */
  61045. getClassName(): string;
  61046. /**
  61047. * Gets the left operand input component
  61048. */
  61049. get left(): NodeMaterialConnectionPoint;
  61050. /**
  61051. * Gets the right operand input component
  61052. */
  61053. get right(): NodeMaterialConnectionPoint;
  61054. /**
  61055. * Gets the gradient operand input component
  61056. */
  61057. get gradient(): NodeMaterialConnectionPoint;
  61058. /**
  61059. * Gets the output component
  61060. */
  61061. get output(): NodeMaterialConnectionPoint;
  61062. protected _buildBlock(state: NodeMaterialBuildState): this;
  61063. }
  61064. }
  61065. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  61066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61069. import { Scene } from "babylonjs/scene";
  61070. /**
  61071. * block used to Generate a Worley Noise 3D Noise Pattern
  61072. */
  61073. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61074. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61075. manhattanDistance: boolean;
  61076. /**
  61077. * Creates a new WorleyNoise3DBlock
  61078. * @param name defines the block name
  61079. */
  61080. constructor(name: string);
  61081. /**
  61082. * Gets the current class name
  61083. * @returns the class name
  61084. */
  61085. getClassName(): string;
  61086. /**
  61087. * Gets the seed input component
  61088. */
  61089. get seed(): NodeMaterialConnectionPoint;
  61090. /**
  61091. * Gets the jitter input component
  61092. */
  61093. get jitter(): NodeMaterialConnectionPoint;
  61094. /**
  61095. * Gets the output component
  61096. */
  61097. get output(): NodeMaterialConnectionPoint;
  61098. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61099. /**
  61100. * Exposes the properties to the UI?
  61101. */
  61102. protected _dumpPropertiesCode(): string;
  61103. /**
  61104. * Exposes the properties to the Seralize?
  61105. */
  61106. serialize(): any;
  61107. /**
  61108. * Exposes the properties to the deseralize?
  61109. */
  61110. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61111. }
  61112. }
  61113. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  61114. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61115. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61116. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61117. /**
  61118. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61119. */
  61120. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61121. /**
  61122. * Creates a new SimplexPerlin3DBlock
  61123. * @param name defines the block name
  61124. */
  61125. constructor(name: string);
  61126. /**
  61127. * Gets the current class name
  61128. * @returns the class name
  61129. */
  61130. getClassName(): string;
  61131. /**
  61132. * Gets the seed operand input component
  61133. */
  61134. get seed(): NodeMaterialConnectionPoint;
  61135. /**
  61136. * Gets the output component
  61137. */
  61138. get output(): NodeMaterialConnectionPoint;
  61139. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61140. }
  61141. }
  61142. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  61143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61145. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61146. /**
  61147. * Block used to blend normals
  61148. */
  61149. export class NormalBlendBlock extends NodeMaterialBlock {
  61150. /**
  61151. * Creates a new NormalBlendBlock
  61152. * @param name defines the block name
  61153. */
  61154. constructor(name: string);
  61155. /**
  61156. * Gets the current class name
  61157. * @returns the class name
  61158. */
  61159. getClassName(): string;
  61160. /**
  61161. * Gets the first input component
  61162. */
  61163. get normalMap0(): NodeMaterialConnectionPoint;
  61164. /**
  61165. * Gets the second input component
  61166. */
  61167. get normalMap1(): NodeMaterialConnectionPoint;
  61168. /**
  61169. * Gets the output component
  61170. */
  61171. get output(): NodeMaterialConnectionPoint;
  61172. protected _buildBlock(state: NodeMaterialBuildState): this;
  61173. }
  61174. }
  61175. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  61176. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61179. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61180. /**
  61181. * Block used to rotate a 2d vector by a given angle
  61182. */
  61183. export class Rotate2dBlock extends NodeMaterialBlock {
  61184. /**
  61185. * Creates a new Rotate2dBlock
  61186. * @param name defines the block name
  61187. */
  61188. constructor(name: string);
  61189. /**
  61190. * Gets the current class name
  61191. * @returns the class name
  61192. */
  61193. getClassName(): string;
  61194. /**
  61195. * Gets the input vector
  61196. */
  61197. get input(): NodeMaterialConnectionPoint;
  61198. /**
  61199. * Gets the input angle
  61200. */
  61201. get angle(): NodeMaterialConnectionPoint;
  61202. /**
  61203. * Gets the output component
  61204. */
  61205. get output(): NodeMaterialConnectionPoint;
  61206. autoConfigure(material: NodeMaterial): void;
  61207. protected _buildBlock(state: NodeMaterialBuildState): this;
  61208. }
  61209. }
  61210. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  61211. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61212. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61213. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61214. /**
  61215. * Block used to get the reflected vector from a direction and a normal
  61216. */
  61217. export class ReflectBlock extends NodeMaterialBlock {
  61218. /**
  61219. * Creates a new ReflectBlock
  61220. * @param name defines the block name
  61221. */
  61222. constructor(name: string);
  61223. /**
  61224. * Gets the current class name
  61225. * @returns the class name
  61226. */
  61227. getClassName(): string;
  61228. /**
  61229. * Gets the incident component
  61230. */
  61231. get incident(): NodeMaterialConnectionPoint;
  61232. /**
  61233. * Gets the normal component
  61234. */
  61235. get normal(): NodeMaterialConnectionPoint;
  61236. /**
  61237. * Gets the output component
  61238. */
  61239. get output(): NodeMaterialConnectionPoint;
  61240. protected _buildBlock(state: NodeMaterialBuildState): this;
  61241. }
  61242. }
  61243. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  61244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61247. /**
  61248. * Block used to get the refracted vector from a direction and a normal
  61249. */
  61250. export class RefractBlock extends NodeMaterialBlock {
  61251. /**
  61252. * Creates a new RefractBlock
  61253. * @param name defines the block name
  61254. */
  61255. constructor(name: string);
  61256. /**
  61257. * Gets the current class name
  61258. * @returns the class name
  61259. */
  61260. getClassName(): string;
  61261. /**
  61262. * Gets the incident component
  61263. */
  61264. get incident(): NodeMaterialConnectionPoint;
  61265. /**
  61266. * Gets the normal component
  61267. */
  61268. get normal(): NodeMaterialConnectionPoint;
  61269. /**
  61270. * Gets the index of refraction component
  61271. */
  61272. get ior(): NodeMaterialConnectionPoint;
  61273. /**
  61274. * Gets the output component
  61275. */
  61276. get output(): NodeMaterialConnectionPoint;
  61277. protected _buildBlock(state: NodeMaterialBuildState): this;
  61278. }
  61279. }
  61280. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  61281. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61282. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61284. /**
  61285. * Block used to desaturate a color
  61286. */
  61287. export class DesaturateBlock extends NodeMaterialBlock {
  61288. /**
  61289. * Creates a new DesaturateBlock
  61290. * @param name defines the block name
  61291. */
  61292. constructor(name: string);
  61293. /**
  61294. * Gets the current class name
  61295. * @returns the class name
  61296. */
  61297. getClassName(): string;
  61298. /**
  61299. * Gets the color operand input component
  61300. */
  61301. get color(): NodeMaterialConnectionPoint;
  61302. /**
  61303. * Gets the level operand input component
  61304. */
  61305. get level(): NodeMaterialConnectionPoint;
  61306. /**
  61307. * Gets the output component
  61308. */
  61309. get output(): NodeMaterialConnectionPoint;
  61310. protected _buildBlock(state: NodeMaterialBuildState): this;
  61311. }
  61312. }
  61313. declare module "babylonjs/Materials/Node/Blocks/index" {
  61314. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  61315. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  61316. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  61317. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  61318. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  61319. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  61320. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  61321. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  61322. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  61323. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  61324. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  61325. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  61326. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  61327. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  61328. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  61329. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  61330. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  61331. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  61332. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  61333. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  61334. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  61335. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  61336. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  61337. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  61338. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  61339. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  61340. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  61341. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  61342. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  61343. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  61344. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  61345. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  61346. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  61347. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  61348. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  61349. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  61350. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  61351. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  61352. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  61353. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  61354. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  61355. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  61356. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  61357. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  61358. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  61359. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  61360. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  61361. }
  61362. declare module "babylonjs/Materials/Node/Optimizers/index" {
  61363. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  61364. }
  61365. declare module "babylonjs/Materials/Node/index" {
  61366. export * from "babylonjs/Materials/Node/Enums/index";
  61367. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61368. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  61369. export * from "babylonjs/Materials/Node/nodeMaterial";
  61370. export * from "babylonjs/Materials/Node/Blocks/index";
  61371. export * from "babylonjs/Materials/Node/Optimizers/index";
  61372. }
  61373. declare module "babylonjs/Materials/effectRenderer" {
  61374. import { Nullable } from "babylonjs/types";
  61375. import { Texture } from "babylonjs/Materials/Textures/texture";
  61376. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61377. import { Viewport } from "babylonjs/Maths/math.viewport";
  61378. import { Observable } from "babylonjs/Misc/observable";
  61379. import { Effect } from "babylonjs/Materials/effect";
  61380. import "babylonjs/Engines/Extensions/engine.renderTarget";
  61381. import "babylonjs/Shaders/postprocess.vertex";
  61382. /**
  61383. * Effect Render Options
  61384. */
  61385. export interface IEffectRendererOptions {
  61386. /**
  61387. * Defines the vertices positions.
  61388. */
  61389. positions?: number[];
  61390. /**
  61391. * Defines the indices.
  61392. */
  61393. indices?: number[];
  61394. }
  61395. /**
  61396. * Helper class to render one or more effects
  61397. */
  61398. export class EffectRenderer {
  61399. private engine;
  61400. private static _DefaultOptions;
  61401. private _vertexBuffers;
  61402. private _indexBuffer;
  61403. private _ringBufferIndex;
  61404. private _ringScreenBuffer;
  61405. private _fullscreenViewport;
  61406. private _getNextFrameBuffer;
  61407. /**
  61408. * Creates an effect renderer
  61409. * @param engine the engine to use for rendering
  61410. * @param options defines the options of the effect renderer
  61411. */
  61412. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61413. /**
  61414. * Sets the current viewport in normalized coordinates 0-1
  61415. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61416. */
  61417. setViewport(viewport?: Viewport): void;
  61418. /**
  61419. * Binds the embedded attributes buffer to the effect.
  61420. * @param effect Defines the effect to bind the attributes for
  61421. */
  61422. bindBuffers(effect: Effect): void;
  61423. /**
  61424. * Sets the current effect wrapper to use during draw.
  61425. * The effect needs to be ready before calling this api.
  61426. * This also sets the default full screen position attribute.
  61427. * @param effectWrapper Defines the effect to draw with
  61428. */
  61429. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61430. /**
  61431. * Draws a full screen quad.
  61432. */
  61433. draw(): void;
  61434. /**
  61435. * renders one or more effects to a specified texture
  61436. * @param effectWrappers list of effects to renderer
  61437. * @param outputTexture texture to draw to, if null it will render to the screen
  61438. */
  61439. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  61440. /**
  61441. * Disposes of the effect renderer
  61442. */
  61443. dispose(): void;
  61444. }
  61445. /**
  61446. * Options to create an EffectWrapper
  61447. */
  61448. interface EffectWrapperCreationOptions {
  61449. /**
  61450. * Engine to use to create the effect
  61451. */
  61452. engine: ThinEngine;
  61453. /**
  61454. * Fragment shader for the effect
  61455. */
  61456. fragmentShader: string;
  61457. /**
  61458. * Vertex shader for the effect
  61459. */
  61460. vertexShader?: string;
  61461. /**
  61462. * Attributes to use in the shader
  61463. */
  61464. attributeNames?: Array<string>;
  61465. /**
  61466. * Uniforms to use in the shader
  61467. */
  61468. uniformNames?: Array<string>;
  61469. /**
  61470. * Texture sampler names to use in the shader
  61471. */
  61472. samplerNames?: Array<string>;
  61473. /**
  61474. * The friendly name of the effect displayed in Spector.
  61475. */
  61476. name?: string;
  61477. }
  61478. /**
  61479. * Wraps an effect to be used for rendering
  61480. */
  61481. export class EffectWrapper {
  61482. /**
  61483. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61484. */
  61485. onApplyObservable: Observable<{}>;
  61486. /**
  61487. * The underlying effect
  61488. */
  61489. effect: Effect;
  61490. /**
  61491. * Creates an effect to be renderer
  61492. * @param creationOptions options to create the effect
  61493. */
  61494. constructor(creationOptions: EffectWrapperCreationOptions);
  61495. /**
  61496. * Disposes of the effect wrapper
  61497. */
  61498. dispose(): void;
  61499. }
  61500. }
  61501. declare module "babylonjs/Materials/index" {
  61502. export * from "babylonjs/Materials/Background/index";
  61503. export * from "babylonjs/Materials/colorCurves";
  61504. export * from "babylonjs/Materials/iEffectFallbacks";
  61505. export * from "babylonjs/Materials/effectFallbacks";
  61506. export * from "babylonjs/Materials/effect";
  61507. export * from "babylonjs/Materials/fresnelParameters";
  61508. export * from "babylonjs/Materials/imageProcessingConfiguration";
  61509. export * from "babylonjs/Materials/material";
  61510. export * from "babylonjs/Materials/materialDefines";
  61511. export * from "babylonjs/Materials/materialHelper";
  61512. export * from "babylonjs/Materials/multiMaterial";
  61513. export * from "babylonjs/Materials/PBR/index";
  61514. export * from "babylonjs/Materials/pushMaterial";
  61515. export * from "babylonjs/Materials/shaderMaterial";
  61516. export * from "babylonjs/Materials/standardMaterial";
  61517. export * from "babylonjs/Materials/Textures/index";
  61518. export * from "babylonjs/Materials/uniformBuffer";
  61519. export * from "babylonjs/Materials/materialFlags";
  61520. export * from "babylonjs/Materials/Node/index";
  61521. export * from "babylonjs/Materials/effectRenderer";
  61522. }
  61523. declare module "babylonjs/Maths/index" {
  61524. export * from "babylonjs/Maths/math.scalar";
  61525. export * from "babylonjs/Maths/math";
  61526. export * from "babylonjs/Maths/sphericalPolynomial";
  61527. }
  61528. declare module "babylonjs/Misc/workerPool" {
  61529. import { IDisposable } from "babylonjs/scene";
  61530. /**
  61531. * Helper class to push actions to a pool of workers.
  61532. */
  61533. export class WorkerPool implements IDisposable {
  61534. private _workerInfos;
  61535. private _pendingActions;
  61536. /**
  61537. * Constructor
  61538. * @param workers Array of workers to use for actions
  61539. */
  61540. constructor(workers: Array<Worker>);
  61541. /**
  61542. * Terminates all workers and clears any pending actions.
  61543. */
  61544. dispose(): void;
  61545. /**
  61546. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61547. * pended until a worker has completed its action.
  61548. * @param action The action to perform. Call onComplete when the action is complete.
  61549. */
  61550. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61551. private _execute;
  61552. }
  61553. }
  61554. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  61555. import { IDisposable } from "babylonjs/scene";
  61556. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61557. /**
  61558. * Configuration for Draco compression
  61559. */
  61560. export interface IDracoCompressionConfiguration {
  61561. /**
  61562. * Configuration for the decoder.
  61563. */
  61564. decoder: {
  61565. /**
  61566. * The url to the WebAssembly module.
  61567. */
  61568. wasmUrl?: string;
  61569. /**
  61570. * The url to the WebAssembly binary.
  61571. */
  61572. wasmBinaryUrl?: string;
  61573. /**
  61574. * The url to the fallback JavaScript module.
  61575. */
  61576. fallbackUrl?: string;
  61577. };
  61578. }
  61579. /**
  61580. * Draco compression (https://google.github.io/draco/)
  61581. *
  61582. * This class wraps the Draco module.
  61583. *
  61584. * **Encoder**
  61585. *
  61586. * The encoder is not currently implemented.
  61587. *
  61588. * **Decoder**
  61589. *
  61590. * 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.
  61591. *
  61592. * To update the configuration, use the following code:
  61593. * ```javascript
  61594. * DracoCompression.Configuration = {
  61595. * decoder: {
  61596. * wasmUrl: "<url to the WebAssembly library>",
  61597. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61598. * fallbackUrl: "<url to the fallback JavaScript library>",
  61599. * }
  61600. * };
  61601. * ```
  61602. *
  61603. * 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.
  61604. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61605. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61606. *
  61607. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61608. * ```javascript
  61609. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61610. * ```
  61611. *
  61612. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61613. */
  61614. export class DracoCompression implements IDisposable {
  61615. private _workerPoolPromise?;
  61616. private _decoderModulePromise?;
  61617. /**
  61618. * The configuration. Defaults to the following urls:
  61619. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61620. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61621. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61622. */
  61623. static Configuration: IDracoCompressionConfiguration;
  61624. /**
  61625. * Returns true if the decoder configuration is available.
  61626. */
  61627. static get DecoderAvailable(): boolean;
  61628. /**
  61629. * Default number of workers to create when creating the draco compression object.
  61630. */
  61631. static DefaultNumWorkers: number;
  61632. private static GetDefaultNumWorkers;
  61633. private static _Default;
  61634. /**
  61635. * Default instance for the draco compression object.
  61636. */
  61637. static get Default(): DracoCompression;
  61638. /**
  61639. * Constructor
  61640. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61641. */
  61642. constructor(numWorkers?: number);
  61643. /**
  61644. * Stop all async operations and release resources.
  61645. */
  61646. dispose(): void;
  61647. /**
  61648. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61649. * @returns a promise that resolves when ready
  61650. */
  61651. whenReadyAsync(): Promise<void>;
  61652. /**
  61653. * Decode Draco compressed mesh data to vertex data.
  61654. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61655. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61656. * @returns A promise that resolves with the decoded vertex data
  61657. */
  61658. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61659. [kind: string]: number;
  61660. }): Promise<VertexData>;
  61661. }
  61662. }
  61663. declare module "babylonjs/Meshes/Compression/index" {
  61664. export * from "babylonjs/Meshes/Compression/dracoCompression";
  61665. }
  61666. declare module "babylonjs/Meshes/csg" {
  61667. import { Nullable } from "babylonjs/types";
  61668. import { Scene } from "babylonjs/scene";
  61669. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61670. import { Mesh } from "babylonjs/Meshes/mesh";
  61671. import { Material } from "babylonjs/Materials/material";
  61672. /**
  61673. * Class for building Constructive Solid Geometry
  61674. */
  61675. export class CSG {
  61676. private polygons;
  61677. /**
  61678. * The world matrix
  61679. */
  61680. matrix: Matrix;
  61681. /**
  61682. * Stores the position
  61683. */
  61684. position: Vector3;
  61685. /**
  61686. * Stores the rotation
  61687. */
  61688. rotation: Vector3;
  61689. /**
  61690. * Stores the rotation quaternion
  61691. */
  61692. rotationQuaternion: Nullable<Quaternion>;
  61693. /**
  61694. * Stores the scaling vector
  61695. */
  61696. scaling: Vector3;
  61697. /**
  61698. * Convert the Mesh to CSG
  61699. * @param mesh The Mesh to convert to CSG
  61700. * @returns A new CSG from the Mesh
  61701. */
  61702. static FromMesh(mesh: Mesh): CSG;
  61703. /**
  61704. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61705. * @param polygons Polygons used to construct a CSG solid
  61706. */
  61707. private static FromPolygons;
  61708. /**
  61709. * Clones, or makes a deep copy, of the CSG
  61710. * @returns A new CSG
  61711. */
  61712. clone(): CSG;
  61713. /**
  61714. * Unions this CSG with another CSG
  61715. * @param csg The CSG to union against this CSG
  61716. * @returns The unioned CSG
  61717. */
  61718. union(csg: CSG): CSG;
  61719. /**
  61720. * Unions this CSG with another CSG in place
  61721. * @param csg The CSG to union against this CSG
  61722. */
  61723. unionInPlace(csg: CSG): void;
  61724. /**
  61725. * Subtracts this CSG with another CSG
  61726. * @param csg The CSG to subtract against this CSG
  61727. * @returns A new CSG
  61728. */
  61729. subtract(csg: CSG): CSG;
  61730. /**
  61731. * Subtracts this CSG with another CSG in place
  61732. * @param csg The CSG to subtact against this CSG
  61733. */
  61734. subtractInPlace(csg: CSG): void;
  61735. /**
  61736. * Intersect this CSG with another CSG
  61737. * @param csg The CSG to intersect against this CSG
  61738. * @returns A new CSG
  61739. */
  61740. intersect(csg: CSG): CSG;
  61741. /**
  61742. * Intersects this CSG with another CSG in place
  61743. * @param csg The CSG to intersect against this CSG
  61744. */
  61745. intersectInPlace(csg: CSG): void;
  61746. /**
  61747. * Return a new CSG solid with solid and empty space switched. This solid is
  61748. * not modified.
  61749. * @returns A new CSG solid with solid and empty space switched
  61750. */
  61751. inverse(): CSG;
  61752. /**
  61753. * Inverses the CSG in place
  61754. */
  61755. inverseInPlace(): void;
  61756. /**
  61757. * This is used to keep meshes transformations so they can be restored
  61758. * when we build back a Babylon Mesh
  61759. * NB : All CSG operations are performed in world coordinates
  61760. * @param csg The CSG to copy the transform attributes from
  61761. * @returns This CSG
  61762. */
  61763. copyTransformAttributes(csg: CSG): CSG;
  61764. /**
  61765. * Build Raw mesh from CSG
  61766. * Coordinates here are in world space
  61767. * @param name The name of the mesh geometry
  61768. * @param scene The Scene
  61769. * @param keepSubMeshes Specifies if the submeshes should be kept
  61770. * @returns A new Mesh
  61771. */
  61772. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61773. /**
  61774. * Build Mesh from CSG taking material and transforms into account
  61775. * @param name The name of the Mesh
  61776. * @param material The material of the Mesh
  61777. * @param scene The Scene
  61778. * @param keepSubMeshes Specifies if submeshes should be kept
  61779. * @returns The new Mesh
  61780. */
  61781. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61782. }
  61783. }
  61784. declare module "babylonjs/Meshes/trailMesh" {
  61785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61786. import { Mesh } from "babylonjs/Meshes/mesh";
  61787. import { Scene } from "babylonjs/scene";
  61788. /**
  61789. * Class used to create a trail following a mesh
  61790. */
  61791. export class TrailMesh extends Mesh {
  61792. private _generator;
  61793. private _autoStart;
  61794. private _running;
  61795. private _diameter;
  61796. private _length;
  61797. private _sectionPolygonPointsCount;
  61798. private _sectionVectors;
  61799. private _sectionNormalVectors;
  61800. private _beforeRenderObserver;
  61801. /**
  61802. * @constructor
  61803. * @param name The value used by scene.getMeshByName() to do a lookup.
  61804. * @param generator The mesh to generate a trail.
  61805. * @param scene The scene to add this mesh to.
  61806. * @param diameter Diameter of trailing mesh. Default is 1.
  61807. * @param length Length of trailing mesh. Default is 60.
  61808. * @param autoStart Automatically start trailing mesh. Default true.
  61809. */
  61810. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61811. /**
  61812. * "TrailMesh"
  61813. * @returns "TrailMesh"
  61814. */
  61815. getClassName(): string;
  61816. private _createMesh;
  61817. /**
  61818. * Start trailing mesh.
  61819. */
  61820. start(): void;
  61821. /**
  61822. * Stop trailing mesh.
  61823. */
  61824. stop(): void;
  61825. /**
  61826. * Update trailing mesh geometry.
  61827. */
  61828. update(): void;
  61829. /**
  61830. * Returns a new TrailMesh object.
  61831. * @param name is a string, the name given to the new mesh
  61832. * @param newGenerator use new generator object for cloned trail mesh
  61833. * @returns a new mesh
  61834. */
  61835. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  61836. /**
  61837. * Serializes this trail mesh
  61838. * @param serializationObject object to write serialization to
  61839. */
  61840. serialize(serializationObject: any): void;
  61841. /**
  61842. * Parses a serialized trail mesh
  61843. * @param parsedMesh the serialized mesh
  61844. * @param scene the scene to create the trail mesh in
  61845. * @returns the created trail mesh
  61846. */
  61847. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61848. }
  61849. }
  61850. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  61851. import { Nullable } from "babylonjs/types";
  61852. import { Scene } from "babylonjs/scene";
  61853. import { Vector4 } from "babylonjs/Maths/math.vector";
  61854. import { Color4 } from "babylonjs/Maths/math.color";
  61855. import { Mesh } from "babylonjs/Meshes/mesh";
  61856. /**
  61857. * Class containing static functions to help procedurally build meshes
  61858. */
  61859. export class TiledBoxBuilder {
  61860. /**
  61861. * Creates a box mesh
  61862. * 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)
  61863. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61865. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61867. * @param name defines the name of the mesh
  61868. * @param options defines the options used to create the mesh
  61869. * @param scene defines the hosting scene
  61870. * @returns the box mesh
  61871. */
  61872. static CreateTiledBox(name: string, options: {
  61873. pattern?: number;
  61874. width?: number;
  61875. height?: number;
  61876. depth?: number;
  61877. tileSize?: number;
  61878. tileWidth?: number;
  61879. tileHeight?: number;
  61880. alignHorizontal?: number;
  61881. alignVertical?: number;
  61882. faceUV?: Vector4[];
  61883. faceColors?: Color4[];
  61884. sideOrientation?: number;
  61885. updatable?: boolean;
  61886. }, scene?: Nullable<Scene>): Mesh;
  61887. }
  61888. }
  61889. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  61890. import { Vector4 } from "babylonjs/Maths/math.vector";
  61891. import { Mesh } from "babylonjs/Meshes/mesh";
  61892. /**
  61893. * Class containing static functions to help procedurally build meshes
  61894. */
  61895. export class TorusKnotBuilder {
  61896. /**
  61897. * Creates a torus knot mesh
  61898. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61899. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61900. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61901. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61905. * @param name defines the name of the mesh
  61906. * @param options defines the options used to create the mesh
  61907. * @param scene defines the hosting scene
  61908. * @returns the torus knot mesh
  61909. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61910. */
  61911. static CreateTorusKnot(name: string, options: {
  61912. radius?: number;
  61913. tube?: number;
  61914. radialSegments?: number;
  61915. tubularSegments?: number;
  61916. p?: number;
  61917. q?: number;
  61918. updatable?: boolean;
  61919. sideOrientation?: number;
  61920. frontUVs?: Vector4;
  61921. backUVs?: Vector4;
  61922. }, scene: any): Mesh;
  61923. }
  61924. }
  61925. declare module "babylonjs/Meshes/polygonMesh" {
  61926. import { Scene } from "babylonjs/scene";
  61927. import { Vector2 } from "babylonjs/Maths/math.vector";
  61928. import { Mesh } from "babylonjs/Meshes/mesh";
  61929. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61930. import { Path2 } from "babylonjs/Maths/math.path";
  61931. /**
  61932. * Polygon
  61933. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61934. */
  61935. export class Polygon {
  61936. /**
  61937. * Creates a rectangle
  61938. * @param xmin bottom X coord
  61939. * @param ymin bottom Y coord
  61940. * @param xmax top X coord
  61941. * @param ymax top Y coord
  61942. * @returns points that make the resulting rectation
  61943. */
  61944. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61945. /**
  61946. * Creates a circle
  61947. * @param radius radius of circle
  61948. * @param cx scale in x
  61949. * @param cy scale in y
  61950. * @param numberOfSides number of sides that make up the circle
  61951. * @returns points that make the resulting circle
  61952. */
  61953. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61954. /**
  61955. * Creates a polygon from input string
  61956. * @param input Input polygon data
  61957. * @returns the parsed points
  61958. */
  61959. static Parse(input: string): Vector2[];
  61960. /**
  61961. * Starts building a polygon from x and y coordinates
  61962. * @param x x coordinate
  61963. * @param y y coordinate
  61964. * @returns the started path2
  61965. */
  61966. static StartingAt(x: number, y: number): Path2;
  61967. }
  61968. /**
  61969. * Builds a polygon
  61970. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61971. */
  61972. export class PolygonMeshBuilder {
  61973. private _points;
  61974. private _outlinepoints;
  61975. private _holes;
  61976. private _name;
  61977. private _scene;
  61978. private _epoints;
  61979. private _eholes;
  61980. private _addToepoint;
  61981. /**
  61982. * Babylon reference to the earcut plugin.
  61983. */
  61984. bjsEarcut: any;
  61985. /**
  61986. * Creates a PolygonMeshBuilder
  61987. * @param name name of the builder
  61988. * @param contours Path of the polygon
  61989. * @param scene scene to add to when creating the mesh
  61990. * @param earcutInjection can be used to inject your own earcut reference
  61991. */
  61992. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61993. /**
  61994. * Adds a whole within the polygon
  61995. * @param hole Array of points defining the hole
  61996. * @returns this
  61997. */
  61998. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61999. /**
  62000. * Creates the polygon
  62001. * @param updatable If the mesh should be updatable
  62002. * @param depth The depth of the mesh created
  62003. * @returns the created mesh
  62004. */
  62005. build(updatable?: boolean, depth?: number): Mesh;
  62006. /**
  62007. * Creates the polygon
  62008. * @param depth The depth of the mesh created
  62009. * @returns the created VertexData
  62010. */
  62011. buildVertexData(depth?: number): VertexData;
  62012. /**
  62013. * Adds a side to the polygon
  62014. * @param positions points that make the polygon
  62015. * @param normals normals of the polygon
  62016. * @param uvs uvs of the polygon
  62017. * @param indices indices of the polygon
  62018. * @param bounds bounds of the polygon
  62019. * @param points points of the polygon
  62020. * @param depth depth of the polygon
  62021. * @param flip flip of the polygon
  62022. */
  62023. private addSide;
  62024. }
  62025. }
  62026. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  62027. import { Scene } from "babylonjs/scene";
  62028. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62029. import { Color4 } from "babylonjs/Maths/math.color";
  62030. import { Mesh } from "babylonjs/Meshes/mesh";
  62031. import { Nullable } from "babylonjs/types";
  62032. /**
  62033. * Class containing static functions to help procedurally build meshes
  62034. */
  62035. export class PolygonBuilder {
  62036. /**
  62037. * Creates a polygon mesh
  62038. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62039. * * 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
  62040. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62043. * * Remember you can only change the shape positions, not their number when updating a polygon
  62044. * @param name defines the name of the mesh
  62045. * @param options defines the options used to create the mesh
  62046. * @param scene defines the hosting scene
  62047. * @param earcutInjection can be used to inject your own earcut reference
  62048. * @returns the polygon mesh
  62049. */
  62050. static CreatePolygon(name: string, options: {
  62051. shape: Vector3[];
  62052. holes?: Vector3[][];
  62053. depth?: number;
  62054. faceUV?: Vector4[];
  62055. faceColors?: Color4[];
  62056. updatable?: boolean;
  62057. sideOrientation?: number;
  62058. frontUVs?: Vector4;
  62059. backUVs?: Vector4;
  62060. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62061. /**
  62062. * Creates an extruded polygon mesh, with depth in the Y direction.
  62063. * * 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)
  62064. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62065. * @param name defines the name of the mesh
  62066. * @param options defines the options used to create the mesh
  62067. * @param scene defines the hosting scene
  62068. * @param earcutInjection can be used to inject your own earcut reference
  62069. * @returns the polygon mesh
  62070. */
  62071. static ExtrudePolygon(name: string, options: {
  62072. shape: Vector3[];
  62073. holes?: Vector3[][];
  62074. depth?: number;
  62075. faceUV?: Vector4[];
  62076. faceColors?: Color4[];
  62077. updatable?: boolean;
  62078. sideOrientation?: number;
  62079. frontUVs?: Vector4;
  62080. backUVs?: Vector4;
  62081. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62082. }
  62083. }
  62084. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  62085. import { Scene } from "babylonjs/scene";
  62086. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62087. import { Mesh } from "babylonjs/Meshes/mesh";
  62088. import { Nullable } from "babylonjs/types";
  62089. /**
  62090. * Class containing static functions to help procedurally build meshes
  62091. */
  62092. export class LatheBuilder {
  62093. /**
  62094. * Creates lathe mesh.
  62095. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62096. * * 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
  62097. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62098. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62099. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62100. * * 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
  62101. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62102. * * 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
  62103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62105. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62107. * @param name defines the name of the mesh
  62108. * @param options defines the options used to create the mesh
  62109. * @param scene defines the hosting scene
  62110. * @returns the lathe mesh
  62111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62112. */
  62113. static CreateLathe(name: string, options: {
  62114. shape: Vector3[];
  62115. radius?: number;
  62116. tessellation?: number;
  62117. clip?: number;
  62118. arc?: number;
  62119. closed?: boolean;
  62120. updatable?: boolean;
  62121. sideOrientation?: number;
  62122. frontUVs?: Vector4;
  62123. backUVs?: Vector4;
  62124. cap?: number;
  62125. invertUV?: boolean;
  62126. }, scene?: Nullable<Scene>): Mesh;
  62127. }
  62128. }
  62129. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  62130. import { Nullable } from "babylonjs/types";
  62131. import { Scene } from "babylonjs/scene";
  62132. import { Vector4 } from "babylonjs/Maths/math.vector";
  62133. import { Mesh } from "babylonjs/Meshes/mesh";
  62134. /**
  62135. * Class containing static functions to help procedurally build meshes
  62136. */
  62137. export class TiledPlaneBuilder {
  62138. /**
  62139. * Creates a tiled plane mesh
  62140. * * The parameter `pattern` will, depending on value, do nothing or
  62141. * * * flip (reflect about central vertical) alternate tiles across and up
  62142. * * * flip every tile on alternate rows
  62143. * * * rotate (180 degs) alternate tiles across and up
  62144. * * * rotate every tile on alternate rows
  62145. * * * flip and rotate alternate tiles across and up
  62146. * * * flip and rotate every tile on alternate rows
  62147. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62148. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62151. * * 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)
  62152. * * 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)
  62153. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62154. * @param name defines the name of the mesh
  62155. * @param options defines the options used to create the mesh
  62156. * @param scene defines the hosting scene
  62157. * @returns the box mesh
  62158. */
  62159. static CreateTiledPlane(name: string, options: {
  62160. pattern?: number;
  62161. tileSize?: number;
  62162. tileWidth?: number;
  62163. tileHeight?: number;
  62164. size?: number;
  62165. width?: number;
  62166. height?: number;
  62167. alignHorizontal?: number;
  62168. alignVertical?: number;
  62169. sideOrientation?: number;
  62170. frontUVs?: Vector4;
  62171. backUVs?: Vector4;
  62172. updatable?: boolean;
  62173. }, scene?: Nullable<Scene>): Mesh;
  62174. }
  62175. }
  62176. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  62177. import { Nullable } from "babylonjs/types";
  62178. import { Scene } from "babylonjs/scene";
  62179. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62180. import { Mesh } from "babylonjs/Meshes/mesh";
  62181. /**
  62182. * Class containing static functions to help procedurally build meshes
  62183. */
  62184. export class TubeBuilder {
  62185. /**
  62186. * Creates a tube mesh.
  62187. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62188. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62189. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62190. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62191. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62192. * * 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)
  62193. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62194. * * 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
  62195. * * 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
  62196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62198. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62200. * @param name defines the name of the mesh
  62201. * @param options defines the options used to create the mesh
  62202. * @param scene defines the hosting scene
  62203. * @returns the tube mesh
  62204. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62205. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62206. */
  62207. static CreateTube(name: string, options: {
  62208. path: Vector3[];
  62209. radius?: number;
  62210. tessellation?: number;
  62211. radiusFunction?: {
  62212. (i: number, distance: number): number;
  62213. };
  62214. cap?: number;
  62215. arc?: number;
  62216. updatable?: boolean;
  62217. sideOrientation?: number;
  62218. frontUVs?: Vector4;
  62219. backUVs?: Vector4;
  62220. instance?: Mesh;
  62221. invertUV?: boolean;
  62222. }, scene?: Nullable<Scene>): Mesh;
  62223. }
  62224. }
  62225. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  62226. import { Scene } from "babylonjs/scene";
  62227. import { Vector4 } from "babylonjs/Maths/math.vector";
  62228. import { Mesh } from "babylonjs/Meshes/mesh";
  62229. import { Nullable } from "babylonjs/types";
  62230. /**
  62231. * Class containing static functions to help procedurally build meshes
  62232. */
  62233. export class IcoSphereBuilder {
  62234. /**
  62235. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62236. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62237. * * 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`)
  62238. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62239. * * 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
  62240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62243. * @param name defines the name of the mesh
  62244. * @param options defines the options used to create the mesh
  62245. * @param scene defines the hosting scene
  62246. * @returns the icosahedron mesh
  62247. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62248. */
  62249. static CreateIcoSphere(name: string, options: {
  62250. radius?: number;
  62251. radiusX?: number;
  62252. radiusY?: number;
  62253. radiusZ?: number;
  62254. flat?: boolean;
  62255. subdivisions?: number;
  62256. sideOrientation?: number;
  62257. frontUVs?: Vector4;
  62258. backUVs?: Vector4;
  62259. updatable?: boolean;
  62260. }, scene?: Nullable<Scene>): Mesh;
  62261. }
  62262. }
  62263. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  62264. import { Vector3 } from "babylonjs/Maths/math.vector";
  62265. import { Mesh } from "babylonjs/Meshes/mesh";
  62266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62267. /**
  62268. * Class containing static functions to help procedurally build meshes
  62269. */
  62270. export class DecalBuilder {
  62271. /**
  62272. * Creates a decal mesh.
  62273. * 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
  62274. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62275. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62276. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62277. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62278. * @param name defines the name of the mesh
  62279. * @param sourceMesh defines the mesh where the decal must be applied
  62280. * @param options defines the options used to create the mesh
  62281. * @param scene defines the hosting scene
  62282. * @returns the decal mesh
  62283. * @see https://doc.babylonjs.com/how_to/decals
  62284. */
  62285. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62286. position?: Vector3;
  62287. normal?: Vector3;
  62288. size?: Vector3;
  62289. angle?: number;
  62290. }): Mesh;
  62291. }
  62292. }
  62293. declare module "babylonjs/Meshes/meshBuilder" {
  62294. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  62295. import { Nullable } from "babylonjs/types";
  62296. import { Scene } from "babylonjs/scene";
  62297. import { Mesh } from "babylonjs/Meshes/mesh";
  62298. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  62299. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  62300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62301. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62302. import { Plane } from "babylonjs/Maths/math.plane";
  62303. /**
  62304. * Class containing static functions to help procedurally build meshes
  62305. */
  62306. export class MeshBuilder {
  62307. /**
  62308. * Creates a box mesh
  62309. * * The parameter `size` sets the size (float) of each box side (default 1)
  62310. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  62311. * * 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)
  62312. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62316. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62317. * @param name defines the name of the mesh
  62318. * @param options defines the options used to create the mesh
  62319. * @param scene defines the hosting scene
  62320. * @returns the box mesh
  62321. */
  62322. static CreateBox(name: string, options: {
  62323. size?: number;
  62324. width?: number;
  62325. height?: number;
  62326. depth?: number;
  62327. faceUV?: Vector4[];
  62328. faceColors?: Color4[];
  62329. sideOrientation?: number;
  62330. frontUVs?: Vector4;
  62331. backUVs?: Vector4;
  62332. updatable?: boolean;
  62333. }, scene?: Nullable<Scene>): Mesh;
  62334. /**
  62335. * Creates a tiled box mesh
  62336. * * faceTiles sets the pattern, tile size and number of tiles for a face
  62337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62338. * @param name defines the name of the mesh
  62339. * @param options defines the options used to create the mesh
  62340. * @param scene defines the hosting scene
  62341. * @returns the tiled box mesh
  62342. */
  62343. static CreateTiledBox(name: string, options: {
  62344. pattern?: number;
  62345. size?: number;
  62346. width?: number;
  62347. height?: number;
  62348. depth: number;
  62349. tileSize?: number;
  62350. tileWidth?: number;
  62351. tileHeight?: number;
  62352. faceUV?: Vector4[];
  62353. faceColors?: Color4[];
  62354. alignHorizontal?: number;
  62355. alignVertical?: number;
  62356. sideOrientation?: number;
  62357. updatable?: boolean;
  62358. }, scene?: Nullable<Scene>): Mesh;
  62359. /**
  62360. * Creates a sphere mesh
  62361. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  62362. * * 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`)
  62363. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  62364. * * 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
  62365. * * 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)
  62366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62369. * @param name defines the name of the mesh
  62370. * @param options defines the options used to create the mesh
  62371. * @param scene defines the hosting scene
  62372. * @returns the sphere mesh
  62373. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  62374. */
  62375. static CreateSphere(name: string, options: {
  62376. segments?: number;
  62377. diameter?: number;
  62378. diameterX?: number;
  62379. diameterY?: number;
  62380. diameterZ?: number;
  62381. arc?: number;
  62382. slice?: number;
  62383. sideOrientation?: number;
  62384. frontUVs?: Vector4;
  62385. backUVs?: Vector4;
  62386. updatable?: boolean;
  62387. }, scene?: Nullable<Scene>): Mesh;
  62388. /**
  62389. * Creates a plane polygonal mesh. By default, this is a disc
  62390. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  62391. * * 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
  62392. * * 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
  62393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62396. * @param name defines the name of the mesh
  62397. * @param options defines the options used to create the mesh
  62398. * @param scene defines the hosting scene
  62399. * @returns the plane polygonal mesh
  62400. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  62401. */
  62402. static CreateDisc(name: string, options: {
  62403. radius?: number;
  62404. tessellation?: number;
  62405. arc?: number;
  62406. updatable?: boolean;
  62407. sideOrientation?: number;
  62408. frontUVs?: Vector4;
  62409. backUVs?: Vector4;
  62410. }, scene?: Nullable<Scene>): Mesh;
  62411. /**
  62412. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62413. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62414. * * 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`)
  62415. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62416. * * 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
  62417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62420. * @param name defines the name of the mesh
  62421. * @param options defines the options used to create the mesh
  62422. * @param scene defines the hosting scene
  62423. * @returns the icosahedron mesh
  62424. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62425. */
  62426. static CreateIcoSphere(name: string, options: {
  62427. radius?: number;
  62428. radiusX?: number;
  62429. radiusY?: number;
  62430. radiusZ?: number;
  62431. flat?: boolean;
  62432. subdivisions?: number;
  62433. sideOrientation?: number;
  62434. frontUVs?: Vector4;
  62435. backUVs?: Vector4;
  62436. updatable?: boolean;
  62437. }, scene?: Nullable<Scene>): Mesh;
  62438. /**
  62439. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62440. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62441. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62442. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62443. * * 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
  62444. * * 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
  62445. * * 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
  62446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62448. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62449. * * 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
  62450. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62451. * * 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
  62452. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62454. * @param name defines the name of the mesh
  62455. * @param options defines the options used to create the mesh
  62456. * @param scene defines the hosting scene
  62457. * @returns the ribbon mesh
  62458. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62459. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62460. */
  62461. static CreateRibbon(name: string, options: {
  62462. pathArray: Vector3[][];
  62463. closeArray?: boolean;
  62464. closePath?: boolean;
  62465. offset?: number;
  62466. updatable?: boolean;
  62467. sideOrientation?: number;
  62468. frontUVs?: Vector4;
  62469. backUVs?: Vector4;
  62470. instance?: Mesh;
  62471. invertUV?: boolean;
  62472. uvs?: Vector2[];
  62473. colors?: Color4[];
  62474. }, scene?: Nullable<Scene>): Mesh;
  62475. /**
  62476. * Creates a cylinder or a cone mesh
  62477. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  62478. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  62479. * * 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.
  62480. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  62481. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  62482. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  62483. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  62484. * * 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).
  62485. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  62486. * * 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).
  62487. * * 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
  62488. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  62489. * * 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
  62490. * * 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.
  62491. * * If `enclose` is false, a ring surface is one element.
  62492. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  62493. * * 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
  62494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62497. * @param name defines the name of the mesh
  62498. * @param options defines the options used to create the mesh
  62499. * @param scene defines the hosting scene
  62500. * @returns the cylinder mesh
  62501. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  62502. */
  62503. static CreateCylinder(name: string, options: {
  62504. height?: number;
  62505. diameterTop?: number;
  62506. diameterBottom?: number;
  62507. diameter?: number;
  62508. tessellation?: number;
  62509. subdivisions?: number;
  62510. arc?: number;
  62511. faceColors?: Color4[];
  62512. faceUV?: Vector4[];
  62513. updatable?: boolean;
  62514. hasRings?: boolean;
  62515. enclose?: boolean;
  62516. cap?: number;
  62517. sideOrientation?: number;
  62518. frontUVs?: Vector4;
  62519. backUVs?: Vector4;
  62520. }, scene?: Nullable<Scene>): Mesh;
  62521. /**
  62522. * Creates a torus mesh
  62523. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  62524. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  62525. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  62526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62529. * @param name defines the name of the mesh
  62530. * @param options defines the options used to create the mesh
  62531. * @param scene defines the hosting scene
  62532. * @returns the torus mesh
  62533. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  62534. */
  62535. static CreateTorus(name: string, options: {
  62536. diameter?: number;
  62537. thickness?: number;
  62538. tessellation?: number;
  62539. updatable?: boolean;
  62540. sideOrientation?: number;
  62541. frontUVs?: Vector4;
  62542. backUVs?: Vector4;
  62543. }, scene?: Nullable<Scene>): Mesh;
  62544. /**
  62545. * Creates a torus knot mesh
  62546. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62547. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62548. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62549. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62553. * @param name defines the name of the mesh
  62554. * @param options defines the options used to create the mesh
  62555. * @param scene defines the hosting scene
  62556. * @returns the torus knot mesh
  62557. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62558. */
  62559. static CreateTorusKnot(name: string, options: {
  62560. radius?: number;
  62561. tube?: number;
  62562. radialSegments?: number;
  62563. tubularSegments?: number;
  62564. p?: number;
  62565. q?: number;
  62566. updatable?: boolean;
  62567. sideOrientation?: number;
  62568. frontUVs?: Vector4;
  62569. backUVs?: Vector4;
  62570. }, scene?: Nullable<Scene>): Mesh;
  62571. /**
  62572. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  62573. * * 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
  62574. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  62575. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  62576. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  62577. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  62578. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  62579. * * 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
  62580. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  62581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  62583. * @param name defines the name of the new line system
  62584. * @param options defines the options used to create the line system
  62585. * @param scene defines the hosting scene
  62586. * @returns a new line system mesh
  62587. */
  62588. static CreateLineSystem(name: string, options: {
  62589. lines: Vector3[][];
  62590. updatable?: boolean;
  62591. instance?: Nullable<LinesMesh>;
  62592. colors?: Nullable<Color4[][]>;
  62593. useVertexAlpha?: boolean;
  62594. }, scene: Nullable<Scene>): LinesMesh;
  62595. /**
  62596. * Creates a line mesh
  62597. * 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
  62598. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62599. * * The parameter `points` is an array successive Vector3
  62600. * * 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
  62601. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62602. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62603. * * When updating an instance, remember that only point positions can change, not the number of points
  62604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62605. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62606. * @param name defines the name of the new line system
  62607. * @param options defines the options used to create the line system
  62608. * @param scene defines the hosting scene
  62609. * @returns a new line mesh
  62610. */
  62611. static CreateLines(name: string, options: {
  62612. points: Vector3[];
  62613. updatable?: boolean;
  62614. instance?: Nullable<LinesMesh>;
  62615. colors?: Color4[];
  62616. useVertexAlpha?: boolean;
  62617. }, scene?: Nullable<Scene>): LinesMesh;
  62618. /**
  62619. * Creates a dashed line mesh
  62620. * * 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
  62621. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62622. * * The parameter `points` is an array successive Vector3
  62623. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62624. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62625. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62626. * * 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
  62627. * * When updating an instance, remember that only point positions can change, not the number of points
  62628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62629. * @param name defines the name of the mesh
  62630. * @param options defines the options used to create the mesh
  62631. * @param scene defines the hosting scene
  62632. * @returns the dashed line mesh
  62633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62634. */
  62635. static CreateDashedLines(name: string, options: {
  62636. points: Vector3[];
  62637. dashSize?: number;
  62638. gapSize?: number;
  62639. dashNb?: number;
  62640. updatable?: boolean;
  62641. instance?: LinesMesh;
  62642. }, scene?: Nullable<Scene>): LinesMesh;
  62643. /**
  62644. * 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.
  62645. * * 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.
  62646. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62647. * * 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.
  62648. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62649. * * 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
  62650. * * 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
  62651. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62653. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62654. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62656. * @param name defines the name of the mesh
  62657. * @param options defines the options used to create the mesh
  62658. * @param scene defines the hosting scene
  62659. * @returns the extruded shape mesh
  62660. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62662. */
  62663. static ExtrudeShape(name: string, options: {
  62664. shape: Vector3[];
  62665. path: Vector3[];
  62666. scale?: number;
  62667. rotation?: number;
  62668. cap?: number;
  62669. updatable?: boolean;
  62670. sideOrientation?: number;
  62671. frontUVs?: Vector4;
  62672. backUVs?: Vector4;
  62673. instance?: Mesh;
  62674. invertUV?: boolean;
  62675. }, scene?: Nullable<Scene>): Mesh;
  62676. /**
  62677. * Creates an custom extruded shape mesh.
  62678. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62679. * * 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.
  62680. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62681. * * 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
  62682. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62683. * * 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
  62684. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62685. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62686. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62687. * * 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
  62688. * * 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
  62689. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62692. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62694. * @param name defines the name of the mesh
  62695. * @param options defines the options used to create the mesh
  62696. * @param scene defines the hosting scene
  62697. * @returns the custom extruded shape mesh
  62698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62699. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62701. */
  62702. static ExtrudeShapeCustom(name: string, options: {
  62703. shape: Vector3[];
  62704. path: Vector3[];
  62705. scaleFunction?: any;
  62706. rotationFunction?: any;
  62707. ribbonCloseArray?: boolean;
  62708. ribbonClosePath?: boolean;
  62709. cap?: number;
  62710. updatable?: boolean;
  62711. sideOrientation?: number;
  62712. frontUVs?: Vector4;
  62713. backUVs?: Vector4;
  62714. instance?: Mesh;
  62715. invertUV?: boolean;
  62716. }, scene?: Nullable<Scene>): Mesh;
  62717. /**
  62718. * Creates lathe mesh.
  62719. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62720. * * 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
  62721. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62722. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62723. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62724. * * 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
  62725. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62726. * * 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
  62727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62729. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62731. * @param name defines the name of the mesh
  62732. * @param options defines the options used to create the mesh
  62733. * @param scene defines the hosting scene
  62734. * @returns the lathe mesh
  62735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62736. */
  62737. static CreateLathe(name: string, options: {
  62738. shape: Vector3[];
  62739. radius?: number;
  62740. tessellation?: number;
  62741. clip?: number;
  62742. arc?: number;
  62743. closed?: boolean;
  62744. updatable?: boolean;
  62745. sideOrientation?: number;
  62746. frontUVs?: Vector4;
  62747. backUVs?: Vector4;
  62748. cap?: number;
  62749. invertUV?: boolean;
  62750. }, scene?: Nullable<Scene>): Mesh;
  62751. /**
  62752. * Creates a tiled plane mesh
  62753. * * You can set a limited pattern arrangement with the tiles
  62754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62757. * @param name defines the name of the mesh
  62758. * @param options defines the options used to create the mesh
  62759. * @param scene defines the hosting scene
  62760. * @returns the plane mesh
  62761. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62762. */
  62763. static CreateTiledPlane(name: string, options: {
  62764. pattern?: number;
  62765. tileSize?: number;
  62766. tileWidth?: number;
  62767. tileHeight?: number;
  62768. size?: number;
  62769. width?: number;
  62770. height?: number;
  62771. alignHorizontal?: number;
  62772. alignVertical?: number;
  62773. sideOrientation?: number;
  62774. frontUVs?: Vector4;
  62775. backUVs?: Vector4;
  62776. updatable?: boolean;
  62777. }, scene?: Nullable<Scene>): Mesh;
  62778. /**
  62779. * Creates a plane mesh
  62780. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62781. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62782. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62786. * @param name defines the name of the mesh
  62787. * @param options defines the options used to create the mesh
  62788. * @param scene defines the hosting scene
  62789. * @returns the plane mesh
  62790. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62791. */
  62792. static CreatePlane(name: string, options: {
  62793. size?: number;
  62794. width?: number;
  62795. height?: number;
  62796. sideOrientation?: number;
  62797. frontUVs?: Vector4;
  62798. backUVs?: Vector4;
  62799. updatable?: boolean;
  62800. sourcePlane?: Plane;
  62801. }, scene?: Nullable<Scene>): Mesh;
  62802. /**
  62803. * Creates a ground mesh
  62804. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62805. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62807. * @param name defines the name of the mesh
  62808. * @param options defines the options used to create the mesh
  62809. * @param scene defines the hosting scene
  62810. * @returns the ground mesh
  62811. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62812. */
  62813. static CreateGround(name: string, options: {
  62814. width?: number;
  62815. height?: number;
  62816. subdivisions?: number;
  62817. subdivisionsX?: number;
  62818. subdivisionsY?: number;
  62819. updatable?: boolean;
  62820. }, scene?: Nullable<Scene>): Mesh;
  62821. /**
  62822. * Creates a tiled ground mesh
  62823. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62824. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62825. * * 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
  62826. * * 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
  62827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62828. * @param name defines the name of the mesh
  62829. * @param options defines the options used to create the mesh
  62830. * @param scene defines the hosting scene
  62831. * @returns the tiled ground mesh
  62832. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62833. */
  62834. static CreateTiledGround(name: string, options: {
  62835. xmin: number;
  62836. zmin: number;
  62837. xmax: number;
  62838. zmax: number;
  62839. subdivisions?: {
  62840. w: number;
  62841. h: number;
  62842. };
  62843. precision?: {
  62844. w: number;
  62845. h: number;
  62846. };
  62847. updatable?: boolean;
  62848. }, scene?: Nullable<Scene>): Mesh;
  62849. /**
  62850. * Creates a ground mesh from a height map
  62851. * * The parameter `url` sets the URL of the height map image resource.
  62852. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62853. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62854. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62855. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62856. * * 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.
  62857. * * 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).
  62858. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62860. * @param name defines the name of the mesh
  62861. * @param url defines the url to the height map
  62862. * @param options defines the options used to create the mesh
  62863. * @param scene defines the hosting scene
  62864. * @returns the ground mesh
  62865. * @see https://doc.babylonjs.com/babylon101/height_map
  62866. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62867. */
  62868. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62869. width?: number;
  62870. height?: number;
  62871. subdivisions?: number;
  62872. minHeight?: number;
  62873. maxHeight?: number;
  62874. colorFilter?: Color3;
  62875. alphaFilter?: number;
  62876. updatable?: boolean;
  62877. onReady?: (mesh: GroundMesh) => void;
  62878. }, scene?: Nullable<Scene>): GroundMesh;
  62879. /**
  62880. * Creates a polygon mesh
  62881. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62882. * * 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
  62883. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62886. * * Remember you can only change the shape positions, not their number when updating a polygon
  62887. * @param name defines the name of the mesh
  62888. * @param options defines the options used to create the mesh
  62889. * @param scene defines the hosting scene
  62890. * @param earcutInjection can be used to inject your own earcut reference
  62891. * @returns the polygon mesh
  62892. */
  62893. static CreatePolygon(name: string, options: {
  62894. shape: Vector3[];
  62895. holes?: Vector3[][];
  62896. depth?: number;
  62897. faceUV?: Vector4[];
  62898. faceColors?: Color4[];
  62899. updatable?: boolean;
  62900. sideOrientation?: number;
  62901. frontUVs?: Vector4;
  62902. backUVs?: Vector4;
  62903. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62904. /**
  62905. * Creates an extruded polygon mesh, with depth in the Y direction.
  62906. * * 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)
  62907. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62908. * @param name defines the name of the mesh
  62909. * @param options defines the options used to create the mesh
  62910. * @param scene defines the hosting scene
  62911. * @param earcutInjection can be used to inject your own earcut reference
  62912. * @returns the polygon mesh
  62913. */
  62914. static ExtrudePolygon(name: string, options: {
  62915. shape: Vector3[];
  62916. holes?: Vector3[][];
  62917. depth?: number;
  62918. faceUV?: Vector4[];
  62919. faceColors?: Color4[];
  62920. updatable?: boolean;
  62921. sideOrientation?: number;
  62922. frontUVs?: Vector4;
  62923. backUVs?: Vector4;
  62924. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62925. /**
  62926. * Creates a tube mesh.
  62927. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62928. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62929. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62930. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62931. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62932. * * 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)
  62933. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62934. * * 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
  62935. * * 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
  62936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62938. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62940. * @param name defines the name of the mesh
  62941. * @param options defines the options used to create the mesh
  62942. * @param scene defines the hosting scene
  62943. * @returns the tube mesh
  62944. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62945. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62946. */
  62947. static CreateTube(name: string, options: {
  62948. path: Vector3[];
  62949. radius?: number;
  62950. tessellation?: number;
  62951. radiusFunction?: {
  62952. (i: number, distance: number): number;
  62953. };
  62954. cap?: number;
  62955. arc?: number;
  62956. updatable?: boolean;
  62957. sideOrientation?: number;
  62958. frontUVs?: Vector4;
  62959. backUVs?: Vector4;
  62960. instance?: Mesh;
  62961. invertUV?: boolean;
  62962. }, scene?: Nullable<Scene>): Mesh;
  62963. /**
  62964. * Creates a polyhedron mesh
  62965. * * 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
  62966. * * The parameter `size` (positive float, default 1) sets the polygon size
  62967. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62968. * * 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`
  62969. * * 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
  62970. * * 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)`)
  62971. * * 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
  62972. * * 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
  62973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62976. * @param name defines the name of the mesh
  62977. * @param options defines the options used to create the mesh
  62978. * @param scene defines the hosting scene
  62979. * @returns the polyhedron mesh
  62980. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62981. */
  62982. static CreatePolyhedron(name: string, options: {
  62983. type?: number;
  62984. size?: number;
  62985. sizeX?: number;
  62986. sizeY?: number;
  62987. sizeZ?: number;
  62988. custom?: any;
  62989. faceUV?: Vector4[];
  62990. faceColors?: Color4[];
  62991. flat?: boolean;
  62992. updatable?: boolean;
  62993. sideOrientation?: number;
  62994. frontUVs?: Vector4;
  62995. backUVs?: Vector4;
  62996. }, scene?: Nullable<Scene>): Mesh;
  62997. /**
  62998. * Creates a decal mesh.
  62999. * 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
  63000. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63001. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63002. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63003. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63004. * @param name defines the name of the mesh
  63005. * @param sourceMesh defines the mesh where the decal must be applied
  63006. * @param options defines the options used to create the mesh
  63007. * @param scene defines the hosting scene
  63008. * @returns the decal mesh
  63009. * @see https://doc.babylonjs.com/how_to/decals
  63010. */
  63011. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63012. position?: Vector3;
  63013. normal?: Vector3;
  63014. size?: Vector3;
  63015. angle?: number;
  63016. }): Mesh;
  63017. }
  63018. }
  63019. declare module "babylonjs/Meshes/meshSimplification" {
  63020. import { Mesh } from "babylonjs/Meshes/mesh";
  63021. /**
  63022. * A simplifier interface for future simplification implementations
  63023. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63024. */
  63025. export interface ISimplifier {
  63026. /**
  63027. * Simplification of a given mesh according to the given settings.
  63028. * Since this requires computation, it is assumed that the function runs async.
  63029. * @param settings The settings of the simplification, including quality and distance
  63030. * @param successCallback A callback that will be called after the mesh was simplified.
  63031. * @param errorCallback in case of an error, this callback will be called. optional.
  63032. */
  63033. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  63034. }
  63035. /**
  63036. * Expected simplification settings.
  63037. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  63038. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63039. */
  63040. export interface ISimplificationSettings {
  63041. /**
  63042. * Gets or sets the expected quality
  63043. */
  63044. quality: number;
  63045. /**
  63046. * Gets or sets the distance when this optimized version should be used
  63047. */
  63048. distance: number;
  63049. /**
  63050. * Gets an already optimized mesh
  63051. */
  63052. optimizeMesh?: boolean;
  63053. }
  63054. /**
  63055. * Class used to specify simplification options
  63056. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63057. */
  63058. export class SimplificationSettings implements ISimplificationSettings {
  63059. /** expected quality */
  63060. quality: number;
  63061. /** distance when this optimized version should be used */
  63062. distance: number;
  63063. /** already optimized mesh */
  63064. optimizeMesh?: boolean | undefined;
  63065. /**
  63066. * Creates a SimplificationSettings
  63067. * @param quality expected quality
  63068. * @param distance distance when this optimized version should be used
  63069. * @param optimizeMesh already optimized mesh
  63070. */
  63071. constructor(
  63072. /** expected quality */
  63073. quality: number,
  63074. /** distance when this optimized version should be used */
  63075. distance: number,
  63076. /** already optimized mesh */
  63077. optimizeMesh?: boolean | undefined);
  63078. }
  63079. /**
  63080. * Interface used to define a simplification task
  63081. */
  63082. export interface ISimplificationTask {
  63083. /**
  63084. * Array of settings
  63085. */
  63086. settings: Array<ISimplificationSettings>;
  63087. /**
  63088. * Simplification type
  63089. */
  63090. simplificationType: SimplificationType;
  63091. /**
  63092. * Mesh to simplify
  63093. */
  63094. mesh: Mesh;
  63095. /**
  63096. * Callback called on success
  63097. */
  63098. successCallback?: () => void;
  63099. /**
  63100. * Defines if parallel processing can be used
  63101. */
  63102. parallelProcessing: boolean;
  63103. }
  63104. /**
  63105. * Queue used to order the simplification tasks
  63106. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63107. */
  63108. export class SimplificationQueue {
  63109. private _simplificationArray;
  63110. /**
  63111. * Gets a boolean indicating that the process is still running
  63112. */
  63113. running: boolean;
  63114. /**
  63115. * Creates a new queue
  63116. */
  63117. constructor();
  63118. /**
  63119. * Adds a new simplification task
  63120. * @param task defines a task to add
  63121. */
  63122. addTask(task: ISimplificationTask): void;
  63123. /**
  63124. * Execute next task
  63125. */
  63126. executeNext(): void;
  63127. /**
  63128. * Execute a simplification task
  63129. * @param task defines the task to run
  63130. */
  63131. runSimplification(task: ISimplificationTask): void;
  63132. private getSimplifier;
  63133. }
  63134. /**
  63135. * The implemented types of simplification
  63136. * At the moment only Quadratic Error Decimation is implemented
  63137. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63138. */
  63139. export enum SimplificationType {
  63140. /** Quadratic error decimation */
  63141. QUADRATIC = 0
  63142. }
  63143. }
  63144. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  63145. import { Scene } from "babylonjs/scene";
  63146. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  63147. import { ISceneComponent } from "babylonjs/sceneComponent";
  63148. module "babylonjs/scene" {
  63149. interface Scene {
  63150. /** @hidden (Backing field) */
  63151. _simplificationQueue: SimplificationQueue;
  63152. /**
  63153. * Gets or sets the simplification queue attached to the scene
  63154. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63155. */
  63156. simplificationQueue: SimplificationQueue;
  63157. }
  63158. }
  63159. module "babylonjs/Meshes/mesh" {
  63160. interface Mesh {
  63161. /**
  63162. * Simplify the mesh according to the given array of settings.
  63163. * Function will return immediately and will simplify async
  63164. * @param settings a collection of simplification settings
  63165. * @param parallelProcessing should all levels calculate parallel or one after the other
  63166. * @param simplificationType the type of simplification to run
  63167. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63168. * @returns the current mesh
  63169. */
  63170. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63171. }
  63172. }
  63173. /**
  63174. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63175. * created in a scene
  63176. */
  63177. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63178. /**
  63179. * The component name helpfull to identify the component in the list of scene components.
  63180. */
  63181. readonly name: string;
  63182. /**
  63183. * The scene the component belongs to.
  63184. */
  63185. scene: Scene;
  63186. /**
  63187. * Creates a new instance of the component for the given scene
  63188. * @param scene Defines the scene to register the component in
  63189. */
  63190. constructor(scene: Scene);
  63191. /**
  63192. * Registers the component in a given scene
  63193. */
  63194. register(): void;
  63195. /**
  63196. * Rebuilds the elements related to this component in case of
  63197. * context lost for instance.
  63198. */
  63199. rebuild(): void;
  63200. /**
  63201. * Disposes the component and the associated ressources
  63202. */
  63203. dispose(): void;
  63204. private _beforeCameraUpdate;
  63205. }
  63206. }
  63207. declare module "babylonjs/Meshes/Builders/index" {
  63208. export * from "babylonjs/Meshes/Builders/boxBuilder";
  63209. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  63210. export * from "babylonjs/Meshes/Builders/discBuilder";
  63211. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  63212. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  63213. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  63214. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  63215. export * from "babylonjs/Meshes/Builders/torusBuilder";
  63216. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  63217. export * from "babylonjs/Meshes/Builders/linesBuilder";
  63218. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  63219. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  63220. export * from "babylonjs/Meshes/Builders/latheBuilder";
  63221. export * from "babylonjs/Meshes/Builders/planeBuilder";
  63222. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  63223. export * from "babylonjs/Meshes/Builders/groundBuilder";
  63224. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  63225. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  63226. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  63227. export * from "babylonjs/Meshes/Builders/decalBuilder";
  63228. }
  63229. declare module "babylonjs/Meshes/index" {
  63230. export * from "babylonjs/Meshes/abstractMesh";
  63231. export * from "babylonjs/Meshes/buffer";
  63232. export * from "babylonjs/Meshes/Compression/index";
  63233. export * from "babylonjs/Meshes/csg";
  63234. export * from "babylonjs/Meshes/geometry";
  63235. export * from "babylonjs/Meshes/groundMesh";
  63236. export * from "babylonjs/Meshes/trailMesh";
  63237. export * from "babylonjs/Meshes/instancedMesh";
  63238. export * from "babylonjs/Meshes/linesMesh";
  63239. export * from "babylonjs/Meshes/mesh";
  63240. export * from "babylonjs/Meshes/mesh.vertexData";
  63241. export * from "babylonjs/Meshes/meshBuilder";
  63242. export * from "babylonjs/Meshes/meshSimplification";
  63243. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  63244. export * from "babylonjs/Meshes/polygonMesh";
  63245. export * from "babylonjs/Meshes/subMesh";
  63246. export * from "babylonjs/Meshes/meshLODLevel";
  63247. export * from "babylonjs/Meshes/transformNode";
  63248. export * from "babylonjs/Meshes/Builders/index";
  63249. export * from "babylonjs/Meshes/dataBuffer";
  63250. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  63251. }
  63252. declare module "babylonjs/Morph/index" {
  63253. export * from "babylonjs/Morph/morphTarget";
  63254. export * from "babylonjs/Morph/morphTargetManager";
  63255. }
  63256. declare module "babylonjs/Navigation/INavigationEngine" {
  63257. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63258. import { Vector3 } from "babylonjs/Maths/math";
  63259. import { Mesh } from "babylonjs/Meshes/mesh";
  63260. import { Scene } from "babylonjs/scene";
  63261. /**
  63262. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63263. */
  63264. export interface INavigationEnginePlugin {
  63265. /**
  63266. * plugin name
  63267. */
  63268. name: string;
  63269. /**
  63270. * Creates a navigation mesh
  63271. * @param meshes array of all the geometry used to compute the navigatio mesh
  63272. * @param parameters bunch of parameters used to filter geometry
  63273. */
  63274. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63275. /**
  63276. * Create a navigation mesh debug mesh
  63277. * @param scene is where the mesh will be added
  63278. * @returns debug display mesh
  63279. */
  63280. createDebugNavMesh(scene: Scene): Mesh;
  63281. /**
  63282. * Get a navigation mesh constrained position, closest to the parameter position
  63283. * @param position world position
  63284. * @returns the closest point to position constrained by the navigation mesh
  63285. */
  63286. getClosestPoint(position: Vector3): Vector3;
  63287. /**
  63288. * Get a navigation mesh constrained position, within a particular radius
  63289. * @param position world position
  63290. * @param maxRadius the maximum distance to the constrained world position
  63291. * @returns the closest point to position constrained by the navigation mesh
  63292. */
  63293. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63294. /**
  63295. * Compute the final position from a segment made of destination-position
  63296. * @param position world position
  63297. * @param destination world position
  63298. * @returns the resulting point along the navmesh
  63299. */
  63300. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63301. /**
  63302. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63303. * @param start world position
  63304. * @param end world position
  63305. * @returns array containing world position composing the path
  63306. */
  63307. computePath(start: Vector3, end: Vector3): Vector3[];
  63308. /**
  63309. * If this plugin is supported
  63310. * @returns true if plugin is supported
  63311. */
  63312. isSupported(): boolean;
  63313. /**
  63314. * Create a new Crowd so you can add agents
  63315. * @param maxAgents the maximum agent count in the crowd
  63316. * @param maxAgentRadius the maximum radius an agent can have
  63317. * @param scene to attach the crowd to
  63318. * @returns the crowd you can add agents to
  63319. */
  63320. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63321. /**
  63322. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63323. * The queries will try to find a solution within those bounds
  63324. * default is (1,1,1)
  63325. * @param extent x,y,z value that define the extent around the queries point of reference
  63326. */
  63327. setDefaultQueryExtent(extent: Vector3): void;
  63328. /**
  63329. * Get the Bounding box extent specified by setDefaultQueryExtent
  63330. * @returns the box extent values
  63331. */
  63332. getDefaultQueryExtent(): Vector3;
  63333. /**
  63334. * Release all resources
  63335. */
  63336. dispose(): void;
  63337. }
  63338. /**
  63339. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  63340. */
  63341. export interface ICrowd {
  63342. /**
  63343. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63344. * You can attach anything to that node. The node position is updated in the scene update tick.
  63345. * @param pos world position that will be constrained by the navigation mesh
  63346. * @param parameters agent parameters
  63347. * @param transform hooked to the agent that will be update by the scene
  63348. * @returns agent index
  63349. */
  63350. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63351. /**
  63352. * Returns the agent position in world space
  63353. * @param index agent index returned by addAgent
  63354. * @returns world space position
  63355. */
  63356. getAgentPosition(index: number): Vector3;
  63357. /**
  63358. * Gets the agent velocity in world space
  63359. * @param index agent index returned by addAgent
  63360. * @returns world space velocity
  63361. */
  63362. getAgentVelocity(index: number): Vector3;
  63363. /**
  63364. * remove a particular agent previously created
  63365. * @param index agent index returned by addAgent
  63366. */
  63367. removeAgent(index: number): void;
  63368. /**
  63369. * get the list of all agents attached to this crowd
  63370. * @returns list of agent indices
  63371. */
  63372. getAgents(): number[];
  63373. /**
  63374. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63375. * @param deltaTime in seconds
  63376. */
  63377. update(deltaTime: number): void;
  63378. /**
  63379. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63380. * @param index agent index returned by addAgent
  63381. * @param destination targeted world position
  63382. */
  63383. agentGoto(index: number, destination: Vector3): void;
  63384. /**
  63385. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63386. * The queries will try to find a solution within those bounds
  63387. * default is (1,1,1)
  63388. * @param extent x,y,z value that define the extent around the queries point of reference
  63389. */
  63390. setDefaultQueryExtent(extent: Vector3): void;
  63391. /**
  63392. * Get the Bounding box extent specified by setDefaultQueryExtent
  63393. * @returns the box extent values
  63394. */
  63395. getDefaultQueryExtent(): Vector3;
  63396. /**
  63397. * Release all resources
  63398. */
  63399. dispose(): void;
  63400. }
  63401. /**
  63402. * Configures an agent
  63403. */
  63404. export interface IAgentParameters {
  63405. /**
  63406. * Agent radius. [Limit: >= 0]
  63407. */
  63408. radius: number;
  63409. /**
  63410. * Agent height. [Limit: > 0]
  63411. */
  63412. height: number;
  63413. /**
  63414. * Maximum allowed acceleration. [Limit: >= 0]
  63415. */
  63416. maxAcceleration: number;
  63417. /**
  63418. * Maximum allowed speed. [Limit: >= 0]
  63419. */
  63420. maxSpeed: number;
  63421. /**
  63422. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  63423. */
  63424. collisionQueryRange: number;
  63425. /**
  63426. * The path visibility optimization range. [Limit: > 0]
  63427. */
  63428. pathOptimizationRange: number;
  63429. /**
  63430. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  63431. */
  63432. separationWeight: number;
  63433. }
  63434. /**
  63435. * Configures the navigation mesh creation
  63436. */
  63437. export interface INavMeshParameters {
  63438. /**
  63439. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  63440. */
  63441. cs: number;
  63442. /**
  63443. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  63444. */
  63445. ch: number;
  63446. /**
  63447. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  63448. */
  63449. walkableSlopeAngle: number;
  63450. /**
  63451. * Minimum floor to 'ceiling' height that will still allow the floor area to
  63452. * be considered walkable. [Limit: >= 3] [Units: vx]
  63453. */
  63454. walkableHeight: number;
  63455. /**
  63456. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  63457. */
  63458. walkableClimb: number;
  63459. /**
  63460. * The distance to erode/shrink the walkable area of the heightfield away from
  63461. * obstructions. [Limit: >=0] [Units: vx]
  63462. */
  63463. walkableRadius: number;
  63464. /**
  63465. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  63466. */
  63467. maxEdgeLen: number;
  63468. /**
  63469. * The maximum distance a simplfied contour's border edges should deviate
  63470. * the original raw contour. [Limit: >=0] [Units: vx]
  63471. */
  63472. maxSimplificationError: number;
  63473. /**
  63474. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  63475. */
  63476. minRegionArea: number;
  63477. /**
  63478. * Any regions with a span count smaller than this value will, if possible,
  63479. * be merged with larger regions. [Limit: >=0] [Units: vx]
  63480. */
  63481. mergeRegionArea: number;
  63482. /**
  63483. * The maximum number of vertices allowed for polygons generated during the
  63484. * contour to polygon conversion process. [Limit: >= 3]
  63485. */
  63486. maxVertsPerPoly: number;
  63487. /**
  63488. * Sets the sampling distance to use when generating the detail mesh.
  63489. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  63490. */
  63491. detailSampleDist: number;
  63492. /**
  63493. * The maximum distance the detail mesh surface should deviate from heightfield
  63494. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  63495. */
  63496. detailSampleMaxError: number;
  63497. }
  63498. }
  63499. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  63500. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  63501. import { Mesh } from "babylonjs/Meshes/mesh";
  63502. import { Scene } from "babylonjs/scene";
  63503. import { Vector3 } from "babylonjs/Maths/math";
  63504. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63505. /**
  63506. * RecastJS navigation plugin
  63507. */
  63508. export class RecastJSPlugin implements INavigationEnginePlugin {
  63509. /**
  63510. * Reference to the Recast library
  63511. */
  63512. bjsRECAST: any;
  63513. /**
  63514. * plugin name
  63515. */
  63516. name: string;
  63517. /**
  63518. * the first navmesh created. We might extend this to support multiple navmeshes
  63519. */
  63520. navMesh: any;
  63521. /**
  63522. * Initializes the recastJS plugin
  63523. * @param recastInjection can be used to inject your own recast reference
  63524. */
  63525. constructor(recastInjection?: any);
  63526. /**
  63527. * Creates a navigation mesh
  63528. * @param meshes array of all the geometry used to compute the navigatio mesh
  63529. * @param parameters bunch of parameters used to filter geometry
  63530. */
  63531. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63532. /**
  63533. * Create a navigation mesh debug mesh
  63534. * @param scene is where the mesh will be added
  63535. * @returns debug display mesh
  63536. */
  63537. createDebugNavMesh(scene: Scene): Mesh;
  63538. /**
  63539. * Get a navigation mesh constrained position, closest to the parameter position
  63540. * @param position world position
  63541. * @returns the closest point to position constrained by the navigation mesh
  63542. */
  63543. getClosestPoint(position: Vector3): Vector3;
  63544. /**
  63545. * Get a navigation mesh constrained position, within a particular radius
  63546. * @param position world position
  63547. * @param maxRadius the maximum distance to the constrained world position
  63548. * @returns the closest point to position constrained by the navigation mesh
  63549. */
  63550. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63551. /**
  63552. * Compute the final position from a segment made of destination-position
  63553. * @param position world position
  63554. * @param destination world position
  63555. * @returns the resulting point along the navmesh
  63556. */
  63557. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63558. /**
  63559. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63560. * @param start world position
  63561. * @param end world position
  63562. * @returns array containing world position composing the path
  63563. */
  63564. computePath(start: Vector3, end: Vector3): Vector3[];
  63565. /**
  63566. * Create a new Crowd so you can add agents
  63567. * @param maxAgents the maximum agent count in the crowd
  63568. * @param maxAgentRadius the maximum radius an agent can have
  63569. * @param scene to attach the crowd to
  63570. * @returns the crowd you can add agents to
  63571. */
  63572. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63573. /**
  63574. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63575. * The queries will try to find a solution within those bounds
  63576. * default is (1,1,1)
  63577. * @param extent x,y,z value that define the extent around the queries point of reference
  63578. */
  63579. setDefaultQueryExtent(extent: Vector3): void;
  63580. /**
  63581. * Get the Bounding box extent specified by setDefaultQueryExtent
  63582. * @returns the box extent values
  63583. */
  63584. getDefaultQueryExtent(): Vector3;
  63585. /**
  63586. * Disposes
  63587. */
  63588. dispose(): void;
  63589. /**
  63590. * If this plugin is supported
  63591. * @returns true if plugin is supported
  63592. */
  63593. isSupported(): boolean;
  63594. }
  63595. /**
  63596. * Recast detour crowd implementation
  63597. */
  63598. export class RecastJSCrowd implements ICrowd {
  63599. /**
  63600. * Recast/detour plugin
  63601. */
  63602. bjsRECASTPlugin: RecastJSPlugin;
  63603. /**
  63604. * Link to the detour crowd
  63605. */
  63606. recastCrowd: any;
  63607. /**
  63608. * One transform per agent
  63609. */
  63610. transforms: TransformNode[];
  63611. /**
  63612. * All agents created
  63613. */
  63614. agents: number[];
  63615. /**
  63616. * Link to the scene is kept to unregister the crowd from the scene
  63617. */
  63618. private _scene;
  63619. /**
  63620. * Observer for crowd updates
  63621. */
  63622. private _onBeforeAnimationsObserver;
  63623. /**
  63624. * Constructor
  63625. * @param plugin recastJS plugin
  63626. * @param maxAgents the maximum agent count in the crowd
  63627. * @param maxAgentRadius the maximum radius an agent can have
  63628. * @param scene to attach the crowd to
  63629. * @returns the crowd you can add agents to
  63630. */
  63631. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63632. /**
  63633. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63634. * You can attach anything to that node. The node position is updated in the scene update tick.
  63635. * @param pos world position that will be constrained by the navigation mesh
  63636. * @param parameters agent parameters
  63637. * @param transform hooked to the agent that will be update by the scene
  63638. * @returns agent index
  63639. */
  63640. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63641. /**
  63642. * Returns the agent position in world space
  63643. * @param index agent index returned by addAgent
  63644. * @returns world space position
  63645. */
  63646. getAgentPosition(index: number): Vector3;
  63647. /**
  63648. * Returns the agent velocity in world space
  63649. * @param index agent index returned by addAgent
  63650. * @returns world space velocity
  63651. */
  63652. getAgentVelocity(index: number): Vector3;
  63653. /**
  63654. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63655. * @param index agent index returned by addAgent
  63656. * @param destination targeted world position
  63657. */
  63658. agentGoto(index: number, destination: Vector3): void;
  63659. /**
  63660. * remove a particular agent previously created
  63661. * @param index agent index returned by addAgent
  63662. */
  63663. removeAgent(index: number): void;
  63664. /**
  63665. * get the list of all agents attached to this crowd
  63666. * @returns list of agent indices
  63667. */
  63668. getAgents(): number[];
  63669. /**
  63670. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63671. * @param deltaTime in seconds
  63672. */
  63673. update(deltaTime: number): void;
  63674. /**
  63675. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63676. * The queries will try to find a solution within those bounds
  63677. * default is (1,1,1)
  63678. * @param extent x,y,z value that define the extent around the queries point of reference
  63679. */
  63680. setDefaultQueryExtent(extent: Vector3): void;
  63681. /**
  63682. * Get the Bounding box extent specified by setDefaultQueryExtent
  63683. * @returns the box extent values
  63684. */
  63685. getDefaultQueryExtent(): Vector3;
  63686. /**
  63687. * Release all resources
  63688. */
  63689. dispose(): void;
  63690. }
  63691. }
  63692. declare module "babylonjs/Navigation/Plugins/index" {
  63693. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  63694. }
  63695. declare module "babylonjs/Navigation/index" {
  63696. export * from "babylonjs/Navigation/INavigationEngine";
  63697. export * from "babylonjs/Navigation/Plugins/index";
  63698. }
  63699. declare module "babylonjs/Offline/database" {
  63700. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  63701. /**
  63702. * Class used to enable access to IndexedDB
  63703. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63704. */
  63705. export class Database implements IOfflineProvider {
  63706. private _callbackManifestChecked;
  63707. private _currentSceneUrl;
  63708. private _db;
  63709. private _enableSceneOffline;
  63710. private _enableTexturesOffline;
  63711. private _manifestVersionFound;
  63712. private _mustUpdateRessources;
  63713. private _hasReachedQuota;
  63714. private _isSupported;
  63715. private _idbFactory;
  63716. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63717. private static IsUASupportingBlobStorage;
  63718. /**
  63719. * Gets a boolean indicating if Database storate is enabled (off by default)
  63720. */
  63721. static IDBStorageEnabled: boolean;
  63722. /**
  63723. * Gets a boolean indicating if scene must be saved in the database
  63724. */
  63725. get enableSceneOffline(): boolean;
  63726. /**
  63727. * Gets a boolean indicating if textures must be saved in the database
  63728. */
  63729. get enableTexturesOffline(): boolean;
  63730. /**
  63731. * Creates a new Database
  63732. * @param urlToScene defines the url to load the scene
  63733. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63734. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63735. */
  63736. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63737. private static _ParseURL;
  63738. private static _ReturnFullUrlLocation;
  63739. private _checkManifestFile;
  63740. /**
  63741. * Open the database and make it available
  63742. * @param successCallback defines the callback to call on success
  63743. * @param errorCallback defines the callback to call on error
  63744. */
  63745. open(successCallback: () => void, errorCallback: () => void): void;
  63746. /**
  63747. * Loads an image from the database
  63748. * @param url defines the url to load from
  63749. * @param image defines the target DOM image
  63750. */
  63751. loadImage(url: string, image: HTMLImageElement): void;
  63752. private _loadImageFromDBAsync;
  63753. private _saveImageIntoDBAsync;
  63754. private _checkVersionFromDB;
  63755. private _loadVersionFromDBAsync;
  63756. private _saveVersionIntoDBAsync;
  63757. /**
  63758. * Loads a file from database
  63759. * @param url defines the URL to load from
  63760. * @param sceneLoaded defines a callback to call on success
  63761. * @param progressCallBack defines a callback to call when progress changed
  63762. * @param errorCallback defines a callback to call on error
  63763. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63764. */
  63765. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63766. private _loadFileAsync;
  63767. private _saveFileAsync;
  63768. /**
  63769. * Validates if xhr data is correct
  63770. * @param xhr defines the request to validate
  63771. * @param dataType defines the expected data type
  63772. * @returns true if data is correct
  63773. */
  63774. private static _ValidateXHRData;
  63775. }
  63776. }
  63777. declare module "babylonjs/Offline/index" {
  63778. export * from "babylonjs/Offline/database";
  63779. export * from "babylonjs/Offline/IOfflineProvider";
  63780. }
  63781. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  63782. /** @hidden */
  63783. export var gpuUpdateParticlesPixelShader: {
  63784. name: string;
  63785. shader: string;
  63786. };
  63787. }
  63788. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  63789. /** @hidden */
  63790. export var gpuUpdateParticlesVertexShader: {
  63791. name: string;
  63792. shader: string;
  63793. };
  63794. }
  63795. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  63796. /** @hidden */
  63797. export var clipPlaneFragmentDeclaration2: {
  63798. name: string;
  63799. shader: string;
  63800. };
  63801. }
  63802. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  63803. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  63804. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63805. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63806. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63807. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63808. /** @hidden */
  63809. export var gpuRenderParticlesPixelShader: {
  63810. name: string;
  63811. shader: string;
  63812. };
  63813. }
  63814. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  63815. /** @hidden */
  63816. export var clipPlaneVertexDeclaration2: {
  63817. name: string;
  63818. shader: string;
  63819. };
  63820. }
  63821. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  63822. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  63823. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63824. /** @hidden */
  63825. export var gpuRenderParticlesVertexShader: {
  63826. name: string;
  63827. shader: string;
  63828. };
  63829. }
  63830. declare module "babylonjs/Particles/gpuParticleSystem" {
  63831. import { Nullable } from "babylonjs/types";
  63832. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  63833. import { Observable } from "babylonjs/Misc/observable";
  63834. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63835. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63836. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  63837. import { Scene, IDisposable } from "babylonjs/scene";
  63838. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  63839. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63840. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  63841. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  63842. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  63843. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  63844. /**
  63845. * This represents a GPU particle system in Babylon
  63846. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63847. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63848. */
  63849. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63850. /**
  63851. * The layer mask we are rendering the particles through.
  63852. */
  63853. layerMask: number;
  63854. private _capacity;
  63855. private _activeCount;
  63856. private _currentActiveCount;
  63857. private _accumulatedCount;
  63858. private _renderEffect;
  63859. private _updateEffect;
  63860. private _buffer0;
  63861. private _buffer1;
  63862. private _spriteBuffer;
  63863. private _updateVAO;
  63864. private _renderVAO;
  63865. private _targetIndex;
  63866. private _sourceBuffer;
  63867. private _targetBuffer;
  63868. private _engine;
  63869. private _currentRenderId;
  63870. private _started;
  63871. private _stopped;
  63872. private _timeDelta;
  63873. private _randomTexture;
  63874. private _randomTexture2;
  63875. private _attributesStrideSize;
  63876. private _updateEffectOptions;
  63877. private _randomTextureSize;
  63878. private _actualFrame;
  63879. private readonly _rawTextureWidth;
  63880. /**
  63881. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63882. */
  63883. static get IsSupported(): boolean;
  63884. /**
  63885. * An event triggered when the system is disposed.
  63886. */
  63887. onDisposeObservable: Observable<GPUParticleSystem>;
  63888. /**
  63889. * Gets the maximum number of particles active at the same time.
  63890. * @returns The max number of active particles.
  63891. */
  63892. getCapacity(): number;
  63893. /**
  63894. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63895. * to override the particles.
  63896. */
  63897. forceDepthWrite: boolean;
  63898. /**
  63899. * Gets or set the number of active particles
  63900. */
  63901. get activeParticleCount(): number;
  63902. set activeParticleCount(value: number);
  63903. private _preWarmDone;
  63904. /**
  63905. * Is this system ready to be used/rendered
  63906. * @return true if the system is ready
  63907. */
  63908. isReady(): boolean;
  63909. /**
  63910. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63911. * @returns True if it has been started, otherwise false.
  63912. */
  63913. isStarted(): boolean;
  63914. /**
  63915. * Starts the particle system and begins to emit
  63916. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63917. */
  63918. start(delay?: number): void;
  63919. /**
  63920. * Stops the particle system.
  63921. */
  63922. stop(): void;
  63923. /**
  63924. * Remove all active particles
  63925. */
  63926. reset(): void;
  63927. /**
  63928. * Returns the string "GPUParticleSystem"
  63929. * @returns a string containing the class name
  63930. */
  63931. getClassName(): string;
  63932. private _colorGradientsTexture;
  63933. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63934. /**
  63935. * Adds a new color gradient
  63936. * @param gradient defines the gradient to use (between 0 and 1)
  63937. * @param color1 defines the color to affect to the specified gradient
  63938. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63939. * @returns the current particle system
  63940. */
  63941. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63942. /**
  63943. * Remove a specific color gradient
  63944. * @param gradient defines the gradient to remove
  63945. * @returns the current particle system
  63946. */
  63947. removeColorGradient(gradient: number): GPUParticleSystem;
  63948. private _angularSpeedGradientsTexture;
  63949. private _sizeGradientsTexture;
  63950. private _velocityGradientsTexture;
  63951. private _limitVelocityGradientsTexture;
  63952. private _dragGradientsTexture;
  63953. private _addFactorGradient;
  63954. /**
  63955. * Adds a new size gradient
  63956. * @param gradient defines the gradient to use (between 0 and 1)
  63957. * @param factor defines the size factor to affect to the specified gradient
  63958. * @returns the current particle system
  63959. */
  63960. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63961. /**
  63962. * Remove a specific size gradient
  63963. * @param gradient defines the gradient to remove
  63964. * @returns the current particle system
  63965. */
  63966. removeSizeGradient(gradient: number): GPUParticleSystem;
  63967. /**
  63968. * Adds a new angular speed gradient
  63969. * @param gradient defines the gradient to use (between 0 and 1)
  63970. * @param factor defines the angular speed to affect to the specified gradient
  63971. * @returns the current particle system
  63972. */
  63973. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63974. /**
  63975. * Remove a specific angular speed gradient
  63976. * @param gradient defines the gradient to remove
  63977. * @returns the current particle system
  63978. */
  63979. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63980. /**
  63981. * Adds a new velocity gradient
  63982. * @param gradient defines the gradient to use (between 0 and 1)
  63983. * @param factor defines the velocity to affect to the specified gradient
  63984. * @returns the current particle system
  63985. */
  63986. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63987. /**
  63988. * Remove a specific velocity gradient
  63989. * @param gradient defines the gradient to remove
  63990. * @returns the current particle system
  63991. */
  63992. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63993. /**
  63994. * Adds a new limit velocity gradient
  63995. * @param gradient defines the gradient to use (between 0 and 1)
  63996. * @param factor defines the limit velocity value to affect to the specified gradient
  63997. * @returns the current particle system
  63998. */
  63999. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64000. /**
  64001. * Remove a specific limit velocity gradient
  64002. * @param gradient defines the gradient to remove
  64003. * @returns the current particle system
  64004. */
  64005. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  64006. /**
  64007. * Adds a new drag gradient
  64008. * @param gradient defines the gradient to use (between 0 and 1)
  64009. * @param factor defines the drag value to affect to the specified gradient
  64010. * @returns the current particle system
  64011. */
  64012. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  64013. /**
  64014. * Remove a specific drag gradient
  64015. * @param gradient defines the gradient to remove
  64016. * @returns the current particle system
  64017. */
  64018. removeDragGradient(gradient: number): GPUParticleSystem;
  64019. /**
  64020. * Not supported by GPUParticleSystem
  64021. * @param gradient defines the gradient to use (between 0 and 1)
  64022. * @param factor defines the emit rate value to affect to the specified gradient
  64023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64024. * @returns the current particle system
  64025. */
  64026. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64027. /**
  64028. * Not supported by GPUParticleSystem
  64029. * @param gradient defines the gradient to remove
  64030. * @returns the current particle system
  64031. */
  64032. removeEmitRateGradient(gradient: number): IParticleSystem;
  64033. /**
  64034. * Not supported by GPUParticleSystem
  64035. * @param gradient defines the gradient to use (between 0 and 1)
  64036. * @param factor defines the start size value to affect to the specified gradient
  64037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64038. * @returns the current particle system
  64039. */
  64040. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64041. /**
  64042. * Not supported by GPUParticleSystem
  64043. * @param gradient defines the gradient to remove
  64044. * @returns the current particle system
  64045. */
  64046. removeStartSizeGradient(gradient: number): IParticleSystem;
  64047. /**
  64048. * Not supported by GPUParticleSystem
  64049. * @param gradient defines the gradient to use (between 0 and 1)
  64050. * @param min defines the color remap minimal range
  64051. * @param max defines the color remap maximal range
  64052. * @returns the current particle system
  64053. */
  64054. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64055. /**
  64056. * Not supported by GPUParticleSystem
  64057. * @param gradient defines the gradient to remove
  64058. * @returns the current particle system
  64059. */
  64060. removeColorRemapGradient(): IParticleSystem;
  64061. /**
  64062. * Not supported by GPUParticleSystem
  64063. * @param gradient defines the gradient to use (between 0 and 1)
  64064. * @param min defines the alpha remap minimal range
  64065. * @param max defines the alpha remap maximal range
  64066. * @returns the current particle system
  64067. */
  64068. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64069. /**
  64070. * Not supported by GPUParticleSystem
  64071. * @param gradient defines the gradient to remove
  64072. * @returns the current particle system
  64073. */
  64074. removeAlphaRemapGradient(): IParticleSystem;
  64075. /**
  64076. * Not supported by GPUParticleSystem
  64077. * @param gradient defines the gradient to use (between 0 and 1)
  64078. * @param color defines the color to affect to the specified gradient
  64079. * @returns the current particle system
  64080. */
  64081. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  64082. /**
  64083. * Not supported by GPUParticleSystem
  64084. * @param gradient defines the gradient to remove
  64085. * @returns the current particle system
  64086. */
  64087. removeRampGradient(): IParticleSystem;
  64088. /**
  64089. * Not supported by GPUParticleSystem
  64090. * @returns the list of ramp gradients
  64091. */
  64092. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64093. /**
  64094. * Not supported by GPUParticleSystem
  64095. * Gets or sets a boolean indicating that ramp gradients must be used
  64096. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64097. */
  64098. get useRampGradients(): boolean;
  64099. set useRampGradients(value: boolean);
  64100. /**
  64101. * Not supported by GPUParticleSystem
  64102. * @param gradient defines the gradient to use (between 0 and 1)
  64103. * @param factor defines the life time factor to affect to the specified gradient
  64104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64105. * @returns the current particle system
  64106. */
  64107. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64108. /**
  64109. * Not supported by GPUParticleSystem
  64110. * @param gradient defines the gradient to remove
  64111. * @returns the current particle system
  64112. */
  64113. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64114. /**
  64115. * Instantiates a GPU particle system.
  64116. * 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.
  64117. * @param name The name of the particle system
  64118. * @param options The options used to create the system
  64119. * @param scene The scene the particle system belongs to
  64120. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64121. */
  64122. constructor(name: string, options: Partial<{
  64123. capacity: number;
  64124. randomTextureSize: number;
  64125. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64126. protected _reset(): void;
  64127. private _createUpdateVAO;
  64128. private _createRenderVAO;
  64129. private _initialize;
  64130. /** @hidden */
  64131. _recreateUpdateEffect(): void;
  64132. /** @hidden */
  64133. _recreateRenderEffect(): void;
  64134. /**
  64135. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64136. * @param preWarm defines if we are in the pre-warmimg phase
  64137. */
  64138. animate(preWarm?: boolean): void;
  64139. private _createFactorGradientTexture;
  64140. private _createSizeGradientTexture;
  64141. private _createAngularSpeedGradientTexture;
  64142. private _createVelocityGradientTexture;
  64143. private _createLimitVelocityGradientTexture;
  64144. private _createDragGradientTexture;
  64145. private _createColorGradientTexture;
  64146. /**
  64147. * Renders the particle system in its current state
  64148. * @param preWarm defines if the system should only update the particles but not render them
  64149. * @returns the current number of particles
  64150. */
  64151. render(preWarm?: boolean): number;
  64152. /**
  64153. * Rebuilds the particle system
  64154. */
  64155. rebuild(): void;
  64156. private _releaseBuffers;
  64157. private _releaseVAOs;
  64158. /**
  64159. * Disposes the particle system and free the associated resources
  64160. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64161. */
  64162. dispose(disposeTexture?: boolean): void;
  64163. /**
  64164. * Clones the particle system.
  64165. * @param name The name of the cloned object
  64166. * @param newEmitter The new emitter to use
  64167. * @returns the cloned particle system
  64168. */
  64169. clone(name: string, newEmitter: any): GPUParticleSystem;
  64170. /**
  64171. * Serializes the particle system to a JSON object.
  64172. * @returns the JSON object
  64173. */
  64174. serialize(): any;
  64175. /**
  64176. * Parses a JSON object to create a GPU particle system.
  64177. * @param parsedParticleSystem The JSON object to parse
  64178. * @param scene The scene to create the particle system in
  64179. * @param rootUrl The root url to use to load external dependencies like texture
  64180. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64181. * @returns the parsed GPU particle system
  64182. */
  64183. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64184. }
  64185. }
  64186. declare module "babylonjs/Particles/particleSystemSet" {
  64187. import { Nullable } from "babylonjs/types";
  64188. import { Color3 } from "babylonjs/Maths/math.color";
  64189. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64191. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64192. import { Scene, IDisposable } from "babylonjs/scene";
  64193. /**
  64194. * Represents a set of particle systems working together to create a specific effect
  64195. */
  64196. export class ParticleSystemSet implements IDisposable {
  64197. /**
  64198. * Gets or sets base Assets URL
  64199. */
  64200. static BaseAssetsUrl: string;
  64201. private _emitterCreationOptions;
  64202. private _emitterNode;
  64203. /**
  64204. * Gets the particle system list
  64205. */
  64206. systems: IParticleSystem[];
  64207. /**
  64208. * Gets the emitter node used with this set
  64209. */
  64210. get emitterNode(): Nullable<TransformNode>;
  64211. /**
  64212. * Creates a new emitter mesh as a sphere
  64213. * @param options defines the options used to create the sphere
  64214. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64215. * @param scene defines the hosting scene
  64216. */
  64217. setEmitterAsSphere(options: {
  64218. diameter: number;
  64219. segments: number;
  64220. color: Color3;
  64221. }, renderingGroupId: number, scene: Scene): void;
  64222. /**
  64223. * Starts all particle systems of the set
  64224. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64225. */
  64226. start(emitter?: AbstractMesh): void;
  64227. /**
  64228. * Release all associated resources
  64229. */
  64230. dispose(): void;
  64231. /**
  64232. * Serialize the set into a JSON compatible object
  64233. * @returns a JSON compatible representation of the set
  64234. */
  64235. serialize(): any;
  64236. /**
  64237. * Parse a new ParticleSystemSet from a serialized source
  64238. * @param data defines a JSON compatible representation of the set
  64239. * @param scene defines the hosting scene
  64240. * @param gpu defines if we want GPU particles or CPU particles
  64241. * @returns a new ParticleSystemSet
  64242. */
  64243. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64244. }
  64245. }
  64246. declare module "babylonjs/Particles/particleHelper" {
  64247. import { Nullable } from "babylonjs/types";
  64248. import { Scene } from "babylonjs/scene";
  64249. import { Vector3 } from "babylonjs/Maths/math.vector";
  64250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64251. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64252. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  64253. /**
  64254. * This class is made for on one-liner static method to help creating particle system set.
  64255. */
  64256. export class ParticleHelper {
  64257. /**
  64258. * Gets or sets base Assets URL
  64259. */
  64260. static BaseAssetsUrl: string;
  64261. /**
  64262. * Create a default particle system that you can tweak
  64263. * @param emitter defines the emitter to use
  64264. * @param capacity defines the system capacity (default is 500 particles)
  64265. * @param scene defines the hosting scene
  64266. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64267. * @returns the new Particle system
  64268. */
  64269. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  64270. /**
  64271. * This is the main static method (one-liner) of this helper to create different particle systems
  64272. * @param type This string represents the type to the particle system to create
  64273. * @param scene The scene where the particle system should live
  64274. * @param gpu If the system will use gpu
  64275. * @returns the ParticleSystemSet created
  64276. */
  64277. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  64278. /**
  64279. * Static function used to export a particle system to a ParticleSystemSet variable.
  64280. * Please note that the emitter shape is not exported
  64281. * @param systems defines the particle systems to export
  64282. * @returns the created particle system set
  64283. */
  64284. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  64285. }
  64286. }
  64287. declare module "babylonjs/Particles/particleSystemComponent" {
  64288. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64289. import { Effect } from "babylonjs/Materials/effect";
  64290. import "babylonjs/Shaders/particles.vertex";
  64291. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64292. module "babylonjs/Engines/engine" {
  64293. interface Engine {
  64294. /**
  64295. * Create an effect to use with particle systems.
  64296. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  64297. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  64298. * @param uniformsNames defines a list of attribute names
  64299. * @param samplers defines an array of string used to represent textures
  64300. * @param defines defines the string containing the defines to use to compile the shaders
  64301. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  64302. * @param onCompiled defines a function to call when the effect creation is successful
  64303. * @param onError defines a function to call when the effect creation has failed
  64304. * @returns the new Effect
  64305. */
  64306. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  64307. }
  64308. }
  64309. module "babylonjs/Meshes/mesh" {
  64310. interface Mesh {
  64311. /**
  64312. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  64313. * @returns an array of IParticleSystem
  64314. */
  64315. getEmittedParticleSystems(): IParticleSystem[];
  64316. /**
  64317. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  64318. * @returns an array of IParticleSystem
  64319. */
  64320. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  64321. }
  64322. }
  64323. /**
  64324. * @hidden
  64325. */
  64326. export var _IDoNeedToBeInTheBuild: number;
  64327. }
  64328. declare module "babylonjs/Particles/pointsCloudSystem" {
  64329. import { Color4 } from "babylonjs/Maths/math";
  64330. import { Mesh } from "babylonjs/Meshes/mesh";
  64331. import { Scene, IDisposable } from "babylonjs/scene";
  64332. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  64333. /** Defines the 4 color options */
  64334. export enum PointColor {
  64335. /** color value */
  64336. Color = 2,
  64337. /** uv value */
  64338. UV = 1,
  64339. /** random value */
  64340. Random = 0,
  64341. /** stated value */
  64342. Stated = 3
  64343. }
  64344. /**
  64345. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  64346. * 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.
  64347. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  64348. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  64349. *
  64350. * Full documentation here : TO BE ENTERED
  64351. */
  64352. export class PointsCloudSystem implements IDisposable {
  64353. /**
  64354. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  64355. * Example : var p = SPS.particles[i];
  64356. */
  64357. particles: CloudPoint[];
  64358. /**
  64359. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  64360. */
  64361. nbParticles: number;
  64362. /**
  64363. * This a counter for your own usage. It's not set by any SPS functions.
  64364. */
  64365. counter: number;
  64366. /**
  64367. * The PCS name. This name is also given to the underlying mesh.
  64368. */
  64369. name: string;
  64370. /**
  64371. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  64372. */
  64373. mesh: Mesh;
  64374. /**
  64375. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  64376. * Please read :
  64377. */
  64378. vars: any;
  64379. /**
  64380. * @hidden
  64381. */
  64382. _size: number;
  64383. private _scene;
  64384. private _promises;
  64385. private _positions;
  64386. private _indices;
  64387. private _normals;
  64388. private _colors;
  64389. private _uvs;
  64390. private _indices32;
  64391. private _positions32;
  64392. private _colors32;
  64393. private _uvs32;
  64394. private _updatable;
  64395. private _isVisibilityBoxLocked;
  64396. private _alwaysVisible;
  64397. private _groups;
  64398. private _groupCounter;
  64399. private _computeParticleColor;
  64400. private _computeParticleTexture;
  64401. private _computeParticleRotation;
  64402. private _computeBoundingBox;
  64403. private _isReady;
  64404. /**
  64405. * Creates a PCS (Points Cloud System) object
  64406. * @param name (String) is the PCS name, this will be the underlying mesh name
  64407. * @param pointSize (number) is the size for each point
  64408. * @param scene (Scene) is the scene in which the PCS is added
  64409. * @param options defines the options of the PCS e.g.
  64410. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  64411. */
  64412. constructor(name: string, pointSize: number, scene: Scene, options?: {
  64413. updatable?: boolean;
  64414. });
  64415. /**
  64416. * Builds the PCS underlying mesh. Returns a standard Mesh.
  64417. * If no points were added to the PCS, the returned mesh is just a single point.
  64418. * @returns a promise for the created mesh
  64419. */
  64420. buildMeshAsync(): Promise<Mesh>;
  64421. /**
  64422. * @hidden
  64423. */
  64424. private _buildMesh;
  64425. private _addParticle;
  64426. private _randomUnitVector;
  64427. private _getColorIndicesForCoord;
  64428. private _setPointsColorOrUV;
  64429. private _colorFromTexture;
  64430. private _calculateDensity;
  64431. /**
  64432. * Adds points to the PCS in random positions within a unit sphere
  64433. * @param nb (positive integer) the number of particles to be created from this model
  64434. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  64435. * @returns the number of groups in the system
  64436. */
  64437. addPoints(nb: number, pointFunction?: any): number;
  64438. /**
  64439. * Adds points to the PCS from the surface of the model shape
  64440. * @param mesh is any Mesh object that will be used as a surface model for the points
  64441. * @param nb (positive integer) the number of particles to be created from this model
  64442. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64443. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64444. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64445. * @returns the number of groups in the system
  64446. */
  64447. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64448. /**
  64449. * Adds points to the PCS inside the model shape
  64450. * @param mesh is any Mesh object that will be used as a surface model for the points
  64451. * @param nb (positive integer) the number of particles to be created from this model
  64452. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64453. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64454. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64455. * @returns the number of groups in the system
  64456. */
  64457. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64458. /**
  64459. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  64460. * This method calls `updateParticle()` for each particle of the SPS.
  64461. * For an animated SPS, it is usually called within the render loop.
  64462. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  64463. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  64464. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  64465. * @returns the PCS.
  64466. */
  64467. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  64468. /**
  64469. * Disposes the PCS.
  64470. */
  64471. dispose(): void;
  64472. /**
  64473. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  64474. * doc :
  64475. * @returns the PCS.
  64476. */
  64477. refreshVisibleSize(): PointsCloudSystem;
  64478. /**
  64479. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  64480. * @param size the size (float) of the visibility box
  64481. * note : this doesn't lock the PCS mesh bounding box.
  64482. * doc :
  64483. */
  64484. setVisibilityBox(size: number): void;
  64485. /**
  64486. * Gets whether the PCS is always visible or not
  64487. * doc :
  64488. */
  64489. get isAlwaysVisible(): boolean;
  64490. /**
  64491. * Sets the PCS as always visible or not
  64492. * doc :
  64493. */
  64494. set isAlwaysVisible(val: boolean);
  64495. /**
  64496. * Tells to `setParticles()` to compute the particle rotations or not
  64497. * Default value : false. The PCS is faster when it's set to false
  64498. * Note : particle rotations are only applied to parent particles
  64499. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64500. */
  64501. set computeParticleRotation(val: boolean);
  64502. /**
  64503. * Tells to `setParticles()` to compute the particle colors or not.
  64504. * Default value : true. The PCS is faster when it's set to false.
  64505. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64506. */
  64507. set computeParticleColor(val: boolean);
  64508. set computeParticleTexture(val: boolean);
  64509. /**
  64510. * Gets if `setParticles()` computes the particle colors or not.
  64511. * Default value : false. The PCS is faster when it's set to false.
  64512. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64513. */
  64514. get computeParticleColor(): boolean;
  64515. /**
  64516. * Gets if `setParticles()` computes the particle textures or not.
  64517. * Default value : false. The PCS is faster when it's set to false.
  64518. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64519. */
  64520. get computeParticleTexture(): boolean;
  64521. /**
  64522. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64523. */
  64524. set computeBoundingBox(val: boolean);
  64525. /**
  64526. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64527. */
  64528. get computeBoundingBox(): boolean;
  64529. /**
  64530. * This function does nothing. It may be overwritten to set all the particle first values.
  64531. * The PCS doesn't call this function, you may have to call it by your own.
  64532. * doc :
  64533. */
  64534. initParticles(): void;
  64535. /**
  64536. * This function does nothing. It may be overwritten to recycle a particle
  64537. * The PCS doesn't call this function, you can to call it
  64538. * doc :
  64539. * @param particle The particle to recycle
  64540. * @returns the recycled particle
  64541. */
  64542. recycleParticle(particle: CloudPoint): CloudPoint;
  64543. /**
  64544. * Updates a particle : this function should be overwritten by the user.
  64545. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64546. * doc :
  64547. * @example : just set a particle position or velocity and recycle conditions
  64548. * @param particle The particle to update
  64549. * @returns the updated particle
  64550. */
  64551. updateParticle(particle: CloudPoint): CloudPoint;
  64552. /**
  64553. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64554. * This does nothing and may be overwritten by the user.
  64555. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64556. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64557. * @param update the boolean update value actually passed to setParticles()
  64558. */
  64559. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64560. /**
  64561. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64562. * This will be passed three parameters.
  64563. * This does nothing and may be overwritten by the user.
  64564. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64565. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64566. * @param update the boolean update value actually passed to setParticles()
  64567. */
  64568. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64569. }
  64570. }
  64571. declare module "babylonjs/Particles/cloudPoint" {
  64572. import { Nullable } from "babylonjs/types";
  64573. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  64574. import { Mesh } from "babylonjs/Meshes/mesh";
  64575. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64576. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  64577. /**
  64578. * Represents one particle of a points cloud system.
  64579. */
  64580. export class CloudPoint {
  64581. /**
  64582. * particle global index
  64583. */
  64584. idx: number;
  64585. /**
  64586. * The color of the particle
  64587. */
  64588. color: Nullable<Color4>;
  64589. /**
  64590. * The world space position of the particle.
  64591. */
  64592. position: Vector3;
  64593. /**
  64594. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64595. */
  64596. rotation: Vector3;
  64597. /**
  64598. * The world space rotation quaternion of the particle.
  64599. */
  64600. rotationQuaternion: Nullable<Quaternion>;
  64601. /**
  64602. * The uv of the particle.
  64603. */
  64604. uv: Nullable<Vector2>;
  64605. /**
  64606. * The current speed of the particle.
  64607. */
  64608. velocity: Vector3;
  64609. /**
  64610. * The pivot point in the particle local space.
  64611. */
  64612. pivot: Vector3;
  64613. /**
  64614. * Must the particle be translated from its pivot point in its local space ?
  64615. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64616. * Default : false
  64617. */
  64618. translateFromPivot: boolean;
  64619. /**
  64620. * Index of this particle in the global "positions" array (Internal use)
  64621. * @hidden
  64622. */
  64623. _pos: number;
  64624. /**
  64625. * @hidden Index of this particle in the global "indices" array (Internal use)
  64626. */
  64627. _ind: number;
  64628. /**
  64629. * Group this particle belongs to
  64630. */
  64631. _group: PointsGroup;
  64632. /**
  64633. * Group id of this particle
  64634. */
  64635. groupId: number;
  64636. /**
  64637. * Index of the particle in its group id (Internal use)
  64638. */
  64639. idxInGroup: number;
  64640. /**
  64641. * @hidden Particle BoundingInfo object (Internal use)
  64642. */
  64643. _boundingInfo: BoundingInfo;
  64644. /**
  64645. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64646. */
  64647. _pcs: PointsCloudSystem;
  64648. /**
  64649. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64650. */
  64651. _stillInvisible: boolean;
  64652. /**
  64653. * @hidden Last computed particle rotation matrix
  64654. */
  64655. _rotationMatrix: number[];
  64656. /**
  64657. * Parent particle Id, if any.
  64658. * Default null.
  64659. */
  64660. parentId: Nullable<number>;
  64661. /**
  64662. * @hidden Internal global position in the PCS.
  64663. */
  64664. _globalPosition: Vector3;
  64665. /**
  64666. * Creates a Point Cloud object.
  64667. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64668. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64669. * @param group (PointsGroup) is the group the particle belongs to
  64670. * @param groupId (integer) is the group identifier in the PCS.
  64671. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64672. * @param pcs defines the PCS it is associated to
  64673. */
  64674. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64675. /**
  64676. * get point size
  64677. */
  64678. get size(): Vector3;
  64679. /**
  64680. * Set point size
  64681. */
  64682. set size(scale: Vector3);
  64683. /**
  64684. * Legacy support, changed quaternion to rotationQuaternion
  64685. */
  64686. get quaternion(): Nullable<Quaternion>;
  64687. /**
  64688. * Legacy support, changed quaternion to rotationQuaternion
  64689. */
  64690. set quaternion(q: Nullable<Quaternion>);
  64691. /**
  64692. * Returns a boolean. True if the particle intersects a mesh, else false
  64693. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64694. * @param target is the object (point or mesh) what the intersection is computed against
  64695. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64696. * @returns true if it intersects
  64697. */
  64698. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64699. /**
  64700. * get the rotation matrix of the particle
  64701. * @hidden
  64702. */
  64703. getRotationMatrix(m: Matrix): void;
  64704. }
  64705. /**
  64706. * Represents a group of points in a points cloud system
  64707. * * PCS internal tool, don't use it manually.
  64708. */
  64709. export class PointsGroup {
  64710. /**
  64711. * The group id
  64712. * @hidden
  64713. */
  64714. groupID: number;
  64715. /**
  64716. * image data for group (internal use)
  64717. * @hidden
  64718. */
  64719. _groupImageData: Nullable<ArrayBufferView>;
  64720. /**
  64721. * Image Width (internal use)
  64722. * @hidden
  64723. */
  64724. _groupImgWidth: number;
  64725. /**
  64726. * Image Height (internal use)
  64727. * @hidden
  64728. */
  64729. _groupImgHeight: number;
  64730. /**
  64731. * Custom position function (internal use)
  64732. * @hidden
  64733. */
  64734. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64735. /**
  64736. * density per facet for surface points
  64737. * @hidden
  64738. */
  64739. _groupDensity: number[];
  64740. /**
  64741. * Only when points are colored by texture carries pointer to texture list array
  64742. * @hidden
  64743. */
  64744. _textureNb: number;
  64745. /**
  64746. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64747. * PCS internal tool, don't use it manually.
  64748. * @hidden
  64749. */
  64750. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64751. }
  64752. }
  64753. declare module "babylonjs/Particles/index" {
  64754. export * from "babylonjs/Particles/baseParticleSystem";
  64755. export * from "babylonjs/Particles/EmitterTypes/index";
  64756. export * from "babylonjs/Particles/gpuParticleSystem";
  64757. export * from "babylonjs/Particles/IParticleSystem";
  64758. export * from "babylonjs/Particles/particle";
  64759. export * from "babylonjs/Particles/particleHelper";
  64760. export * from "babylonjs/Particles/particleSystem";
  64761. export * from "babylonjs/Particles/particleSystemComponent";
  64762. export * from "babylonjs/Particles/particleSystemSet";
  64763. export * from "babylonjs/Particles/solidParticle";
  64764. export * from "babylonjs/Particles/solidParticleSystem";
  64765. export * from "babylonjs/Particles/cloudPoint";
  64766. export * from "babylonjs/Particles/pointsCloudSystem";
  64767. export * from "babylonjs/Particles/subEmitter";
  64768. }
  64769. declare module "babylonjs/Physics/physicsEngineComponent" {
  64770. import { Nullable } from "babylonjs/types";
  64771. import { Observable, Observer } from "babylonjs/Misc/observable";
  64772. import { Vector3 } from "babylonjs/Maths/math.vector";
  64773. import { Mesh } from "babylonjs/Meshes/mesh";
  64774. import { ISceneComponent } from "babylonjs/sceneComponent";
  64775. import { Scene } from "babylonjs/scene";
  64776. import { Node } from "babylonjs/node";
  64777. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64778. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64779. module "babylonjs/scene" {
  64780. interface Scene {
  64781. /** @hidden (Backing field) */
  64782. _physicsEngine: Nullable<IPhysicsEngine>;
  64783. /** @hidden */
  64784. _physicsTimeAccumulator: number;
  64785. /**
  64786. * Gets the current physics engine
  64787. * @returns a IPhysicsEngine or null if none attached
  64788. */
  64789. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64790. /**
  64791. * Enables physics to the current scene
  64792. * @param gravity defines the scene's gravity for the physics engine
  64793. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64794. * @return a boolean indicating if the physics engine was initialized
  64795. */
  64796. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64797. /**
  64798. * Disables and disposes the physics engine associated with the scene
  64799. */
  64800. disablePhysicsEngine(): void;
  64801. /**
  64802. * Gets a boolean indicating if there is an active physics engine
  64803. * @returns a boolean indicating if there is an active physics engine
  64804. */
  64805. isPhysicsEnabled(): boolean;
  64806. /**
  64807. * Deletes a physics compound impostor
  64808. * @param compound defines the compound to delete
  64809. */
  64810. deleteCompoundImpostor(compound: any): void;
  64811. /**
  64812. * An event triggered when physic simulation is about to be run
  64813. */
  64814. onBeforePhysicsObservable: Observable<Scene>;
  64815. /**
  64816. * An event triggered when physic simulation has been done
  64817. */
  64818. onAfterPhysicsObservable: Observable<Scene>;
  64819. }
  64820. }
  64821. module "babylonjs/Meshes/abstractMesh" {
  64822. interface AbstractMesh {
  64823. /** @hidden */
  64824. _physicsImpostor: Nullable<PhysicsImpostor>;
  64825. /**
  64826. * Gets or sets impostor used for physic simulation
  64827. * @see http://doc.babylonjs.com/features/physics_engine
  64828. */
  64829. physicsImpostor: Nullable<PhysicsImpostor>;
  64830. /**
  64831. * Gets the current physics impostor
  64832. * @see http://doc.babylonjs.com/features/physics_engine
  64833. * @returns a physics impostor or null
  64834. */
  64835. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64836. /** Apply a physic impulse to the mesh
  64837. * @param force defines the force to apply
  64838. * @param contactPoint defines where to apply the force
  64839. * @returns the current mesh
  64840. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64841. */
  64842. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64843. /**
  64844. * Creates a physic joint between two meshes
  64845. * @param otherMesh defines the other mesh to use
  64846. * @param pivot1 defines the pivot to use on this mesh
  64847. * @param pivot2 defines the pivot to use on the other mesh
  64848. * @param options defines additional options (can be plugin dependent)
  64849. * @returns the current mesh
  64850. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64851. */
  64852. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64853. /** @hidden */
  64854. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64855. }
  64856. }
  64857. /**
  64858. * Defines the physics engine scene component responsible to manage a physics engine
  64859. */
  64860. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64861. /**
  64862. * The component name helpful to identify the component in the list of scene components.
  64863. */
  64864. readonly name: string;
  64865. /**
  64866. * The scene the component belongs to.
  64867. */
  64868. scene: Scene;
  64869. /**
  64870. * Creates a new instance of the component for the given scene
  64871. * @param scene Defines the scene to register the component in
  64872. */
  64873. constructor(scene: Scene);
  64874. /**
  64875. * Registers the component in a given scene
  64876. */
  64877. register(): void;
  64878. /**
  64879. * Rebuilds the elements related to this component in case of
  64880. * context lost for instance.
  64881. */
  64882. rebuild(): void;
  64883. /**
  64884. * Disposes the component and the associated ressources
  64885. */
  64886. dispose(): void;
  64887. }
  64888. }
  64889. declare module "babylonjs/Physics/physicsHelper" {
  64890. import { Nullable } from "babylonjs/types";
  64891. import { Vector3 } from "babylonjs/Maths/math.vector";
  64892. import { Mesh } from "babylonjs/Meshes/mesh";
  64893. import { Scene } from "babylonjs/scene";
  64894. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64895. /**
  64896. * A helper for physics simulations
  64897. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64898. */
  64899. export class PhysicsHelper {
  64900. private _scene;
  64901. private _physicsEngine;
  64902. /**
  64903. * Initializes the Physics helper
  64904. * @param scene Babylon.js scene
  64905. */
  64906. constructor(scene: Scene);
  64907. /**
  64908. * Applies a radial explosion impulse
  64909. * @param origin the origin of the explosion
  64910. * @param radiusOrEventOptions the radius or the options of radial explosion
  64911. * @param strength the explosion strength
  64912. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64913. * @returns A physics radial explosion event, or null
  64914. */
  64915. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64916. /**
  64917. * Applies a radial explosion force
  64918. * @param origin the origin of the explosion
  64919. * @param radiusOrEventOptions the radius or the options of radial explosion
  64920. * @param strength the explosion strength
  64921. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64922. * @returns A physics radial explosion event, or null
  64923. */
  64924. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64925. /**
  64926. * Creates a gravitational field
  64927. * @param origin the origin of the explosion
  64928. * @param radiusOrEventOptions the radius or the options of radial explosion
  64929. * @param strength the explosion strength
  64930. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64931. * @returns A physics gravitational field event, or null
  64932. */
  64933. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64934. /**
  64935. * Creates a physics updraft event
  64936. * @param origin the origin of the updraft
  64937. * @param radiusOrEventOptions the radius or the options of the updraft
  64938. * @param strength the strength of the updraft
  64939. * @param height the height of the updraft
  64940. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64941. * @returns A physics updraft event, or null
  64942. */
  64943. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64944. /**
  64945. * Creates a physics vortex event
  64946. * @param origin the of the vortex
  64947. * @param radiusOrEventOptions the radius or the options of the vortex
  64948. * @param strength the strength of the vortex
  64949. * @param height the height of the vortex
  64950. * @returns a Physics vortex event, or null
  64951. * A physics vortex event or null
  64952. */
  64953. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64954. }
  64955. /**
  64956. * Represents a physics radial explosion event
  64957. */
  64958. class PhysicsRadialExplosionEvent {
  64959. private _scene;
  64960. private _options;
  64961. private _sphere;
  64962. private _dataFetched;
  64963. /**
  64964. * Initializes a radial explosioin event
  64965. * @param _scene BabylonJS scene
  64966. * @param _options The options for the vortex event
  64967. */
  64968. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64969. /**
  64970. * Returns the data related to the radial explosion event (sphere).
  64971. * @returns The radial explosion event data
  64972. */
  64973. getData(): PhysicsRadialExplosionEventData;
  64974. /**
  64975. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64976. * @param impostor A physics imposter
  64977. * @param origin the origin of the explosion
  64978. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64979. */
  64980. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64981. /**
  64982. * Triggers affecterd impostors callbacks
  64983. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64984. */
  64985. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64986. /**
  64987. * Disposes the sphere.
  64988. * @param force Specifies if the sphere should be disposed by force
  64989. */
  64990. dispose(force?: boolean): void;
  64991. /*** Helpers ***/
  64992. private _prepareSphere;
  64993. private _intersectsWithSphere;
  64994. }
  64995. /**
  64996. * Represents a gravitational field event
  64997. */
  64998. class PhysicsGravitationalFieldEvent {
  64999. private _physicsHelper;
  65000. private _scene;
  65001. private _origin;
  65002. private _options;
  65003. private _tickCallback;
  65004. private _sphere;
  65005. private _dataFetched;
  65006. /**
  65007. * Initializes the physics gravitational field event
  65008. * @param _physicsHelper A physics helper
  65009. * @param _scene BabylonJS scene
  65010. * @param _origin The origin position of the gravitational field event
  65011. * @param _options The options for the vortex event
  65012. */
  65013. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  65014. /**
  65015. * Returns the data related to the gravitational field event (sphere).
  65016. * @returns A gravitational field event
  65017. */
  65018. getData(): PhysicsGravitationalFieldEventData;
  65019. /**
  65020. * Enables the gravitational field.
  65021. */
  65022. enable(): void;
  65023. /**
  65024. * Disables the gravitational field.
  65025. */
  65026. disable(): void;
  65027. /**
  65028. * Disposes the sphere.
  65029. * @param force The force to dispose from the gravitational field event
  65030. */
  65031. dispose(force?: boolean): void;
  65032. private _tick;
  65033. }
  65034. /**
  65035. * Represents a physics updraft event
  65036. */
  65037. class PhysicsUpdraftEvent {
  65038. private _scene;
  65039. private _origin;
  65040. private _options;
  65041. private _physicsEngine;
  65042. private _originTop;
  65043. private _originDirection;
  65044. private _tickCallback;
  65045. private _cylinder;
  65046. private _cylinderPosition;
  65047. private _dataFetched;
  65048. /**
  65049. * Initializes the physics updraft event
  65050. * @param _scene BabylonJS scene
  65051. * @param _origin The origin position of the updraft
  65052. * @param _options The options for the updraft event
  65053. */
  65054. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  65055. /**
  65056. * Returns the data related to the updraft event (cylinder).
  65057. * @returns A physics updraft event
  65058. */
  65059. getData(): PhysicsUpdraftEventData;
  65060. /**
  65061. * Enables the updraft.
  65062. */
  65063. enable(): void;
  65064. /**
  65065. * Disables the updraft.
  65066. */
  65067. disable(): void;
  65068. /**
  65069. * Disposes the cylinder.
  65070. * @param force Specifies if the updraft should be disposed by force
  65071. */
  65072. dispose(force?: boolean): void;
  65073. private getImpostorHitData;
  65074. private _tick;
  65075. /*** Helpers ***/
  65076. private _prepareCylinder;
  65077. private _intersectsWithCylinder;
  65078. }
  65079. /**
  65080. * Represents a physics vortex event
  65081. */
  65082. class PhysicsVortexEvent {
  65083. private _scene;
  65084. private _origin;
  65085. private _options;
  65086. private _physicsEngine;
  65087. private _originTop;
  65088. private _tickCallback;
  65089. private _cylinder;
  65090. private _cylinderPosition;
  65091. private _dataFetched;
  65092. /**
  65093. * Initializes the physics vortex event
  65094. * @param _scene The BabylonJS scene
  65095. * @param _origin The origin position of the vortex
  65096. * @param _options The options for the vortex event
  65097. */
  65098. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65099. /**
  65100. * Returns the data related to the vortex event (cylinder).
  65101. * @returns The physics vortex event data
  65102. */
  65103. getData(): PhysicsVortexEventData;
  65104. /**
  65105. * Enables the vortex.
  65106. */
  65107. enable(): void;
  65108. /**
  65109. * Disables the cortex.
  65110. */
  65111. disable(): void;
  65112. /**
  65113. * Disposes the sphere.
  65114. * @param force
  65115. */
  65116. dispose(force?: boolean): void;
  65117. private getImpostorHitData;
  65118. private _tick;
  65119. /*** Helpers ***/
  65120. private _prepareCylinder;
  65121. private _intersectsWithCylinder;
  65122. }
  65123. /**
  65124. * Options fot the radial explosion event
  65125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65126. */
  65127. export class PhysicsRadialExplosionEventOptions {
  65128. /**
  65129. * The radius of the sphere for the radial explosion.
  65130. */
  65131. radius: number;
  65132. /**
  65133. * The strenth of the explosion.
  65134. */
  65135. strength: number;
  65136. /**
  65137. * The strenght of the force in correspondence to the distance of the affected object
  65138. */
  65139. falloff: PhysicsRadialImpulseFalloff;
  65140. /**
  65141. * Sphere options for the radial explosion.
  65142. */
  65143. sphere: {
  65144. segments: number;
  65145. diameter: number;
  65146. };
  65147. /**
  65148. * Sphere options for the radial explosion.
  65149. */
  65150. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65151. }
  65152. /**
  65153. * Options fot the updraft event
  65154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65155. */
  65156. export class PhysicsUpdraftEventOptions {
  65157. /**
  65158. * The radius of the cylinder for the vortex
  65159. */
  65160. radius: number;
  65161. /**
  65162. * The strenth of the updraft.
  65163. */
  65164. strength: number;
  65165. /**
  65166. * The height of the cylinder for the updraft.
  65167. */
  65168. height: number;
  65169. /**
  65170. * The mode for the the updraft.
  65171. */
  65172. updraftMode: PhysicsUpdraftMode;
  65173. }
  65174. /**
  65175. * Options fot the vortex event
  65176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65177. */
  65178. export class PhysicsVortexEventOptions {
  65179. /**
  65180. * The radius of the cylinder for the vortex
  65181. */
  65182. radius: number;
  65183. /**
  65184. * The strenth of the vortex.
  65185. */
  65186. strength: number;
  65187. /**
  65188. * The height of the cylinder for the vortex.
  65189. */
  65190. height: number;
  65191. /**
  65192. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65193. */
  65194. centripetalForceThreshold: number;
  65195. /**
  65196. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65197. */
  65198. centripetalForceMultiplier: number;
  65199. /**
  65200. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65201. */
  65202. centrifugalForceMultiplier: number;
  65203. /**
  65204. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65205. */
  65206. updraftForceMultiplier: number;
  65207. }
  65208. /**
  65209. * The strenght of the force in correspondence to the distance of the affected object
  65210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65211. */
  65212. export enum PhysicsRadialImpulseFalloff {
  65213. /** Defines that impulse is constant in strength across it's whole radius */
  65214. Constant = 0,
  65215. /** Defines that impulse gets weaker if it's further from the origin */
  65216. Linear = 1
  65217. }
  65218. /**
  65219. * The strength of the force in correspondence to the distance of the affected object
  65220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65221. */
  65222. export enum PhysicsUpdraftMode {
  65223. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65224. Center = 0,
  65225. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65226. Perpendicular = 1
  65227. }
  65228. /**
  65229. * Interface for a physics hit data
  65230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65231. */
  65232. export interface PhysicsHitData {
  65233. /**
  65234. * The force applied at the contact point
  65235. */
  65236. force: Vector3;
  65237. /**
  65238. * The contact point
  65239. */
  65240. contactPoint: Vector3;
  65241. /**
  65242. * The distance from the origin to the contact point
  65243. */
  65244. distanceFromOrigin: number;
  65245. }
  65246. /**
  65247. * Interface for radial explosion event data
  65248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65249. */
  65250. export interface PhysicsRadialExplosionEventData {
  65251. /**
  65252. * A sphere used for the radial explosion event
  65253. */
  65254. sphere: Mesh;
  65255. }
  65256. /**
  65257. * Interface for gravitational field event data
  65258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65259. */
  65260. export interface PhysicsGravitationalFieldEventData {
  65261. /**
  65262. * A sphere mesh used for the gravitational field event
  65263. */
  65264. sphere: Mesh;
  65265. }
  65266. /**
  65267. * Interface for updraft event data
  65268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65269. */
  65270. export interface PhysicsUpdraftEventData {
  65271. /**
  65272. * A cylinder used for the updraft event
  65273. */
  65274. cylinder: Mesh;
  65275. }
  65276. /**
  65277. * Interface for vortex event data
  65278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65279. */
  65280. export interface PhysicsVortexEventData {
  65281. /**
  65282. * A cylinder used for the vortex event
  65283. */
  65284. cylinder: Mesh;
  65285. }
  65286. /**
  65287. * Interface for an affected physics impostor
  65288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65289. */
  65290. export interface PhysicsAffectedImpostorWithData {
  65291. /**
  65292. * The impostor affected by the effect
  65293. */
  65294. impostor: PhysicsImpostor;
  65295. /**
  65296. * The data about the hit/horce from the explosion
  65297. */
  65298. hitData: PhysicsHitData;
  65299. }
  65300. }
  65301. declare module "babylonjs/Physics/Plugins/index" {
  65302. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  65303. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  65304. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  65305. }
  65306. declare module "babylonjs/Physics/index" {
  65307. export * from "babylonjs/Physics/IPhysicsEngine";
  65308. export * from "babylonjs/Physics/physicsEngine";
  65309. export * from "babylonjs/Physics/physicsEngineComponent";
  65310. export * from "babylonjs/Physics/physicsHelper";
  65311. export * from "babylonjs/Physics/physicsImpostor";
  65312. export * from "babylonjs/Physics/physicsJoint";
  65313. export * from "babylonjs/Physics/Plugins/index";
  65314. }
  65315. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  65316. /** @hidden */
  65317. export var blackAndWhitePixelShader: {
  65318. name: string;
  65319. shader: string;
  65320. };
  65321. }
  65322. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  65323. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65324. import { Camera } from "babylonjs/Cameras/camera";
  65325. import { Engine } from "babylonjs/Engines/engine";
  65326. import "babylonjs/Shaders/blackAndWhite.fragment";
  65327. /**
  65328. * Post process used to render in black and white
  65329. */
  65330. export class BlackAndWhitePostProcess extends PostProcess {
  65331. /**
  65332. * Linear about to convert he result to black and white (default: 1)
  65333. */
  65334. degree: number;
  65335. /**
  65336. * Creates a black and white post process
  65337. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  65338. * @param name The name of the effect.
  65339. * @param options The required width/height ratio to downsize to before computing the render pass.
  65340. * @param camera The camera to apply the render pass to.
  65341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65342. * @param engine The engine which the post process will be applied. (default: current engine)
  65343. * @param reusable If the post process can be reused on the same frame. (default: false)
  65344. */
  65345. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65346. }
  65347. }
  65348. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  65349. import { Nullable } from "babylonjs/types";
  65350. import { Camera } from "babylonjs/Cameras/camera";
  65351. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65352. import { Engine } from "babylonjs/Engines/engine";
  65353. /**
  65354. * This represents a set of one or more post processes in Babylon.
  65355. * A post process can be used to apply a shader to a texture after it is rendered.
  65356. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65357. */
  65358. export class PostProcessRenderEffect {
  65359. private _postProcesses;
  65360. private _getPostProcesses;
  65361. private _singleInstance;
  65362. private _cameras;
  65363. private _indicesForCamera;
  65364. /**
  65365. * Name of the effect
  65366. * @hidden
  65367. */
  65368. _name: string;
  65369. /**
  65370. * Instantiates a post process render effect.
  65371. * A post process can be used to apply a shader to a texture after it is rendered.
  65372. * @param engine The engine the effect is tied to
  65373. * @param name The name of the effect
  65374. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  65375. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  65376. */
  65377. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  65378. /**
  65379. * Checks if all the post processes in the effect are supported.
  65380. */
  65381. get isSupported(): boolean;
  65382. /**
  65383. * Updates the current state of the effect
  65384. * @hidden
  65385. */
  65386. _update(): void;
  65387. /**
  65388. * Attaches the effect on cameras
  65389. * @param cameras The camera to attach to.
  65390. * @hidden
  65391. */
  65392. _attachCameras(cameras: Camera): void;
  65393. /**
  65394. * Attaches the effect on cameras
  65395. * @param cameras The camera to attach to.
  65396. * @hidden
  65397. */
  65398. _attachCameras(cameras: Camera[]): void;
  65399. /**
  65400. * Detaches the effect on cameras
  65401. * @param cameras The camera to detatch from.
  65402. * @hidden
  65403. */
  65404. _detachCameras(cameras: Camera): void;
  65405. /**
  65406. * Detatches the effect on cameras
  65407. * @param cameras The camera to detatch from.
  65408. * @hidden
  65409. */
  65410. _detachCameras(cameras: Camera[]): void;
  65411. /**
  65412. * Enables the effect on given cameras
  65413. * @param cameras The camera to enable.
  65414. * @hidden
  65415. */
  65416. _enable(cameras: Camera): void;
  65417. /**
  65418. * Enables the effect on given cameras
  65419. * @param cameras The camera to enable.
  65420. * @hidden
  65421. */
  65422. _enable(cameras: Nullable<Camera[]>): void;
  65423. /**
  65424. * Disables the effect on the given cameras
  65425. * @param cameras The camera to disable.
  65426. * @hidden
  65427. */
  65428. _disable(cameras: Camera): void;
  65429. /**
  65430. * Disables the effect on the given cameras
  65431. * @param cameras The camera to disable.
  65432. * @hidden
  65433. */
  65434. _disable(cameras: Nullable<Camera[]>): void;
  65435. /**
  65436. * Gets a list of the post processes contained in the effect.
  65437. * @param camera The camera to get the post processes on.
  65438. * @returns The list of the post processes in the effect.
  65439. */
  65440. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  65441. }
  65442. }
  65443. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  65444. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65445. /** @hidden */
  65446. export var extractHighlightsPixelShader: {
  65447. name: string;
  65448. shader: string;
  65449. };
  65450. }
  65451. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  65452. import { Nullable } from "babylonjs/types";
  65453. import { Camera } from "babylonjs/Cameras/camera";
  65454. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65455. import { Engine } from "babylonjs/Engines/engine";
  65456. import "babylonjs/Shaders/extractHighlights.fragment";
  65457. /**
  65458. * 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.
  65459. */
  65460. export class ExtractHighlightsPostProcess extends PostProcess {
  65461. /**
  65462. * The luminance threshold, pixels below this value will be set to black.
  65463. */
  65464. threshold: number;
  65465. /** @hidden */
  65466. _exposure: number;
  65467. /**
  65468. * Post process which has the input texture to be used when performing highlight extraction
  65469. * @hidden
  65470. */
  65471. _inputPostProcess: Nullable<PostProcess>;
  65472. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65473. }
  65474. }
  65475. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  65476. /** @hidden */
  65477. export var bloomMergePixelShader: {
  65478. name: string;
  65479. shader: string;
  65480. };
  65481. }
  65482. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  65483. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65484. import { Nullable } from "babylonjs/types";
  65485. import { Engine } from "babylonjs/Engines/engine";
  65486. import { Camera } from "babylonjs/Cameras/camera";
  65487. import "babylonjs/Shaders/bloomMerge.fragment";
  65488. /**
  65489. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65490. */
  65491. export class BloomMergePostProcess extends PostProcess {
  65492. /** Weight of the bloom to be added to the original input. */
  65493. weight: number;
  65494. /**
  65495. * Creates a new instance of @see BloomMergePostProcess
  65496. * @param name The name of the effect.
  65497. * @param originalFromInput Post process which's input will be used for the merge.
  65498. * @param blurred Blurred highlights post process which's output will be used.
  65499. * @param weight Weight of the bloom to be added to the original input.
  65500. * @param options The required width/height ratio to downsize to before computing the render pass.
  65501. * @param camera The camera to apply the render pass to.
  65502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65503. * @param engine The engine which the post process will be applied. (default: current engine)
  65504. * @param reusable If the post process can be reused on the same frame. (default: false)
  65505. * @param textureType Type of textures used when performing the post process. (default: 0)
  65506. * @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)
  65507. */
  65508. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  65509. /** Weight of the bloom to be added to the original input. */
  65510. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65511. }
  65512. }
  65513. declare module "babylonjs/PostProcesses/bloomEffect" {
  65514. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65515. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65516. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65517. import { Camera } from "babylonjs/Cameras/camera";
  65518. import { Scene } from "babylonjs/scene";
  65519. /**
  65520. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  65521. */
  65522. export class BloomEffect extends PostProcessRenderEffect {
  65523. private bloomScale;
  65524. /**
  65525. * @hidden Internal
  65526. */
  65527. _effects: Array<PostProcess>;
  65528. /**
  65529. * @hidden Internal
  65530. */
  65531. _downscale: ExtractHighlightsPostProcess;
  65532. private _blurX;
  65533. private _blurY;
  65534. private _merge;
  65535. /**
  65536. * The luminance threshold to find bright areas of the image to bloom.
  65537. */
  65538. get threshold(): number;
  65539. set threshold(value: number);
  65540. /**
  65541. * The strength of the bloom.
  65542. */
  65543. get weight(): number;
  65544. set weight(value: number);
  65545. /**
  65546. * Specifies the size of the bloom blur kernel, relative to the final output size
  65547. */
  65548. get kernel(): number;
  65549. set kernel(value: number);
  65550. /**
  65551. * Creates a new instance of @see BloomEffect
  65552. * @param scene The scene the effect belongs to.
  65553. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  65554. * @param bloomKernel The size of the kernel to be used when applying the blur.
  65555. * @param bloomWeight The the strength of bloom.
  65556. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65557. * @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)
  65558. */
  65559. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  65560. /**
  65561. * Disposes each of the internal effects for a given camera.
  65562. * @param camera The camera to dispose the effect on.
  65563. */
  65564. disposeEffects(camera: Camera): void;
  65565. /**
  65566. * @hidden Internal
  65567. */
  65568. _updateEffects(): void;
  65569. /**
  65570. * Internal
  65571. * @returns if all the contained post processes are ready.
  65572. * @hidden
  65573. */
  65574. _isReady(): boolean;
  65575. }
  65576. }
  65577. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  65578. /** @hidden */
  65579. export var chromaticAberrationPixelShader: {
  65580. name: string;
  65581. shader: string;
  65582. };
  65583. }
  65584. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  65585. import { Vector2 } from "babylonjs/Maths/math.vector";
  65586. import { Nullable } from "babylonjs/types";
  65587. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65588. import { Camera } from "babylonjs/Cameras/camera";
  65589. import { Engine } from "babylonjs/Engines/engine";
  65590. import "babylonjs/Shaders/chromaticAberration.fragment";
  65591. /**
  65592. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65593. */
  65594. export class ChromaticAberrationPostProcess extends PostProcess {
  65595. /**
  65596. * The amount of seperation of rgb channels (default: 30)
  65597. */
  65598. aberrationAmount: number;
  65599. /**
  65600. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65601. */
  65602. radialIntensity: number;
  65603. /**
  65604. * 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))
  65605. */
  65606. direction: Vector2;
  65607. /**
  65608. * 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))
  65609. */
  65610. centerPosition: Vector2;
  65611. /**
  65612. * Creates a new instance ChromaticAberrationPostProcess
  65613. * @param name The name of the effect.
  65614. * @param screenWidth The width of the screen to apply the effect on.
  65615. * @param screenHeight The height of the screen to apply the effect on.
  65616. * @param options The required width/height ratio to downsize to before computing the render pass.
  65617. * @param camera The camera to apply the render pass to.
  65618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65619. * @param engine The engine which the post process will be applied. (default: current engine)
  65620. * @param reusable If the post process can be reused on the same frame. (default: false)
  65621. * @param textureType Type of textures used when performing the post process. (default: 0)
  65622. * @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)
  65623. */
  65624. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65625. }
  65626. }
  65627. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  65628. /** @hidden */
  65629. export var circleOfConfusionPixelShader: {
  65630. name: string;
  65631. shader: string;
  65632. };
  65633. }
  65634. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  65635. import { Nullable } from "babylonjs/types";
  65636. import { Engine } from "babylonjs/Engines/engine";
  65637. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65638. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65639. import { Camera } from "babylonjs/Cameras/camera";
  65640. import "babylonjs/Shaders/circleOfConfusion.fragment";
  65641. /**
  65642. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65643. */
  65644. export class CircleOfConfusionPostProcess extends PostProcess {
  65645. /**
  65646. * 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.
  65647. */
  65648. lensSize: number;
  65649. /**
  65650. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65651. */
  65652. fStop: number;
  65653. /**
  65654. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65655. */
  65656. focusDistance: number;
  65657. /**
  65658. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65659. */
  65660. focalLength: number;
  65661. private _depthTexture;
  65662. /**
  65663. * Creates a new instance CircleOfConfusionPostProcess
  65664. * @param name The name of the effect.
  65665. * @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.
  65666. * @param options The required width/height ratio to downsize to before computing the render pass.
  65667. * @param camera The camera to apply the render pass to.
  65668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65669. * @param engine The engine which the post process will be applied. (default: current engine)
  65670. * @param reusable If the post process can be reused on the same frame. (default: false)
  65671. * @param textureType Type of textures used when performing the post process. (default: 0)
  65672. * @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)
  65673. */
  65674. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65675. /**
  65676. * 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.
  65677. */
  65678. set depthTexture(value: RenderTargetTexture);
  65679. }
  65680. }
  65681. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  65682. /** @hidden */
  65683. export var colorCorrectionPixelShader: {
  65684. name: string;
  65685. shader: string;
  65686. };
  65687. }
  65688. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  65689. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65690. import { Engine } from "babylonjs/Engines/engine";
  65691. import { Camera } from "babylonjs/Cameras/camera";
  65692. import "babylonjs/Shaders/colorCorrection.fragment";
  65693. /**
  65694. *
  65695. * This post-process allows the modification of rendered colors by using
  65696. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65697. *
  65698. * The object needs to be provided an url to a texture containing the color
  65699. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65700. * Use an image editing software to tweak the LUT to match your needs.
  65701. *
  65702. * For an example of a color LUT, see here:
  65703. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65704. * For explanations on color grading, see here:
  65705. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65706. *
  65707. */
  65708. export class ColorCorrectionPostProcess extends PostProcess {
  65709. private _colorTableTexture;
  65710. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65711. }
  65712. }
  65713. declare module "babylonjs/Shaders/convolution.fragment" {
  65714. /** @hidden */
  65715. export var convolutionPixelShader: {
  65716. name: string;
  65717. shader: string;
  65718. };
  65719. }
  65720. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  65721. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65722. import { Nullable } from "babylonjs/types";
  65723. import { Camera } from "babylonjs/Cameras/camera";
  65724. import { Engine } from "babylonjs/Engines/engine";
  65725. import "babylonjs/Shaders/convolution.fragment";
  65726. /**
  65727. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65728. * input texture to perform effects such as edge detection or sharpening
  65729. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65730. */
  65731. export class ConvolutionPostProcess extends PostProcess {
  65732. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65733. kernel: number[];
  65734. /**
  65735. * Creates a new instance ConvolutionPostProcess
  65736. * @param name The name of the effect.
  65737. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65738. * @param options The required width/height ratio to downsize to before computing the render pass.
  65739. * @param camera The camera to apply the render pass to.
  65740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65741. * @param engine The engine which the post process will be applied. (default: current engine)
  65742. * @param reusable If the post process can be reused on the same frame. (default: false)
  65743. * @param textureType Type of textures used when performing the post process. (default: 0)
  65744. */
  65745. constructor(name: string,
  65746. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65747. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65748. /**
  65749. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65750. */
  65751. static EdgeDetect0Kernel: number[];
  65752. /**
  65753. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65754. */
  65755. static EdgeDetect1Kernel: number[];
  65756. /**
  65757. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65758. */
  65759. static EdgeDetect2Kernel: number[];
  65760. /**
  65761. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65762. */
  65763. static SharpenKernel: number[];
  65764. /**
  65765. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65766. */
  65767. static EmbossKernel: number[];
  65768. /**
  65769. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65770. */
  65771. static GaussianKernel: number[];
  65772. }
  65773. }
  65774. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  65775. import { Nullable } from "babylonjs/types";
  65776. import { Vector2 } from "babylonjs/Maths/math.vector";
  65777. import { Camera } from "babylonjs/Cameras/camera";
  65778. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65779. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65780. import { Engine } from "babylonjs/Engines/engine";
  65781. import { Scene } from "babylonjs/scene";
  65782. /**
  65783. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65784. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65785. * based on samples that have a large difference in distance than the center pixel.
  65786. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65787. */
  65788. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65789. direction: Vector2;
  65790. /**
  65791. * Creates a new instance CircleOfConfusionPostProcess
  65792. * @param name The name of the effect.
  65793. * @param scene The scene the effect belongs to.
  65794. * @param direction The direction the blur should be applied.
  65795. * @param kernel The size of the kernel used to blur.
  65796. * @param options The required width/height ratio to downsize to before computing the render pass.
  65797. * @param camera The camera to apply the render pass to.
  65798. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65799. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65801. * @param engine The engine which the post process will be applied. (default: current engine)
  65802. * @param reusable If the post process can be reused on the same frame. (default: false)
  65803. * @param textureType Type of textures used when performing the post process. (default: 0)
  65804. * @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)
  65805. */
  65806. 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);
  65807. }
  65808. }
  65809. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  65810. /** @hidden */
  65811. export var depthOfFieldMergePixelShader: {
  65812. name: string;
  65813. shader: string;
  65814. };
  65815. }
  65816. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  65817. import { Nullable } from "babylonjs/types";
  65818. import { Camera } from "babylonjs/Cameras/camera";
  65819. import { Effect } from "babylonjs/Materials/effect";
  65820. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65821. import { Engine } from "babylonjs/Engines/engine";
  65822. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  65823. /**
  65824. * Options to be set when merging outputs from the default pipeline.
  65825. */
  65826. export class DepthOfFieldMergePostProcessOptions {
  65827. /**
  65828. * The original image to merge on top of
  65829. */
  65830. originalFromInput: PostProcess;
  65831. /**
  65832. * Parameters to perform the merge of the depth of field effect
  65833. */
  65834. depthOfField?: {
  65835. circleOfConfusion: PostProcess;
  65836. blurSteps: Array<PostProcess>;
  65837. };
  65838. /**
  65839. * Parameters to perform the merge of bloom effect
  65840. */
  65841. bloom?: {
  65842. blurred: PostProcess;
  65843. weight: number;
  65844. };
  65845. }
  65846. /**
  65847. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65848. */
  65849. export class DepthOfFieldMergePostProcess extends PostProcess {
  65850. private blurSteps;
  65851. /**
  65852. * Creates a new instance of DepthOfFieldMergePostProcess
  65853. * @param name The name of the effect.
  65854. * @param originalFromInput Post process which's input will be used for the merge.
  65855. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65856. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65857. * @param options The required width/height ratio to downsize to before computing the render pass.
  65858. * @param camera The camera to apply the render pass to.
  65859. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65860. * @param engine The engine which the post process will be applied. (default: current engine)
  65861. * @param reusable If the post process can be reused on the same frame. (default: false)
  65862. * @param textureType Type of textures used when performing the post process. (default: 0)
  65863. * @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)
  65864. */
  65865. 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);
  65866. /**
  65867. * Updates the effect with the current post process compile time values and recompiles the shader.
  65868. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65869. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65870. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65871. * @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
  65872. * @param onCompiled Called when the shader has been compiled.
  65873. * @param onError Called if there is an error when compiling a shader.
  65874. */
  65875. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65876. }
  65877. }
  65878. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  65879. import { Nullable } from "babylonjs/types";
  65880. import { Camera } from "babylonjs/Cameras/camera";
  65881. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65882. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65883. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65884. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65885. import { Scene } from "babylonjs/scene";
  65886. /**
  65887. * Specifies the level of max blur that should be applied when using the depth of field effect
  65888. */
  65889. export enum DepthOfFieldEffectBlurLevel {
  65890. /**
  65891. * Subtle blur
  65892. */
  65893. Low = 0,
  65894. /**
  65895. * Medium blur
  65896. */
  65897. Medium = 1,
  65898. /**
  65899. * Large blur
  65900. */
  65901. High = 2
  65902. }
  65903. /**
  65904. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65905. */
  65906. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65907. private _circleOfConfusion;
  65908. /**
  65909. * @hidden Internal, blurs from high to low
  65910. */
  65911. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65912. private _depthOfFieldBlurY;
  65913. private _dofMerge;
  65914. /**
  65915. * @hidden Internal post processes in depth of field effect
  65916. */
  65917. _effects: Array<PostProcess>;
  65918. /**
  65919. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65920. */
  65921. set focalLength(value: number);
  65922. get focalLength(): number;
  65923. /**
  65924. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65925. */
  65926. set fStop(value: number);
  65927. get fStop(): number;
  65928. /**
  65929. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65930. */
  65931. set focusDistance(value: number);
  65932. get focusDistance(): number;
  65933. /**
  65934. * 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.
  65935. */
  65936. set lensSize(value: number);
  65937. get lensSize(): number;
  65938. /**
  65939. * Creates a new instance DepthOfFieldEffect
  65940. * @param scene The scene the effect belongs to.
  65941. * @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.
  65942. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65943. * @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)
  65944. */
  65945. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65946. /**
  65947. * Get the current class name of the current effet
  65948. * @returns "DepthOfFieldEffect"
  65949. */
  65950. getClassName(): string;
  65951. /**
  65952. * 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.
  65953. */
  65954. set depthTexture(value: RenderTargetTexture);
  65955. /**
  65956. * Disposes each of the internal effects for a given camera.
  65957. * @param camera The camera to dispose the effect on.
  65958. */
  65959. disposeEffects(camera: Camera): void;
  65960. /**
  65961. * @hidden Internal
  65962. */
  65963. _updateEffects(): void;
  65964. /**
  65965. * Internal
  65966. * @returns if all the contained post processes are ready.
  65967. * @hidden
  65968. */
  65969. _isReady(): boolean;
  65970. }
  65971. }
  65972. declare module "babylonjs/Shaders/displayPass.fragment" {
  65973. /** @hidden */
  65974. export var displayPassPixelShader: {
  65975. name: string;
  65976. shader: string;
  65977. };
  65978. }
  65979. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  65980. import { Nullable } from "babylonjs/types";
  65981. import { Camera } from "babylonjs/Cameras/camera";
  65982. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65983. import { Engine } from "babylonjs/Engines/engine";
  65984. import "babylonjs/Shaders/displayPass.fragment";
  65985. /**
  65986. * DisplayPassPostProcess which produces an output the same as it's input
  65987. */
  65988. export class DisplayPassPostProcess extends PostProcess {
  65989. /**
  65990. * Creates the DisplayPassPostProcess
  65991. * @param name The name of the effect.
  65992. * @param options The required width/height ratio to downsize to before computing the render pass.
  65993. * @param camera The camera to apply the render pass to.
  65994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65995. * @param engine The engine which the post process will be applied. (default: current engine)
  65996. * @param reusable If the post process can be reused on the same frame. (default: false)
  65997. */
  65998. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65999. }
  66000. }
  66001. declare module "babylonjs/Shaders/filter.fragment" {
  66002. /** @hidden */
  66003. export var filterPixelShader: {
  66004. name: string;
  66005. shader: string;
  66006. };
  66007. }
  66008. declare module "babylonjs/PostProcesses/filterPostProcess" {
  66009. import { Nullable } from "babylonjs/types";
  66010. import { Matrix } from "babylonjs/Maths/math.vector";
  66011. import { Camera } from "babylonjs/Cameras/camera";
  66012. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66013. import { Engine } from "babylonjs/Engines/engine";
  66014. import "babylonjs/Shaders/filter.fragment";
  66015. /**
  66016. * Applies a kernel filter to the image
  66017. */
  66018. export class FilterPostProcess extends PostProcess {
  66019. /** The matrix to be applied to the image */
  66020. kernelMatrix: Matrix;
  66021. /**
  66022. *
  66023. * @param name The name of the effect.
  66024. * @param kernelMatrix The matrix to be applied to the image
  66025. * @param options The required width/height ratio to downsize to before computing the render pass.
  66026. * @param camera The camera to apply the render pass to.
  66027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66028. * @param engine The engine which the post process will be applied. (default: current engine)
  66029. * @param reusable If the post process can be reused on the same frame. (default: false)
  66030. */
  66031. constructor(name: string,
  66032. /** The matrix to be applied to the image */
  66033. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66034. }
  66035. }
  66036. declare module "babylonjs/Shaders/fxaa.fragment" {
  66037. /** @hidden */
  66038. export var fxaaPixelShader: {
  66039. name: string;
  66040. shader: string;
  66041. };
  66042. }
  66043. declare module "babylonjs/Shaders/fxaa.vertex" {
  66044. /** @hidden */
  66045. export var fxaaVertexShader: {
  66046. name: string;
  66047. shader: string;
  66048. };
  66049. }
  66050. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  66051. import { Nullable } from "babylonjs/types";
  66052. import { Camera } from "babylonjs/Cameras/camera";
  66053. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66054. import { Engine } from "babylonjs/Engines/engine";
  66055. import "babylonjs/Shaders/fxaa.fragment";
  66056. import "babylonjs/Shaders/fxaa.vertex";
  66057. /**
  66058. * Fxaa post process
  66059. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  66060. */
  66061. export class FxaaPostProcess extends PostProcess {
  66062. /** @hidden */
  66063. texelWidth: number;
  66064. /** @hidden */
  66065. texelHeight: number;
  66066. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66067. private _getDefines;
  66068. }
  66069. }
  66070. declare module "babylonjs/Shaders/grain.fragment" {
  66071. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66072. /** @hidden */
  66073. export var grainPixelShader: {
  66074. name: string;
  66075. shader: string;
  66076. };
  66077. }
  66078. declare module "babylonjs/PostProcesses/grainPostProcess" {
  66079. import { Nullable } from "babylonjs/types";
  66080. import { Camera } from "babylonjs/Cameras/camera";
  66081. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66082. import { Engine } from "babylonjs/Engines/engine";
  66083. import "babylonjs/Shaders/grain.fragment";
  66084. /**
  66085. * The GrainPostProcess adds noise to the image at mid luminance levels
  66086. */
  66087. export class GrainPostProcess extends PostProcess {
  66088. /**
  66089. * The intensity of the grain added (default: 30)
  66090. */
  66091. intensity: number;
  66092. /**
  66093. * If the grain should be randomized on every frame
  66094. */
  66095. animated: boolean;
  66096. /**
  66097. * Creates a new instance of @see GrainPostProcess
  66098. * @param name The name of the effect.
  66099. * @param options The required width/height ratio to downsize to before computing the render pass.
  66100. * @param camera The camera to apply the render pass to.
  66101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66102. * @param engine The engine which the post process will be applied. (default: current engine)
  66103. * @param reusable If the post process can be reused on the same frame. (default: false)
  66104. * @param textureType Type of textures used when performing the post process. (default: 0)
  66105. * @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)
  66106. */
  66107. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66108. }
  66109. }
  66110. declare module "babylonjs/Shaders/highlights.fragment" {
  66111. /** @hidden */
  66112. export var highlightsPixelShader: {
  66113. name: string;
  66114. shader: string;
  66115. };
  66116. }
  66117. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  66118. import { Nullable } from "babylonjs/types";
  66119. import { Camera } from "babylonjs/Cameras/camera";
  66120. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66121. import { Engine } from "babylonjs/Engines/engine";
  66122. import "babylonjs/Shaders/highlights.fragment";
  66123. /**
  66124. * Extracts highlights from the image
  66125. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66126. */
  66127. export class HighlightsPostProcess extends PostProcess {
  66128. /**
  66129. * Extracts highlights from the image
  66130. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66131. * @param name The name of the effect.
  66132. * @param options The required width/height ratio to downsize to before computing the render pass.
  66133. * @param camera The camera to apply the render pass to.
  66134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66135. * @param engine The engine which the post process will be applied. (default: current engine)
  66136. * @param reusable If the post process can be reused on the same frame. (default: false)
  66137. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66138. */
  66139. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66140. }
  66141. }
  66142. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  66143. /** @hidden */
  66144. export var mrtFragmentDeclaration: {
  66145. name: string;
  66146. shader: string;
  66147. };
  66148. }
  66149. declare module "babylonjs/Shaders/geometry.fragment" {
  66150. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  66151. /** @hidden */
  66152. export var geometryPixelShader: {
  66153. name: string;
  66154. shader: string;
  66155. };
  66156. }
  66157. declare module "babylonjs/Shaders/geometry.vertex" {
  66158. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66159. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66160. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66161. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66162. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66163. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66164. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66165. /** @hidden */
  66166. export var geometryVertexShader: {
  66167. name: string;
  66168. shader: string;
  66169. };
  66170. }
  66171. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  66172. import { Matrix } from "babylonjs/Maths/math.vector";
  66173. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66174. import { Mesh } from "babylonjs/Meshes/mesh";
  66175. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  66176. import { Effect } from "babylonjs/Materials/effect";
  66177. import { Scene } from "babylonjs/scene";
  66178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66179. import "babylonjs/Shaders/geometry.fragment";
  66180. import "babylonjs/Shaders/geometry.vertex";
  66181. /** @hidden */
  66182. interface ISavedTransformationMatrix {
  66183. world: Matrix;
  66184. viewProjection: Matrix;
  66185. }
  66186. /**
  66187. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66188. */
  66189. export class GeometryBufferRenderer {
  66190. /**
  66191. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66192. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66193. */
  66194. static readonly POSITION_TEXTURE_TYPE: number;
  66195. /**
  66196. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66197. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66198. */
  66199. static readonly VELOCITY_TEXTURE_TYPE: number;
  66200. /**
  66201. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66202. * in order to compute objects velocities when enableVelocity is set to "true"
  66203. * @hidden
  66204. */
  66205. _previousTransformationMatrices: {
  66206. [index: number]: ISavedTransformationMatrix;
  66207. };
  66208. /**
  66209. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66210. * in order to compute objects velocities when enableVelocity is set to "true"
  66211. * @hidden
  66212. */
  66213. _previousBonesTransformationMatrices: {
  66214. [index: number]: Float32Array;
  66215. };
  66216. /**
  66217. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66218. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66219. */
  66220. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66221. private _scene;
  66222. private _multiRenderTarget;
  66223. private _ratio;
  66224. private _enablePosition;
  66225. private _enableVelocity;
  66226. private _positionIndex;
  66227. private _velocityIndex;
  66228. protected _effect: Effect;
  66229. protected _cachedDefines: string;
  66230. /**
  66231. * Set the render list (meshes to be rendered) used in the G buffer.
  66232. */
  66233. set renderList(meshes: Mesh[]);
  66234. /**
  66235. * Gets wether or not G buffer are supported by the running hardware.
  66236. * This requires draw buffer supports
  66237. */
  66238. get isSupported(): boolean;
  66239. /**
  66240. * Returns the index of the given texture type in the G-Buffer textures array
  66241. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66242. * @returns the index of the given texture type in the G-Buffer textures array
  66243. */
  66244. getTextureIndex(textureType: number): number;
  66245. /**
  66246. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66247. */
  66248. get enablePosition(): boolean;
  66249. /**
  66250. * Sets whether or not objects positions are enabled for the G buffer.
  66251. */
  66252. set enablePosition(enable: boolean);
  66253. /**
  66254. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66255. */
  66256. get enableVelocity(): boolean;
  66257. /**
  66258. * Sets wether or not objects velocities are enabled for the G buffer.
  66259. */
  66260. set enableVelocity(enable: boolean);
  66261. /**
  66262. * Gets the scene associated with the buffer.
  66263. */
  66264. get scene(): Scene;
  66265. /**
  66266. * Gets the ratio used by the buffer during its creation.
  66267. * How big is the buffer related to the main canvas.
  66268. */
  66269. get ratio(): number;
  66270. /** @hidden */
  66271. static _SceneComponentInitialization: (scene: Scene) => void;
  66272. /**
  66273. * Creates a new G Buffer for the scene
  66274. * @param scene The scene the buffer belongs to
  66275. * @param ratio How big is the buffer related to the main canvas.
  66276. */
  66277. constructor(scene: Scene, ratio?: number);
  66278. /**
  66279. * Checks wether everything is ready to render a submesh to the G buffer.
  66280. * @param subMesh the submesh to check readiness for
  66281. * @param useInstances is the mesh drawn using instance or not
  66282. * @returns true if ready otherwise false
  66283. */
  66284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66285. /**
  66286. * Gets the current underlying G Buffer.
  66287. * @returns the buffer
  66288. */
  66289. getGBuffer(): MultiRenderTarget;
  66290. /**
  66291. * Gets the number of samples used to render the buffer (anti aliasing).
  66292. */
  66293. get samples(): number;
  66294. /**
  66295. * Sets the number of samples used to render the buffer (anti aliasing).
  66296. */
  66297. set samples(value: number);
  66298. /**
  66299. * Disposes the renderer and frees up associated resources.
  66300. */
  66301. dispose(): void;
  66302. protected _createRenderTargets(): void;
  66303. private _copyBonesTransformationMatrices;
  66304. }
  66305. }
  66306. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  66307. import { Nullable } from "babylonjs/types";
  66308. import { Scene } from "babylonjs/scene";
  66309. import { ISceneComponent } from "babylonjs/sceneComponent";
  66310. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  66311. module "babylonjs/scene" {
  66312. interface Scene {
  66313. /** @hidden (Backing field) */
  66314. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66315. /**
  66316. * Gets or Sets the current geometry buffer associated to the scene.
  66317. */
  66318. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66319. /**
  66320. * Enables a GeometryBufferRender and associates it with the scene
  66321. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  66322. * @returns the GeometryBufferRenderer
  66323. */
  66324. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  66325. /**
  66326. * Disables the GeometryBufferRender associated with the scene
  66327. */
  66328. disableGeometryBufferRenderer(): void;
  66329. }
  66330. }
  66331. /**
  66332. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  66333. * in several rendering techniques.
  66334. */
  66335. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  66336. /**
  66337. * The component name helpful to identify the component in the list of scene components.
  66338. */
  66339. readonly name: string;
  66340. /**
  66341. * The scene the component belongs to.
  66342. */
  66343. scene: Scene;
  66344. /**
  66345. * Creates a new instance of the component for the given scene
  66346. * @param scene Defines the scene to register the component in
  66347. */
  66348. constructor(scene: Scene);
  66349. /**
  66350. * Registers the component in a given scene
  66351. */
  66352. register(): void;
  66353. /**
  66354. * Rebuilds the elements related to this component in case of
  66355. * context lost for instance.
  66356. */
  66357. rebuild(): void;
  66358. /**
  66359. * Disposes the component and the associated ressources
  66360. */
  66361. dispose(): void;
  66362. private _gatherRenderTargets;
  66363. }
  66364. }
  66365. declare module "babylonjs/Shaders/motionBlur.fragment" {
  66366. /** @hidden */
  66367. export var motionBlurPixelShader: {
  66368. name: string;
  66369. shader: string;
  66370. };
  66371. }
  66372. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  66373. import { Nullable } from "babylonjs/types";
  66374. import { Camera } from "babylonjs/Cameras/camera";
  66375. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66376. import { Scene } from "babylonjs/scene";
  66377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66378. import "babylonjs/Animations/animatable";
  66379. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66380. import "babylonjs/Shaders/motionBlur.fragment";
  66381. import { Engine } from "babylonjs/Engines/engine";
  66382. /**
  66383. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  66384. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  66385. * As an example, all you have to do is to create the post-process:
  66386. * var mb = new BABYLON.MotionBlurPostProcess(
  66387. * 'mb', // The name of the effect.
  66388. * scene, // The scene containing the objects to blur according to their velocity.
  66389. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  66390. * camera // The camera to apply the render pass to.
  66391. * );
  66392. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  66393. */
  66394. export class MotionBlurPostProcess extends PostProcess {
  66395. /**
  66396. * Defines how much the image is blurred by the movement. Default value is equal to 1
  66397. */
  66398. motionStrength: number;
  66399. /**
  66400. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  66401. */
  66402. get motionBlurSamples(): number;
  66403. /**
  66404. * Sets the number of iterations to be used for motion blur quality
  66405. */
  66406. set motionBlurSamples(samples: number);
  66407. private _motionBlurSamples;
  66408. private _geometryBufferRenderer;
  66409. /**
  66410. * Creates a new instance MotionBlurPostProcess
  66411. * @param name The name of the effect.
  66412. * @param scene The scene containing the objects to blur according to their velocity.
  66413. * @param options The required width/height ratio to downsize to before computing the render pass.
  66414. * @param camera The camera to apply the render pass to.
  66415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66416. * @param engine The engine which the post process will be applied. (default: current engine)
  66417. * @param reusable If the post process can be reused on the same frame. (default: false)
  66418. * @param textureType Type of textures used when performing the post process. (default: 0)
  66419. * @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)
  66420. */
  66421. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66422. /**
  66423. * Excludes the given skinned mesh from computing bones velocities.
  66424. * 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.
  66425. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  66426. */
  66427. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66428. /**
  66429. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  66430. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  66431. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  66432. */
  66433. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66434. /**
  66435. * Disposes the post process.
  66436. * @param camera The camera to dispose the post process on.
  66437. */
  66438. dispose(camera?: Camera): void;
  66439. }
  66440. }
  66441. declare module "babylonjs/Shaders/refraction.fragment" {
  66442. /** @hidden */
  66443. export var refractionPixelShader: {
  66444. name: string;
  66445. shader: string;
  66446. };
  66447. }
  66448. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  66449. import { Color3 } from "babylonjs/Maths/math.color";
  66450. import { Camera } from "babylonjs/Cameras/camera";
  66451. import { Texture } from "babylonjs/Materials/Textures/texture";
  66452. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66453. import { Engine } from "babylonjs/Engines/engine";
  66454. import "babylonjs/Shaders/refraction.fragment";
  66455. /**
  66456. * Post process which applies a refractin texture
  66457. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66458. */
  66459. export class RefractionPostProcess extends PostProcess {
  66460. /** the base color of the refraction (used to taint the rendering) */
  66461. color: Color3;
  66462. /** simulated refraction depth */
  66463. depth: number;
  66464. /** the coefficient of the base color (0 to remove base color tainting) */
  66465. colorLevel: number;
  66466. private _refTexture;
  66467. private _ownRefractionTexture;
  66468. /**
  66469. * Gets or sets the refraction texture
  66470. * Please note that you are responsible for disposing the texture if you set it manually
  66471. */
  66472. get refractionTexture(): Texture;
  66473. set refractionTexture(value: Texture);
  66474. /**
  66475. * Initializes the RefractionPostProcess
  66476. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66477. * @param name The name of the effect.
  66478. * @param refractionTextureUrl Url of the refraction texture to use
  66479. * @param color the base color of the refraction (used to taint the rendering)
  66480. * @param depth simulated refraction depth
  66481. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  66482. * @param camera The camera to apply the render pass to.
  66483. * @param options The required width/height ratio to downsize to before computing the render pass.
  66484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66485. * @param engine The engine which the post process will be applied. (default: current engine)
  66486. * @param reusable If the post process can be reused on the same frame. (default: false)
  66487. */
  66488. constructor(name: string, refractionTextureUrl: string,
  66489. /** the base color of the refraction (used to taint the rendering) */
  66490. color: Color3,
  66491. /** simulated refraction depth */
  66492. depth: number,
  66493. /** the coefficient of the base color (0 to remove base color tainting) */
  66494. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66495. /**
  66496. * Disposes of the post process
  66497. * @param camera Camera to dispose post process on
  66498. */
  66499. dispose(camera: Camera): void;
  66500. }
  66501. }
  66502. declare module "babylonjs/Shaders/sharpen.fragment" {
  66503. /** @hidden */
  66504. export var sharpenPixelShader: {
  66505. name: string;
  66506. shader: string;
  66507. };
  66508. }
  66509. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  66510. import { Nullable } from "babylonjs/types";
  66511. import { Camera } from "babylonjs/Cameras/camera";
  66512. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66513. import "babylonjs/Shaders/sharpen.fragment";
  66514. import { Engine } from "babylonjs/Engines/engine";
  66515. /**
  66516. * The SharpenPostProcess applies a sharpen kernel to every pixel
  66517. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66518. */
  66519. export class SharpenPostProcess extends PostProcess {
  66520. /**
  66521. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  66522. */
  66523. colorAmount: number;
  66524. /**
  66525. * How much sharpness should be applied (default: 0.3)
  66526. */
  66527. edgeAmount: number;
  66528. /**
  66529. * Creates a new instance ConvolutionPostProcess
  66530. * @param name The name of the effect.
  66531. * @param options The required width/height ratio to downsize to before computing the render pass.
  66532. * @param camera The camera to apply the render pass to.
  66533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66534. * @param engine The engine which the post process will be applied. (default: current engine)
  66535. * @param reusable If the post process can be reused on the same frame. (default: false)
  66536. * @param textureType Type of textures used when performing the post process. (default: 0)
  66537. * @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)
  66538. */
  66539. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66540. }
  66541. }
  66542. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  66543. import { Nullable } from "babylonjs/types";
  66544. import { Camera } from "babylonjs/Cameras/camera";
  66545. import { Engine } from "babylonjs/Engines/engine";
  66546. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66547. import { IInspectable } from "babylonjs/Misc/iInspectable";
  66548. /**
  66549. * PostProcessRenderPipeline
  66550. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66551. */
  66552. export class PostProcessRenderPipeline {
  66553. private engine;
  66554. private _renderEffects;
  66555. private _renderEffectsForIsolatedPass;
  66556. /**
  66557. * List of inspectable custom properties (used by the Inspector)
  66558. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66559. */
  66560. inspectableCustomProperties: IInspectable[];
  66561. /**
  66562. * @hidden
  66563. */
  66564. protected _cameras: Camera[];
  66565. /** @hidden */
  66566. _name: string;
  66567. /**
  66568. * Gets pipeline name
  66569. */
  66570. get name(): string;
  66571. /** Gets the list of attached cameras */
  66572. get cameras(): Camera[];
  66573. /**
  66574. * Initializes a PostProcessRenderPipeline
  66575. * @param engine engine to add the pipeline to
  66576. * @param name name of the pipeline
  66577. */
  66578. constructor(engine: Engine, name: string);
  66579. /**
  66580. * Gets the class name
  66581. * @returns "PostProcessRenderPipeline"
  66582. */
  66583. getClassName(): string;
  66584. /**
  66585. * If all the render effects in the pipeline are supported
  66586. */
  66587. get isSupported(): boolean;
  66588. /**
  66589. * Adds an effect to the pipeline
  66590. * @param renderEffect the effect to add
  66591. */
  66592. addEffect(renderEffect: PostProcessRenderEffect): void;
  66593. /** @hidden */
  66594. _rebuild(): void;
  66595. /** @hidden */
  66596. _enableEffect(renderEffectName: string, cameras: Camera): void;
  66597. /** @hidden */
  66598. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  66599. /** @hidden */
  66600. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66601. /** @hidden */
  66602. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66603. /** @hidden */
  66604. _attachCameras(cameras: Camera, unique: boolean): void;
  66605. /** @hidden */
  66606. _attachCameras(cameras: Camera[], unique: boolean): void;
  66607. /** @hidden */
  66608. _detachCameras(cameras: Camera): void;
  66609. /** @hidden */
  66610. _detachCameras(cameras: Nullable<Camera[]>): void;
  66611. /** @hidden */
  66612. _update(): void;
  66613. /** @hidden */
  66614. _reset(): void;
  66615. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  66616. /**
  66617. * Disposes of the pipeline
  66618. */
  66619. dispose(): void;
  66620. }
  66621. }
  66622. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  66623. import { Camera } from "babylonjs/Cameras/camera";
  66624. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66625. /**
  66626. * PostProcessRenderPipelineManager class
  66627. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66628. */
  66629. export class PostProcessRenderPipelineManager {
  66630. private _renderPipelines;
  66631. /**
  66632. * Initializes a PostProcessRenderPipelineManager
  66633. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66634. */
  66635. constructor();
  66636. /**
  66637. * Gets the list of supported render pipelines
  66638. */
  66639. get supportedPipelines(): PostProcessRenderPipeline[];
  66640. /**
  66641. * Adds a pipeline to the manager
  66642. * @param renderPipeline The pipeline to add
  66643. */
  66644. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  66645. /**
  66646. * Attaches a camera to the pipeline
  66647. * @param renderPipelineName The name of the pipeline to attach to
  66648. * @param cameras the camera to attach
  66649. * @param unique if the camera can be attached multiple times to the pipeline
  66650. */
  66651. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  66652. /**
  66653. * Detaches a camera from the pipeline
  66654. * @param renderPipelineName The name of the pipeline to detach from
  66655. * @param cameras the camera to detach
  66656. */
  66657. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66658. /**
  66659. * Enables an effect by name on a pipeline
  66660. * @param renderPipelineName the name of the pipeline to enable the effect in
  66661. * @param renderEffectName the name of the effect to enable
  66662. * @param cameras the cameras that the effect should be enabled on
  66663. */
  66664. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66665. /**
  66666. * Disables an effect by name on a pipeline
  66667. * @param renderPipelineName the name of the pipeline to disable the effect in
  66668. * @param renderEffectName the name of the effect to disable
  66669. * @param cameras the cameras that the effect should be disabled on
  66670. */
  66671. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66672. /**
  66673. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66674. */
  66675. update(): void;
  66676. /** @hidden */
  66677. _rebuild(): void;
  66678. /**
  66679. * Disposes of the manager and pipelines
  66680. */
  66681. dispose(): void;
  66682. }
  66683. }
  66684. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  66685. import { ISceneComponent } from "babylonjs/sceneComponent";
  66686. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66687. import { Scene } from "babylonjs/scene";
  66688. module "babylonjs/scene" {
  66689. interface Scene {
  66690. /** @hidden (Backing field) */
  66691. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66692. /**
  66693. * Gets the postprocess render pipeline manager
  66694. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66695. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66696. */
  66697. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66698. }
  66699. }
  66700. /**
  66701. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66702. */
  66703. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66704. /**
  66705. * The component name helpfull to identify the component in the list of scene components.
  66706. */
  66707. readonly name: string;
  66708. /**
  66709. * The scene the component belongs to.
  66710. */
  66711. scene: Scene;
  66712. /**
  66713. * Creates a new instance of the component for the given scene
  66714. * @param scene Defines the scene to register the component in
  66715. */
  66716. constructor(scene: Scene);
  66717. /**
  66718. * Registers the component in a given scene
  66719. */
  66720. register(): void;
  66721. /**
  66722. * Rebuilds the elements related to this component in case of
  66723. * context lost for instance.
  66724. */
  66725. rebuild(): void;
  66726. /**
  66727. * Disposes the component and the associated ressources
  66728. */
  66729. dispose(): void;
  66730. private _gatherRenderTargets;
  66731. }
  66732. }
  66733. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  66734. import { Nullable } from "babylonjs/types";
  66735. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66736. import { Camera } from "babylonjs/Cameras/camera";
  66737. import { IDisposable } from "babylonjs/scene";
  66738. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  66739. import { Scene } from "babylonjs/scene";
  66740. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  66741. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66742. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66743. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  66744. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66745. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66746. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  66747. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66748. import { Animation } from "babylonjs/Animations/animation";
  66749. /**
  66750. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66751. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66752. */
  66753. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66754. private _scene;
  66755. private _camerasToBeAttached;
  66756. /**
  66757. * ID of the sharpen post process,
  66758. */
  66759. private readonly SharpenPostProcessId;
  66760. /**
  66761. * @ignore
  66762. * ID of the image processing post process;
  66763. */
  66764. readonly ImageProcessingPostProcessId: string;
  66765. /**
  66766. * @ignore
  66767. * ID of the Fast Approximate Anti-Aliasing post process;
  66768. */
  66769. readonly FxaaPostProcessId: string;
  66770. /**
  66771. * ID of the chromatic aberration post process,
  66772. */
  66773. private readonly ChromaticAberrationPostProcessId;
  66774. /**
  66775. * ID of the grain post process
  66776. */
  66777. private readonly GrainPostProcessId;
  66778. /**
  66779. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66780. */
  66781. sharpen: SharpenPostProcess;
  66782. private _sharpenEffect;
  66783. private bloom;
  66784. /**
  66785. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66786. */
  66787. depthOfField: DepthOfFieldEffect;
  66788. /**
  66789. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66790. */
  66791. fxaa: FxaaPostProcess;
  66792. /**
  66793. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66794. */
  66795. imageProcessing: ImageProcessingPostProcess;
  66796. /**
  66797. * Chromatic aberration post process which will shift rgb colors in the image
  66798. */
  66799. chromaticAberration: ChromaticAberrationPostProcess;
  66800. private _chromaticAberrationEffect;
  66801. /**
  66802. * Grain post process which add noise to the image
  66803. */
  66804. grain: GrainPostProcess;
  66805. private _grainEffect;
  66806. /**
  66807. * Glow post process which adds a glow to emissive areas of the image
  66808. */
  66809. private _glowLayer;
  66810. /**
  66811. * Animations which can be used to tweak settings over a period of time
  66812. */
  66813. animations: Animation[];
  66814. private _imageProcessingConfigurationObserver;
  66815. private _sharpenEnabled;
  66816. private _bloomEnabled;
  66817. private _depthOfFieldEnabled;
  66818. private _depthOfFieldBlurLevel;
  66819. private _fxaaEnabled;
  66820. private _imageProcessingEnabled;
  66821. private _defaultPipelineTextureType;
  66822. private _bloomScale;
  66823. private _chromaticAberrationEnabled;
  66824. private _grainEnabled;
  66825. private _buildAllowed;
  66826. /**
  66827. * Gets active scene
  66828. */
  66829. get scene(): Scene;
  66830. /**
  66831. * Enable or disable the sharpen process from the pipeline
  66832. */
  66833. set sharpenEnabled(enabled: boolean);
  66834. get sharpenEnabled(): boolean;
  66835. private _resizeObserver;
  66836. private _hardwareScaleLevel;
  66837. private _bloomKernel;
  66838. /**
  66839. * Specifies the size of the bloom blur kernel, relative to the final output size
  66840. */
  66841. get bloomKernel(): number;
  66842. set bloomKernel(value: number);
  66843. /**
  66844. * Specifies the weight of the bloom in the final rendering
  66845. */
  66846. private _bloomWeight;
  66847. /**
  66848. * Specifies the luma threshold for the area that will be blurred by the bloom
  66849. */
  66850. private _bloomThreshold;
  66851. private _hdr;
  66852. /**
  66853. * The strength of the bloom.
  66854. */
  66855. set bloomWeight(value: number);
  66856. get bloomWeight(): number;
  66857. /**
  66858. * The strength of the bloom.
  66859. */
  66860. set bloomThreshold(value: number);
  66861. get bloomThreshold(): number;
  66862. /**
  66863. * The scale of the bloom, lower value will provide better performance.
  66864. */
  66865. set bloomScale(value: number);
  66866. get bloomScale(): number;
  66867. /**
  66868. * Enable or disable the bloom from the pipeline
  66869. */
  66870. set bloomEnabled(enabled: boolean);
  66871. get bloomEnabled(): boolean;
  66872. private _rebuildBloom;
  66873. /**
  66874. * If the depth of field is enabled.
  66875. */
  66876. get depthOfFieldEnabled(): boolean;
  66877. set depthOfFieldEnabled(enabled: boolean);
  66878. /**
  66879. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66880. */
  66881. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66882. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66883. /**
  66884. * If the anti aliasing is enabled.
  66885. */
  66886. set fxaaEnabled(enabled: boolean);
  66887. get fxaaEnabled(): boolean;
  66888. private _samples;
  66889. /**
  66890. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66891. */
  66892. set samples(sampleCount: number);
  66893. get samples(): number;
  66894. /**
  66895. * If image processing is enabled.
  66896. */
  66897. set imageProcessingEnabled(enabled: boolean);
  66898. get imageProcessingEnabled(): boolean;
  66899. /**
  66900. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66901. */
  66902. set glowLayerEnabled(enabled: boolean);
  66903. get glowLayerEnabled(): boolean;
  66904. /**
  66905. * Gets the glow layer (or null if not defined)
  66906. */
  66907. get glowLayer(): Nullable<GlowLayer>;
  66908. /**
  66909. * Enable or disable the chromaticAberration process from the pipeline
  66910. */
  66911. set chromaticAberrationEnabled(enabled: boolean);
  66912. get chromaticAberrationEnabled(): boolean;
  66913. /**
  66914. * Enable or disable the grain process from the pipeline
  66915. */
  66916. set grainEnabled(enabled: boolean);
  66917. get grainEnabled(): boolean;
  66918. /**
  66919. * @constructor
  66920. * @param name - The rendering pipeline name (default: "")
  66921. * @param hdr - If high dynamic range textures should be used (default: true)
  66922. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66923. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66924. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66925. */
  66926. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66927. /**
  66928. * Get the class name
  66929. * @returns "DefaultRenderingPipeline"
  66930. */
  66931. getClassName(): string;
  66932. /**
  66933. * Force the compilation of the entire pipeline.
  66934. */
  66935. prepare(): void;
  66936. private _hasCleared;
  66937. private _prevPostProcess;
  66938. private _prevPrevPostProcess;
  66939. private _setAutoClearAndTextureSharing;
  66940. private _depthOfFieldSceneObserver;
  66941. private _buildPipeline;
  66942. private _disposePostProcesses;
  66943. /**
  66944. * Adds a camera to the pipeline
  66945. * @param camera the camera to be added
  66946. */
  66947. addCamera(camera: Camera): void;
  66948. /**
  66949. * Removes a camera from the pipeline
  66950. * @param camera the camera to remove
  66951. */
  66952. removeCamera(camera: Camera): void;
  66953. /**
  66954. * Dispose of the pipeline and stop all post processes
  66955. */
  66956. dispose(): void;
  66957. /**
  66958. * Serialize the rendering pipeline (Used when exporting)
  66959. * @returns the serialized object
  66960. */
  66961. serialize(): any;
  66962. /**
  66963. * Parse the serialized pipeline
  66964. * @param source Source pipeline.
  66965. * @param scene The scene to load the pipeline to.
  66966. * @param rootUrl The URL of the serialized pipeline.
  66967. * @returns An instantiated pipeline from the serialized object.
  66968. */
  66969. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66970. }
  66971. }
  66972. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  66973. /** @hidden */
  66974. export var lensHighlightsPixelShader: {
  66975. name: string;
  66976. shader: string;
  66977. };
  66978. }
  66979. declare module "babylonjs/Shaders/depthOfField.fragment" {
  66980. /** @hidden */
  66981. export var depthOfFieldPixelShader: {
  66982. name: string;
  66983. shader: string;
  66984. };
  66985. }
  66986. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  66987. import { Camera } from "babylonjs/Cameras/camera";
  66988. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66989. import { Scene } from "babylonjs/scene";
  66990. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66991. import "babylonjs/Shaders/chromaticAberration.fragment";
  66992. import "babylonjs/Shaders/lensHighlights.fragment";
  66993. import "babylonjs/Shaders/depthOfField.fragment";
  66994. /**
  66995. * BABYLON.JS Chromatic Aberration GLSL Shader
  66996. * Author: Olivier Guyot
  66997. * Separates very slightly R, G and B colors on the edges of the screen
  66998. * Inspired by Francois Tarlier & Martins Upitis
  66999. */
  67000. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  67001. /**
  67002. * @ignore
  67003. * The chromatic aberration PostProcess id in the pipeline
  67004. */
  67005. LensChromaticAberrationEffect: string;
  67006. /**
  67007. * @ignore
  67008. * The highlights enhancing PostProcess id in the pipeline
  67009. */
  67010. HighlightsEnhancingEffect: string;
  67011. /**
  67012. * @ignore
  67013. * The depth-of-field PostProcess id in the pipeline
  67014. */
  67015. LensDepthOfFieldEffect: string;
  67016. private _scene;
  67017. private _depthTexture;
  67018. private _grainTexture;
  67019. private _chromaticAberrationPostProcess;
  67020. private _highlightsPostProcess;
  67021. private _depthOfFieldPostProcess;
  67022. private _edgeBlur;
  67023. private _grainAmount;
  67024. private _chromaticAberration;
  67025. private _distortion;
  67026. private _highlightsGain;
  67027. private _highlightsThreshold;
  67028. private _dofDistance;
  67029. private _dofAperture;
  67030. private _dofDarken;
  67031. private _dofPentagon;
  67032. private _blurNoise;
  67033. /**
  67034. * @constructor
  67035. *
  67036. * Effect parameters are as follow:
  67037. * {
  67038. * chromatic_aberration: number; // from 0 to x (1 for realism)
  67039. * edge_blur: number; // from 0 to x (1 for realism)
  67040. * distortion: number; // from 0 to x (1 for realism)
  67041. * grain_amount: number; // from 0 to 1
  67042. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  67043. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  67044. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  67045. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  67046. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  67047. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  67048. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  67049. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  67050. * }
  67051. * Note: if an effect parameter is unset, effect is disabled
  67052. *
  67053. * @param name The rendering pipeline name
  67054. * @param parameters - An object containing all parameters (see above)
  67055. * @param scene The scene linked to this pipeline
  67056. * @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)
  67057. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67058. */
  67059. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  67060. /**
  67061. * Get the class name
  67062. * @returns "LensRenderingPipeline"
  67063. */
  67064. getClassName(): string;
  67065. /**
  67066. * Gets associated scene
  67067. */
  67068. get scene(): Scene;
  67069. /**
  67070. * Gets or sets the edge blur
  67071. */
  67072. get edgeBlur(): number;
  67073. set edgeBlur(value: number);
  67074. /**
  67075. * Gets or sets the grain amount
  67076. */
  67077. get grainAmount(): number;
  67078. set grainAmount(value: number);
  67079. /**
  67080. * Gets or sets the chromatic aberration amount
  67081. */
  67082. get chromaticAberration(): number;
  67083. set chromaticAberration(value: number);
  67084. /**
  67085. * Gets or sets the depth of field aperture
  67086. */
  67087. get dofAperture(): number;
  67088. set dofAperture(value: number);
  67089. /**
  67090. * Gets or sets the edge distortion
  67091. */
  67092. get edgeDistortion(): number;
  67093. set edgeDistortion(value: number);
  67094. /**
  67095. * Gets or sets the depth of field distortion
  67096. */
  67097. get dofDistortion(): number;
  67098. set dofDistortion(value: number);
  67099. /**
  67100. * Gets or sets the darken out of focus amount
  67101. */
  67102. get darkenOutOfFocus(): number;
  67103. set darkenOutOfFocus(value: number);
  67104. /**
  67105. * Gets or sets a boolean indicating if blur noise is enabled
  67106. */
  67107. get blurNoise(): boolean;
  67108. set blurNoise(value: boolean);
  67109. /**
  67110. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67111. */
  67112. get pentagonBokeh(): boolean;
  67113. set pentagonBokeh(value: boolean);
  67114. /**
  67115. * Gets or sets the highlight grain amount
  67116. */
  67117. get highlightsGain(): number;
  67118. set highlightsGain(value: number);
  67119. /**
  67120. * Gets or sets the highlight threshold
  67121. */
  67122. get highlightsThreshold(): number;
  67123. set highlightsThreshold(value: number);
  67124. /**
  67125. * Sets the amount of blur at the edges
  67126. * @param amount blur amount
  67127. */
  67128. setEdgeBlur(amount: number): void;
  67129. /**
  67130. * Sets edge blur to 0
  67131. */
  67132. disableEdgeBlur(): void;
  67133. /**
  67134. * Sets the amout of grain
  67135. * @param amount Amount of grain
  67136. */
  67137. setGrainAmount(amount: number): void;
  67138. /**
  67139. * Set grain amount to 0
  67140. */
  67141. disableGrain(): void;
  67142. /**
  67143. * Sets the chromatic aberration amount
  67144. * @param amount amount of chromatic aberration
  67145. */
  67146. setChromaticAberration(amount: number): void;
  67147. /**
  67148. * Sets chromatic aberration amount to 0
  67149. */
  67150. disableChromaticAberration(): void;
  67151. /**
  67152. * Sets the EdgeDistortion amount
  67153. * @param amount amount of EdgeDistortion
  67154. */
  67155. setEdgeDistortion(amount: number): void;
  67156. /**
  67157. * Sets edge distortion to 0
  67158. */
  67159. disableEdgeDistortion(): void;
  67160. /**
  67161. * Sets the FocusDistance amount
  67162. * @param amount amount of FocusDistance
  67163. */
  67164. setFocusDistance(amount: number): void;
  67165. /**
  67166. * Disables depth of field
  67167. */
  67168. disableDepthOfField(): void;
  67169. /**
  67170. * Sets the Aperture amount
  67171. * @param amount amount of Aperture
  67172. */
  67173. setAperture(amount: number): void;
  67174. /**
  67175. * Sets the DarkenOutOfFocus amount
  67176. * @param amount amount of DarkenOutOfFocus
  67177. */
  67178. setDarkenOutOfFocus(amount: number): void;
  67179. private _pentagonBokehIsEnabled;
  67180. /**
  67181. * Creates a pentagon bokeh effect
  67182. */
  67183. enablePentagonBokeh(): void;
  67184. /**
  67185. * Disables the pentagon bokeh effect
  67186. */
  67187. disablePentagonBokeh(): void;
  67188. /**
  67189. * Enables noise blur
  67190. */
  67191. enableNoiseBlur(): void;
  67192. /**
  67193. * Disables noise blur
  67194. */
  67195. disableNoiseBlur(): void;
  67196. /**
  67197. * Sets the HighlightsGain amount
  67198. * @param amount amount of HighlightsGain
  67199. */
  67200. setHighlightsGain(amount: number): void;
  67201. /**
  67202. * Sets the HighlightsThreshold amount
  67203. * @param amount amount of HighlightsThreshold
  67204. */
  67205. setHighlightsThreshold(amount: number): void;
  67206. /**
  67207. * Disables highlights
  67208. */
  67209. disableHighlights(): void;
  67210. /**
  67211. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67212. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67213. */
  67214. dispose(disableDepthRender?: boolean): void;
  67215. private _createChromaticAberrationPostProcess;
  67216. private _createHighlightsPostProcess;
  67217. private _createDepthOfFieldPostProcess;
  67218. private _createGrainTexture;
  67219. }
  67220. }
  67221. declare module "babylonjs/Shaders/ssao2.fragment" {
  67222. /** @hidden */
  67223. export var ssao2PixelShader: {
  67224. name: string;
  67225. shader: string;
  67226. };
  67227. }
  67228. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  67229. /** @hidden */
  67230. export var ssaoCombinePixelShader: {
  67231. name: string;
  67232. shader: string;
  67233. };
  67234. }
  67235. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  67236. import { Camera } from "babylonjs/Cameras/camera";
  67237. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67238. import { Scene } from "babylonjs/scene";
  67239. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67240. import "babylonjs/Shaders/ssao2.fragment";
  67241. import "babylonjs/Shaders/ssaoCombine.fragment";
  67242. /**
  67243. * Render pipeline to produce ssao effect
  67244. */
  67245. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67246. /**
  67247. * @ignore
  67248. * The PassPostProcess id in the pipeline that contains the original scene color
  67249. */
  67250. SSAOOriginalSceneColorEffect: string;
  67251. /**
  67252. * @ignore
  67253. * The SSAO PostProcess id in the pipeline
  67254. */
  67255. SSAORenderEffect: string;
  67256. /**
  67257. * @ignore
  67258. * The horizontal blur PostProcess id in the pipeline
  67259. */
  67260. SSAOBlurHRenderEffect: string;
  67261. /**
  67262. * @ignore
  67263. * The vertical blur PostProcess id in the pipeline
  67264. */
  67265. SSAOBlurVRenderEffect: string;
  67266. /**
  67267. * @ignore
  67268. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67269. */
  67270. SSAOCombineRenderEffect: string;
  67271. /**
  67272. * The output strength of the SSAO post-process. Default value is 1.0.
  67273. */
  67274. totalStrength: number;
  67275. /**
  67276. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67277. */
  67278. maxZ: number;
  67279. /**
  67280. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67281. */
  67282. minZAspect: number;
  67283. private _samples;
  67284. /**
  67285. * Number of samples used for the SSAO calculations. Default value is 8
  67286. */
  67287. set samples(n: number);
  67288. get samples(): number;
  67289. private _textureSamples;
  67290. /**
  67291. * Number of samples to use for antialiasing
  67292. */
  67293. set textureSamples(n: number);
  67294. get textureSamples(): number;
  67295. /**
  67296. * Ratio object used for SSAO ratio and blur ratio
  67297. */
  67298. private _ratio;
  67299. /**
  67300. * Dynamically generated sphere sampler.
  67301. */
  67302. private _sampleSphere;
  67303. /**
  67304. * Blur filter offsets
  67305. */
  67306. private _samplerOffsets;
  67307. private _expensiveBlur;
  67308. /**
  67309. * If bilateral blur should be used
  67310. */
  67311. set expensiveBlur(b: boolean);
  67312. get expensiveBlur(): boolean;
  67313. /**
  67314. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67315. */
  67316. radius: number;
  67317. /**
  67318. * The base color of the SSAO post-process
  67319. * The final result is "base + ssao" between [0, 1]
  67320. */
  67321. base: number;
  67322. /**
  67323. * Support test.
  67324. */
  67325. static get IsSupported(): boolean;
  67326. private _scene;
  67327. private _depthTexture;
  67328. private _normalTexture;
  67329. private _randomTexture;
  67330. private _originalColorPostProcess;
  67331. private _ssaoPostProcess;
  67332. private _blurHPostProcess;
  67333. private _blurVPostProcess;
  67334. private _ssaoCombinePostProcess;
  67335. /**
  67336. * Gets active scene
  67337. */
  67338. get scene(): Scene;
  67339. /**
  67340. * @constructor
  67341. * @param name The rendering pipeline name
  67342. * @param scene The scene linked to this pipeline
  67343. * @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 }
  67344. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67345. */
  67346. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67347. /**
  67348. * Get the class name
  67349. * @returns "SSAO2RenderingPipeline"
  67350. */
  67351. getClassName(): string;
  67352. /**
  67353. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67354. */
  67355. dispose(disableGeometryBufferRenderer?: boolean): void;
  67356. private _createBlurPostProcess;
  67357. /** @hidden */
  67358. _rebuild(): void;
  67359. private _bits;
  67360. private _radicalInverse_VdC;
  67361. private _hammersley;
  67362. private _hemisphereSample_uniform;
  67363. private _generateHemisphere;
  67364. private _createSSAOPostProcess;
  67365. private _createSSAOCombinePostProcess;
  67366. private _createRandomTexture;
  67367. /**
  67368. * Serialize the rendering pipeline (Used when exporting)
  67369. * @returns the serialized object
  67370. */
  67371. serialize(): any;
  67372. /**
  67373. * Parse the serialized pipeline
  67374. * @param source Source pipeline.
  67375. * @param scene The scene to load the pipeline to.
  67376. * @param rootUrl The URL of the serialized pipeline.
  67377. * @returns An instantiated pipeline from the serialized object.
  67378. */
  67379. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  67380. }
  67381. }
  67382. declare module "babylonjs/Shaders/ssao.fragment" {
  67383. /** @hidden */
  67384. export var ssaoPixelShader: {
  67385. name: string;
  67386. shader: string;
  67387. };
  67388. }
  67389. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  67390. import { Camera } from "babylonjs/Cameras/camera";
  67391. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67392. import { Scene } from "babylonjs/scene";
  67393. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67394. import "babylonjs/Shaders/ssao.fragment";
  67395. import "babylonjs/Shaders/ssaoCombine.fragment";
  67396. /**
  67397. * Render pipeline to produce ssao effect
  67398. */
  67399. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  67400. /**
  67401. * @ignore
  67402. * The PassPostProcess id in the pipeline that contains the original scene color
  67403. */
  67404. SSAOOriginalSceneColorEffect: string;
  67405. /**
  67406. * @ignore
  67407. * The SSAO PostProcess id in the pipeline
  67408. */
  67409. SSAORenderEffect: string;
  67410. /**
  67411. * @ignore
  67412. * The horizontal blur PostProcess id in the pipeline
  67413. */
  67414. SSAOBlurHRenderEffect: string;
  67415. /**
  67416. * @ignore
  67417. * The vertical blur PostProcess id in the pipeline
  67418. */
  67419. SSAOBlurVRenderEffect: string;
  67420. /**
  67421. * @ignore
  67422. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67423. */
  67424. SSAOCombineRenderEffect: string;
  67425. /**
  67426. * The output strength of the SSAO post-process. Default value is 1.0.
  67427. */
  67428. totalStrength: number;
  67429. /**
  67430. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  67431. */
  67432. radius: number;
  67433. /**
  67434. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  67435. * Must not be equal to fallOff and superior to fallOff.
  67436. * Default value is 0.0075
  67437. */
  67438. area: number;
  67439. /**
  67440. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  67441. * Must not be equal to area and inferior to area.
  67442. * Default value is 0.000001
  67443. */
  67444. fallOff: number;
  67445. /**
  67446. * The base color of the SSAO post-process
  67447. * The final result is "base + ssao" between [0, 1]
  67448. */
  67449. base: number;
  67450. private _scene;
  67451. private _depthTexture;
  67452. private _randomTexture;
  67453. private _originalColorPostProcess;
  67454. private _ssaoPostProcess;
  67455. private _blurHPostProcess;
  67456. private _blurVPostProcess;
  67457. private _ssaoCombinePostProcess;
  67458. private _firstUpdate;
  67459. /**
  67460. * Gets active scene
  67461. */
  67462. get scene(): Scene;
  67463. /**
  67464. * @constructor
  67465. * @param name - The rendering pipeline name
  67466. * @param scene - The scene linked to this pipeline
  67467. * @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 }
  67468. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  67469. */
  67470. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67471. /**
  67472. * Get the class name
  67473. * @returns "SSAORenderingPipeline"
  67474. */
  67475. getClassName(): string;
  67476. /**
  67477. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67478. */
  67479. dispose(disableDepthRender?: boolean): void;
  67480. private _createBlurPostProcess;
  67481. /** @hidden */
  67482. _rebuild(): void;
  67483. private _createSSAOPostProcess;
  67484. private _createSSAOCombinePostProcess;
  67485. private _createRandomTexture;
  67486. }
  67487. }
  67488. declare module "babylonjs/Shaders/standard.fragment" {
  67489. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  67490. /** @hidden */
  67491. export var standardPixelShader: {
  67492. name: string;
  67493. shader: string;
  67494. };
  67495. }
  67496. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  67497. import { Nullable } from "babylonjs/types";
  67498. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67499. import { Camera } from "babylonjs/Cameras/camera";
  67500. import { Texture } from "babylonjs/Materials/Textures/texture";
  67501. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67502. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67503. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67504. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  67505. import { IDisposable } from "babylonjs/scene";
  67506. import { SpotLight } from "babylonjs/Lights/spotLight";
  67507. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  67508. import { Scene } from "babylonjs/scene";
  67509. import { Animation } from "babylonjs/Animations/animation";
  67510. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67511. import "babylonjs/Shaders/standard.fragment";
  67512. /**
  67513. * Standard rendering pipeline
  67514. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67515. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  67516. */
  67517. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67518. /**
  67519. * Public members
  67520. */
  67521. /**
  67522. * Post-process which contains the original scene color before the pipeline applies all the effects
  67523. */
  67524. originalPostProcess: Nullable<PostProcess>;
  67525. /**
  67526. * Post-process used to down scale an image x4
  67527. */
  67528. downSampleX4PostProcess: Nullable<PostProcess>;
  67529. /**
  67530. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  67531. */
  67532. brightPassPostProcess: Nullable<PostProcess>;
  67533. /**
  67534. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  67535. */
  67536. blurHPostProcesses: PostProcess[];
  67537. /**
  67538. * Post-process array storing all the vertical blur post-processes used by the pipeline
  67539. */
  67540. blurVPostProcesses: PostProcess[];
  67541. /**
  67542. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  67543. */
  67544. textureAdderPostProcess: Nullable<PostProcess>;
  67545. /**
  67546. * Post-process used to create volumetric lighting effect
  67547. */
  67548. volumetricLightPostProcess: Nullable<PostProcess>;
  67549. /**
  67550. * Post-process used to smooth the previous volumetric light post-process on the X axis
  67551. */
  67552. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  67553. /**
  67554. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  67555. */
  67556. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  67557. /**
  67558. * Post-process used to merge the volumetric light effect and the real scene color
  67559. */
  67560. volumetricLightMergePostProces: Nullable<PostProcess>;
  67561. /**
  67562. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  67563. */
  67564. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  67565. /**
  67566. * Base post-process used to calculate the average luminance of the final image for HDR
  67567. */
  67568. luminancePostProcess: Nullable<PostProcess>;
  67569. /**
  67570. * Post-processes used to create down sample post-processes in order to get
  67571. * the average luminance of the final image for HDR
  67572. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  67573. */
  67574. luminanceDownSamplePostProcesses: PostProcess[];
  67575. /**
  67576. * Post-process used to create a HDR effect (light adaptation)
  67577. */
  67578. hdrPostProcess: Nullable<PostProcess>;
  67579. /**
  67580. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  67581. */
  67582. textureAdderFinalPostProcess: Nullable<PostProcess>;
  67583. /**
  67584. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  67585. */
  67586. lensFlareFinalPostProcess: Nullable<PostProcess>;
  67587. /**
  67588. * Post-process used to merge the final HDR post-process and the real scene color
  67589. */
  67590. hdrFinalPostProcess: Nullable<PostProcess>;
  67591. /**
  67592. * Post-process used to create a lens flare effect
  67593. */
  67594. lensFlarePostProcess: Nullable<PostProcess>;
  67595. /**
  67596. * Post-process that merges the result of the lens flare post-process and the real scene color
  67597. */
  67598. lensFlareComposePostProcess: Nullable<PostProcess>;
  67599. /**
  67600. * Post-process used to create a motion blur effect
  67601. */
  67602. motionBlurPostProcess: Nullable<PostProcess>;
  67603. /**
  67604. * Post-process used to create a depth of field effect
  67605. */
  67606. depthOfFieldPostProcess: Nullable<PostProcess>;
  67607. /**
  67608. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67609. */
  67610. fxaaPostProcess: Nullable<FxaaPostProcess>;
  67611. /**
  67612. * Represents the brightness threshold in order to configure the illuminated surfaces
  67613. */
  67614. brightThreshold: number;
  67615. /**
  67616. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  67617. */
  67618. blurWidth: number;
  67619. /**
  67620. * Sets if the blur for highlighted surfaces must be only horizontal
  67621. */
  67622. horizontalBlur: boolean;
  67623. /**
  67624. * Gets the overall exposure used by the pipeline
  67625. */
  67626. get exposure(): number;
  67627. /**
  67628. * Sets the overall exposure used by the pipeline
  67629. */
  67630. set exposure(value: number);
  67631. /**
  67632. * Texture used typically to simulate "dirty" on camera lens
  67633. */
  67634. lensTexture: Nullable<Texture>;
  67635. /**
  67636. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  67637. */
  67638. volumetricLightCoefficient: number;
  67639. /**
  67640. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  67641. */
  67642. volumetricLightPower: number;
  67643. /**
  67644. * Used the set the blur intensity to smooth the volumetric lights
  67645. */
  67646. volumetricLightBlurScale: number;
  67647. /**
  67648. * Light (spot or directional) used to generate the volumetric lights rays
  67649. * The source light must have a shadow generate so the pipeline can get its
  67650. * depth map
  67651. */
  67652. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67653. /**
  67654. * For eye adaptation, represents the minimum luminance the eye can see
  67655. */
  67656. hdrMinimumLuminance: number;
  67657. /**
  67658. * For eye adaptation, represents the decrease luminance speed
  67659. */
  67660. hdrDecreaseRate: number;
  67661. /**
  67662. * For eye adaptation, represents the increase luminance speed
  67663. */
  67664. hdrIncreaseRate: number;
  67665. /**
  67666. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67667. */
  67668. get hdrAutoExposure(): boolean;
  67669. /**
  67670. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67671. */
  67672. set hdrAutoExposure(value: boolean);
  67673. /**
  67674. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67675. */
  67676. lensColorTexture: Nullable<Texture>;
  67677. /**
  67678. * The overall strengh for the lens flare effect
  67679. */
  67680. lensFlareStrength: number;
  67681. /**
  67682. * Dispersion coefficient for lens flare ghosts
  67683. */
  67684. lensFlareGhostDispersal: number;
  67685. /**
  67686. * Main lens flare halo width
  67687. */
  67688. lensFlareHaloWidth: number;
  67689. /**
  67690. * Based on the lens distortion effect, defines how much the lens flare result
  67691. * is distorted
  67692. */
  67693. lensFlareDistortionStrength: number;
  67694. /**
  67695. * Configures the blur intensity used for for lens flare (halo)
  67696. */
  67697. lensFlareBlurWidth: number;
  67698. /**
  67699. * Lens star texture must be used to simulate rays on the flares and is available
  67700. * in the documentation
  67701. */
  67702. lensStarTexture: Nullable<Texture>;
  67703. /**
  67704. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67705. * flare effect by taking account of the dirt texture
  67706. */
  67707. lensFlareDirtTexture: Nullable<Texture>;
  67708. /**
  67709. * Represents the focal length for the depth of field effect
  67710. */
  67711. depthOfFieldDistance: number;
  67712. /**
  67713. * Represents the blur intensity for the blurred part of the depth of field effect
  67714. */
  67715. depthOfFieldBlurWidth: number;
  67716. /**
  67717. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67718. */
  67719. get motionStrength(): number;
  67720. /**
  67721. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67722. */
  67723. set motionStrength(strength: number);
  67724. /**
  67725. * Gets wether or not the motion blur post-process is object based or screen based.
  67726. */
  67727. get objectBasedMotionBlur(): boolean;
  67728. /**
  67729. * Sets wether or not the motion blur post-process should be object based or screen based
  67730. */
  67731. set objectBasedMotionBlur(value: boolean);
  67732. /**
  67733. * List of animations for the pipeline (IAnimatable implementation)
  67734. */
  67735. animations: Animation[];
  67736. /**
  67737. * Private members
  67738. */
  67739. private _scene;
  67740. private _currentDepthOfFieldSource;
  67741. private _basePostProcess;
  67742. private _fixedExposure;
  67743. private _currentExposure;
  67744. private _hdrAutoExposure;
  67745. private _hdrCurrentLuminance;
  67746. private _motionStrength;
  67747. private _isObjectBasedMotionBlur;
  67748. private _floatTextureType;
  67749. private _camerasToBeAttached;
  67750. private _ratio;
  67751. private _bloomEnabled;
  67752. private _depthOfFieldEnabled;
  67753. private _vlsEnabled;
  67754. private _lensFlareEnabled;
  67755. private _hdrEnabled;
  67756. private _motionBlurEnabled;
  67757. private _fxaaEnabled;
  67758. private _motionBlurSamples;
  67759. private _volumetricLightStepsCount;
  67760. private _samples;
  67761. /**
  67762. * @ignore
  67763. * Specifies if the bloom pipeline is enabled
  67764. */
  67765. get BloomEnabled(): boolean;
  67766. set BloomEnabled(enabled: boolean);
  67767. /**
  67768. * @ignore
  67769. * Specifies if the depth of field pipeline is enabed
  67770. */
  67771. get DepthOfFieldEnabled(): boolean;
  67772. set DepthOfFieldEnabled(enabled: boolean);
  67773. /**
  67774. * @ignore
  67775. * Specifies if the lens flare pipeline is enabed
  67776. */
  67777. get LensFlareEnabled(): boolean;
  67778. set LensFlareEnabled(enabled: boolean);
  67779. /**
  67780. * @ignore
  67781. * Specifies if the HDR pipeline is enabled
  67782. */
  67783. get HDREnabled(): boolean;
  67784. set HDREnabled(enabled: boolean);
  67785. /**
  67786. * @ignore
  67787. * Specifies if the volumetric lights scattering effect is enabled
  67788. */
  67789. get VLSEnabled(): boolean;
  67790. set VLSEnabled(enabled: boolean);
  67791. /**
  67792. * @ignore
  67793. * Specifies if the motion blur effect is enabled
  67794. */
  67795. get MotionBlurEnabled(): boolean;
  67796. set MotionBlurEnabled(enabled: boolean);
  67797. /**
  67798. * Specifies if anti-aliasing is enabled
  67799. */
  67800. get fxaaEnabled(): boolean;
  67801. set fxaaEnabled(enabled: boolean);
  67802. /**
  67803. * Specifies the number of steps used to calculate the volumetric lights
  67804. * Typically in interval [50, 200]
  67805. */
  67806. get volumetricLightStepsCount(): number;
  67807. set volumetricLightStepsCount(count: number);
  67808. /**
  67809. * Specifies the number of samples used for the motion blur effect
  67810. * Typically in interval [16, 64]
  67811. */
  67812. get motionBlurSamples(): number;
  67813. set motionBlurSamples(samples: number);
  67814. /**
  67815. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67816. */
  67817. get samples(): number;
  67818. set samples(sampleCount: number);
  67819. /**
  67820. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67821. * @constructor
  67822. * @param name The rendering pipeline name
  67823. * @param scene The scene linked to this pipeline
  67824. * @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)
  67825. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67826. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67827. */
  67828. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67829. private _buildPipeline;
  67830. private _createDownSampleX4PostProcess;
  67831. private _createBrightPassPostProcess;
  67832. private _createBlurPostProcesses;
  67833. private _createTextureAdderPostProcess;
  67834. private _createVolumetricLightPostProcess;
  67835. private _createLuminancePostProcesses;
  67836. private _createHdrPostProcess;
  67837. private _createLensFlarePostProcess;
  67838. private _createDepthOfFieldPostProcess;
  67839. private _createMotionBlurPostProcess;
  67840. private _getDepthTexture;
  67841. private _disposePostProcesses;
  67842. /**
  67843. * Dispose of the pipeline and stop all post processes
  67844. */
  67845. dispose(): void;
  67846. /**
  67847. * Serialize the rendering pipeline (Used when exporting)
  67848. * @returns the serialized object
  67849. */
  67850. serialize(): any;
  67851. /**
  67852. * Parse the serialized pipeline
  67853. * @param source Source pipeline.
  67854. * @param scene The scene to load the pipeline to.
  67855. * @param rootUrl The URL of the serialized pipeline.
  67856. * @returns An instantiated pipeline from the serialized object.
  67857. */
  67858. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67859. /**
  67860. * Luminance steps
  67861. */
  67862. static LuminanceSteps: number;
  67863. }
  67864. }
  67865. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  67866. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  67867. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  67868. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  67869. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  67870. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  67871. }
  67872. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  67873. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  67874. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67875. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67876. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  67877. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67878. }
  67879. declare module "babylonjs/Shaders/tonemap.fragment" {
  67880. /** @hidden */
  67881. export var tonemapPixelShader: {
  67882. name: string;
  67883. shader: string;
  67884. };
  67885. }
  67886. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  67887. import { Camera } from "babylonjs/Cameras/camera";
  67888. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67889. import "babylonjs/Shaders/tonemap.fragment";
  67890. import { Engine } from "babylonjs/Engines/engine";
  67891. /** Defines operator used for tonemapping */
  67892. export enum TonemappingOperator {
  67893. /** Hable */
  67894. Hable = 0,
  67895. /** Reinhard */
  67896. Reinhard = 1,
  67897. /** HejiDawson */
  67898. HejiDawson = 2,
  67899. /** Photographic */
  67900. Photographic = 3
  67901. }
  67902. /**
  67903. * Defines a post process to apply tone mapping
  67904. */
  67905. export class TonemapPostProcess extends PostProcess {
  67906. private _operator;
  67907. /** Defines the required exposure adjustement */
  67908. exposureAdjustment: number;
  67909. /**
  67910. * Creates a new TonemapPostProcess
  67911. * @param name defines the name of the postprocess
  67912. * @param _operator defines the operator to use
  67913. * @param exposureAdjustment defines the required exposure adjustement
  67914. * @param camera defines the camera to use (can be null)
  67915. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67916. * @param engine defines the hosting engine (can be ignore if camera is set)
  67917. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67918. */
  67919. constructor(name: string, _operator: TonemappingOperator,
  67920. /** Defines the required exposure adjustement */
  67921. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67922. }
  67923. }
  67924. declare module "babylonjs/Shaders/depth.vertex" {
  67925. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67926. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67927. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67928. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67929. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67930. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67931. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67932. /** @hidden */
  67933. export var depthVertexShader: {
  67934. name: string;
  67935. shader: string;
  67936. };
  67937. }
  67938. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  67939. /** @hidden */
  67940. export var volumetricLightScatteringPixelShader: {
  67941. name: string;
  67942. shader: string;
  67943. };
  67944. }
  67945. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  67946. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67948. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67949. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67950. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67951. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67952. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67953. /** @hidden */
  67954. export var volumetricLightScatteringPassVertexShader: {
  67955. name: string;
  67956. shader: string;
  67957. };
  67958. }
  67959. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  67960. /** @hidden */
  67961. export var volumetricLightScatteringPassPixelShader: {
  67962. name: string;
  67963. shader: string;
  67964. };
  67965. }
  67966. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  67967. import { Vector3 } from "babylonjs/Maths/math.vector";
  67968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67969. import { Mesh } from "babylonjs/Meshes/mesh";
  67970. import { Camera } from "babylonjs/Cameras/camera";
  67971. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67972. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67973. import { Scene } from "babylonjs/scene";
  67974. import "babylonjs/Meshes/Builders/planeBuilder";
  67975. import "babylonjs/Shaders/depth.vertex";
  67976. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  67977. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  67978. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  67979. import { Engine } from "babylonjs/Engines/engine";
  67980. /**
  67981. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67982. */
  67983. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67984. private _volumetricLightScatteringPass;
  67985. private _volumetricLightScatteringRTT;
  67986. private _viewPort;
  67987. private _screenCoordinates;
  67988. private _cachedDefines;
  67989. /**
  67990. * If not undefined, the mesh position is computed from the attached node position
  67991. */
  67992. attachedNode: {
  67993. position: Vector3;
  67994. };
  67995. /**
  67996. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67997. */
  67998. customMeshPosition: Vector3;
  67999. /**
  68000. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  68001. */
  68002. useCustomMeshPosition: boolean;
  68003. /**
  68004. * If the post-process should inverse the light scattering direction
  68005. */
  68006. invert: boolean;
  68007. /**
  68008. * The internal mesh used by the post-process
  68009. */
  68010. mesh: Mesh;
  68011. /**
  68012. * @hidden
  68013. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  68014. */
  68015. get useDiffuseColor(): boolean;
  68016. set useDiffuseColor(useDiffuseColor: boolean);
  68017. /**
  68018. * Array containing the excluded meshes not rendered in the internal pass
  68019. */
  68020. excludedMeshes: AbstractMesh[];
  68021. /**
  68022. * Controls the overall intensity of the post-process
  68023. */
  68024. exposure: number;
  68025. /**
  68026. * Dissipates each sample's contribution in range [0, 1]
  68027. */
  68028. decay: number;
  68029. /**
  68030. * Controls the overall intensity of each sample
  68031. */
  68032. weight: number;
  68033. /**
  68034. * Controls the density of each sample
  68035. */
  68036. density: number;
  68037. /**
  68038. * @constructor
  68039. * @param name The post-process name
  68040. * @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)
  68041. * @param camera The camera that the post-process will be attached to
  68042. * @param mesh The mesh used to create the light scattering
  68043. * @param samples The post-process quality, default 100
  68044. * @param samplingModeThe post-process filtering mode
  68045. * @param engine The babylon engine
  68046. * @param reusable If the post-process is reusable
  68047. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  68048. */
  68049. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  68050. /**
  68051. * Returns the string "VolumetricLightScatteringPostProcess"
  68052. * @returns "VolumetricLightScatteringPostProcess"
  68053. */
  68054. getClassName(): string;
  68055. private _isReady;
  68056. /**
  68057. * Sets the new light position for light scattering effect
  68058. * @param position The new custom light position
  68059. */
  68060. setCustomMeshPosition(position: Vector3): void;
  68061. /**
  68062. * Returns the light position for light scattering effect
  68063. * @return Vector3 The custom light position
  68064. */
  68065. getCustomMeshPosition(): Vector3;
  68066. /**
  68067. * Disposes the internal assets and detaches the post-process from the camera
  68068. */
  68069. dispose(camera: Camera): void;
  68070. /**
  68071. * Returns the render target texture used by the post-process
  68072. * @return the render target texture used by the post-process
  68073. */
  68074. getPass(): RenderTargetTexture;
  68075. private _meshExcluded;
  68076. private _createPass;
  68077. private _updateMeshScreenCoordinates;
  68078. /**
  68079. * Creates a default mesh for the Volumeric Light Scattering post-process
  68080. * @param name The mesh name
  68081. * @param scene The scene where to create the mesh
  68082. * @return the default mesh
  68083. */
  68084. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  68085. }
  68086. }
  68087. declare module "babylonjs/PostProcesses/index" {
  68088. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  68089. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  68090. export * from "babylonjs/PostProcesses/bloomEffect";
  68091. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  68092. export * from "babylonjs/PostProcesses/blurPostProcess";
  68093. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68094. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  68095. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  68096. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  68097. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68098. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  68099. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  68100. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  68101. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68102. export * from "babylonjs/PostProcesses/filterPostProcess";
  68103. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  68104. export * from "babylonjs/PostProcesses/grainPostProcess";
  68105. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  68106. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68107. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  68108. export * from "babylonjs/PostProcesses/passPostProcess";
  68109. export * from "babylonjs/PostProcesses/postProcess";
  68110. export * from "babylonjs/PostProcesses/postProcessManager";
  68111. export * from "babylonjs/PostProcesses/refractionPostProcess";
  68112. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  68113. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  68114. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  68115. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  68116. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  68117. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  68118. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  68119. }
  68120. declare module "babylonjs/Probes/index" {
  68121. export * from "babylonjs/Probes/reflectionProbe";
  68122. }
  68123. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  68124. import { Scene } from "babylonjs/scene";
  68125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68126. import { SmartArray } from "babylonjs/Misc/smartArray";
  68127. import { ISceneComponent } from "babylonjs/sceneComponent";
  68128. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  68129. import "babylonjs/Meshes/Builders/boxBuilder";
  68130. import "babylonjs/Shaders/color.fragment";
  68131. import "babylonjs/Shaders/color.vertex";
  68132. import { Color3 } from "babylonjs/Maths/math.color";
  68133. module "babylonjs/scene" {
  68134. interface Scene {
  68135. /** @hidden (Backing field) */
  68136. _boundingBoxRenderer: BoundingBoxRenderer;
  68137. /** @hidden (Backing field) */
  68138. _forceShowBoundingBoxes: boolean;
  68139. /**
  68140. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68141. */
  68142. forceShowBoundingBoxes: boolean;
  68143. /**
  68144. * Gets the bounding box renderer associated with the scene
  68145. * @returns a BoundingBoxRenderer
  68146. */
  68147. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68148. }
  68149. }
  68150. module "babylonjs/Meshes/abstractMesh" {
  68151. interface AbstractMesh {
  68152. /** @hidden (Backing field) */
  68153. _showBoundingBox: boolean;
  68154. /**
  68155. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68156. */
  68157. showBoundingBox: boolean;
  68158. }
  68159. }
  68160. /**
  68161. * Component responsible of rendering the bounding box of the meshes in a scene.
  68162. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68163. */
  68164. export class BoundingBoxRenderer implements ISceneComponent {
  68165. /**
  68166. * The component name helpfull to identify the component in the list of scene components.
  68167. */
  68168. readonly name: string;
  68169. /**
  68170. * The scene the component belongs to.
  68171. */
  68172. scene: Scene;
  68173. /**
  68174. * Color of the bounding box lines placed in front of an object
  68175. */
  68176. frontColor: Color3;
  68177. /**
  68178. * Color of the bounding box lines placed behind an object
  68179. */
  68180. backColor: Color3;
  68181. /**
  68182. * Defines if the renderer should show the back lines or not
  68183. */
  68184. showBackLines: boolean;
  68185. /**
  68186. * @hidden
  68187. */
  68188. renderList: SmartArray<BoundingBox>;
  68189. private _colorShader;
  68190. private _vertexBuffers;
  68191. private _indexBuffer;
  68192. private _fillIndexBuffer;
  68193. private _fillIndexData;
  68194. /**
  68195. * Instantiates a new bounding box renderer in a scene.
  68196. * @param scene the scene the renderer renders in
  68197. */
  68198. constructor(scene: Scene);
  68199. /**
  68200. * Registers the component in a given scene
  68201. */
  68202. register(): void;
  68203. private _evaluateSubMesh;
  68204. private _activeMesh;
  68205. private _prepareRessources;
  68206. private _createIndexBuffer;
  68207. /**
  68208. * Rebuilds the elements related to this component in case of
  68209. * context lost for instance.
  68210. */
  68211. rebuild(): void;
  68212. /**
  68213. * @hidden
  68214. */
  68215. reset(): void;
  68216. /**
  68217. * Render the bounding boxes of a specific rendering group
  68218. * @param renderingGroupId defines the rendering group to render
  68219. */
  68220. render(renderingGroupId: number): void;
  68221. /**
  68222. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68223. * @param mesh Define the mesh to render the occlusion bounding box for
  68224. */
  68225. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68226. /**
  68227. * Dispose and release the resources attached to this renderer.
  68228. */
  68229. dispose(): void;
  68230. }
  68231. }
  68232. declare module "babylonjs/Shaders/depth.fragment" {
  68233. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68234. /** @hidden */
  68235. export var depthPixelShader: {
  68236. name: string;
  68237. shader: string;
  68238. };
  68239. }
  68240. declare module "babylonjs/Rendering/depthRenderer" {
  68241. import { Nullable } from "babylonjs/types";
  68242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68243. import { Scene } from "babylonjs/scene";
  68244. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68245. import { Camera } from "babylonjs/Cameras/camera";
  68246. import "babylonjs/Shaders/depth.fragment";
  68247. import "babylonjs/Shaders/depth.vertex";
  68248. /**
  68249. * This represents a depth renderer in Babylon.
  68250. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  68251. */
  68252. export class DepthRenderer {
  68253. private _scene;
  68254. private _depthMap;
  68255. private _effect;
  68256. private readonly _storeNonLinearDepth;
  68257. private readonly _clearColor;
  68258. /** Get if the depth renderer is using packed depth or not */
  68259. readonly isPacked: boolean;
  68260. private _cachedDefines;
  68261. private _camera;
  68262. /**
  68263. * Specifiess that the depth renderer will only be used within
  68264. * the camera it is created for.
  68265. * This can help forcing its rendering during the camera processing.
  68266. */
  68267. useOnlyInActiveCamera: boolean;
  68268. /** @hidden */
  68269. static _SceneComponentInitialization: (scene: Scene) => void;
  68270. /**
  68271. * Instantiates a depth renderer
  68272. * @param scene The scene the renderer belongs to
  68273. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  68274. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  68275. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68276. */
  68277. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  68278. /**
  68279. * Creates the depth rendering effect and checks if the effect is ready.
  68280. * @param subMesh The submesh to be used to render the depth map of
  68281. * @param useInstances If multiple world instances should be used
  68282. * @returns if the depth renderer is ready to render the depth map
  68283. */
  68284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68285. /**
  68286. * Gets the texture which the depth map will be written to.
  68287. * @returns The depth map texture
  68288. */
  68289. getDepthMap(): RenderTargetTexture;
  68290. /**
  68291. * Disposes of the depth renderer.
  68292. */
  68293. dispose(): void;
  68294. }
  68295. }
  68296. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  68297. import { Nullable } from "babylonjs/types";
  68298. import { Scene } from "babylonjs/scene";
  68299. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  68300. import { Camera } from "babylonjs/Cameras/camera";
  68301. import { ISceneComponent } from "babylonjs/sceneComponent";
  68302. module "babylonjs/scene" {
  68303. interface Scene {
  68304. /** @hidden (Backing field) */
  68305. _depthRenderer: {
  68306. [id: string]: DepthRenderer;
  68307. };
  68308. /**
  68309. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68310. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68311. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68312. * @returns the created depth renderer
  68313. */
  68314. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68315. /**
  68316. * Disables a depth renderer for a given camera
  68317. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68318. */
  68319. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68320. }
  68321. }
  68322. /**
  68323. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68324. * in several rendering techniques.
  68325. */
  68326. export class DepthRendererSceneComponent implements ISceneComponent {
  68327. /**
  68328. * The component name helpfull to identify the component in the list of scene components.
  68329. */
  68330. readonly name: string;
  68331. /**
  68332. * The scene the component belongs to.
  68333. */
  68334. scene: Scene;
  68335. /**
  68336. * Creates a new instance of the component for the given scene
  68337. * @param scene Defines the scene to register the component in
  68338. */
  68339. constructor(scene: Scene);
  68340. /**
  68341. * Registers the component in a given scene
  68342. */
  68343. register(): void;
  68344. /**
  68345. * Rebuilds the elements related to this component in case of
  68346. * context lost for instance.
  68347. */
  68348. rebuild(): void;
  68349. /**
  68350. * Disposes the component and the associated ressources
  68351. */
  68352. dispose(): void;
  68353. private _gatherRenderTargets;
  68354. private _gatherActiveCameraRenderTargets;
  68355. }
  68356. }
  68357. declare module "babylonjs/Shaders/outline.fragment" {
  68358. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68359. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  68360. /** @hidden */
  68361. export var outlinePixelShader: {
  68362. name: string;
  68363. shader: string;
  68364. };
  68365. }
  68366. declare module "babylonjs/Shaders/outline.vertex" {
  68367. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68368. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68369. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68370. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68371. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68372. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68373. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68374. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68375. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  68376. /** @hidden */
  68377. export var outlineVertexShader: {
  68378. name: string;
  68379. shader: string;
  68380. };
  68381. }
  68382. declare module "babylonjs/Rendering/outlineRenderer" {
  68383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68384. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  68385. import { Scene } from "babylonjs/scene";
  68386. import { ISceneComponent } from "babylonjs/sceneComponent";
  68387. import "babylonjs/Shaders/outline.fragment";
  68388. import "babylonjs/Shaders/outline.vertex";
  68389. module "babylonjs/scene" {
  68390. interface Scene {
  68391. /** @hidden */
  68392. _outlineRenderer: OutlineRenderer;
  68393. /**
  68394. * Gets the outline renderer associated with the scene
  68395. * @returns a OutlineRenderer
  68396. */
  68397. getOutlineRenderer(): OutlineRenderer;
  68398. }
  68399. }
  68400. module "babylonjs/Meshes/abstractMesh" {
  68401. interface AbstractMesh {
  68402. /** @hidden (Backing field) */
  68403. _renderOutline: boolean;
  68404. /**
  68405. * Gets or sets a boolean indicating if the outline must be rendered as well
  68406. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  68407. */
  68408. renderOutline: boolean;
  68409. /** @hidden (Backing field) */
  68410. _renderOverlay: boolean;
  68411. /**
  68412. * Gets or sets a boolean indicating if the overlay must be rendered as well
  68413. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  68414. */
  68415. renderOverlay: boolean;
  68416. }
  68417. }
  68418. /**
  68419. * This class is responsible to draw bothe outline/overlay of meshes.
  68420. * It should not be used directly but through the available method on mesh.
  68421. */
  68422. export class OutlineRenderer implements ISceneComponent {
  68423. /**
  68424. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  68425. */
  68426. private static _StencilReference;
  68427. /**
  68428. * The name of the component. Each component must have a unique name.
  68429. */
  68430. name: string;
  68431. /**
  68432. * The scene the component belongs to.
  68433. */
  68434. scene: Scene;
  68435. /**
  68436. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  68437. */
  68438. zOffset: number;
  68439. private _engine;
  68440. private _effect;
  68441. private _cachedDefines;
  68442. private _savedDepthWrite;
  68443. /**
  68444. * Instantiates a new outline renderer. (There could be only one per scene).
  68445. * @param scene Defines the scene it belongs to
  68446. */
  68447. constructor(scene: Scene);
  68448. /**
  68449. * Register the component to one instance of a scene.
  68450. */
  68451. register(): void;
  68452. /**
  68453. * Rebuilds the elements related to this component in case of
  68454. * context lost for instance.
  68455. */
  68456. rebuild(): void;
  68457. /**
  68458. * Disposes the component and the associated ressources.
  68459. */
  68460. dispose(): void;
  68461. /**
  68462. * Renders the outline in the canvas.
  68463. * @param subMesh Defines the sumesh to render
  68464. * @param batch Defines the batch of meshes in case of instances
  68465. * @param useOverlay Defines if the rendering is for the overlay or the outline
  68466. */
  68467. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  68468. /**
  68469. * Returns whether or not the outline renderer is ready for a given submesh.
  68470. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  68471. * @param subMesh Defines the submesh to check readyness for
  68472. * @param useInstances Defines wheter wee are trying to render instances or not
  68473. * @returns true if ready otherwise false
  68474. */
  68475. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68476. private _beforeRenderingMesh;
  68477. private _afterRenderingMesh;
  68478. }
  68479. }
  68480. declare module "babylonjs/Rendering/index" {
  68481. export * from "babylonjs/Rendering/boundingBoxRenderer";
  68482. export * from "babylonjs/Rendering/depthRenderer";
  68483. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  68484. export * from "babylonjs/Rendering/edgesRenderer";
  68485. export * from "babylonjs/Rendering/geometryBufferRenderer";
  68486. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68487. export * from "babylonjs/Rendering/outlineRenderer";
  68488. export * from "babylonjs/Rendering/renderingGroup";
  68489. export * from "babylonjs/Rendering/renderingManager";
  68490. export * from "babylonjs/Rendering/utilityLayerRenderer";
  68491. }
  68492. declare module "babylonjs/Sprites/ISprites" {
  68493. /**
  68494. * Defines the basic options interface of a Sprite Frame Source Size.
  68495. */
  68496. export interface ISpriteJSONSpriteSourceSize {
  68497. /**
  68498. * number of the original width of the Frame
  68499. */
  68500. w: number;
  68501. /**
  68502. * number of the original height of the Frame
  68503. */
  68504. h: number;
  68505. }
  68506. /**
  68507. * Defines the basic options interface of a Sprite Frame Data.
  68508. */
  68509. export interface ISpriteJSONSpriteFrameData {
  68510. /**
  68511. * number of the x offset of the Frame
  68512. */
  68513. x: number;
  68514. /**
  68515. * number of the y offset of the Frame
  68516. */
  68517. y: number;
  68518. /**
  68519. * number of the width of the Frame
  68520. */
  68521. w: number;
  68522. /**
  68523. * number of the height of the Frame
  68524. */
  68525. h: number;
  68526. }
  68527. /**
  68528. * Defines the basic options interface of a JSON Sprite.
  68529. */
  68530. export interface ISpriteJSONSprite {
  68531. /**
  68532. * string name of the Frame
  68533. */
  68534. filename: string;
  68535. /**
  68536. * ISpriteJSONSpriteFrame basic object of the frame data
  68537. */
  68538. frame: ISpriteJSONSpriteFrameData;
  68539. /**
  68540. * boolean to flag is the frame was rotated.
  68541. */
  68542. rotated: boolean;
  68543. /**
  68544. * boolean to flag is the frame was trimmed.
  68545. */
  68546. trimmed: boolean;
  68547. /**
  68548. * ISpriteJSONSpriteFrame basic object of the source data
  68549. */
  68550. spriteSourceSize: ISpriteJSONSpriteFrameData;
  68551. /**
  68552. * ISpriteJSONSpriteFrame basic object of the source data
  68553. */
  68554. sourceSize: ISpriteJSONSpriteSourceSize;
  68555. }
  68556. /**
  68557. * Defines the basic options interface of a JSON atlas.
  68558. */
  68559. export interface ISpriteJSONAtlas {
  68560. /**
  68561. * Array of objects that contain the frame data.
  68562. */
  68563. frames: Array<ISpriteJSONSprite>;
  68564. /**
  68565. * object basic object containing the sprite meta data.
  68566. */
  68567. meta?: object;
  68568. }
  68569. }
  68570. declare module "babylonjs/Shaders/spriteMap.fragment" {
  68571. /** @hidden */
  68572. export var spriteMapPixelShader: {
  68573. name: string;
  68574. shader: string;
  68575. };
  68576. }
  68577. declare module "babylonjs/Shaders/spriteMap.vertex" {
  68578. /** @hidden */
  68579. export var spriteMapVertexShader: {
  68580. name: string;
  68581. shader: string;
  68582. };
  68583. }
  68584. declare module "babylonjs/Sprites/spriteMap" {
  68585. import { IDisposable, Scene } from "babylonjs/scene";
  68586. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  68587. import { Texture } from "babylonjs/Materials/Textures/texture";
  68588. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68589. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  68590. import "babylonjs/Meshes/Builders/planeBuilder";
  68591. import "babylonjs/Shaders/spriteMap.fragment";
  68592. import "babylonjs/Shaders/spriteMap.vertex";
  68593. /**
  68594. * Defines the basic options interface of a SpriteMap
  68595. */
  68596. export interface ISpriteMapOptions {
  68597. /**
  68598. * Vector2 of the number of cells in the grid.
  68599. */
  68600. stageSize?: Vector2;
  68601. /**
  68602. * Vector2 of the size of the output plane in World Units.
  68603. */
  68604. outputSize?: Vector2;
  68605. /**
  68606. * Vector3 of the position of the output plane in World Units.
  68607. */
  68608. outputPosition?: Vector3;
  68609. /**
  68610. * Vector3 of the rotation of the output plane.
  68611. */
  68612. outputRotation?: Vector3;
  68613. /**
  68614. * number of layers that the system will reserve in resources.
  68615. */
  68616. layerCount?: number;
  68617. /**
  68618. * number of max animation frames a single cell will reserve in resources.
  68619. */
  68620. maxAnimationFrames?: number;
  68621. /**
  68622. * number cell index of the base tile when the system compiles.
  68623. */
  68624. baseTile?: number;
  68625. /**
  68626. * boolean flip the sprite after its been repositioned by the framing data.
  68627. */
  68628. flipU?: boolean;
  68629. /**
  68630. * Vector3 scalar of the global RGB values of the SpriteMap.
  68631. */
  68632. colorMultiply?: Vector3;
  68633. }
  68634. /**
  68635. * Defines the IDisposable interface in order to be cleanable from resources.
  68636. */
  68637. export interface ISpriteMap extends IDisposable {
  68638. /**
  68639. * String name of the SpriteMap.
  68640. */
  68641. name: string;
  68642. /**
  68643. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  68644. */
  68645. atlasJSON: ISpriteJSONAtlas;
  68646. /**
  68647. * Texture of the SpriteMap.
  68648. */
  68649. spriteSheet: Texture;
  68650. /**
  68651. * The parameters to initialize the SpriteMap with.
  68652. */
  68653. options: ISpriteMapOptions;
  68654. }
  68655. /**
  68656. * Class used to manage a grid restricted sprite deployment on an Output plane.
  68657. */
  68658. export class SpriteMap implements ISpriteMap {
  68659. /** The Name of the spriteMap */
  68660. name: string;
  68661. /** The JSON file with the frame and meta data */
  68662. atlasJSON: ISpriteJSONAtlas;
  68663. /** The systems Sprite Sheet Texture */
  68664. spriteSheet: Texture;
  68665. /** Arguments passed with the Constructor */
  68666. options: ISpriteMapOptions;
  68667. /** Public Sprite Storage array, parsed from atlasJSON */
  68668. sprites: Array<ISpriteJSONSprite>;
  68669. /** Returns the Number of Sprites in the System */
  68670. get spriteCount(): number;
  68671. /** Returns the Position of Output Plane*/
  68672. get position(): Vector3;
  68673. /** Returns the Position of Output Plane*/
  68674. set position(v: Vector3);
  68675. /** Returns the Rotation of Output Plane*/
  68676. get rotation(): Vector3;
  68677. /** Returns the Rotation of Output Plane*/
  68678. set rotation(v: Vector3);
  68679. /** Sets the AnimationMap*/
  68680. get animationMap(): RawTexture;
  68681. /** Sets the AnimationMap*/
  68682. set animationMap(v: RawTexture);
  68683. /** Scene that the SpriteMap was created in */
  68684. private _scene;
  68685. /** Texture Buffer of Float32 that holds tile frame data*/
  68686. private _frameMap;
  68687. /** Texture Buffers of Float32 that holds tileMap data*/
  68688. private _tileMaps;
  68689. /** Texture Buffer of Float32 that holds Animation Data*/
  68690. private _animationMap;
  68691. /** Custom ShaderMaterial Central to the System*/
  68692. private _material;
  68693. /** Custom ShaderMaterial Central to the System*/
  68694. private _output;
  68695. /** Systems Time Ticker*/
  68696. private _time;
  68697. /**
  68698. * Creates a new SpriteMap
  68699. * @param name defines the SpriteMaps Name
  68700. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  68701. * @param spriteSheet is the Texture that the Sprites are on.
  68702. * @param options a basic deployment configuration
  68703. * @param scene The Scene that the map is deployed on
  68704. */
  68705. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  68706. /**
  68707. * Returns tileID location
  68708. * @returns Vector2 the cell position ID
  68709. */
  68710. getTileID(): Vector2;
  68711. /**
  68712. * Gets the UV location of the mouse over the SpriteMap.
  68713. * @returns Vector2 the UV position of the mouse interaction
  68714. */
  68715. getMousePosition(): Vector2;
  68716. /**
  68717. * Creates the "frame" texture Buffer
  68718. * -------------------------------------
  68719. * Structure of frames
  68720. * "filename": "Falling-Water-2.png",
  68721. * "frame": {"x":69,"y":103,"w":24,"h":32},
  68722. * "rotated": true,
  68723. * "trimmed": true,
  68724. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  68725. * "sourceSize": {"w":32,"h":32}
  68726. * @returns RawTexture of the frameMap
  68727. */
  68728. private _createFrameBuffer;
  68729. /**
  68730. * Creates the tileMap texture Buffer
  68731. * @param buffer normally and array of numbers, or a false to generate from scratch
  68732. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  68733. * @returns RawTexture of the tileMap
  68734. */
  68735. private _createTileBuffer;
  68736. /**
  68737. * Modifies the data of the tileMaps
  68738. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  68739. * @param pos is the iVector2 Coordinates of the Tile
  68740. * @param tile The SpriteIndex of the new Tile
  68741. */
  68742. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  68743. /**
  68744. * Creates the animationMap texture Buffer
  68745. * @param buffer normally and array of numbers, or a false to generate from scratch
  68746. * @returns RawTexture of the animationMap
  68747. */
  68748. private _createTileAnimationBuffer;
  68749. /**
  68750. * Modifies the data of the animationMap
  68751. * @param cellID is the Index of the Sprite
  68752. * @param _frame is the target Animation frame
  68753. * @param toCell is the Target Index of the next frame of the animation
  68754. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  68755. * @param speed is a global scalar of the time variable on the map.
  68756. */
  68757. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  68758. /**
  68759. * Exports the .tilemaps file
  68760. */
  68761. saveTileMaps(): void;
  68762. /**
  68763. * Imports the .tilemaps file
  68764. * @param url of the .tilemaps file
  68765. */
  68766. loadTileMaps(url: string): void;
  68767. /**
  68768. * Release associated resources
  68769. */
  68770. dispose(): void;
  68771. }
  68772. }
  68773. declare module "babylonjs/Sprites/spritePackedManager" {
  68774. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  68775. import { Scene } from "babylonjs/scene";
  68776. /**
  68777. * Class used to manage multiple sprites of different sizes on the same spritesheet
  68778. * @see http://doc.babylonjs.com/babylon101/sprites
  68779. */
  68780. export class SpritePackedManager extends SpriteManager {
  68781. /** defines the packed manager's name */
  68782. name: string;
  68783. /**
  68784. * Creates a new sprite manager from a packed sprite sheet
  68785. * @param name defines the manager's name
  68786. * @param imgUrl defines the sprite sheet url
  68787. * @param capacity defines the maximum allowed number of sprites
  68788. * @param scene defines the hosting scene
  68789. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  68790. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68791. * @param samplingMode defines the smapling mode to use with spritesheet
  68792. * @param fromPacked set to true; do not alter
  68793. */
  68794. constructor(
  68795. /** defines the packed manager's name */
  68796. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68797. }
  68798. }
  68799. declare module "babylonjs/Sprites/index" {
  68800. export * from "babylonjs/Sprites/sprite";
  68801. export * from "babylonjs/Sprites/ISprites";
  68802. export * from "babylonjs/Sprites/spriteManager";
  68803. export * from "babylonjs/Sprites/spriteMap";
  68804. export * from "babylonjs/Sprites/spritePackedManager";
  68805. export * from "babylonjs/Sprites/spriteSceneComponent";
  68806. }
  68807. declare module "babylonjs/States/index" {
  68808. export * from "babylonjs/States/alphaCullingState";
  68809. export * from "babylonjs/States/depthCullingState";
  68810. export * from "babylonjs/States/stencilState";
  68811. }
  68812. declare module "babylonjs/Misc/assetsManager" {
  68813. import { Scene } from "babylonjs/scene";
  68814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68815. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68816. import { Skeleton } from "babylonjs/Bones/skeleton";
  68817. import { Observable } from "babylonjs/Misc/observable";
  68818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68819. import { Texture } from "babylonjs/Materials/Textures/texture";
  68820. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  68821. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  68822. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  68823. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  68824. /**
  68825. * Defines the list of states available for a task inside a AssetsManager
  68826. */
  68827. export enum AssetTaskState {
  68828. /**
  68829. * Initialization
  68830. */
  68831. INIT = 0,
  68832. /**
  68833. * Running
  68834. */
  68835. RUNNING = 1,
  68836. /**
  68837. * Done
  68838. */
  68839. DONE = 2,
  68840. /**
  68841. * Error
  68842. */
  68843. ERROR = 3
  68844. }
  68845. /**
  68846. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68847. */
  68848. export abstract class AbstractAssetTask {
  68849. /**
  68850. * Task name
  68851. */ name: string;
  68852. /**
  68853. * Callback called when the task is successful
  68854. */
  68855. onSuccess: (task: any) => void;
  68856. /**
  68857. * Callback called when the task is not successful
  68858. */
  68859. onError: (task: any, message?: string, exception?: any) => void;
  68860. /**
  68861. * Creates a new AssetsManager
  68862. * @param name defines the name of the task
  68863. */
  68864. constructor(
  68865. /**
  68866. * Task name
  68867. */ name: string);
  68868. private _isCompleted;
  68869. private _taskState;
  68870. private _errorObject;
  68871. /**
  68872. * Get if the task is completed
  68873. */
  68874. get isCompleted(): boolean;
  68875. /**
  68876. * Gets the current state of the task
  68877. */
  68878. get taskState(): AssetTaskState;
  68879. /**
  68880. * Gets the current error object (if task is in error)
  68881. */
  68882. get errorObject(): {
  68883. message?: string;
  68884. exception?: any;
  68885. };
  68886. /**
  68887. * Internal only
  68888. * @hidden
  68889. */
  68890. _setErrorObject(message?: string, exception?: any): void;
  68891. /**
  68892. * Execute the current task
  68893. * @param scene defines the scene where you want your assets to be loaded
  68894. * @param onSuccess is a callback called when the task is successfully executed
  68895. * @param onError is a callback called if an error occurs
  68896. */
  68897. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68898. /**
  68899. * Execute the current task
  68900. * @param scene defines the scene where you want your assets to be loaded
  68901. * @param onSuccess is a callback called when the task is successfully executed
  68902. * @param onError is a callback called if an error occurs
  68903. */
  68904. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68905. /**
  68906. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68907. * This can be used with failed tasks that have the reason for failure fixed.
  68908. */
  68909. reset(): void;
  68910. private onErrorCallback;
  68911. private onDoneCallback;
  68912. }
  68913. /**
  68914. * Define the interface used by progress events raised during assets loading
  68915. */
  68916. export interface IAssetsProgressEvent {
  68917. /**
  68918. * Defines the number of remaining tasks to process
  68919. */
  68920. remainingCount: number;
  68921. /**
  68922. * Defines the total number of tasks
  68923. */
  68924. totalCount: number;
  68925. /**
  68926. * Defines the task that was just processed
  68927. */
  68928. task: AbstractAssetTask;
  68929. }
  68930. /**
  68931. * Class used to share progress information about assets loading
  68932. */
  68933. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68934. /**
  68935. * Defines the number of remaining tasks to process
  68936. */
  68937. remainingCount: number;
  68938. /**
  68939. * Defines the total number of tasks
  68940. */
  68941. totalCount: number;
  68942. /**
  68943. * Defines the task that was just processed
  68944. */
  68945. task: AbstractAssetTask;
  68946. /**
  68947. * Creates a AssetsProgressEvent
  68948. * @param remainingCount defines the number of remaining tasks to process
  68949. * @param totalCount defines the total number of tasks
  68950. * @param task defines the task that was just processed
  68951. */
  68952. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68953. }
  68954. /**
  68955. * Define a task used by AssetsManager to load meshes
  68956. */
  68957. export class MeshAssetTask extends AbstractAssetTask {
  68958. /**
  68959. * Defines the name of the task
  68960. */
  68961. name: string;
  68962. /**
  68963. * Defines the list of mesh's names you want to load
  68964. */
  68965. meshesNames: any;
  68966. /**
  68967. * Defines the root url to use as a base to load your meshes and associated resources
  68968. */
  68969. rootUrl: string;
  68970. /**
  68971. * Defines the filename of the scene to load from
  68972. */
  68973. sceneFilename: string;
  68974. /**
  68975. * Gets the list of loaded meshes
  68976. */
  68977. loadedMeshes: Array<AbstractMesh>;
  68978. /**
  68979. * Gets the list of loaded particle systems
  68980. */
  68981. loadedParticleSystems: Array<IParticleSystem>;
  68982. /**
  68983. * Gets the list of loaded skeletons
  68984. */
  68985. loadedSkeletons: Array<Skeleton>;
  68986. /**
  68987. * Gets the list of loaded animation groups
  68988. */
  68989. loadedAnimationGroups: Array<AnimationGroup>;
  68990. /**
  68991. * Callback called when the task is successful
  68992. */
  68993. onSuccess: (task: MeshAssetTask) => void;
  68994. /**
  68995. * Callback called when the task is successful
  68996. */
  68997. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68998. /**
  68999. * Creates a new MeshAssetTask
  69000. * @param name defines the name of the task
  69001. * @param meshesNames defines the list of mesh's names you want to load
  69002. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  69003. * @param sceneFilename defines the filename of the scene to load from
  69004. */
  69005. constructor(
  69006. /**
  69007. * Defines the name of the task
  69008. */
  69009. name: string,
  69010. /**
  69011. * Defines the list of mesh's names you want to load
  69012. */
  69013. meshesNames: any,
  69014. /**
  69015. * Defines the root url to use as a base to load your meshes and associated resources
  69016. */
  69017. rootUrl: string,
  69018. /**
  69019. * Defines the filename of the scene to load from
  69020. */
  69021. sceneFilename: string);
  69022. /**
  69023. * Execute the current task
  69024. * @param scene defines the scene where you want your assets to be loaded
  69025. * @param onSuccess is a callback called when the task is successfully executed
  69026. * @param onError is a callback called if an error occurs
  69027. */
  69028. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69029. }
  69030. /**
  69031. * Define a task used by AssetsManager to load text content
  69032. */
  69033. export class TextFileAssetTask extends AbstractAssetTask {
  69034. /**
  69035. * Defines the name of the task
  69036. */
  69037. name: string;
  69038. /**
  69039. * Defines the location of the file to load
  69040. */
  69041. url: string;
  69042. /**
  69043. * Gets the loaded text string
  69044. */
  69045. text: string;
  69046. /**
  69047. * Callback called when the task is successful
  69048. */
  69049. onSuccess: (task: TextFileAssetTask) => void;
  69050. /**
  69051. * Callback called when the task is successful
  69052. */
  69053. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  69054. /**
  69055. * Creates a new TextFileAssetTask object
  69056. * @param name defines the name of the task
  69057. * @param url defines the location of the file to load
  69058. */
  69059. constructor(
  69060. /**
  69061. * Defines the name of the task
  69062. */
  69063. name: string,
  69064. /**
  69065. * Defines the location of the file to load
  69066. */
  69067. url: string);
  69068. /**
  69069. * Execute the current task
  69070. * @param scene defines the scene where you want your assets to be loaded
  69071. * @param onSuccess is a callback called when the task is successfully executed
  69072. * @param onError is a callback called if an error occurs
  69073. */
  69074. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69075. }
  69076. /**
  69077. * Define a task used by AssetsManager to load binary data
  69078. */
  69079. export class BinaryFileAssetTask extends AbstractAssetTask {
  69080. /**
  69081. * Defines the name of the task
  69082. */
  69083. name: string;
  69084. /**
  69085. * Defines the location of the file to load
  69086. */
  69087. url: string;
  69088. /**
  69089. * Gets the lodaded data (as an array buffer)
  69090. */
  69091. data: ArrayBuffer;
  69092. /**
  69093. * Callback called when the task is successful
  69094. */
  69095. onSuccess: (task: BinaryFileAssetTask) => void;
  69096. /**
  69097. * Callback called when the task is successful
  69098. */
  69099. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69100. /**
  69101. * Creates a new BinaryFileAssetTask object
  69102. * @param name defines the name of the new task
  69103. * @param url defines the location of the file to load
  69104. */
  69105. constructor(
  69106. /**
  69107. * Defines the name of the task
  69108. */
  69109. name: string,
  69110. /**
  69111. * Defines the location of the file to load
  69112. */
  69113. url: string);
  69114. /**
  69115. * Execute the current task
  69116. * @param scene defines the scene where you want your assets to be loaded
  69117. * @param onSuccess is a callback called when the task is successfully executed
  69118. * @param onError is a callback called if an error occurs
  69119. */
  69120. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69121. }
  69122. /**
  69123. * Define a task used by AssetsManager to load images
  69124. */
  69125. export class ImageAssetTask extends AbstractAssetTask {
  69126. /**
  69127. * Defines the name of the task
  69128. */
  69129. name: string;
  69130. /**
  69131. * Defines the location of the image to load
  69132. */
  69133. url: string;
  69134. /**
  69135. * Gets the loaded images
  69136. */
  69137. image: HTMLImageElement;
  69138. /**
  69139. * Callback called when the task is successful
  69140. */
  69141. onSuccess: (task: ImageAssetTask) => void;
  69142. /**
  69143. * Callback called when the task is successful
  69144. */
  69145. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69146. /**
  69147. * Creates a new ImageAssetTask
  69148. * @param name defines the name of the task
  69149. * @param url defines the location of the image to load
  69150. */
  69151. constructor(
  69152. /**
  69153. * Defines the name of the task
  69154. */
  69155. name: string,
  69156. /**
  69157. * Defines the location of the image to load
  69158. */
  69159. url: string);
  69160. /**
  69161. * Execute the current task
  69162. * @param scene defines the scene where you want your assets to be loaded
  69163. * @param onSuccess is a callback called when the task is successfully executed
  69164. * @param onError is a callback called if an error occurs
  69165. */
  69166. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69167. }
  69168. /**
  69169. * Defines the interface used by texture loading tasks
  69170. */
  69171. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69172. /**
  69173. * Gets the loaded texture
  69174. */
  69175. texture: TEX;
  69176. }
  69177. /**
  69178. * Define a task used by AssetsManager to load 2D textures
  69179. */
  69180. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69181. /**
  69182. * Defines the name of the task
  69183. */
  69184. name: string;
  69185. /**
  69186. * Defines the location of the file to load
  69187. */
  69188. url: string;
  69189. /**
  69190. * Defines if mipmap should not be generated (default is false)
  69191. */
  69192. noMipmap?: boolean | undefined;
  69193. /**
  69194. * Defines if texture must be inverted on Y axis (default is false)
  69195. */
  69196. invertY?: boolean | undefined;
  69197. /**
  69198. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69199. */
  69200. samplingMode: number;
  69201. /**
  69202. * Gets the loaded texture
  69203. */
  69204. texture: Texture;
  69205. /**
  69206. * Callback called when the task is successful
  69207. */
  69208. onSuccess: (task: TextureAssetTask) => void;
  69209. /**
  69210. * Callback called when the task is successful
  69211. */
  69212. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69213. /**
  69214. * Creates a new TextureAssetTask object
  69215. * @param name defines the name of the task
  69216. * @param url defines the location of the file to load
  69217. * @param noMipmap defines if mipmap should not be generated (default is false)
  69218. * @param invertY defines if texture must be inverted on Y axis (default is false)
  69219. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69220. */
  69221. constructor(
  69222. /**
  69223. * Defines the name of the task
  69224. */
  69225. name: string,
  69226. /**
  69227. * Defines the location of the file to load
  69228. */
  69229. url: string,
  69230. /**
  69231. * Defines if mipmap should not be generated (default is false)
  69232. */
  69233. noMipmap?: boolean | undefined,
  69234. /**
  69235. * Defines if texture must be inverted on Y axis (default is false)
  69236. */
  69237. invertY?: boolean | undefined,
  69238. /**
  69239. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69240. */
  69241. samplingMode?: number);
  69242. /**
  69243. * Execute the current task
  69244. * @param scene defines the scene where you want your assets to be loaded
  69245. * @param onSuccess is a callback called when the task is successfully executed
  69246. * @param onError is a callback called if an error occurs
  69247. */
  69248. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69249. }
  69250. /**
  69251. * Define a task used by AssetsManager to load cube textures
  69252. */
  69253. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69254. /**
  69255. * Defines the name of the task
  69256. */
  69257. name: string;
  69258. /**
  69259. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69260. */
  69261. url: string;
  69262. /**
  69263. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69264. */
  69265. extensions?: string[] | undefined;
  69266. /**
  69267. * Defines if mipmaps should not be generated (default is false)
  69268. */
  69269. noMipmap?: boolean | undefined;
  69270. /**
  69271. * Defines the explicit list of files (undefined by default)
  69272. */
  69273. files?: string[] | undefined;
  69274. /**
  69275. * Gets the loaded texture
  69276. */
  69277. texture: CubeTexture;
  69278. /**
  69279. * Callback called when the task is successful
  69280. */
  69281. onSuccess: (task: CubeTextureAssetTask) => void;
  69282. /**
  69283. * Callback called when the task is successful
  69284. */
  69285. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69286. /**
  69287. * Creates a new CubeTextureAssetTask
  69288. * @param name defines the name of the task
  69289. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69290. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69291. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69292. * @param files defines the explicit list of files (undefined by default)
  69293. */
  69294. constructor(
  69295. /**
  69296. * Defines the name of the task
  69297. */
  69298. name: string,
  69299. /**
  69300. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69301. */
  69302. url: string,
  69303. /**
  69304. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69305. */
  69306. extensions?: string[] | undefined,
  69307. /**
  69308. * Defines if mipmaps should not be generated (default is false)
  69309. */
  69310. noMipmap?: boolean | undefined,
  69311. /**
  69312. * Defines the explicit list of files (undefined by default)
  69313. */
  69314. files?: string[] | undefined);
  69315. /**
  69316. * Execute the current task
  69317. * @param scene defines the scene where you want your assets to be loaded
  69318. * @param onSuccess is a callback called when the task is successfully executed
  69319. * @param onError is a callback called if an error occurs
  69320. */
  69321. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69322. }
  69323. /**
  69324. * Define a task used by AssetsManager to load HDR cube textures
  69325. */
  69326. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69327. /**
  69328. * Defines the name of the task
  69329. */
  69330. name: string;
  69331. /**
  69332. * Defines the location of the file to load
  69333. */
  69334. url: string;
  69335. /**
  69336. * Defines the desired size (the more it increases the longer the generation will be)
  69337. */
  69338. size: number;
  69339. /**
  69340. * Defines if mipmaps should not be generated (default is false)
  69341. */
  69342. noMipmap: boolean;
  69343. /**
  69344. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69345. */
  69346. generateHarmonics: boolean;
  69347. /**
  69348. * 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)
  69349. */
  69350. gammaSpace: boolean;
  69351. /**
  69352. * Internal Use Only
  69353. */
  69354. reserved: boolean;
  69355. /**
  69356. * Gets the loaded texture
  69357. */
  69358. texture: HDRCubeTexture;
  69359. /**
  69360. * Callback called when the task is successful
  69361. */
  69362. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69363. /**
  69364. * Callback called when the task is successful
  69365. */
  69366. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69367. /**
  69368. * Creates a new HDRCubeTextureAssetTask object
  69369. * @param name defines the name of the task
  69370. * @param url defines the location of the file to load
  69371. * @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.
  69372. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69373. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69374. * @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)
  69375. * @param reserved Internal use only
  69376. */
  69377. constructor(
  69378. /**
  69379. * Defines the name of the task
  69380. */
  69381. name: string,
  69382. /**
  69383. * Defines the location of the file to load
  69384. */
  69385. url: string,
  69386. /**
  69387. * Defines the desired size (the more it increases the longer the generation will be)
  69388. */
  69389. size: number,
  69390. /**
  69391. * Defines if mipmaps should not be generated (default is false)
  69392. */
  69393. noMipmap?: boolean,
  69394. /**
  69395. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69396. */
  69397. generateHarmonics?: boolean,
  69398. /**
  69399. * 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)
  69400. */
  69401. gammaSpace?: boolean,
  69402. /**
  69403. * Internal Use Only
  69404. */
  69405. reserved?: boolean);
  69406. /**
  69407. * Execute the current task
  69408. * @param scene defines the scene where you want your assets to be loaded
  69409. * @param onSuccess is a callback called when the task is successfully executed
  69410. * @param onError is a callback called if an error occurs
  69411. */
  69412. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69413. }
  69414. /**
  69415. * Define a task used by AssetsManager to load Equirectangular cube textures
  69416. */
  69417. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69418. /**
  69419. * Defines the name of the task
  69420. */
  69421. name: string;
  69422. /**
  69423. * Defines the location of the file to load
  69424. */
  69425. url: string;
  69426. /**
  69427. * Defines the desired size (the more it increases the longer the generation will be)
  69428. */
  69429. size: number;
  69430. /**
  69431. * Defines if mipmaps should not be generated (default is false)
  69432. */
  69433. noMipmap: boolean;
  69434. /**
  69435. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69436. * but the standard material would require them in Gamma space) (default is true)
  69437. */
  69438. gammaSpace: boolean;
  69439. /**
  69440. * Gets the loaded texture
  69441. */
  69442. texture: EquiRectangularCubeTexture;
  69443. /**
  69444. * Callback called when the task is successful
  69445. */
  69446. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  69447. /**
  69448. * Callback called when the task is successful
  69449. */
  69450. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  69451. /**
  69452. * Creates a new EquiRectangularCubeTextureAssetTask object
  69453. * @param name defines the name of the task
  69454. * @param url defines the location of the file to load
  69455. * @param size defines the desired size (the more it increases the longer the generation will be)
  69456. * If the size is omitted this implies you are using a preprocessed cubemap.
  69457. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69458. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  69459. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  69460. * (default is true)
  69461. */
  69462. constructor(
  69463. /**
  69464. * Defines the name of the task
  69465. */
  69466. name: string,
  69467. /**
  69468. * Defines the location of the file to load
  69469. */
  69470. url: string,
  69471. /**
  69472. * Defines the desired size (the more it increases the longer the generation will be)
  69473. */
  69474. size: number,
  69475. /**
  69476. * Defines if mipmaps should not be generated (default is false)
  69477. */
  69478. noMipmap?: boolean,
  69479. /**
  69480. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69481. * but the standard material would require them in Gamma space) (default is true)
  69482. */
  69483. gammaSpace?: boolean);
  69484. /**
  69485. * Execute the current task
  69486. * @param scene defines the scene where you want your assets to be loaded
  69487. * @param onSuccess is a callback called when the task is successfully executed
  69488. * @param onError is a callback called if an error occurs
  69489. */
  69490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69491. }
  69492. /**
  69493. * This class can be used to easily import assets into a scene
  69494. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  69495. */
  69496. export class AssetsManager {
  69497. private _scene;
  69498. private _isLoading;
  69499. protected _tasks: AbstractAssetTask[];
  69500. protected _waitingTasksCount: number;
  69501. protected _totalTasksCount: number;
  69502. /**
  69503. * Callback called when all tasks are processed
  69504. */
  69505. onFinish: (tasks: AbstractAssetTask[]) => void;
  69506. /**
  69507. * Callback called when a task is successful
  69508. */
  69509. onTaskSuccess: (task: AbstractAssetTask) => void;
  69510. /**
  69511. * Callback called when a task had an error
  69512. */
  69513. onTaskError: (task: AbstractAssetTask) => void;
  69514. /**
  69515. * Callback called when a task is done (whatever the result is)
  69516. */
  69517. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  69518. /**
  69519. * Observable called when all tasks are processed
  69520. */
  69521. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  69522. /**
  69523. * Observable called when a task had an error
  69524. */
  69525. onTaskErrorObservable: Observable<AbstractAssetTask>;
  69526. /**
  69527. * Observable called when all tasks were executed
  69528. */
  69529. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  69530. /**
  69531. * Observable called when a task is done (whatever the result is)
  69532. */
  69533. onProgressObservable: Observable<IAssetsProgressEvent>;
  69534. /**
  69535. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  69536. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  69537. */
  69538. useDefaultLoadingScreen: boolean;
  69539. /**
  69540. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  69541. * when all assets have been downloaded.
  69542. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  69543. */
  69544. autoHideLoadingUI: boolean;
  69545. /**
  69546. * Creates a new AssetsManager
  69547. * @param scene defines the scene to work on
  69548. */
  69549. constructor(scene: Scene);
  69550. /**
  69551. * Add a MeshAssetTask to the list of active tasks
  69552. * @param taskName defines the name of the new task
  69553. * @param meshesNames defines the name of meshes to load
  69554. * @param rootUrl defines the root url to use to locate files
  69555. * @param sceneFilename defines the filename of the scene file
  69556. * @returns a new MeshAssetTask object
  69557. */
  69558. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  69559. /**
  69560. * Add a TextFileAssetTask to the list of active tasks
  69561. * @param taskName defines the name of the new task
  69562. * @param url defines the url of the file to load
  69563. * @returns a new TextFileAssetTask object
  69564. */
  69565. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  69566. /**
  69567. * Add a BinaryFileAssetTask to the list of active tasks
  69568. * @param taskName defines the name of the new task
  69569. * @param url defines the url of the file to load
  69570. * @returns a new BinaryFileAssetTask object
  69571. */
  69572. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  69573. /**
  69574. * Add a ImageAssetTask to the list of active tasks
  69575. * @param taskName defines the name of the new task
  69576. * @param url defines the url of the file to load
  69577. * @returns a new ImageAssetTask object
  69578. */
  69579. addImageTask(taskName: string, url: string): ImageAssetTask;
  69580. /**
  69581. * Add a TextureAssetTask to the list of active tasks
  69582. * @param taskName defines the name of the new task
  69583. * @param url defines the url of the file to load
  69584. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69585. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  69586. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69587. * @returns a new TextureAssetTask object
  69588. */
  69589. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  69590. /**
  69591. * Add a CubeTextureAssetTask to the list of active tasks
  69592. * @param taskName defines the name of the new task
  69593. * @param url defines the url of the file to load
  69594. * @param extensions defines the extension to use to load the cube map (can be null)
  69595. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69596. * @param files defines the list of files to load (can be null)
  69597. * @returns a new CubeTextureAssetTask object
  69598. */
  69599. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  69600. /**
  69601. *
  69602. * Add a HDRCubeTextureAssetTask to the list of active tasks
  69603. * @param taskName defines the name of the new task
  69604. * @param url defines the url of the file to load
  69605. * @param size defines the size you want for the cubemap (can be null)
  69606. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69607. * @param generateHarmonics defines if you want to automatically generate (true by default)
  69608. * @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)
  69609. * @param reserved Internal use only
  69610. * @returns a new HDRCubeTextureAssetTask object
  69611. */
  69612. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  69613. /**
  69614. *
  69615. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  69616. * @param taskName defines the name of the new task
  69617. * @param url defines the url of the file to load
  69618. * @param size defines the size you want for the cubemap (can be null)
  69619. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69620. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69621. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69622. * @returns a new EquiRectangularCubeTextureAssetTask object
  69623. */
  69624. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  69625. /**
  69626. * Remove a task from the assets manager.
  69627. * @param task the task to remove
  69628. */
  69629. removeTask(task: AbstractAssetTask): void;
  69630. private _decreaseWaitingTasksCount;
  69631. private _runTask;
  69632. /**
  69633. * Reset the AssetsManager and remove all tasks
  69634. * @return the current instance of the AssetsManager
  69635. */
  69636. reset(): AssetsManager;
  69637. /**
  69638. * Start the loading process
  69639. * @return the current instance of the AssetsManager
  69640. */
  69641. load(): AssetsManager;
  69642. /**
  69643. * Start the loading process as an async operation
  69644. * @return a promise returning the list of failed tasks
  69645. */
  69646. loadAsync(): Promise<void>;
  69647. }
  69648. }
  69649. declare module "babylonjs/Misc/deferred" {
  69650. /**
  69651. * Wrapper class for promise with external resolve and reject.
  69652. */
  69653. export class Deferred<T> {
  69654. /**
  69655. * The promise associated with this deferred object.
  69656. */
  69657. readonly promise: Promise<T>;
  69658. private _resolve;
  69659. private _reject;
  69660. /**
  69661. * The resolve method of the promise associated with this deferred object.
  69662. */
  69663. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  69664. /**
  69665. * The reject method of the promise associated with this deferred object.
  69666. */
  69667. get reject(): (reason?: any) => void;
  69668. /**
  69669. * Constructor for this deferred object.
  69670. */
  69671. constructor();
  69672. }
  69673. }
  69674. declare module "babylonjs/Misc/meshExploder" {
  69675. import { Mesh } from "babylonjs/Meshes/mesh";
  69676. /**
  69677. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  69678. */
  69679. export class MeshExploder {
  69680. private _centerMesh;
  69681. private _meshes;
  69682. private _meshesOrigins;
  69683. private _toCenterVectors;
  69684. private _scaledDirection;
  69685. private _newPosition;
  69686. private _centerPosition;
  69687. /**
  69688. * Explodes meshes from a center mesh.
  69689. * @param meshes The meshes to explode.
  69690. * @param centerMesh The mesh to be center of explosion.
  69691. */
  69692. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  69693. private _setCenterMesh;
  69694. /**
  69695. * Get class name
  69696. * @returns "MeshExploder"
  69697. */
  69698. getClassName(): string;
  69699. /**
  69700. * "Exploded meshes"
  69701. * @returns Array of meshes with the centerMesh at index 0.
  69702. */
  69703. getMeshes(): Array<Mesh>;
  69704. /**
  69705. * Explodes meshes giving a specific direction
  69706. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  69707. */
  69708. explode(direction?: number): void;
  69709. }
  69710. }
  69711. declare module "babylonjs/Misc/filesInput" {
  69712. import { Engine } from "babylonjs/Engines/engine";
  69713. import { Scene } from "babylonjs/scene";
  69714. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  69715. /**
  69716. * Class used to help managing file picking and drag'n'drop
  69717. */
  69718. export class FilesInput {
  69719. /**
  69720. * List of files ready to be loaded
  69721. */
  69722. static get FilesToLoad(): {
  69723. [key: string]: File;
  69724. };
  69725. /**
  69726. * Callback called when a file is processed
  69727. */
  69728. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  69729. private _engine;
  69730. private _currentScene;
  69731. private _sceneLoadedCallback;
  69732. private _progressCallback;
  69733. private _additionalRenderLoopLogicCallback;
  69734. private _textureLoadingCallback;
  69735. private _startingProcessingFilesCallback;
  69736. private _onReloadCallback;
  69737. private _errorCallback;
  69738. private _elementToMonitor;
  69739. private _sceneFileToLoad;
  69740. private _filesToLoad;
  69741. /**
  69742. * Creates a new FilesInput
  69743. * @param engine defines the rendering engine
  69744. * @param scene defines the hosting scene
  69745. * @param sceneLoadedCallback callback called when scene is loaded
  69746. * @param progressCallback callback called to track progress
  69747. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  69748. * @param textureLoadingCallback callback called when a texture is loading
  69749. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  69750. * @param onReloadCallback callback called when a reload is requested
  69751. * @param errorCallback callback call if an error occurs
  69752. */
  69753. 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);
  69754. private _dragEnterHandler;
  69755. private _dragOverHandler;
  69756. private _dropHandler;
  69757. /**
  69758. * Calls this function to listen to drag'n'drop events on a specific DOM element
  69759. * @param elementToMonitor defines the DOM element to track
  69760. */
  69761. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  69762. /**
  69763. * Release all associated resources
  69764. */
  69765. dispose(): void;
  69766. private renderFunction;
  69767. private drag;
  69768. private drop;
  69769. private _traverseFolder;
  69770. private _processFiles;
  69771. /**
  69772. * Load files from a drop event
  69773. * @param event defines the drop event to use as source
  69774. */
  69775. loadFiles(event: any): void;
  69776. private _processReload;
  69777. /**
  69778. * Reload the current scene from the loaded files
  69779. */
  69780. reload(): void;
  69781. }
  69782. }
  69783. declare module "babylonjs/Misc/HighDynamicRange/index" {
  69784. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  69785. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  69786. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  69787. }
  69788. declare module "babylonjs/Misc/sceneOptimizer" {
  69789. import { Scene, IDisposable } from "babylonjs/scene";
  69790. import { Observable } from "babylonjs/Misc/observable";
  69791. /**
  69792. * Defines the root class used to create scene optimization to use with SceneOptimizer
  69793. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69794. */
  69795. export class SceneOptimization {
  69796. /**
  69797. * Defines the priority of this optimization (0 by default which means first in the list)
  69798. */
  69799. priority: number;
  69800. /**
  69801. * Gets a string describing the action executed by the current optimization
  69802. * @returns description string
  69803. */
  69804. getDescription(): string;
  69805. /**
  69806. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69807. * @param scene defines the current scene where to apply this optimization
  69808. * @param optimizer defines the current optimizer
  69809. * @returns true if everything that can be done was applied
  69810. */
  69811. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69812. /**
  69813. * Creates the SceneOptimization object
  69814. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69815. * @param desc defines the description associated with the optimization
  69816. */
  69817. constructor(
  69818. /**
  69819. * Defines the priority of this optimization (0 by default which means first in the list)
  69820. */
  69821. priority?: number);
  69822. }
  69823. /**
  69824. * Defines an optimization used to reduce the size of render target textures
  69825. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69826. */
  69827. export class TextureOptimization extends SceneOptimization {
  69828. /**
  69829. * Defines the priority of this optimization (0 by default which means first in the list)
  69830. */
  69831. priority: number;
  69832. /**
  69833. * 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
  69834. */
  69835. maximumSize: number;
  69836. /**
  69837. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69838. */
  69839. step: number;
  69840. /**
  69841. * Gets a string describing the action executed by the current optimization
  69842. * @returns description string
  69843. */
  69844. getDescription(): string;
  69845. /**
  69846. * Creates the TextureOptimization object
  69847. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69848. * @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
  69849. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69850. */
  69851. constructor(
  69852. /**
  69853. * Defines the priority of this optimization (0 by default which means first in the list)
  69854. */
  69855. priority?: number,
  69856. /**
  69857. * 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
  69858. */
  69859. maximumSize?: number,
  69860. /**
  69861. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69862. */
  69863. step?: number);
  69864. /**
  69865. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69866. * @param scene defines the current scene where to apply this optimization
  69867. * @param optimizer defines the current optimizer
  69868. * @returns true if everything that can be done was applied
  69869. */
  69870. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69871. }
  69872. /**
  69873. * Defines an optimization used to increase or decrease the rendering resolution
  69874. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69875. */
  69876. export class HardwareScalingOptimization extends SceneOptimization {
  69877. /**
  69878. * Defines the priority of this optimization (0 by default which means first in the list)
  69879. */
  69880. priority: number;
  69881. /**
  69882. * Defines the maximum scale to use (2 by default)
  69883. */
  69884. maximumScale: number;
  69885. /**
  69886. * Defines the step to use between two passes (0.5 by default)
  69887. */
  69888. step: number;
  69889. private _currentScale;
  69890. private _directionOffset;
  69891. /**
  69892. * Gets a string describing the action executed by the current optimization
  69893. * @return description string
  69894. */
  69895. getDescription(): string;
  69896. /**
  69897. * Creates the HardwareScalingOptimization object
  69898. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69899. * @param maximumScale defines the maximum scale to use (2 by default)
  69900. * @param step defines the step to use between two passes (0.5 by default)
  69901. */
  69902. constructor(
  69903. /**
  69904. * Defines the priority of this optimization (0 by default which means first in the list)
  69905. */
  69906. priority?: number,
  69907. /**
  69908. * Defines the maximum scale to use (2 by default)
  69909. */
  69910. maximumScale?: number,
  69911. /**
  69912. * Defines the step to use between two passes (0.5 by default)
  69913. */
  69914. step?: number);
  69915. /**
  69916. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69917. * @param scene defines the current scene where to apply this optimization
  69918. * @param optimizer defines the current optimizer
  69919. * @returns true if everything that can be done was applied
  69920. */
  69921. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69922. }
  69923. /**
  69924. * Defines an optimization used to remove shadows
  69925. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69926. */
  69927. export class ShadowsOptimization extends SceneOptimization {
  69928. /**
  69929. * Gets a string describing the action executed by the current optimization
  69930. * @return description string
  69931. */
  69932. getDescription(): string;
  69933. /**
  69934. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69935. * @param scene defines the current scene where to apply this optimization
  69936. * @param optimizer defines the current optimizer
  69937. * @returns true if everything that can be done was applied
  69938. */
  69939. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69940. }
  69941. /**
  69942. * Defines an optimization used to turn post-processes off
  69943. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69944. */
  69945. export class PostProcessesOptimization extends SceneOptimization {
  69946. /**
  69947. * Gets a string describing the action executed by the current optimization
  69948. * @return description string
  69949. */
  69950. getDescription(): string;
  69951. /**
  69952. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69953. * @param scene defines the current scene where to apply this optimization
  69954. * @param optimizer defines the current optimizer
  69955. * @returns true if everything that can be done was applied
  69956. */
  69957. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69958. }
  69959. /**
  69960. * Defines an optimization used to turn lens flares off
  69961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69962. */
  69963. export class LensFlaresOptimization extends SceneOptimization {
  69964. /**
  69965. * Gets a string describing the action executed by the current optimization
  69966. * @return description string
  69967. */
  69968. getDescription(): string;
  69969. /**
  69970. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69971. * @param scene defines the current scene where to apply this optimization
  69972. * @param optimizer defines the current optimizer
  69973. * @returns true if everything that can be done was applied
  69974. */
  69975. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69976. }
  69977. /**
  69978. * Defines an optimization based on user defined callback.
  69979. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69980. */
  69981. export class CustomOptimization extends SceneOptimization {
  69982. /**
  69983. * Callback called to apply the custom optimization.
  69984. */
  69985. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69986. /**
  69987. * Callback called to get custom description
  69988. */
  69989. onGetDescription: () => string;
  69990. /**
  69991. * Gets a string describing the action executed by the current optimization
  69992. * @returns description string
  69993. */
  69994. getDescription(): string;
  69995. /**
  69996. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69997. * @param scene defines the current scene where to apply this optimization
  69998. * @param optimizer defines the current optimizer
  69999. * @returns true if everything that can be done was applied
  70000. */
  70001. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70002. }
  70003. /**
  70004. * Defines an optimization used to turn particles off
  70005. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70006. */
  70007. export class ParticlesOptimization extends SceneOptimization {
  70008. /**
  70009. * Gets a string describing the action executed by the current optimization
  70010. * @return description string
  70011. */
  70012. getDescription(): string;
  70013. /**
  70014. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70015. * @param scene defines the current scene where to apply this optimization
  70016. * @param optimizer defines the current optimizer
  70017. * @returns true if everything that can be done was applied
  70018. */
  70019. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70020. }
  70021. /**
  70022. * Defines an optimization used to turn render targets off
  70023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70024. */
  70025. export class RenderTargetsOptimization extends SceneOptimization {
  70026. /**
  70027. * Gets a string describing the action executed by the current optimization
  70028. * @return description string
  70029. */
  70030. getDescription(): string;
  70031. /**
  70032. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70033. * @param scene defines the current scene where to apply this optimization
  70034. * @param optimizer defines the current optimizer
  70035. * @returns true if everything that can be done was applied
  70036. */
  70037. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70038. }
  70039. /**
  70040. * Defines an optimization used to merge meshes with compatible materials
  70041. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70042. */
  70043. export class MergeMeshesOptimization extends SceneOptimization {
  70044. private static _UpdateSelectionTree;
  70045. /**
  70046. * Gets or sets a boolean which defines if optimization octree has to be updated
  70047. */
  70048. static get UpdateSelectionTree(): boolean;
  70049. /**
  70050. * Gets or sets a boolean which defines if optimization octree has to be updated
  70051. */
  70052. static set UpdateSelectionTree(value: boolean);
  70053. /**
  70054. * Gets a string describing the action executed by the current optimization
  70055. * @return description string
  70056. */
  70057. getDescription(): string;
  70058. private _canBeMerged;
  70059. /**
  70060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70061. * @param scene defines the current scene where to apply this optimization
  70062. * @param optimizer defines the current optimizer
  70063. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  70064. * @returns true if everything that can be done was applied
  70065. */
  70066. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  70067. }
  70068. /**
  70069. * Defines a list of options used by SceneOptimizer
  70070. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70071. */
  70072. export class SceneOptimizerOptions {
  70073. /**
  70074. * Defines the target frame rate to reach (60 by default)
  70075. */
  70076. targetFrameRate: number;
  70077. /**
  70078. * Defines the interval between two checkes (2000ms by default)
  70079. */
  70080. trackerDuration: number;
  70081. /**
  70082. * Gets the list of optimizations to apply
  70083. */
  70084. optimizations: SceneOptimization[];
  70085. /**
  70086. * Creates a new list of options used by SceneOptimizer
  70087. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  70088. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  70089. */
  70090. constructor(
  70091. /**
  70092. * Defines the target frame rate to reach (60 by default)
  70093. */
  70094. targetFrameRate?: number,
  70095. /**
  70096. * Defines the interval between two checkes (2000ms by default)
  70097. */
  70098. trackerDuration?: number);
  70099. /**
  70100. * Add a new optimization
  70101. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70102. * @returns the current SceneOptimizerOptions
  70103. */
  70104. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70105. /**
  70106. * Add a new custom optimization
  70107. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70108. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70109. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70110. * @returns the current SceneOptimizerOptions
  70111. */
  70112. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70113. /**
  70114. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70115. * @param targetFrameRate defines the target frame rate (60 by default)
  70116. * @returns a SceneOptimizerOptions object
  70117. */
  70118. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70119. /**
  70120. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70121. * @param targetFrameRate defines the target frame rate (60 by default)
  70122. * @returns a SceneOptimizerOptions object
  70123. */
  70124. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70125. /**
  70126. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70127. * @param targetFrameRate defines the target frame rate (60 by default)
  70128. * @returns a SceneOptimizerOptions object
  70129. */
  70130. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70131. }
  70132. /**
  70133. * Class used to run optimizations in order to reach a target frame rate
  70134. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70135. */
  70136. export class SceneOptimizer implements IDisposable {
  70137. private _isRunning;
  70138. private _options;
  70139. private _scene;
  70140. private _currentPriorityLevel;
  70141. private _targetFrameRate;
  70142. private _trackerDuration;
  70143. private _currentFrameRate;
  70144. private _sceneDisposeObserver;
  70145. private _improvementMode;
  70146. /**
  70147. * Defines an observable called when the optimizer reaches the target frame rate
  70148. */
  70149. onSuccessObservable: Observable<SceneOptimizer>;
  70150. /**
  70151. * Defines an observable called when the optimizer enables an optimization
  70152. */
  70153. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70154. /**
  70155. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70156. */
  70157. onFailureObservable: Observable<SceneOptimizer>;
  70158. /**
  70159. * Gets a boolean indicating if the optimizer is in improvement mode
  70160. */
  70161. get isInImprovementMode(): boolean;
  70162. /**
  70163. * Gets the current priority level (0 at start)
  70164. */
  70165. get currentPriorityLevel(): number;
  70166. /**
  70167. * Gets the current frame rate checked by the SceneOptimizer
  70168. */
  70169. get currentFrameRate(): number;
  70170. /**
  70171. * Gets or sets the current target frame rate (60 by default)
  70172. */
  70173. get targetFrameRate(): number;
  70174. /**
  70175. * Gets or sets the current target frame rate (60 by default)
  70176. */
  70177. set targetFrameRate(value: number);
  70178. /**
  70179. * Gets or sets the current interval between two checks (every 2000ms by default)
  70180. */
  70181. get trackerDuration(): number;
  70182. /**
  70183. * Gets or sets the current interval between two checks (every 2000ms by default)
  70184. */
  70185. set trackerDuration(value: number);
  70186. /**
  70187. * Gets the list of active optimizations
  70188. */
  70189. get optimizations(): SceneOptimization[];
  70190. /**
  70191. * Creates a new SceneOptimizer
  70192. * @param scene defines the scene to work on
  70193. * @param options defines the options to use with the SceneOptimizer
  70194. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70195. * @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)
  70196. */
  70197. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70198. /**
  70199. * Stops the current optimizer
  70200. */
  70201. stop(): void;
  70202. /**
  70203. * Reset the optimizer to initial step (current priority level = 0)
  70204. */
  70205. reset(): void;
  70206. /**
  70207. * Start the optimizer. By default it will try to reach a specific framerate
  70208. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70209. */
  70210. start(): void;
  70211. private _checkCurrentState;
  70212. /**
  70213. * Release all resources
  70214. */
  70215. dispose(): void;
  70216. /**
  70217. * Helper function to create a SceneOptimizer with one single line of code
  70218. * @param scene defines the scene to work on
  70219. * @param options defines the options to use with the SceneOptimizer
  70220. * @param onSuccess defines a callback to call on success
  70221. * @param onFailure defines a callback to call on failure
  70222. * @returns the new SceneOptimizer object
  70223. */
  70224. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70225. }
  70226. }
  70227. declare module "babylonjs/Misc/sceneSerializer" {
  70228. import { Scene } from "babylonjs/scene";
  70229. /**
  70230. * Class used to serialize a scene into a string
  70231. */
  70232. export class SceneSerializer {
  70233. /**
  70234. * Clear cache used by a previous serialization
  70235. */
  70236. static ClearCache(): void;
  70237. /**
  70238. * Serialize a scene into a JSON compatible object
  70239. * @param scene defines the scene to serialize
  70240. * @returns a JSON compatible object
  70241. */
  70242. static Serialize(scene: Scene): any;
  70243. /**
  70244. * Serialize a mesh into a JSON compatible object
  70245. * @param toSerialize defines the mesh to serialize
  70246. * @param withParents defines if parents must be serialized as well
  70247. * @param withChildren defines if children must be serialized as well
  70248. * @returns a JSON compatible object
  70249. */
  70250. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70251. }
  70252. }
  70253. declare module "babylonjs/Misc/textureTools" {
  70254. import { Texture } from "babylonjs/Materials/Textures/texture";
  70255. /**
  70256. * Class used to host texture specific utilities
  70257. */
  70258. export class TextureTools {
  70259. /**
  70260. * Uses the GPU to create a copy texture rescaled at a given size
  70261. * @param texture Texture to copy from
  70262. * @param width defines the desired width
  70263. * @param height defines the desired height
  70264. * @param useBilinearMode defines if bilinear mode has to be used
  70265. * @return the generated texture
  70266. */
  70267. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70268. }
  70269. }
  70270. declare module "babylonjs/Misc/videoRecorder" {
  70271. import { Nullable } from "babylonjs/types";
  70272. import { Engine } from "babylonjs/Engines/engine";
  70273. /**
  70274. * This represents the different options available for the video capture.
  70275. */
  70276. export interface VideoRecorderOptions {
  70277. /** Defines the mime type of the video. */
  70278. mimeType: string;
  70279. /** Defines the FPS the video should be recorded at. */
  70280. fps: number;
  70281. /** Defines the chunk size for the recording data. */
  70282. recordChunckSize: number;
  70283. /** The audio tracks to attach to the recording. */
  70284. audioTracks?: MediaStreamTrack[];
  70285. }
  70286. /**
  70287. * This can help with recording videos from BabylonJS.
  70288. * This is based on the available WebRTC functionalities of the browser.
  70289. *
  70290. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70291. */
  70292. export class VideoRecorder {
  70293. private static readonly _defaultOptions;
  70294. /**
  70295. * Returns whether or not the VideoRecorder is available in your browser.
  70296. * @param engine Defines the Babylon Engine.
  70297. * @returns true if supported otherwise false.
  70298. */
  70299. static IsSupported(engine: Engine): boolean;
  70300. private readonly _options;
  70301. private _canvas;
  70302. private _mediaRecorder;
  70303. private _recordedChunks;
  70304. private _fileName;
  70305. private _resolve;
  70306. private _reject;
  70307. /**
  70308. * True when a recording is already in progress.
  70309. */
  70310. get isRecording(): boolean;
  70311. /**
  70312. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70313. * @param engine Defines the BabylonJS Engine you wish to record.
  70314. * @param options Defines options that can be used to customize the capture.
  70315. */
  70316. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70317. /**
  70318. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70319. */
  70320. stopRecording(): void;
  70321. /**
  70322. * Starts recording the canvas for a max duration specified in parameters.
  70323. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70324. * If null no automatic download will start and you can rely on the promise to get the data back.
  70325. * @param maxDuration Defines the maximum recording time in seconds.
  70326. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70327. * @return A promise callback at the end of the recording with the video data in Blob.
  70328. */
  70329. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70330. /**
  70331. * Releases internal resources used during the recording.
  70332. */
  70333. dispose(): void;
  70334. private _handleDataAvailable;
  70335. private _handleError;
  70336. private _handleStop;
  70337. }
  70338. }
  70339. declare module "babylonjs/Misc/screenshotTools" {
  70340. import { Camera } from "babylonjs/Cameras/camera";
  70341. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  70342. import { Engine } from "babylonjs/Engines/engine";
  70343. /**
  70344. * Class containing a set of static utilities functions for screenshots
  70345. */
  70346. export class ScreenshotTools {
  70347. /**
  70348. * Captures a screenshot of the current rendering
  70349. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70350. * @param engine defines the rendering engine
  70351. * @param camera defines the source camera
  70352. * @param size This parameter can be set to a single number or to an object with the
  70353. * following (optional) properties: precision, width, height. If a single number is passed,
  70354. * it will be used for both width and height. If an object is passed, the screenshot size
  70355. * will be derived from the parameters. The precision property is a multiplier allowing
  70356. * rendering at a higher or lower resolution
  70357. * @param successCallback defines the callback receives a single parameter which contains the
  70358. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70359. * src parameter of an <img> to display it
  70360. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70361. * Check your browser for supported MIME types
  70362. */
  70363. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70364. /**
  70365. * Captures a screenshot of the current rendering
  70366. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70367. * @param engine defines the rendering engine
  70368. * @param camera defines the source camera
  70369. * @param size This parameter can be set to a single number or to an object with the
  70370. * following (optional) properties: precision, width, height. If a single number is passed,
  70371. * it will be used for both width and height. If an object is passed, the screenshot size
  70372. * will be derived from the parameters. The precision property is a multiplier allowing
  70373. * rendering at a higher or lower resolution
  70374. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70375. * Check your browser for supported MIME types
  70376. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70377. * to the src parameter of an <img> to display it
  70378. */
  70379. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70380. /**
  70381. * Generates an image screenshot from the specified camera.
  70382. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70383. * @param engine The engine to use for rendering
  70384. * @param camera The camera to use for rendering
  70385. * @param size This parameter can be set to a single number or to an object with the
  70386. * following (optional) properties: precision, width, height. If a single number is passed,
  70387. * it will be used for both width and height. If an object is passed, the screenshot size
  70388. * will be derived from the parameters. The precision property is a multiplier allowing
  70389. * rendering at a higher or lower resolution
  70390. * @param successCallback The callback receives a single parameter which contains the
  70391. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70392. * src parameter of an <img> to display it
  70393. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70394. * Check your browser for supported MIME types
  70395. * @param samples Texture samples (default: 1)
  70396. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70397. * @param fileName A name for for the downloaded file.
  70398. */
  70399. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  70400. /**
  70401. * Generates an image screenshot from the specified camera.
  70402. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70403. * @param engine The engine to use for rendering
  70404. * @param camera The camera to use for rendering
  70405. * @param size This parameter can be set to a single number or to an object with the
  70406. * following (optional) properties: precision, width, height. If a single number is passed,
  70407. * it will be used for both width and height. If an object is passed, the screenshot size
  70408. * will be derived from the parameters. The precision property is a multiplier allowing
  70409. * rendering at a higher or lower resolution
  70410. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70411. * Check your browser for supported MIME types
  70412. * @param samples Texture samples (default: 1)
  70413. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70414. * @param fileName A name for for the downloaded file.
  70415. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70416. * to the src parameter of an <img> to display it
  70417. */
  70418. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  70419. /**
  70420. * Gets height and width for screenshot size
  70421. * @private
  70422. */
  70423. private static _getScreenshotSize;
  70424. }
  70425. }
  70426. declare module "babylonjs/Misc/dataReader" {
  70427. /**
  70428. * Interface for a data buffer
  70429. */
  70430. export interface IDataBuffer {
  70431. /**
  70432. * Reads bytes from the data buffer.
  70433. * @param byteOffset The byte offset to read
  70434. * @param byteLength The byte length to read
  70435. * @returns A promise that resolves when the bytes are read
  70436. */
  70437. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70438. /**
  70439. * The byte length of the buffer.
  70440. */
  70441. readonly byteLength: number;
  70442. }
  70443. /**
  70444. * Utility class for reading from a data buffer
  70445. */
  70446. export class DataReader {
  70447. /**
  70448. * The data buffer associated with this data reader.
  70449. */
  70450. readonly buffer: IDataBuffer;
  70451. /**
  70452. * The current byte offset from the beginning of the data buffer.
  70453. */
  70454. byteOffset: number;
  70455. private _dataView;
  70456. private _dataByteOffset;
  70457. /**
  70458. * Constructor
  70459. * @param buffer The buffer to read
  70460. */
  70461. constructor(buffer: IDataBuffer);
  70462. /**
  70463. * Loads the given byte length.
  70464. * @param byteLength The byte length to load
  70465. * @returns A promise that resolves when the load is complete
  70466. */
  70467. loadAsync(byteLength: number): Promise<void>;
  70468. /**
  70469. * Read a unsigned 32-bit integer from the currently loaded data range.
  70470. * @returns The 32-bit integer read
  70471. */
  70472. readUint32(): number;
  70473. /**
  70474. * Read a byte array from the currently loaded data range.
  70475. * @param byteLength The byte length to read
  70476. * @returns The byte array read
  70477. */
  70478. readUint8Array(byteLength: number): Uint8Array;
  70479. /**
  70480. * Read a string from the currently loaded data range.
  70481. * @param byteLength The byte length to read
  70482. * @returns The string read
  70483. */
  70484. readString(byteLength: number): string;
  70485. /**
  70486. * Skips the given byte length the currently loaded data range.
  70487. * @param byteLength The byte length to skip
  70488. */
  70489. skipBytes(byteLength: number): void;
  70490. }
  70491. }
  70492. declare module "babylonjs/Misc/index" {
  70493. export * from "babylonjs/Misc/andOrNotEvaluator";
  70494. export * from "babylonjs/Misc/assetsManager";
  70495. export * from "babylonjs/Misc/basis";
  70496. export * from "babylonjs/Misc/dds";
  70497. export * from "babylonjs/Misc/decorators";
  70498. export * from "babylonjs/Misc/deferred";
  70499. export * from "babylonjs/Misc/environmentTextureTools";
  70500. export * from "babylonjs/Misc/meshExploder";
  70501. export * from "babylonjs/Misc/filesInput";
  70502. export * from "babylonjs/Misc/HighDynamicRange/index";
  70503. export * from "babylonjs/Misc/khronosTextureContainer";
  70504. export * from "babylonjs/Misc/observable";
  70505. export * from "babylonjs/Misc/performanceMonitor";
  70506. export * from "babylonjs/Misc/promise";
  70507. export * from "babylonjs/Misc/sceneOptimizer";
  70508. export * from "babylonjs/Misc/sceneSerializer";
  70509. export * from "babylonjs/Misc/smartArray";
  70510. export * from "babylonjs/Misc/stringDictionary";
  70511. export * from "babylonjs/Misc/tags";
  70512. export * from "babylonjs/Misc/textureTools";
  70513. export * from "babylonjs/Misc/tga";
  70514. export * from "babylonjs/Misc/tools";
  70515. export * from "babylonjs/Misc/videoRecorder";
  70516. export * from "babylonjs/Misc/virtualJoystick";
  70517. export * from "babylonjs/Misc/workerPool";
  70518. export * from "babylonjs/Misc/logger";
  70519. export * from "babylonjs/Misc/typeStore";
  70520. export * from "babylonjs/Misc/filesInputStore";
  70521. export * from "babylonjs/Misc/deepCopier";
  70522. export * from "babylonjs/Misc/pivotTools";
  70523. export * from "babylonjs/Misc/precisionDate";
  70524. export * from "babylonjs/Misc/screenshotTools";
  70525. export * from "babylonjs/Misc/typeStore";
  70526. export * from "babylonjs/Misc/webRequest";
  70527. export * from "babylonjs/Misc/iInspectable";
  70528. export * from "babylonjs/Misc/brdfTextureTools";
  70529. export * from "babylonjs/Misc/rgbdTextureTools";
  70530. export * from "babylonjs/Misc/gradients";
  70531. export * from "babylonjs/Misc/perfCounter";
  70532. export * from "babylonjs/Misc/fileRequest";
  70533. export * from "babylonjs/Misc/customAnimationFrameRequester";
  70534. export * from "babylonjs/Misc/retryStrategy";
  70535. export * from "babylonjs/Misc/interfaces/screenshotSize";
  70536. export * from "babylonjs/Misc/canvasGenerator";
  70537. export * from "babylonjs/Misc/fileTools";
  70538. export * from "babylonjs/Misc/stringTools";
  70539. export * from "babylonjs/Misc/dataReader";
  70540. }
  70541. declare module "babylonjs/index" {
  70542. export * from "babylonjs/abstractScene";
  70543. export * from "babylonjs/Actions/index";
  70544. export * from "babylonjs/Animations/index";
  70545. export * from "babylonjs/assetContainer";
  70546. export * from "babylonjs/Audio/index";
  70547. export * from "babylonjs/Behaviors/index";
  70548. export * from "babylonjs/Bones/index";
  70549. export * from "babylonjs/Cameras/index";
  70550. export * from "babylonjs/Collisions/index";
  70551. export * from "babylonjs/Culling/index";
  70552. export * from "babylonjs/Debug/index";
  70553. export * from "babylonjs/Engines/index";
  70554. export * from "babylonjs/Events/index";
  70555. export * from "babylonjs/Gamepads/index";
  70556. export * from "babylonjs/Gizmos/index";
  70557. export * from "babylonjs/Helpers/index";
  70558. export * from "babylonjs/Instrumentation/index";
  70559. export * from "babylonjs/Layers/index";
  70560. export * from "babylonjs/LensFlares/index";
  70561. export * from "babylonjs/Lights/index";
  70562. export * from "babylonjs/Loading/index";
  70563. export * from "babylonjs/Materials/index";
  70564. export * from "babylonjs/Maths/index";
  70565. export * from "babylonjs/Meshes/index";
  70566. export * from "babylonjs/Morph/index";
  70567. export * from "babylonjs/Navigation/index";
  70568. export * from "babylonjs/node";
  70569. export * from "babylonjs/Offline/index";
  70570. export * from "babylonjs/Particles/index";
  70571. export * from "babylonjs/Physics/index";
  70572. export * from "babylonjs/PostProcesses/index";
  70573. export * from "babylonjs/Probes/index";
  70574. export * from "babylonjs/Rendering/index";
  70575. export * from "babylonjs/scene";
  70576. export * from "babylonjs/sceneComponent";
  70577. export * from "babylonjs/Sprites/index";
  70578. export * from "babylonjs/States/index";
  70579. export * from "babylonjs/Misc/index";
  70580. export * from "babylonjs/types";
  70581. }
  70582. declare module "babylonjs/Animations/pathCursor" {
  70583. import { Vector3 } from "babylonjs/Maths/math.vector";
  70584. import { Path2 } from "babylonjs/Maths/math.path";
  70585. /**
  70586. * A cursor which tracks a point on a path
  70587. */
  70588. export class PathCursor {
  70589. private path;
  70590. /**
  70591. * Stores path cursor callbacks for when an onchange event is triggered
  70592. */
  70593. private _onchange;
  70594. /**
  70595. * The value of the path cursor
  70596. */
  70597. value: number;
  70598. /**
  70599. * The animation array of the path cursor
  70600. */
  70601. animations: Animation[];
  70602. /**
  70603. * Initializes the path cursor
  70604. * @param path The path to track
  70605. */
  70606. constructor(path: Path2);
  70607. /**
  70608. * Gets the cursor point on the path
  70609. * @returns A point on the path cursor at the cursor location
  70610. */
  70611. getPoint(): Vector3;
  70612. /**
  70613. * Moves the cursor ahead by the step amount
  70614. * @param step The amount to move the cursor forward
  70615. * @returns This path cursor
  70616. */
  70617. moveAhead(step?: number): PathCursor;
  70618. /**
  70619. * Moves the cursor behind by the step amount
  70620. * @param step The amount to move the cursor back
  70621. * @returns This path cursor
  70622. */
  70623. moveBack(step?: number): PathCursor;
  70624. /**
  70625. * Moves the cursor by the step amount
  70626. * If the step amount is greater than one, an exception is thrown
  70627. * @param step The amount to move the cursor
  70628. * @returns This path cursor
  70629. */
  70630. move(step: number): PathCursor;
  70631. /**
  70632. * Ensures that the value is limited between zero and one
  70633. * @returns This path cursor
  70634. */
  70635. private ensureLimits;
  70636. /**
  70637. * Runs onchange callbacks on change (used by the animation engine)
  70638. * @returns This path cursor
  70639. */
  70640. private raiseOnChange;
  70641. /**
  70642. * Executes a function on change
  70643. * @param f A path cursor onchange callback
  70644. * @returns This path cursor
  70645. */
  70646. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70647. }
  70648. }
  70649. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  70650. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  70651. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  70652. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  70653. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  70654. }
  70655. declare module "babylonjs/Engines/Processors/Expressions/index" {
  70656. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  70657. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  70658. }
  70659. declare module "babylonjs/Engines/Processors/index" {
  70660. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  70661. export * from "babylonjs/Engines/Processors/Expressions/index";
  70662. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  70663. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  70664. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  70665. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  70666. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  70667. export * from "babylonjs/Engines/Processors/shaderProcessor";
  70668. }
  70669. declare module "babylonjs/Legacy/legacy" {
  70670. import * as Babylon from "babylonjs/index";
  70671. export * from "babylonjs/index";
  70672. }
  70673. declare module "babylonjs/Shaders/blur.fragment" {
  70674. /** @hidden */
  70675. export var blurPixelShader: {
  70676. name: string;
  70677. shader: string;
  70678. };
  70679. }
  70680. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  70681. /** @hidden */
  70682. export var pointCloudVertexDeclaration: {
  70683. name: string;
  70684. shader: string;
  70685. };
  70686. }
  70687. declare module "babylonjs" {
  70688. export * from "babylonjs/Legacy/legacy";
  70689. }
  70690. declare module BABYLON {
  70691. /** Alias type for value that can be null */
  70692. export type Nullable<T> = T | null;
  70693. /**
  70694. * Alias type for number that are floats
  70695. * @ignorenaming
  70696. */
  70697. export type float = number;
  70698. /**
  70699. * Alias type for number that are doubles.
  70700. * @ignorenaming
  70701. */
  70702. export type double = number;
  70703. /**
  70704. * Alias type for number that are integer
  70705. * @ignorenaming
  70706. */
  70707. export type int = number;
  70708. /** Alias type for number array or Float32Array */
  70709. export type FloatArray = number[] | Float32Array;
  70710. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  70711. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  70712. /**
  70713. * Alias for types that can be used by a Buffer or VertexBuffer.
  70714. */
  70715. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  70716. /**
  70717. * Alias type for primitive types
  70718. * @ignorenaming
  70719. */
  70720. type Primitive = undefined | null | boolean | string | number | Function;
  70721. /**
  70722. * Type modifier to make all the properties of an object Readonly
  70723. */
  70724. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  70725. /**
  70726. * Type modifier to make all the properties of an object Readonly recursively
  70727. */
  70728. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  70729. /**
  70730. * Type modifier to make object properties readonly.
  70731. */
  70732. export type DeepImmutableObject<T> = {
  70733. readonly [K in keyof T]: DeepImmutable<T[K]>;
  70734. };
  70735. /** @hidden */
  70736. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  70737. }
  70738. }
  70739. declare module BABYLON {
  70740. /**
  70741. * A class serves as a medium between the observable and its observers
  70742. */
  70743. export class EventState {
  70744. /**
  70745. * Create a new EventState
  70746. * @param mask defines the mask associated with this state
  70747. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70748. * @param target defines the original target of the state
  70749. * @param currentTarget defines the current target of the state
  70750. */
  70751. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  70752. /**
  70753. * Initialize the current event state
  70754. * @param mask defines the mask associated with this state
  70755. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70756. * @param target defines the original target of the state
  70757. * @param currentTarget defines the current target of the state
  70758. * @returns the current event state
  70759. */
  70760. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  70761. /**
  70762. * An Observer can set this property to true to prevent subsequent observers of being notified
  70763. */
  70764. skipNextObservers: boolean;
  70765. /**
  70766. * Get the mask value that were used to trigger the event corresponding to this EventState object
  70767. */
  70768. mask: number;
  70769. /**
  70770. * The object that originally notified the event
  70771. */
  70772. target?: any;
  70773. /**
  70774. * The current object in the bubbling phase
  70775. */
  70776. currentTarget?: any;
  70777. /**
  70778. * This will be populated with the return value of the last function that was executed.
  70779. * If it is the first function in the callback chain it will be the event data.
  70780. */
  70781. lastReturnValue?: any;
  70782. }
  70783. /**
  70784. * Represent an Observer registered to a given Observable object.
  70785. */
  70786. export class Observer<T> {
  70787. /**
  70788. * Defines the callback to call when the observer is notified
  70789. */
  70790. callback: (eventData: T, eventState: EventState) => void;
  70791. /**
  70792. * Defines the mask of the observer (used to filter notifications)
  70793. */
  70794. mask: number;
  70795. /**
  70796. * Defines the current scope used to restore the JS context
  70797. */
  70798. scope: any;
  70799. /** @hidden */
  70800. _willBeUnregistered: boolean;
  70801. /**
  70802. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  70803. */
  70804. unregisterOnNextCall: boolean;
  70805. /**
  70806. * Creates a new observer
  70807. * @param callback defines the callback to call when the observer is notified
  70808. * @param mask defines the mask of the observer (used to filter notifications)
  70809. * @param scope defines the current scope used to restore the JS context
  70810. */
  70811. constructor(
  70812. /**
  70813. * Defines the callback to call when the observer is notified
  70814. */
  70815. callback: (eventData: T, eventState: EventState) => void,
  70816. /**
  70817. * Defines the mask of the observer (used to filter notifications)
  70818. */
  70819. mask: number,
  70820. /**
  70821. * Defines the current scope used to restore the JS context
  70822. */
  70823. scope?: any);
  70824. }
  70825. /**
  70826. * Represent a list of observers registered to multiple Observables object.
  70827. */
  70828. export class MultiObserver<T> {
  70829. private _observers;
  70830. private _observables;
  70831. /**
  70832. * Release associated resources
  70833. */
  70834. dispose(): void;
  70835. /**
  70836. * Raise a callback when one of the observable will notify
  70837. * @param observables defines a list of observables to watch
  70838. * @param callback defines the callback to call on notification
  70839. * @param mask defines the mask used to filter notifications
  70840. * @param scope defines the current scope used to restore the JS context
  70841. * @returns the new MultiObserver
  70842. */
  70843. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  70844. }
  70845. /**
  70846. * The Observable class is a simple implementation of the Observable pattern.
  70847. *
  70848. * 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.
  70849. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  70850. * 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).
  70851. * 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.
  70852. */
  70853. export class Observable<T> {
  70854. private _observers;
  70855. private _eventState;
  70856. private _onObserverAdded;
  70857. /**
  70858. * Gets the list of observers
  70859. */
  70860. get observers(): Array<Observer<T>>;
  70861. /**
  70862. * Creates a new observable
  70863. * @param onObserverAdded defines a callback to call when a new observer is added
  70864. */
  70865. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  70866. /**
  70867. * Create a new Observer with the specified callback
  70868. * @param callback the callback that will be executed for that Observer
  70869. * @param mask the mask used to filter observers
  70870. * @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.
  70871. * @param scope optional scope for the callback to be called from
  70872. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  70873. * @returns the new observer created for the callback
  70874. */
  70875. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  70876. /**
  70877. * Create a new Observer with the specified callback and unregisters after the next notification
  70878. * @param callback the callback that will be executed for that Observer
  70879. * @returns the new observer created for the callback
  70880. */
  70881. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  70882. /**
  70883. * Remove an Observer from the Observable object
  70884. * @param observer the instance of the Observer to remove
  70885. * @returns false if it doesn't belong to this Observable
  70886. */
  70887. remove(observer: Nullable<Observer<T>>): boolean;
  70888. /**
  70889. * Remove a callback from the Observable object
  70890. * @param callback the callback to remove
  70891. * @param scope optional scope. If used only the callbacks with this scope will be removed
  70892. * @returns false if it doesn't belong to this Observable
  70893. */
  70894. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  70895. private _deferUnregister;
  70896. private _remove;
  70897. /**
  70898. * Moves the observable to the top of the observer list making it get called first when notified
  70899. * @param observer the observer to move
  70900. */
  70901. makeObserverTopPriority(observer: Observer<T>): void;
  70902. /**
  70903. * Moves the observable to the bottom of the observer list making it get called last when notified
  70904. * @param observer the observer to move
  70905. */
  70906. makeObserverBottomPriority(observer: Observer<T>): void;
  70907. /**
  70908. * Notify all Observers by calling their respective callback with the given data
  70909. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  70910. * @param eventData defines the data to send to all observers
  70911. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  70912. * @param target defines the original target of the state
  70913. * @param currentTarget defines the current target of the state
  70914. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  70915. */
  70916. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  70917. /**
  70918. * Calling this will execute each callback, expecting it to be a promise or return a value.
  70919. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  70920. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  70921. * and it is crucial that all callbacks will be executed.
  70922. * The order of the callbacks is kept, callbacks are not executed parallel.
  70923. *
  70924. * @param eventData The data to be sent to each callback
  70925. * @param mask is used to filter observers defaults to -1
  70926. * @param target defines the callback target (see EventState)
  70927. * @param currentTarget defines he current object in the bubbling phase
  70928. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  70929. */
  70930. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  70931. /**
  70932. * Notify a specific observer
  70933. * @param observer defines the observer to notify
  70934. * @param eventData defines the data to be sent to each callback
  70935. * @param mask is used to filter observers defaults to -1
  70936. */
  70937. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  70938. /**
  70939. * Gets a boolean indicating if the observable has at least one observer
  70940. * @returns true is the Observable has at least one Observer registered
  70941. */
  70942. hasObservers(): boolean;
  70943. /**
  70944. * Clear the list of observers
  70945. */
  70946. clear(): void;
  70947. /**
  70948. * Clone the current observable
  70949. * @returns a new observable
  70950. */
  70951. clone(): Observable<T>;
  70952. /**
  70953. * Does this observable handles observer registered with a given mask
  70954. * @param mask defines the mask to be tested
  70955. * @return whether or not one observer registered with the given mask is handeled
  70956. **/
  70957. hasSpecificMask(mask?: number): boolean;
  70958. }
  70959. }
  70960. declare module BABYLON {
  70961. /**
  70962. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  70963. * Babylon.js
  70964. */
  70965. export class DomManagement {
  70966. /**
  70967. * Checks if the window object exists
  70968. * @returns true if the window object exists
  70969. */
  70970. static IsWindowObjectExist(): boolean;
  70971. /**
  70972. * Checks if the navigator object exists
  70973. * @returns true if the navigator object exists
  70974. */
  70975. static IsNavigatorAvailable(): boolean;
  70976. /**
  70977. * Extracts text content from a DOM element hierarchy
  70978. * @param element defines the root element
  70979. * @returns a string
  70980. */
  70981. static GetDOMTextContent(element: HTMLElement): string;
  70982. }
  70983. }
  70984. declare module BABYLON {
  70985. /**
  70986. * Logger used througouht the application to allow configuration of
  70987. * the log level required for the messages.
  70988. */
  70989. export class Logger {
  70990. /**
  70991. * No log
  70992. */
  70993. static readonly NoneLogLevel: number;
  70994. /**
  70995. * Only message logs
  70996. */
  70997. static readonly MessageLogLevel: number;
  70998. /**
  70999. * Only warning logs
  71000. */
  71001. static readonly WarningLogLevel: number;
  71002. /**
  71003. * Only error logs
  71004. */
  71005. static readonly ErrorLogLevel: number;
  71006. /**
  71007. * All logs
  71008. */
  71009. static readonly AllLogLevel: number;
  71010. private static _LogCache;
  71011. /**
  71012. * Gets a value indicating the number of loading errors
  71013. * @ignorenaming
  71014. */
  71015. static errorsCount: number;
  71016. /**
  71017. * Callback called when a new log is added
  71018. */
  71019. static OnNewCacheEntry: (entry: string) => void;
  71020. private static _AddLogEntry;
  71021. private static _FormatMessage;
  71022. private static _LogDisabled;
  71023. private static _LogEnabled;
  71024. private static _WarnDisabled;
  71025. private static _WarnEnabled;
  71026. private static _ErrorDisabled;
  71027. private static _ErrorEnabled;
  71028. /**
  71029. * Log a message to the console
  71030. */
  71031. static Log: (message: string) => void;
  71032. /**
  71033. * Write a warning message to the console
  71034. */
  71035. static Warn: (message: string) => void;
  71036. /**
  71037. * Write an error message to the console
  71038. */
  71039. static Error: (message: string) => void;
  71040. /**
  71041. * Gets current log cache (list of logs)
  71042. */
  71043. static get LogCache(): string;
  71044. /**
  71045. * Clears the log cache
  71046. */
  71047. static ClearLogCache(): void;
  71048. /**
  71049. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  71050. */
  71051. static set LogLevels(level: number);
  71052. }
  71053. }
  71054. declare module BABYLON {
  71055. /** @hidden */
  71056. export class _TypeStore {
  71057. /** @hidden */
  71058. static RegisteredTypes: {
  71059. [key: string]: Object;
  71060. };
  71061. /** @hidden */
  71062. static GetClass(fqdn: string): any;
  71063. }
  71064. }
  71065. declare module BABYLON {
  71066. /**
  71067. * Helper to manipulate strings
  71068. */
  71069. export class StringTools {
  71070. /**
  71071. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71072. * @param str Source string
  71073. * @param suffix Suffix to search for in the source string
  71074. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71075. */
  71076. static EndsWith(str: string, suffix: string): boolean;
  71077. /**
  71078. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71079. * @param str Source string
  71080. * @param suffix Suffix to search for in the source string
  71081. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71082. */
  71083. static StartsWith(str: string, suffix: string): boolean;
  71084. /**
  71085. * Decodes a buffer into a string
  71086. * @param buffer The buffer to decode
  71087. * @returns The decoded string
  71088. */
  71089. static Decode(buffer: Uint8Array | Uint16Array): string;
  71090. /**
  71091. * Encode a buffer to a base64 string
  71092. * @param buffer defines the buffer to encode
  71093. * @returns the encoded string
  71094. */
  71095. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  71096. }
  71097. }
  71098. declare module BABYLON {
  71099. /**
  71100. * Class containing a set of static utilities functions for deep copy.
  71101. */
  71102. export class DeepCopier {
  71103. /**
  71104. * Tries to copy an object by duplicating every property
  71105. * @param source defines the source object
  71106. * @param destination defines the target object
  71107. * @param doNotCopyList defines a list of properties to avoid
  71108. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  71109. */
  71110. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  71111. }
  71112. }
  71113. declare module BABYLON {
  71114. /**
  71115. * Class containing a set of static utilities functions for precision date
  71116. */
  71117. export class PrecisionDate {
  71118. /**
  71119. * Gets either window.performance.now() if supported or Date.now() else
  71120. */
  71121. static get Now(): number;
  71122. }
  71123. }
  71124. declare module BABYLON {
  71125. /** @hidden */
  71126. export class _DevTools {
  71127. static WarnImport(name: string): string;
  71128. }
  71129. }
  71130. declare module BABYLON {
  71131. /**
  71132. * Interface used to define the mechanism to get data from the network
  71133. */
  71134. export interface IWebRequest {
  71135. /**
  71136. * Returns client's response url
  71137. */
  71138. responseURL: string;
  71139. /**
  71140. * Returns client's status
  71141. */
  71142. status: number;
  71143. /**
  71144. * Returns client's status as a text
  71145. */
  71146. statusText: string;
  71147. }
  71148. }
  71149. declare module BABYLON {
  71150. /**
  71151. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  71152. */
  71153. export class WebRequest implements IWebRequest {
  71154. private _xhr;
  71155. /**
  71156. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  71157. * i.e. when loading files, where the server/service expects an Authorization header
  71158. */
  71159. static CustomRequestHeaders: {
  71160. [key: string]: string;
  71161. };
  71162. /**
  71163. * Add callback functions in this array to update all the requests before they get sent to the network
  71164. */
  71165. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  71166. private _injectCustomRequestHeaders;
  71167. /**
  71168. * Gets or sets a function to be called when loading progress changes
  71169. */
  71170. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  71171. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  71172. /**
  71173. * Returns client's state
  71174. */
  71175. get readyState(): number;
  71176. /**
  71177. * Returns client's status
  71178. */
  71179. get status(): number;
  71180. /**
  71181. * Returns client's status as a text
  71182. */
  71183. get statusText(): string;
  71184. /**
  71185. * Returns client's response
  71186. */
  71187. get response(): any;
  71188. /**
  71189. * Returns client's response url
  71190. */
  71191. get responseURL(): string;
  71192. /**
  71193. * Returns client's response as text
  71194. */
  71195. get responseText(): string;
  71196. /**
  71197. * Gets or sets the expected response type
  71198. */
  71199. get responseType(): XMLHttpRequestResponseType;
  71200. set responseType(value: XMLHttpRequestResponseType);
  71201. /** @hidden */
  71202. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  71203. /** @hidden */
  71204. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  71205. /**
  71206. * Cancels any network activity
  71207. */
  71208. abort(): void;
  71209. /**
  71210. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  71211. * @param body defines an optional request body
  71212. */
  71213. send(body?: Document | BodyInit | null): void;
  71214. /**
  71215. * Sets the request method, request URL
  71216. * @param method defines the method to use (GET, POST, etc..)
  71217. * @param url defines the url to connect with
  71218. */
  71219. open(method: string, url: string): void;
  71220. /**
  71221. * Sets the value of a request header.
  71222. * @param name The name of the header whose value is to be set
  71223. * @param value The value to set as the body of the header
  71224. */
  71225. setRequestHeader(name: string, value: string): void;
  71226. /**
  71227. * Get the string containing the text of a particular header's value.
  71228. * @param name The name of the header
  71229. * @returns The string containing the text of the given header name
  71230. */
  71231. getResponseHeader(name: string): Nullable<string>;
  71232. }
  71233. }
  71234. declare module BABYLON {
  71235. /**
  71236. * File request interface
  71237. */
  71238. export interface IFileRequest {
  71239. /**
  71240. * Raised when the request is complete (success or error).
  71241. */
  71242. onCompleteObservable: Observable<IFileRequest>;
  71243. /**
  71244. * Aborts the request for a file.
  71245. */
  71246. abort: () => void;
  71247. }
  71248. }
  71249. declare module BABYLON {
  71250. /**
  71251. * Define options used to create a render target texture
  71252. */
  71253. export class RenderTargetCreationOptions {
  71254. /**
  71255. * Specifies is mipmaps must be generated
  71256. */
  71257. generateMipMaps?: boolean;
  71258. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71259. generateDepthBuffer?: boolean;
  71260. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71261. generateStencilBuffer?: boolean;
  71262. /** Defines texture type (int by default) */
  71263. type?: number;
  71264. /** Defines sampling mode (trilinear by default) */
  71265. samplingMode?: number;
  71266. /** Defines format (RGBA by default) */
  71267. format?: number;
  71268. }
  71269. }
  71270. declare module BABYLON {
  71271. /**
  71272. * @hidden
  71273. **/
  71274. export class _TimeToken {
  71275. _startTimeQuery: Nullable<WebGLQuery>;
  71276. _endTimeQuery: Nullable<WebGLQuery>;
  71277. _timeElapsedQuery: Nullable<WebGLQuery>;
  71278. _timeElapsedQueryEnded: boolean;
  71279. }
  71280. }
  71281. declare module BABYLON {
  71282. /** Defines the cross module used constants to avoid circular dependncies */
  71283. export class Constants {
  71284. /** Defines that alpha blending is disabled */
  71285. static readonly ALPHA_DISABLE: number;
  71286. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  71287. static readonly ALPHA_ADD: number;
  71288. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71289. static readonly ALPHA_COMBINE: number;
  71290. /** Defines that alpha blending is DEST - SRC * DEST */
  71291. static readonly ALPHA_SUBTRACT: number;
  71292. /** Defines that alpha blending is SRC * DEST */
  71293. static readonly ALPHA_MULTIPLY: number;
  71294. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  71295. static readonly ALPHA_MAXIMIZED: number;
  71296. /** Defines that alpha blending is SRC + DEST */
  71297. static readonly ALPHA_ONEONE: number;
  71298. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  71299. static readonly ALPHA_PREMULTIPLIED: number;
  71300. /**
  71301. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  71302. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71303. */
  71304. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71305. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  71306. static readonly ALPHA_INTERPOLATE: number;
  71307. /**
  71308. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  71309. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71310. */
  71311. static readonly ALPHA_SCREENMODE: number;
  71312. /**
  71313. * Defines that alpha blending is SRC + DST
  71314. * Alpha will be set to SRC ALPHA + DST ALPHA
  71315. */
  71316. static readonly ALPHA_ONEONE_ONEONE: number;
  71317. /**
  71318. * Defines that alpha blending is SRC * DST ALPHA + DST
  71319. * Alpha will be set to 0
  71320. */
  71321. static readonly ALPHA_ALPHATOCOLOR: number;
  71322. /**
  71323. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71324. */
  71325. static readonly ALPHA_REVERSEONEMINUS: number;
  71326. /**
  71327. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  71328. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71329. */
  71330. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71331. /**
  71332. * Defines that alpha blending is SRC + DST
  71333. * Alpha will be set to SRC ALPHA
  71334. */
  71335. static readonly ALPHA_ONEONE_ONEZERO: number;
  71336. /**
  71337. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71338. * Alpha will be set to DST ALPHA
  71339. */
  71340. static readonly ALPHA_EXCLUSION: number;
  71341. /** Defines that alpha blending equation a SUM */
  71342. static readonly ALPHA_EQUATION_ADD: number;
  71343. /** Defines that alpha blending equation a SUBSTRACTION */
  71344. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71345. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71346. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71347. /** Defines that alpha blending equation a MAX operation */
  71348. static readonly ALPHA_EQUATION_MAX: number;
  71349. /** Defines that alpha blending equation a MIN operation */
  71350. static readonly ALPHA_EQUATION_MIN: number;
  71351. /**
  71352. * Defines that alpha blending equation a DARKEN operation:
  71353. * It takes the min of the src and sums the alpha channels.
  71354. */
  71355. static readonly ALPHA_EQUATION_DARKEN: number;
  71356. /** Defines that the ressource is not delayed*/
  71357. static readonly DELAYLOADSTATE_NONE: number;
  71358. /** Defines that the ressource was successfully delay loaded */
  71359. static readonly DELAYLOADSTATE_LOADED: number;
  71360. /** Defines that the ressource is currently delay loading */
  71361. static readonly DELAYLOADSTATE_LOADING: number;
  71362. /** Defines that the ressource is delayed and has not started loading */
  71363. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71364. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71365. static readonly NEVER: number;
  71366. /** 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 */
  71367. static readonly ALWAYS: number;
  71368. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71369. static readonly LESS: number;
  71370. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71371. static readonly EQUAL: number;
  71372. /** 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 */
  71373. static readonly LEQUAL: number;
  71374. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71375. static readonly GREATER: number;
  71376. /** 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 */
  71377. static readonly GEQUAL: number;
  71378. /** 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 */
  71379. static readonly NOTEQUAL: number;
  71380. /** Passed to stencilOperation to specify that stencil value must be kept */
  71381. static readonly KEEP: number;
  71382. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71383. static readonly REPLACE: number;
  71384. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71385. static readonly INCR: number;
  71386. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71387. static readonly DECR: number;
  71388. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71389. static readonly INVERT: number;
  71390. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71391. static readonly INCR_WRAP: number;
  71392. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71393. static readonly DECR_WRAP: number;
  71394. /** Texture is not repeating outside of 0..1 UVs */
  71395. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71396. /** Texture is repeating outside of 0..1 UVs */
  71397. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71398. /** Texture is repeating and mirrored */
  71399. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71400. /** ALPHA */
  71401. static readonly TEXTUREFORMAT_ALPHA: number;
  71402. /** LUMINANCE */
  71403. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71404. /** LUMINANCE_ALPHA */
  71405. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71406. /** RGB */
  71407. static readonly TEXTUREFORMAT_RGB: number;
  71408. /** RGBA */
  71409. static readonly TEXTUREFORMAT_RGBA: number;
  71410. /** RED */
  71411. static readonly TEXTUREFORMAT_RED: number;
  71412. /** RED (2nd reference) */
  71413. static readonly TEXTUREFORMAT_R: number;
  71414. /** RG */
  71415. static readonly TEXTUREFORMAT_RG: number;
  71416. /** RED_INTEGER */
  71417. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71418. /** RED_INTEGER (2nd reference) */
  71419. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71420. /** RG_INTEGER */
  71421. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71422. /** RGB_INTEGER */
  71423. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71424. /** RGBA_INTEGER */
  71425. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71426. /** UNSIGNED_BYTE */
  71427. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71428. /** UNSIGNED_BYTE (2nd reference) */
  71429. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71430. /** FLOAT */
  71431. static readonly TEXTURETYPE_FLOAT: number;
  71432. /** HALF_FLOAT */
  71433. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71434. /** BYTE */
  71435. static readonly TEXTURETYPE_BYTE: number;
  71436. /** SHORT */
  71437. static readonly TEXTURETYPE_SHORT: number;
  71438. /** UNSIGNED_SHORT */
  71439. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71440. /** INT */
  71441. static readonly TEXTURETYPE_INT: number;
  71442. /** UNSIGNED_INT */
  71443. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71444. /** UNSIGNED_SHORT_4_4_4_4 */
  71445. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71446. /** UNSIGNED_SHORT_5_5_5_1 */
  71447. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71448. /** UNSIGNED_SHORT_5_6_5 */
  71449. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71450. /** UNSIGNED_INT_2_10_10_10_REV */
  71451. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71452. /** UNSIGNED_INT_24_8 */
  71453. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71454. /** UNSIGNED_INT_10F_11F_11F_REV */
  71455. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71456. /** UNSIGNED_INT_5_9_9_9_REV */
  71457. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71458. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71459. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71460. /** nearest is mag = nearest and min = nearest and no mip */
  71461. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71462. /** mag = nearest and min = nearest and mip = none */
  71463. static readonly TEXTURE_NEAREST_NEAREST: number;
  71464. /** Bilinear is mag = linear and min = linear and no mip */
  71465. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71466. /** mag = linear and min = linear and mip = none */
  71467. static readonly TEXTURE_LINEAR_LINEAR: number;
  71468. /** Trilinear is mag = linear and min = linear and mip = linear */
  71469. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71470. /** Trilinear is mag = linear and min = linear and mip = linear */
  71471. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71472. /** mag = nearest and min = nearest and mip = nearest */
  71473. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71474. /** mag = nearest and min = linear and mip = nearest */
  71475. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71476. /** mag = nearest and min = linear and mip = linear */
  71477. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71478. /** mag = nearest and min = linear and mip = none */
  71479. static readonly TEXTURE_NEAREST_LINEAR: number;
  71480. /** nearest is mag = nearest and min = nearest and mip = linear */
  71481. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71482. /** mag = linear and min = nearest and mip = nearest */
  71483. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71484. /** mag = linear and min = nearest and mip = linear */
  71485. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71486. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71487. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71488. /** mag = linear and min = nearest and mip = none */
  71489. static readonly TEXTURE_LINEAR_NEAREST: number;
  71490. /** Explicit coordinates mode */
  71491. static readonly TEXTURE_EXPLICIT_MODE: number;
  71492. /** Spherical coordinates mode */
  71493. static readonly TEXTURE_SPHERICAL_MODE: number;
  71494. /** Planar coordinates mode */
  71495. static readonly TEXTURE_PLANAR_MODE: number;
  71496. /** Cubic coordinates mode */
  71497. static readonly TEXTURE_CUBIC_MODE: number;
  71498. /** Projection coordinates mode */
  71499. static readonly TEXTURE_PROJECTION_MODE: number;
  71500. /** Skybox coordinates mode */
  71501. static readonly TEXTURE_SKYBOX_MODE: number;
  71502. /** Inverse Cubic coordinates mode */
  71503. static readonly TEXTURE_INVCUBIC_MODE: number;
  71504. /** Equirectangular coordinates mode */
  71505. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71506. /** Equirectangular Fixed coordinates mode */
  71507. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71508. /** Equirectangular Fixed Mirrored coordinates mode */
  71509. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71510. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71511. static readonly SCALEMODE_FLOOR: number;
  71512. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71513. static readonly SCALEMODE_NEAREST: number;
  71514. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71515. static readonly SCALEMODE_CEILING: number;
  71516. /**
  71517. * The dirty texture flag value
  71518. */
  71519. static readonly MATERIAL_TextureDirtyFlag: number;
  71520. /**
  71521. * The dirty light flag value
  71522. */
  71523. static readonly MATERIAL_LightDirtyFlag: number;
  71524. /**
  71525. * The dirty fresnel flag value
  71526. */
  71527. static readonly MATERIAL_FresnelDirtyFlag: number;
  71528. /**
  71529. * The dirty attribute flag value
  71530. */
  71531. static readonly MATERIAL_AttributesDirtyFlag: number;
  71532. /**
  71533. * The dirty misc flag value
  71534. */
  71535. static readonly MATERIAL_MiscDirtyFlag: number;
  71536. /**
  71537. * The all dirty flag value
  71538. */
  71539. static readonly MATERIAL_AllDirtyFlag: number;
  71540. /**
  71541. * Returns the triangle fill mode
  71542. */
  71543. static readonly MATERIAL_TriangleFillMode: number;
  71544. /**
  71545. * Returns the wireframe mode
  71546. */
  71547. static readonly MATERIAL_WireFrameFillMode: number;
  71548. /**
  71549. * Returns the point fill mode
  71550. */
  71551. static readonly MATERIAL_PointFillMode: number;
  71552. /**
  71553. * Returns the point list draw mode
  71554. */
  71555. static readonly MATERIAL_PointListDrawMode: number;
  71556. /**
  71557. * Returns the line list draw mode
  71558. */
  71559. static readonly MATERIAL_LineListDrawMode: number;
  71560. /**
  71561. * Returns the line loop draw mode
  71562. */
  71563. static readonly MATERIAL_LineLoopDrawMode: number;
  71564. /**
  71565. * Returns the line strip draw mode
  71566. */
  71567. static readonly MATERIAL_LineStripDrawMode: number;
  71568. /**
  71569. * Returns the triangle strip draw mode
  71570. */
  71571. static readonly MATERIAL_TriangleStripDrawMode: number;
  71572. /**
  71573. * Returns the triangle fan draw mode
  71574. */
  71575. static readonly MATERIAL_TriangleFanDrawMode: number;
  71576. /**
  71577. * Stores the clock-wise side orientation
  71578. */
  71579. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71580. /**
  71581. * Stores the counter clock-wise side orientation
  71582. */
  71583. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71584. /**
  71585. * Nothing
  71586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71587. */
  71588. static readonly ACTION_NothingTrigger: number;
  71589. /**
  71590. * On pick
  71591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71592. */
  71593. static readonly ACTION_OnPickTrigger: number;
  71594. /**
  71595. * On left pick
  71596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71597. */
  71598. static readonly ACTION_OnLeftPickTrigger: number;
  71599. /**
  71600. * On right pick
  71601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71602. */
  71603. static readonly ACTION_OnRightPickTrigger: number;
  71604. /**
  71605. * On center pick
  71606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71607. */
  71608. static readonly ACTION_OnCenterPickTrigger: number;
  71609. /**
  71610. * On pick down
  71611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71612. */
  71613. static readonly ACTION_OnPickDownTrigger: number;
  71614. /**
  71615. * On double pick
  71616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71617. */
  71618. static readonly ACTION_OnDoublePickTrigger: number;
  71619. /**
  71620. * On pick up
  71621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71622. */
  71623. static readonly ACTION_OnPickUpTrigger: number;
  71624. /**
  71625. * On pick out.
  71626. * This trigger will only be raised if you also declared a OnPickDown
  71627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71628. */
  71629. static readonly ACTION_OnPickOutTrigger: number;
  71630. /**
  71631. * On long press
  71632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71633. */
  71634. static readonly ACTION_OnLongPressTrigger: number;
  71635. /**
  71636. * On pointer over
  71637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71638. */
  71639. static readonly ACTION_OnPointerOverTrigger: number;
  71640. /**
  71641. * On pointer out
  71642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71643. */
  71644. static readonly ACTION_OnPointerOutTrigger: number;
  71645. /**
  71646. * On every frame
  71647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71648. */
  71649. static readonly ACTION_OnEveryFrameTrigger: number;
  71650. /**
  71651. * On intersection enter
  71652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71653. */
  71654. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71655. /**
  71656. * On intersection exit
  71657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71658. */
  71659. static readonly ACTION_OnIntersectionExitTrigger: number;
  71660. /**
  71661. * On key down
  71662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71663. */
  71664. static readonly ACTION_OnKeyDownTrigger: number;
  71665. /**
  71666. * On key up
  71667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71668. */
  71669. static readonly ACTION_OnKeyUpTrigger: number;
  71670. /**
  71671. * Billboard mode will only apply to Y axis
  71672. */
  71673. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71674. /**
  71675. * Billboard mode will apply to all axes
  71676. */
  71677. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71678. /**
  71679. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71680. */
  71681. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71682. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71683. * Test order :
  71684. * Is the bounding sphere outside the frustum ?
  71685. * If not, are the bounding box vertices outside the frustum ?
  71686. * It not, then the cullable object is in the frustum.
  71687. */
  71688. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71689. /** Culling strategy : Bounding Sphere Only.
  71690. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71691. * It's also less accurate than the standard because some not visible objects can still be selected.
  71692. * Test : is the bounding sphere outside the frustum ?
  71693. * If not, then the cullable object is in the frustum.
  71694. */
  71695. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71696. /** Culling strategy : Optimistic Inclusion.
  71697. * This in an inclusion test first, then the standard exclusion test.
  71698. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71699. * 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.
  71700. * Anyway, it's as accurate as the standard strategy.
  71701. * Test :
  71702. * Is the cullable object bounding sphere center in the frustum ?
  71703. * If not, apply the default culling strategy.
  71704. */
  71705. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71706. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71707. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71708. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71709. * 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.
  71710. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71711. * Test :
  71712. * Is the cullable object bounding sphere center in the frustum ?
  71713. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71714. */
  71715. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71716. /**
  71717. * No logging while loading
  71718. */
  71719. static readonly SCENELOADER_NO_LOGGING: number;
  71720. /**
  71721. * Minimal logging while loading
  71722. */
  71723. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71724. /**
  71725. * Summary logging while loading
  71726. */
  71727. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71728. /**
  71729. * Detailled logging while loading
  71730. */
  71731. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71732. }
  71733. }
  71734. declare module BABYLON {
  71735. /**
  71736. * This represents the required contract to create a new type of texture loader.
  71737. */
  71738. export interface IInternalTextureLoader {
  71739. /**
  71740. * Defines wether the loader supports cascade loading the different faces.
  71741. */
  71742. supportCascades: boolean;
  71743. /**
  71744. * This returns if the loader support the current file information.
  71745. * @param extension defines the file extension of the file being loaded
  71746. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71747. * @param fallback defines the fallback internal texture if any
  71748. * @param isBase64 defines whether the texture is encoded as a base64
  71749. * @param isBuffer defines whether the texture data are stored as a buffer
  71750. * @returns true if the loader can load the specified file
  71751. */
  71752. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71753. /**
  71754. * Transform the url before loading if required.
  71755. * @param rootUrl the url of the texture
  71756. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71757. * @returns the transformed texture
  71758. */
  71759. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71760. /**
  71761. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71762. * @param rootUrl the url of the texture
  71763. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71764. * @returns the fallback texture
  71765. */
  71766. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71767. /**
  71768. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71769. * @param data contains the texture data
  71770. * @param texture defines the BabylonJS internal texture
  71771. * @param createPolynomials will be true if polynomials have been requested
  71772. * @param onLoad defines the callback to trigger once the texture is ready
  71773. * @param onError defines the callback to trigger in case of error
  71774. */
  71775. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71776. /**
  71777. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71778. * @param data contains the texture data
  71779. * @param texture defines the BabylonJS internal texture
  71780. * @param callback defines the method to call once ready to upload
  71781. */
  71782. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71783. }
  71784. }
  71785. declare module BABYLON {
  71786. /**
  71787. * Class used to store and describe the pipeline context associated with an effect
  71788. */
  71789. export interface IPipelineContext {
  71790. /**
  71791. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71792. */
  71793. isAsync: boolean;
  71794. /**
  71795. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71796. */
  71797. isReady: boolean;
  71798. /** @hidden */
  71799. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71800. }
  71801. }
  71802. declare module BABYLON {
  71803. /**
  71804. * Class used to store gfx data (like WebGLBuffer)
  71805. */
  71806. export class DataBuffer {
  71807. /**
  71808. * Gets or sets the number of objects referencing this buffer
  71809. */
  71810. references: number;
  71811. /** Gets or sets the size of the underlying buffer */
  71812. capacity: number;
  71813. /**
  71814. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71815. */
  71816. is32Bits: boolean;
  71817. /**
  71818. * Gets the underlying buffer
  71819. */
  71820. get underlyingResource(): any;
  71821. }
  71822. }
  71823. declare module BABYLON {
  71824. /** @hidden */
  71825. export interface IShaderProcessor {
  71826. attributeProcessor?: (attribute: string) => string;
  71827. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71828. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71829. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71830. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71831. lineProcessor?: (line: string, isFragment: boolean) => string;
  71832. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71833. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71834. }
  71835. }
  71836. declare module BABYLON {
  71837. /** @hidden */
  71838. export interface ProcessingOptions {
  71839. defines: string[];
  71840. indexParameters: any;
  71841. isFragment: boolean;
  71842. shouldUseHighPrecisionShader: boolean;
  71843. supportsUniformBuffers: boolean;
  71844. shadersRepository: string;
  71845. includesShadersStore: {
  71846. [key: string]: string;
  71847. };
  71848. processor?: IShaderProcessor;
  71849. version: string;
  71850. platformName: string;
  71851. lookForClosingBracketForUniformBuffer?: boolean;
  71852. }
  71853. }
  71854. declare module BABYLON {
  71855. /** @hidden */
  71856. export class ShaderCodeNode {
  71857. line: string;
  71858. children: ShaderCodeNode[];
  71859. additionalDefineKey?: string;
  71860. additionalDefineValue?: string;
  71861. isValid(preprocessors: {
  71862. [key: string]: string;
  71863. }): boolean;
  71864. process(preprocessors: {
  71865. [key: string]: string;
  71866. }, options: ProcessingOptions): string;
  71867. }
  71868. }
  71869. declare module BABYLON {
  71870. /** @hidden */
  71871. export class ShaderCodeCursor {
  71872. private _lines;
  71873. lineIndex: number;
  71874. get currentLine(): string;
  71875. get canRead(): boolean;
  71876. set lines(value: string[]);
  71877. }
  71878. }
  71879. declare module BABYLON {
  71880. /** @hidden */
  71881. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71882. process(preprocessors: {
  71883. [key: string]: string;
  71884. }, options: ProcessingOptions): string;
  71885. }
  71886. }
  71887. declare module BABYLON {
  71888. /** @hidden */
  71889. export class ShaderDefineExpression {
  71890. isTrue(preprocessors: {
  71891. [key: string]: string;
  71892. }): boolean;
  71893. }
  71894. }
  71895. declare module BABYLON {
  71896. /** @hidden */
  71897. export class ShaderCodeTestNode extends ShaderCodeNode {
  71898. testExpression: ShaderDefineExpression;
  71899. isValid(preprocessors: {
  71900. [key: string]: string;
  71901. }): boolean;
  71902. }
  71903. }
  71904. declare module BABYLON {
  71905. /** @hidden */
  71906. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71907. define: string;
  71908. not: boolean;
  71909. constructor(define: string, not?: boolean);
  71910. isTrue(preprocessors: {
  71911. [key: string]: string;
  71912. }): boolean;
  71913. }
  71914. }
  71915. declare module BABYLON {
  71916. /** @hidden */
  71917. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71918. leftOperand: ShaderDefineExpression;
  71919. rightOperand: ShaderDefineExpression;
  71920. isTrue(preprocessors: {
  71921. [key: string]: string;
  71922. }): boolean;
  71923. }
  71924. }
  71925. declare module BABYLON {
  71926. /** @hidden */
  71927. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71928. leftOperand: ShaderDefineExpression;
  71929. rightOperand: ShaderDefineExpression;
  71930. isTrue(preprocessors: {
  71931. [key: string]: string;
  71932. }): boolean;
  71933. }
  71934. }
  71935. declare module BABYLON {
  71936. /** @hidden */
  71937. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71938. define: string;
  71939. operand: string;
  71940. testValue: string;
  71941. constructor(define: string, operand: string, testValue: string);
  71942. isTrue(preprocessors: {
  71943. [key: string]: string;
  71944. }): boolean;
  71945. }
  71946. }
  71947. declare module BABYLON {
  71948. /**
  71949. * Class used to enable access to offline support
  71950. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71951. */
  71952. export interface IOfflineProvider {
  71953. /**
  71954. * Gets a boolean indicating if scene must be saved in the database
  71955. */
  71956. enableSceneOffline: boolean;
  71957. /**
  71958. * Gets a boolean indicating if textures must be saved in the database
  71959. */
  71960. enableTexturesOffline: boolean;
  71961. /**
  71962. * Open the offline support and make it available
  71963. * @param successCallback defines the callback to call on success
  71964. * @param errorCallback defines the callback to call on error
  71965. */
  71966. open(successCallback: () => void, errorCallback: () => void): void;
  71967. /**
  71968. * Loads an image from the offline support
  71969. * @param url defines the url to load from
  71970. * @param image defines the target DOM image
  71971. */
  71972. loadImage(url: string, image: HTMLImageElement): void;
  71973. /**
  71974. * Loads a file from offline support
  71975. * @param url defines the URL to load from
  71976. * @param sceneLoaded defines a callback to call on success
  71977. * @param progressCallBack defines a callback to call when progress changed
  71978. * @param errorCallback defines a callback to call on error
  71979. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71980. */
  71981. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71982. }
  71983. }
  71984. declare module BABYLON {
  71985. /**
  71986. * Class used to help managing file picking and drag'n'drop
  71987. * File Storage
  71988. */
  71989. export class FilesInputStore {
  71990. /**
  71991. * List of files ready to be loaded
  71992. */
  71993. static FilesToLoad: {
  71994. [key: string]: File;
  71995. };
  71996. }
  71997. }
  71998. declare module BABYLON {
  71999. /**
  72000. * Class used to define a retry strategy when error happens while loading assets
  72001. */
  72002. export class RetryStrategy {
  72003. /**
  72004. * Function used to defines an exponential back off strategy
  72005. * @param maxRetries defines the maximum number of retries (3 by default)
  72006. * @param baseInterval defines the interval between retries
  72007. * @returns the strategy function to use
  72008. */
  72009. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  72010. }
  72011. }
  72012. declare module BABYLON {
  72013. /**
  72014. * @ignore
  72015. * Application error to support additional information when loading a file
  72016. */
  72017. export abstract class BaseError extends Error {
  72018. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  72019. }
  72020. }
  72021. declare module BABYLON {
  72022. /** @ignore */
  72023. export class LoadFileError extends BaseError {
  72024. request?: WebRequest;
  72025. file?: File;
  72026. /**
  72027. * Creates a new LoadFileError
  72028. * @param message defines the message of the error
  72029. * @param request defines the optional web request
  72030. * @param file defines the optional file
  72031. */
  72032. constructor(message: string, object?: WebRequest | File);
  72033. }
  72034. /** @ignore */
  72035. export class RequestFileError extends BaseError {
  72036. request: WebRequest;
  72037. /**
  72038. * Creates a new LoadFileError
  72039. * @param message defines the message of the error
  72040. * @param request defines the optional web request
  72041. */
  72042. constructor(message: string, request: WebRequest);
  72043. }
  72044. /** @ignore */
  72045. export class ReadFileError extends BaseError {
  72046. file: File;
  72047. /**
  72048. * Creates a new ReadFileError
  72049. * @param message defines the message of the error
  72050. * @param file defines the optional file
  72051. */
  72052. constructor(message: string, file: File);
  72053. }
  72054. /**
  72055. * @hidden
  72056. */
  72057. export class FileTools {
  72058. /**
  72059. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  72060. */
  72061. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  72062. /**
  72063. * Gets or sets the base URL to use to load assets
  72064. */
  72065. static BaseUrl: string;
  72066. /**
  72067. * Default behaviour for cors in the application.
  72068. * It can be a string if the expected behavior is identical in the entire app.
  72069. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  72070. */
  72071. static CorsBehavior: string | ((url: string | string[]) => string);
  72072. /**
  72073. * Gets or sets a function used to pre-process url before using them to load assets
  72074. */
  72075. static PreprocessUrl: (url: string) => string;
  72076. /**
  72077. * Removes unwanted characters from an url
  72078. * @param url defines the url to clean
  72079. * @returns the cleaned url
  72080. */
  72081. private static _CleanUrl;
  72082. /**
  72083. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  72084. * @param url define the url we are trying
  72085. * @param element define the dom element where to configure the cors policy
  72086. */
  72087. static SetCorsBehavior(url: string | string[], element: {
  72088. crossOrigin: string | null;
  72089. }): void;
  72090. /**
  72091. * Loads an image as an HTMLImageElement.
  72092. * @param input url string, ArrayBuffer, or Blob to load
  72093. * @param onLoad callback called when the image successfully loads
  72094. * @param onError callback called when the image fails to load
  72095. * @param offlineProvider offline provider for caching
  72096. * @param mimeType optional mime type
  72097. * @returns the HTMLImageElement of the loaded image
  72098. */
  72099. 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>;
  72100. /**
  72101. * Reads a file from a File object
  72102. * @param file defines the file to load
  72103. * @param onSuccess defines the callback to call when data is loaded
  72104. * @param onProgress defines the callback to call during loading process
  72105. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  72106. * @param onError defines the callback to call when an error occurs
  72107. * @returns a file request object
  72108. */
  72109. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  72110. /**
  72111. * Loads a file from a url
  72112. * @param url url to load
  72113. * @param onSuccess callback called when the file successfully loads
  72114. * @param onProgress callback called while file is loading (if the server supports this mode)
  72115. * @param offlineProvider defines the offline provider for caching
  72116. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72117. * @param onError callback called when the file fails to load
  72118. * @returns a file request object
  72119. */
  72120. 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;
  72121. /**
  72122. * Loads a file
  72123. * @param url url to load
  72124. * @param onSuccess callback called when the file successfully loads
  72125. * @param onProgress callback called while file is loading (if the server supports this mode)
  72126. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72127. * @param onError callback called when the file fails to load
  72128. * @param onOpened callback called when the web request is opened
  72129. * @returns a file request object
  72130. */
  72131. 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;
  72132. /**
  72133. * Checks if the loaded document was accessed via `file:`-Protocol.
  72134. * @returns boolean
  72135. */
  72136. static IsFileURL(): boolean;
  72137. }
  72138. }
  72139. declare module BABYLON {
  72140. /** @hidden */
  72141. export class ShaderProcessor {
  72142. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  72143. private static _ProcessPrecision;
  72144. private static _ExtractOperation;
  72145. private static _BuildSubExpression;
  72146. private static _BuildExpression;
  72147. private static _MoveCursorWithinIf;
  72148. private static _MoveCursor;
  72149. private static _EvaluatePreProcessors;
  72150. private static _PreparePreProcessors;
  72151. private static _ProcessShaderConversion;
  72152. private static _ProcessIncludes;
  72153. /**
  72154. * Loads a file from a url
  72155. * @param url url to load
  72156. * @param onSuccess callback called when the file successfully loads
  72157. * @param onProgress callback called while file is loading (if the server supports this mode)
  72158. * @param offlineProvider defines the offline provider for caching
  72159. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72160. * @param onError callback called when the file fails to load
  72161. * @returns a file request object
  72162. * @hidden
  72163. */
  72164. 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;
  72165. }
  72166. }
  72167. declare module BABYLON {
  72168. /**
  72169. * @hidden
  72170. */
  72171. export interface IColor4Like {
  72172. r: float;
  72173. g: float;
  72174. b: float;
  72175. a: float;
  72176. }
  72177. /**
  72178. * @hidden
  72179. */
  72180. export interface IColor3Like {
  72181. r: float;
  72182. g: float;
  72183. b: float;
  72184. }
  72185. /**
  72186. * @hidden
  72187. */
  72188. export interface IVector4Like {
  72189. x: float;
  72190. y: float;
  72191. z: float;
  72192. w: float;
  72193. }
  72194. /**
  72195. * @hidden
  72196. */
  72197. export interface IVector3Like {
  72198. x: float;
  72199. y: float;
  72200. z: float;
  72201. }
  72202. /**
  72203. * @hidden
  72204. */
  72205. export interface IVector2Like {
  72206. x: float;
  72207. y: float;
  72208. }
  72209. /**
  72210. * @hidden
  72211. */
  72212. export interface IMatrixLike {
  72213. toArray(): DeepImmutable<Float32Array>;
  72214. updateFlag: int;
  72215. }
  72216. /**
  72217. * @hidden
  72218. */
  72219. export interface IViewportLike {
  72220. x: float;
  72221. y: float;
  72222. width: float;
  72223. height: float;
  72224. }
  72225. /**
  72226. * @hidden
  72227. */
  72228. export interface IPlaneLike {
  72229. normal: IVector3Like;
  72230. d: float;
  72231. normalize(): void;
  72232. }
  72233. }
  72234. declare module BABYLON {
  72235. /**
  72236. * Interface used to define common properties for effect fallbacks
  72237. */
  72238. export interface IEffectFallbacks {
  72239. /**
  72240. * Removes the defines that should be removed when falling back.
  72241. * @param currentDefines defines the current define statements for the shader.
  72242. * @param effect defines the current effect we try to compile
  72243. * @returns The resulting defines with defines of the current rank removed.
  72244. */
  72245. reduce(currentDefines: string, effect: Effect): string;
  72246. /**
  72247. * Removes the fallback from the bound mesh.
  72248. */
  72249. unBindMesh(): void;
  72250. /**
  72251. * Checks to see if more fallbacks are still availible.
  72252. */
  72253. hasMoreFallbacks: boolean;
  72254. }
  72255. }
  72256. declare module BABYLON {
  72257. /**
  72258. * Class used to evalaute queries containing `and` and `or` operators
  72259. */
  72260. export class AndOrNotEvaluator {
  72261. /**
  72262. * Evaluate a query
  72263. * @param query defines the query to evaluate
  72264. * @param evaluateCallback defines the callback used to filter result
  72265. * @returns true if the query matches
  72266. */
  72267. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  72268. private static _HandleParenthesisContent;
  72269. private static _SimplifyNegation;
  72270. }
  72271. }
  72272. declare module BABYLON {
  72273. /**
  72274. * Class used to store custom tags
  72275. */
  72276. export class Tags {
  72277. /**
  72278. * Adds support for tags on the given object
  72279. * @param obj defines the object to use
  72280. */
  72281. static EnableFor(obj: any): void;
  72282. /**
  72283. * Removes tags support
  72284. * @param obj defines the object to use
  72285. */
  72286. static DisableFor(obj: any): void;
  72287. /**
  72288. * Gets a boolean indicating if the given object has tags
  72289. * @param obj defines the object to use
  72290. * @returns a boolean
  72291. */
  72292. static HasTags(obj: any): boolean;
  72293. /**
  72294. * Gets the tags available on a given object
  72295. * @param obj defines the object to use
  72296. * @param asString defines if the tags must be returned as a string instead of an array of strings
  72297. * @returns the tags
  72298. */
  72299. static GetTags(obj: any, asString?: boolean): any;
  72300. /**
  72301. * Adds tags to an object
  72302. * @param obj defines the object to use
  72303. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  72304. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  72305. */
  72306. static AddTagsTo(obj: any, tagsString: string): void;
  72307. /**
  72308. * @hidden
  72309. */
  72310. static _AddTagTo(obj: any, tag: string): void;
  72311. /**
  72312. * Removes specific tags from a specific object
  72313. * @param obj defines the object to use
  72314. * @param tagsString defines the tags to remove
  72315. */
  72316. static RemoveTagsFrom(obj: any, tagsString: string): void;
  72317. /**
  72318. * @hidden
  72319. */
  72320. static _RemoveTagFrom(obj: any, tag: string): void;
  72321. /**
  72322. * Defines if tags hosted on an object match a given query
  72323. * @param obj defines the object to use
  72324. * @param tagsQuery defines the tag query
  72325. * @returns a boolean
  72326. */
  72327. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  72328. }
  72329. }
  72330. declare module BABYLON {
  72331. /**
  72332. * Scalar computation library
  72333. */
  72334. export class Scalar {
  72335. /**
  72336. * Two pi constants convenient for computation.
  72337. */
  72338. static TwoPi: number;
  72339. /**
  72340. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72341. * @param a number
  72342. * @param b number
  72343. * @param epsilon (default = 1.401298E-45)
  72344. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72345. */
  72346. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  72347. /**
  72348. * Returns a string : the upper case translation of the number i to hexadecimal.
  72349. * @param i number
  72350. * @returns the upper case translation of the number i to hexadecimal.
  72351. */
  72352. static ToHex(i: number): string;
  72353. /**
  72354. * Returns -1 if value is negative and +1 is value is positive.
  72355. * @param value the value
  72356. * @returns the value itself if it's equal to zero.
  72357. */
  72358. static Sign(value: number): number;
  72359. /**
  72360. * Returns the value itself if it's between min and max.
  72361. * Returns min if the value is lower than min.
  72362. * Returns max if the value is greater than max.
  72363. * @param value the value to clmap
  72364. * @param min the min value to clamp to (default: 0)
  72365. * @param max the max value to clamp to (default: 1)
  72366. * @returns the clamped value
  72367. */
  72368. static Clamp(value: number, min?: number, max?: number): number;
  72369. /**
  72370. * the log2 of value.
  72371. * @param value the value to compute log2 of
  72372. * @returns the log2 of value.
  72373. */
  72374. static Log2(value: number): number;
  72375. /**
  72376. * Loops the value, so that it is never larger than length and never smaller than 0.
  72377. *
  72378. * This is similar to the modulo operator but it works with floating point numbers.
  72379. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  72380. * With t = 5 and length = 2.5, the result would be 0.0.
  72381. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  72382. * @param value the value
  72383. * @param length the length
  72384. * @returns the looped value
  72385. */
  72386. static Repeat(value: number, length: number): number;
  72387. /**
  72388. * Normalize the value between 0.0 and 1.0 using min and max values
  72389. * @param value value to normalize
  72390. * @param min max to normalize between
  72391. * @param max min to normalize between
  72392. * @returns the normalized value
  72393. */
  72394. static Normalize(value: number, min: number, max: number): number;
  72395. /**
  72396. * Denormalize the value from 0.0 and 1.0 using min and max values
  72397. * @param normalized value to denormalize
  72398. * @param min max to denormalize between
  72399. * @param max min to denormalize between
  72400. * @returns the denormalized value
  72401. */
  72402. static Denormalize(normalized: number, min: number, max: number): number;
  72403. /**
  72404. * Calculates the shortest difference between two given angles given in degrees.
  72405. * @param current current angle in degrees
  72406. * @param target target angle in degrees
  72407. * @returns the delta
  72408. */
  72409. static DeltaAngle(current: number, target: number): number;
  72410. /**
  72411. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  72412. * @param tx value
  72413. * @param length length
  72414. * @returns The returned value will move back and forth between 0 and length
  72415. */
  72416. static PingPong(tx: number, length: number): number;
  72417. /**
  72418. * Interpolates between min and max with smoothing at the limits.
  72419. *
  72420. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  72421. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  72422. * @param from from
  72423. * @param to to
  72424. * @param tx value
  72425. * @returns the smooth stepped value
  72426. */
  72427. static SmoothStep(from: number, to: number, tx: number): number;
  72428. /**
  72429. * Moves a value current towards target.
  72430. *
  72431. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  72432. * Negative values of maxDelta pushes the value away from target.
  72433. * @param current current value
  72434. * @param target target value
  72435. * @param maxDelta max distance to move
  72436. * @returns resulting value
  72437. */
  72438. static MoveTowards(current: number, target: number, maxDelta: number): number;
  72439. /**
  72440. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72441. *
  72442. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  72443. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  72444. * @param current current value
  72445. * @param target target value
  72446. * @param maxDelta max distance to move
  72447. * @returns resulting angle
  72448. */
  72449. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  72450. /**
  72451. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  72452. * @param start start value
  72453. * @param end target value
  72454. * @param amount amount to lerp between
  72455. * @returns the lerped value
  72456. */
  72457. static Lerp(start: number, end: number, amount: number): number;
  72458. /**
  72459. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72460. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  72461. * @param start start value
  72462. * @param end target value
  72463. * @param amount amount to lerp between
  72464. * @returns the lerped value
  72465. */
  72466. static LerpAngle(start: number, end: number, amount: number): number;
  72467. /**
  72468. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  72469. * @param a start value
  72470. * @param b target value
  72471. * @param value value between a and b
  72472. * @returns the inverseLerp value
  72473. */
  72474. static InverseLerp(a: number, b: number, value: number): number;
  72475. /**
  72476. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  72477. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  72478. * @param value1 spline value
  72479. * @param tangent1 spline value
  72480. * @param value2 spline value
  72481. * @param tangent2 spline value
  72482. * @param amount input value
  72483. * @returns hermite result
  72484. */
  72485. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  72486. /**
  72487. * Returns a random float number between and min and max values
  72488. * @param min min value of random
  72489. * @param max max value of random
  72490. * @returns random value
  72491. */
  72492. static RandomRange(min: number, max: number): number;
  72493. /**
  72494. * This function returns percentage of a number in a given range.
  72495. *
  72496. * RangeToPercent(40,20,60) will return 0.5 (50%)
  72497. * RangeToPercent(34,0,100) will return 0.34 (34%)
  72498. * @param number to convert to percentage
  72499. * @param min min range
  72500. * @param max max range
  72501. * @returns the percentage
  72502. */
  72503. static RangeToPercent(number: number, min: number, max: number): number;
  72504. /**
  72505. * This function returns number that corresponds to the percentage in a given range.
  72506. *
  72507. * PercentToRange(0.34,0,100) will return 34.
  72508. * @param percent to convert to number
  72509. * @param min min range
  72510. * @param max max range
  72511. * @returns the number
  72512. */
  72513. static PercentToRange(percent: number, min: number, max: number): number;
  72514. /**
  72515. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  72516. * @param angle The angle to normalize in radian.
  72517. * @return The converted angle.
  72518. */
  72519. static NormalizeRadians(angle: number): number;
  72520. }
  72521. }
  72522. declare module BABYLON {
  72523. /**
  72524. * Constant used to convert a value to gamma space
  72525. * @ignorenaming
  72526. */
  72527. export const ToGammaSpace: number;
  72528. /**
  72529. * Constant used to convert a value to linear space
  72530. * @ignorenaming
  72531. */
  72532. export const ToLinearSpace = 2.2;
  72533. /**
  72534. * Constant used to define the minimal number value in Babylon.js
  72535. * @ignorenaming
  72536. */
  72537. let Epsilon: number;
  72538. }
  72539. declare module BABYLON {
  72540. /**
  72541. * Class used to represent a viewport on screen
  72542. */
  72543. export class Viewport {
  72544. /** viewport left coordinate */
  72545. x: number;
  72546. /** viewport top coordinate */
  72547. y: number;
  72548. /**viewport width */
  72549. width: number;
  72550. /** viewport height */
  72551. height: number;
  72552. /**
  72553. * Creates a Viewport object located at (x, y) and sized (width, height)
  72554. * @param x defines viewport left coordinate
  72555. * @param y defines viewport top coordinate
  72556. * @param width defines the viewport width
  72557. * @param height defines the viewport height
  72558. */
  72559. constructor(
  72560. /** viewport left coordinate */
  72561. x: number,
  72562. /** viewport top coordinate */
  72563. y: number,
  72564. /**viewport width */
  72565. width: number,
  72566. /** viewport height */
  72567. height: number);
  72568. /**
  72569. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  72570. * @param renderWidth defines the rendering width
  72571. * @param renderHeight defines the rendering height
  72572. * @returns a new Viewport
  72573. */
  72574. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  72575. /**
  72576. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  72577. * @param renderWidth defines the rendering width
  72578. * @param renderHeight defines the rendering height
  72579. * @param ref defines the target viewport
  72580. * @returns the current viewport
  72581. */
  72582. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  72583. /**
  72584. * Returns a new Viewport copied from the current one
  72585. * @returns a new Viewport
  72586. */
  72587. clone(): Viewport;
  72588. }
  72589. }
  72590. declare module BABYLON {
  72591. /**
  72592. * Class containing a set of static utilities functions for arrays.
  72593. */
  72594. export class ArrayTools {
  72595. /**
  72596. * Returns an array of the given size filled with element built from the given constructor and the paramters
  72597. * @param size the number of element to construct and put in the array
  72598. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  72599. * @returns a new array filled with new objects
  72600. */
  72601. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  72602. }
  72603. }
  72604. declare module BABYLON {
  72605. /**
  72606. * Class representing a vector containing 2 coordinates
  72607. */
  72608. export class Vector2 {
  72609. /** defines the first coordinate */
  72610. x: number;
  72611. /** defines the second coordinate */
  72612. y: number;
  72613. /**
  72614. * Creates a new Vector2 from the given x and y coordinates
  72615. * @param x defines the first coordinate
  72616. * @param y defines the second coordinate
  72617. */
  72618. constructor(
  72619. /** defines the first coordinate */
  72620. x?: number,
  72621. /** defines the second coordinate */
  72622. y?: number);
  72623. /**
  72624. * Gets a string with the Vector2 coordinates
  72625. * @returns a string with the Vector2 coordinates
  72626. */
  72627. toString(): string;
  72628. /**
  72629. * Gets class name
  72630. * @returns the string "Vector2"
  72631. */
  72632. getClassName(): string;
  72633. /**
  72634. * Gets current vector hash code
  72635. * @returns the Vector2 hash code as a number
  72636. */
  72637. getHashCode(): number;
  72638. /**
  72639. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  72640. * @param array defines the source array
  72641. * @param index defines the offset in source array
  72642. * @returns the current Vector2
  72643. */
  72644. toArray(array: FloatArray, index?: number): Vector2;
  72645. /**
  72646. * Copy the current vector to an array
  72647. * @returns a new array with 2 elements: the Vector2 coordinates.
  72648. */
  72649. asArray(): number[];
  72650. /**
  72651. * Sets the Vector2 coordinates with the given Vector2 coordinates
  72652. * @param source defines the source Vector2
  72653. * @returns the current updated Vector2
  72654. */
  72655. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  72656. /**
  72657. * Sets the Vector2 coordinates with the given floats
  72658. * @param x defines the first coordinate
  72659. * @param y defines the second coordinate
  72660. * @returns the current updated Vector2
  72661. */
  72662. copyFromFloats(x: number, y: number): Vector2;
  72663. /**
  72664. * Sets the Vector2 coordinates with the given floats
  72665. * @param x defines the first coordinate
  72666. * @param y defines the second coordinate
  72667. * @returns the current updated Vector2
  72668. */
  72669. set(x: number, y: number): Vector2;
  72670. /**
  72671. * Add another vector with the current one
  72672. * @param otherVector defines the other vector
  72673. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  72674. */
  72675. add(otherVector: DeepImmutable<Vector2>): Vector2;
  72676. /**
  72677. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  72678. * @param otherVector defines the other vector
  72679. * @param result defines the target vector
  72680. * @returns the unmodified current Vector2
  72681. */
  72682. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72683. /**
  72684. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  72685. * @param otherVector defines the other vector
  72686. * @returns the current updated Vector2
  72687. */
  72688. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72689. /**
  72690. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  72691. * @param otherVector defines the other vector
  72692. * @returns a new Vector2
  72693. */
  72694. addVector3(otherVector: Vector3): Vector2;
  72695. /**
  72696. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  72697. * @param otherVector defines the other vector
  72698. * @returns a new Vector2
  72699. */
  72700. subtract(otherVector: Vector2): Vector2;
  72701. /**
  72702. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  72703. * @param otherVector defines the other vector
  72704. * @param result defines the target vector
  72705. * @returns the unmodified current Vector2
  72706. */
  72707. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72708. /**
  72709. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  72710. * @param otherVector defines the other vector
  72711. * @returns the current updated Vector2
  72712. */
  72713. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72714. /**
  72715. * Multiplies in place the current Vector2 coordinates by the given ones
  72716. * @param otherVector defines the other vector
  72717. * @returns the current updated Vector2
  72718. */
  72719. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72720. /**
  72721. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  72722. * @param otherVector defines the other vector
  72723. * @returns a new Vector2
  72724. */
  72725. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  72726. /**
  72727. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  72728. * @param otherVector defines the other vector
  72729. * @param result defines the target vector
  72730. * @returns the unmodified current Vector2
  72731. */
  72732. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72733. /**
  72734. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  72735. * @param x defines the first coordinate
  72736. * @param y defines the second coordinate
  72737. * @returns a new Vector2
  72738. */
  72739. multiplyByFloats(x: number, y: number): Vector2;
  72740. /**
  72741. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  72742. * @param otherVector defines the other vector
  72743. * @returns a new Vector2
  72744. */
  72745. divide(otherVector: Vector2): Vector2;
  72746. /**
  72747. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  72748. * @param otherVector defines the other vector
  72749. * @param result defines the target vector
  72750. * @returns the unmodified current Vector2
  72751. */
  72752. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72753. /**
  72754. * Divides the current Vector2 coordinates by the given ones
  72755. * @param otherVector defines the other vector
  72756. * @returns the current updated Vector2
  72757. */
  72758. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72759. /**
  72760. * Gets a new Vector2 with current Vector2 negated coordinates
  72761. * @returns a new Vector2
  72762. */
  72763. negate(): Vector2;
  72764. /**
  72765. * Multiply the Vector2 coordinates by scale
  72766. * @param scale defines the scaling factor
  72767. * @returns the current updated Vector2
  72768. */
  72769. scaleInPlace(scale: number): Vector2;
  72770. /**
  72771. * Returns a new Vector2 scaled by "scale" from the current Vector2
  72772. * @param scale defines the scaling factor
  72773. * @returns a new Vector2
  72774. */
  72775. scale(scale: number): Vector2;
  72776. /**
  72777. * Scale the current Vector2 values by a factor to a given Vector2
  72778. * @param scale defines the scale factor
  72779. * @param result defines the Vector2 object where to store the result
  72780. * @returns the unmodified current Vector2
  72781. */
  72782. scaleToRef(scale: number, result: Vector2): Vector2;
  72783. /**
  72784. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  72785. * @param scale defines the scale factor
  72786. * @param result defines the Vector2 object where to store the result
  72787. * @returns the unmodified current Vector2
  72788. */
  72789. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  72790. /**
  72791. * Gets a boolean if two vectors are equals
  72792. * @param otherVector defines the other vector
  72793. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  72794. */
  72795. equals(otherVector: DeepImmutable<Vector2>): boolean;
  72796. /**
  72797. * Gets a boolean if two vectors are equals (using an epsilon value)
  72798. * @param otherVector defines the other vector
  72799. * @param epsilon defines the minimal distance to consider equality
  72800. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  72801. */
  72802. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  72803. /**
  72804. * Gets a new Vector2 from current Vector2 floored values
  72805. * @returns a new Vector2
  72806. */
  72807. floor(): Vector2;
  72808. /**
  72809. * Gets a new Vector2 from current Vector2 floored values
  72810. * @returns a new Vector2
  72811. */
  72812. fract(): Vector2;
  72813. /**
  72814. * Gets the length of the vector
  72815. * @returns the vector length (float)
  72816. */
  72817. length(): number;
  72818. /**
  72819. * Gets the vector squared length
  72820. * @returns the vector squared length (float)
  72821. */
  72822. lengthSquared(): number;
  72823. /**
  72824. * Normalize the vector
  72825. * @returns the current updated Vector2
  72826. */
  72827. normalize(): Vector2;
  72828. /**
  72829. * Gets a new Vector2 copied from the Vector2
  72830. * @returns a new Vector2
  72831. */
  72832. clone(): Vector2;
  72833. /**
  72834. * Gets a new Vector2(0, 0)
  72835. * @returns a new Vector2
  72836. */
  72837. static Zero(): Vector2;
  72838. /**
  72839. * Gets a new Vector2(1, 1)
  72840. * @returns a new Vector2
  72841. */
  72842. static One(): Vector2;
  72843. /**
  72844. * Gets a new Vector2 set from the given index element of the given array
  72845. * @param array defines the data source
  72846. * @param offset defines the offset in the data source
  72847. * @returns a new Vector2
  72848. */
  72849. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  72850. /**
  72851. * Sets "result" from the given index element of the given array
  72852. * @param array defines the data source
  72853. * @param offset defines the offset in the data source
  72854. * @param result defines the target vector
  72855. */
  72856. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  72857. /**
  72858. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  72859. * @param value1 defines 1st point of control
  72860. * @param value2 defines 2nd point of control
  72861. * @param value3 defines 3rd point of control
  72862. * @param value4 defines 4th point of control
  72863. * @param amount defines the interpolation factor
  72864. * @returns a new Vector2
  72865. */
  72866. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  72867. /**
  72868. * 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".
  72869. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  72870. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  72871. * @param value defines the value to clamp
  72872. * @param min defines the lower limit
  72873. * @param max defines the upper limit
  72874. * @returns a new Vector2
  72875. */
  72876. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  72877. /**
  72878. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  72879. * @param value1 defines the 1st control point
  72880. * @param tangent1 defines the outgoing tangent
  72881. * @param value2 defines the 2nd control point
  72882. * @param tangent2 defines the incoming tangent
  72883. * @param amount defines the interpolation factor
  72884. * @returns a new Vector2
  72885. */
  72886. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  72887. /**
  72888. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  72889. * @param start defines the start vector
  72890. * @param end defines the end vector
  72891. * @param amount defines the interpolation factor
  72892. * @returns a new Vector2
  72893. */
  72894. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  72895. /**
  72896. * Gets the dot product of the vector "left" and the vector "right"
  72897. * @param left defines first vector
  72898. * @param right defines second vector
  72899. * @returns the dot product (float)
  72900. */
  72901. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  72902. /**
  72903. * Returns a new Vector2 equal to the normalized given vector
  72904. * @param vector defines the vector to normalize
  72905. * @returns a new Vector2
  72906. */
  72907. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  72908. /**
  72909. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  72910. * @param left defines 1st vector
  72911. * @param right defines 2nd vector
  72912. * @returns a new Vector2
  72913. */
  72914. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72915. /**
  72916. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  72917. * @param left defines 1st vector
  72918. * @param right defines 2nd vector
  72919. * @returns a new Vector2
  72920. */
  72921. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72922. /**
  72923. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  72924. * @param vector defines the vector to transform
  72925. * @param transformation defines the matrix to apply
  72926. * @returns a new Vector2
  72927. */
  72928. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  72929. /**
  72930. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  72931. * @param vector defines the vector to transform
  72932. * @param transformation defines the matrix to apply
  72933. * @param result defines the target vector
  72934. */
  72935. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  72936. /**
  72937. * Determines if a given vector is included in a triangle
  72938. * @param p defines the vector to test
  72939. * @param p0 defines 1st triangle point
  72940. * @param p1 defines 2nd triangle point
  72941. * @param p2 defines 3rd triangle point
  72942. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  72943. */
  72944. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  72945. /**
  72946. * Gets the distance between the vectors "value1" and "value2"
  72947. * @param value1 defines first vector
  72948. * @param value2 defines second vector
  72949. * @returns the distance between vectors
  72950. */
  72951. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72952. /**
  72953. * Returns the squared distance between the vectors "value1" and "value2"
  72954. * @param value1 defines first vector
  72955. * @param value2 defines second vector
  72956. * @returns the squared distance between vectors
  72957. */
  72958. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72959. /**
  72960. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  72961. * @param value1 defines first vector
  72962. * @param value2 defines second vector
  72963. * @returns a new Vector2
  72964. */
  72965. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  72966. /**
  72967. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  72968. * @param p defines the middle point
  72969. * @param segA defines one point of the segment
  72970. * @param segB defines the other point of the segment
  72971. * @returns the shortest distance
  72972. */
  72973. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  72974. }
  72975. /**
  72976. * Class used to store (x,y,z) vector representation
  72977. * A Vector3 is the main object used in 3D geometry
  72978. * It can represent etiher the coordinates of a point the space, either a direction
  72979. * Reminder: js uses a left handed forward facing system
  72980. */
  72981. export class Vector3 {
  72982. /**
  72983. * Defines the first coordinates (on X axis)
  72984. */
  72985. x: number;
  72986. /**
  72987. * Defines the second coordinates (on Y axis)
  72988. */
  72989. y: number;
  72990. /**
  72991. * Defines the third coordinates (on Z axis)
  72992. */
  72993. z: number;
  72994. private static _UpReadOnly;
  72995. private static _ZeroReadOnly;
  72996. /**
  72997. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  72998. * @param x defines the first coordinates (on X axis)
  72999. * @param y defines the second coordinates (on Y axis)
  73000. * @param z defines the third coordinates (on Z axis)
  73001. */
  73002. constructor(
  73003. /**
  73004. * Defines the first coordinates (on X axis)
  73005. */
  73006. x?: number,
  73007. /**
  73008. * Defines the second coordinates (on Y axis)
  73009. */
  73010. y?: number,
  73011. /**
  73012. * Defines the third coordinates (on Z axis)
  73013. */
  73014. z?: number);
  73015. /**
  73016. * Creates a string representation of the Vector3
  73017. * @returns a string with the Vector3 coordinates.
  73018. */
  73019. toString(): string;
  73020. /**
  73021. * Gets the class name
  73022. * @returns the string "Vector3"
  73023. */
  73024. getClassName(): string;
  73025. /**
  73026. * Creates the Vector3 hash code
  73027. * @returns a number which tends to be unique between Vector3 instances
  73028. */
  73029. getHashCode(): number;
  73030. /**
  73031. * Creates an array containing three elements : the coordinates of the Vector3
  73032. * @returns a new array of numbers
  73033. */
  73034. asArray(): number[];
  73035. /**
  73036. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  73037. * @param array defines the destination array
  73038. * @param index defines the offset in the destination array
  73039. * @returns the current Vector3
  73040. */
  73041. toArray(array: FloatArray, index?: number): Vector3;
  73042. /**
  73043. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  73044. * @returns a new Quaternion object, computed from the Vector3 coordinates
  73045. */
  73046. toQuaternion(): Quaternion;
  73047. /**
  73048. * Adds the given vector to the current Vector3
  73049. * @param otherVector defines the second operand
  73050. * @returns the current updated Vector3
  73051. */
  73052. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73053. /**
  73054. * Adds the given coordinates to the current Vector3
  73055. * @param x defines the x coordinate of the operand
  73056. * @param y defines the y coordinate of the operand
  73057. * @param z defines the z coordinate of the operand
  73058. * @returns the current updated Vector3
  73059. */
  73060. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73061. /**
  73062. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  73063. * @param otherVector defines the second operand
  73064. * @returns the resulting Vector3
  73065. */
  73066. add(otherVector: DeepImmutable<Vector3>): Vector3;
  73067. /**
  73068. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  73069. * @param otherVector defines the second operand
  73070. * @param result defines the Vector3 object where to store the result
  73071. * @returns the current Vector3
  73072. */
  73073. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73074. /**
  73075. * Subtract the given vector from the current Vector3
  73076. * @param otherVector defines the second operand
  73077. * @returns the current updated Vector3
  73078. */
  73079. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73080. /**
  73081. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  73082. * @param otherVector defines the second operand
  73083. * @returns the resulting Vector3
  73084. */
  73085. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  73086. /**
  73087. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  73088. * @param otherVector defines the second operand
  73089. * @param result defines the Vector3 object where to store the result
  73090. * @returns the current Vector3
  73091. */
  73092. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73093. /**
  73094. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  73095. * @param x defines the x coordinate of the operand
  73096. * @param y defines the y coordinate of the operand
  73097. * @param z defines the z coordinate of the operand
  73098. * @returns the resulting Vector3
  73099. */
  73100. subtractFromFloats(x: number, y: number, z: number): Vector3;
  73101. /**
  73102. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  73103. * @param x defines the x coordinate of the operand
  73104. * @param y defines the y coordinate of the operand
  73105. * @param z defines the z coordinate of the operand
  73106. * @param result defines the Vector3 object where to store the result
  73107. * @returns the current Vector3
  73108. */
  73109. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  73110. /**
  73111. * Gets a new Vector3 set with the current Vector3 negated coordinates
  73112. * @returns a new Vector3
  73113. */
  73114. negate(): Vector3;
  73115. /**
  73116. * Negate this vector in place
  73117. * @returns this
  73118. */
  73119. negateInPlace(): Vector3;
  73120. /**
  73121. * Multiplies the Vector3 coordinates by the float "scale"
  73122. * @param scale defines the multiplier factor
  73123. * @returns the current updated Vector3
  73124. */
  73125. scaleInPlace(scale: number): Vector3;
  73126. /**
  73127. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  73128. * @param scale defines the multiplier factor
  73129. * @returns a new Vector3
  73130. */
  73131. scale(scale: number): Vector3;
  73132. /**
  73133. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  73134. * @param scale defines the multiplier factor
  73135. * @param result defines the Vector3 object where to store the result
  73136. * @returns the current Vector3
  73137. */
  73138. scaleToRef(scale: number, result: Vector3): Vector3;
  73139. /**
  73140. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  73141. * @param scale defines the scale factor
  73142. * @param result defines the Vector3 object where to store the result
  73143. * @returns the unmodified current Vector3
  73144. */
  73145. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  73146. /**
  73147. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  73148. * @param otherVector defines the second operand
  73149. * @returns true if both vectors are equals
  73150. */
  73151. equals(otherVector: DeepImmutable<Vector3>): boolean;
  73152. /**
  73153. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  73154. * @param otherVector defines the second operand
  73155. * @param epsilon defines the minimal distance to define values as equals
  73156. * @returns true if both vectors are distant less than epsilon
  73157. */
  73158. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  73159. /**
  73160. * Returns true if the current Vector3 coordinates equals the given floats
  73161. * @param x defines the x coordinate of the operand
  73162. * @param y defines the y coordinate of the operand
  73163. * @param z defines the z coordinate of the operand
  73164. * @returns true if both vectors are equals
  73165. */
  73166. equalsToFloats(x: number, y: number, z: number): boolean;
  73167. /**
  73168. * Multiplies the current Vector3 coordinates by the given ones
  73169. * @param otherVector defines the second operand
  73170. * @returns the current updated Vector3
  73171. */
  73172. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73173. /**
  73174. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  73175. * @param otherVector defines the second operand
  73176. * @returns the new Vector3
  73177. */
  73178. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  73179. /**
  73180. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  73181. * @param otherVector defines the second operand
  73182. * @param result defines the Vector3 object where to store the result
  73183. * @returns the current Vector3
  73184. */
  73185. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73186. /**
  73187. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  73188. * @param x defines the x coordinate of the operand
  73189. * @param y defines the y coordinate of the operand
  73190. * @param z defines the z coordinate of the operand
  73191. * @returns the new Vector3
  73192. */
  73193. multiplyByFloats(x: number, y: number, z: number): Vector3;
  73194. /**
  73195. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  73196. * @param otherVector defines the second operand
  73197. * @returns the new Vector3
  73198. */
  73199. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  73200. /**
  73201. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  73202. * @param otherVector defines the second operand
  73203. * @param result defines the Vector3 object where to store the result
  73204. * @returns the current Vector3
  73205. */
  73206. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73207. /**
  73208. * Divides the current Vector3 coordinates by the given ones.
  73209. * @param otherVector defines the second operand
  73210. * @returns the current updated Vector3
  73211. */
  73212. divideInPlace(otherVector: Vector3): Vector3;
  73213. /**
  73214. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  73215. * @param other defines the second operand
  73216. * @returns the current updated Vector3
  73217. */
  73218. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73219. /**
  73220. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  73221. * @param other defines the second operand
  73222. * @returns the current updated Vector3
  73223. */
  73224. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73225. /**
  73226. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  73227. * @param x defines the x coordinate of the operand
  73228. * @param y defines the y coordinate of the operand
  73229. * @param z defines the z coordinate of the operand
  73230. * @returns the current updated Vector3
  73231. */
  73232. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73233. /**
  73234. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  73235. * @param x defines the x coordinate of the operand
  73236. * @param y defines the y coordinate of the operand
  73237. * @param z defines the z coordinate of the operand
  73238. * @returns the current updated Vector3
  73239. */
  73240. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73241. /**
  73242. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  73243. * Check if is non uniform within a certain amount of decimal places to account for this
  73244. * @param epsilon the amount the values can differ
  73245. * @returns if the the vector is non uniform to a certain number of decimal places
  73246. */
  73247. isNonUniformWithinEpsilon(epsilon: number): boolean;
  73248. /**
  73249. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  73250. */
  73251. get isNonUniform(): boolean;
  73252. /**
  73253. * Gets a new Vector3 from current Vector3 floored values
  73254. * @returns a new Vector3
  73255. */
  73256. floor(): Vector3;
  73257. /**
  73258. * Gets a new Vector3 from current Vector3 floored values
  73259. * @returns a new Vector3
  73260. */
  73261. fract(): Vector3;
  73262. /**
  73263. * Gets the length of the Vector3
  73264. * @returns the length of the Vector3
  73265. */
  73266. length(): number;
  73267. /**
  73268. * Gets the squared length of the Vector3
  73269. * @returns squared length of the Vector3
  73270. */
  73271. lengthSquared(): number;
  73272. /**
  73273. * Normalize the current Vector3.
  73274. * Please note that this is an in place operation.
  73275. * @returns the current updated Vector3
  73276. */
  73277. normalize(): Vector3;
  73278. /**
  73279. * Reorders the x y z properties of the vector in place
  73280. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  73281. * @returns the current updated vector
  73282. */
  73283. reorderInPlace(order: string): this;
  73284. /**
  73285. * Rotates the vector around 0,0,0 by a quaternion
  73286. * @param quaternion the rotation quaternion
  73287. * @param result vector to store the result
  73288. * @returns the resulting vector
  73289. */
  73290. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  73291. /**
  73292. * Rotates a vector around a given point
  73293. * @param quaternion the rotation quaternion
  73294. * @param point the point to rotate around
  73295. * @param result vector to store the result
  73296. * @returns the resulting vector
  73297. */
  73298. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  73299. /**
  73300. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  73301. * The cross product is then orthogonal to both current and "other"
  73302. * @param other defines the right operand
  73303. * @returns the cross product
  73304. */
  73305. cross(other: Vector3): Vector3;
  73306. /**
  73307. * Normalize the current Vector3 with the given input length.
  73308. * Please note that this is an in place operation.
  73309. * @param len the length of the vector
  73310. * @returns the current updated Vector3
  73311. */
  73312. normalizeFromLength(len: number): Vector3;
  73313. /**
  73314. * Normalize the current Vector3 to a new vector
  73315. * @returns the new Vector3
  73316. */
  73317. normalizeToNew(): Vector3;
  73318. /**
  73319. * Normalize the current Vector3 to the reference
  73320. * @param reference define the Vector3 to update
  73321. * @returns the updated Vector3
  73322. */
  73323. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  73324. /**
  73325. * Creates a new Vector3 copied from the current Vector3
  73326. * @returns the new Vector3
  73327. */
  73328. clone(): Vector3;
  73329. /**
  73330. * Copies the given vector coordinates to the current Vector3 ones
  73331. * @param source defines the source Vector3
  73332. * @returns the current updated Vector3
  73333. */
  73334. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  73335. /**
  73336. * Copies the given floats to the current Vector3 coordinates
  73337. * @param x defines the x coordinate of the operand
  73338. * @param y defines the y coordinate of the operand
  73339. * @param z defines the z coordinate of the operand
  73340. * @returns the current updated Vector3
  73341. */
  73342. copyFromFloats(x: number, y: number, z: number): Vector3;
  73343. /**
  73344. * Copies the given floats to the current Vector3 coordinates
  73345. * @param x defines the x coordinate of the operand
  73346. * @param y defines the y coordinate of the operand
  73347. * @param z defines the z coordinate of the operand
  73348. * @returns the current updated Vector3
  73349. */
  73350. set(x: number, y: number, z: number): Vector3;
  73351. /**
  73352. * Copies the given float to the current Vector3 coordinates
  73353. * @param v defines the x, y and z coordinates of the operand
  73354. * @returns the current updated Vector3
  73355. */
  73356. setAll(v: number): Vector3;
  73357. /**
  73358. * Get the clip factor between two vectors
  73359. * @param vector0 defines the first operand
  73360. * @param vector1 defines the second operand
  73361. * @param axis defines the axis to use
  73362. * @param size defines the size along the axis
  73363. * @returns the clip factor
  73364. */
  73365. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  73366. /**
  73367. * Get angle between two vectors
  73368. * @param vector0 angle between vector0 and vector1
  73369. * @param vector1 angle between vector0 and vector1
  73370. * @param normal direction of the normal
  73371. * @return the angle between vector0 and vector1
  73372. */
  73373. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  73374. /**
  73375. * Returns a new Vector3 set from the index "offset" of the given array
  73376. * @param array defines the source array
  73377. * @param offset defines the offset in the source array
  73378. * @returns the new Vector3
  73379. */
  73380. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  73381. /**
  73382. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  73383. * @param array defines the source array
  73384. * @param offset defines the offset in the source array
  73385. * @returns the new Vector3
  73386. * @deprecated Please use FromArray instead.
  73387. */
  73388. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  73389. /**
  73390. * Sets the given vector "result" with the element values from the index "offset" of the given array
  73391. * @param array defines the source array
  73392. * @param offset defines the offset in the source array
  73393. * @param result defines the Vector3 where to store the result
  73394. */
  73395. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  73396. /**
  73397. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  73398. * @param array defines the source array
  73399. * @param offset defines the offset in the source array
  73400. * @param result defines the Vector3 where to store the result
  73401. * @deprecated Please use FromArrayToRef instead.
  73402. */
  73403. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  73404. /**
  73405. * Sets the given vector "result" with the given floats.
  73406. * @param x defines the x coordinate of the source
  73407. * @param y defines the y coordinate of the source
  73408. * @param z defines the z coordinate of the source
  73409. * @param result defines the Vector3 where to store the result
  73410. */
  73411. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  73412. /**
  73413. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  73414. * @returns a new empty Vector3
  73415. */
  73416. static Zero(): Vector3;
  73417. /**
  73418. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  73419. * @returns a new unit Vector3
  73420. */
  73421. static One(): Vector3;
  73422. /**
  73423. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  73424. * @returns a new up Vector3
  73425. */
  73426. static Up(): Vector3;
  73427. /**
  73428. * Gets a up Vector3 that must not be updated
  73429. */
  73430. static get UpReadOnly(): DeepImmutable<Vector3>;
  73431. /**
  73432. * Gets a zero Vector3 that must not be updated
  73433. */
  73434. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  73435. /**
  73436. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  73437. * @returns a new down Vector3
  73438. */
  73439. static Down(): Vector3;
  73440. /**
  73441. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  73442. * @returns a new forward Vector3
  73443. */
  73444. static Forward(): Vector3;
  73445. /**
  73446. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  73447. * @returns a new forward Vector3
  73448. */
  73449. static Backward(): Vector3;
  73450. /**
  73451. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  73452. * @returns a new right Vector3
  73453. */
  73454. static Right(): Vector3;
  73455. /**
  73456. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  73457. * @returns a new left Vector3
  73458. */
  73459. static Left(): Vector3;
  73460. /**
  73461. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  73462. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73463. * @param vector defines the Vector3 to transform
  73464. * @param transformation defines the transformation matrix
  73465. * @returns the transformed Vector3
  73466. */
  73467. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73468. /**
  73469. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  73470. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73471. * @param vector defines the Vector3 to transform
  73472. * @param transformation defines the transformation matrix
  73473. * @param result defines the Vector3 where to store the result
  73474. */
  73475. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73476. /**
  73477. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  73478. * This method computes tranformed coordinates only, not transformed direction vectors
  73479. * @param x define the x coordinate of the source vector
  73480. * @param y define the y coordinate of the source vector
  73481. * @param z define the z coordinate of the source vector
  73482. * @param transformation defines the transformation matrix
  73483. * @param result defines the Vector3 where to store the result
  73484. */
  73485. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73486. /**
  73487. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  73488. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73489. * @param vector defines the Vector3 to transform
  73490. * @param transformation defines the transformation matrix
  73491. * @returns the new Vector3
  73492. */
  73493. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73494. /**
  73495. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  73496. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73497. * @param vector defines the Vector3 to transform
  73498. * @param transformation defines the transformation matrix
  73499. * @param result defines the Vector3 where to store the result
  73500. */
  73501. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73502. /**
  73503. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  73504. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73505. * @param x define the x coordinate of the source vector
  73506. * @param y define the y coordinate of the source vector
  73507. * @param z define the z coordinate of the source vector
  73508. * @param transformation defines the transformation matrix
  73509. * @param result defines the Vector3 where to store the result
  73510. */
  73511. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73512. /**
  73513. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  73514. * @param value1 defines the first control point
  73515. * @param value2 defines the second control point
  73516. * @param value3 defines the third control point
  73517. * @param value4 defines the fourth control point
  73518. * @param amount defines the amount on the spline to use
  73519. * @returns the new Vector3
  73520. */
  73521. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  73522. /**
  73523. * 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"
  73524. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73525. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73526. * @param value defines the current value
  73527. * @param min defines the lower range value
  73528. * @param max defines the upper range value
  73529. * @returns the new Vector3
  73530. */
  73531. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  73532. /**
  73533. * 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"
  73534. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73535. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73536. * @param value defines the current value
  73537. * @param min defines the lower range value
  73538. * @param max defines the upper range value
  73539. * @param result defines the Vector3 where to store the result
  73540. */
  73541. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  73542. /**
  73543. * Checks if a given vector is inside a specific range
  73544. * @param v defines the vector to test
  73545. * @param min defines the minimum range
  73546. * @param max defines the maximum range
  73547. */
  73548. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  73549. /**
  73550. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  73551. * @param value1 defines the first control point
  73552. * @param tangent1 defines the first tangent vector
  73553. * @param value2 defines the second control point
  73554. * @param tangent2 defines the second tangent vector
  73555. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  73556. * @returns the new Vector3
  73557. */
  73558. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  73559. /**
  73560. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  73561. * @param start defines the start value
  73562. * @param end defines the end value
  73563. * @param amount max defines amount between both (between 0 and 1)
  73564. * @returns the new Vector3
  73565. */
  73566. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  73567. /**
  73568. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  73569. * @param start defines the start value
  73570. * @param end defines the end value
  73571. * @param amount max defines amount between both (between 0 and 1)
  73572. * @param result defines the Vector3 where to store the result
  73573. */
  73574. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  73575. /**
  73576. * Returns the dot product (float) between the vectors "left" and "right"
  73577. * @param left defines the left operand
  73578. * @param right defines the right operand
  73579. * @returns the dot product
  73580. */
  73581. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  73582. /**
  73583. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  73584. * The cross product is then orthogonal to both "left" and "right"
  73585. * @param left defines the left operand
  73586. * @param right defines the right operand
  73587. * @returns the cross product
  73588. */
  73589. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73590. /**
  73591. * Sets the given vector "result" with the cross product of "left" and "right"
  73592. * The cross product is then orthogonal to both "left" and "right"
  73593. * @param left defines the left operand
  73594. * @param right defines the right operand
  73595. * @param result defines the Vector3 where to store the result
  73596. */
  73597. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  73598. /**
  73599. * Returns a new Vector3 as the normalization of the given vector
  73600. * @param vector defines the Vector3 to normalize
  73601. * @returns the new Vector3
  73602. */
  73603. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  73604. /**
  73605. * Sets the given vector "result" with the normalization of the given first vector
  73606. * @param vector defines the Vector3 to normalize
  73607. * @param result defines the Vector3 where to store the result
  73608. */
  73609. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  73610. /**
  73611. * Project a Vector3 onto screen space
  73612. * @param vector defines the Vector3 to project
  73613. * @param world defines the world matrix to use
  73614. * @param transform defines the transform (view x projection) matrix to use
  73615. * @param viewport defines the screen viewport to use
  73616. * @returns the new Vector3
  73617. */
  73618. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  73619. /** @hidden */
  73620. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  73621. /**
  73622. * Unproject from screen space to object space
  73623. * @param source defines the screen space Vector3 to use
  73624. * @param viewportWidth defines the current width of the viewport
  73625. * @param viewportHeight defines the current height of the viewport
  73626. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73627. * @param transform defines the transform (view x projection) matrix to use
  73628. * @returns the new Vector3
  73629. */
  73630. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  73631. /**
  73632. * Unproject from screen space to object space
  73633. * @param source defines the screen space Vector3 to use
  73634. * @param viewportWidth defines the current width of the viewport
  73635. * @param viewportHeight defines the current height of the viewport
  73636. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73637. * @param view defines the view matrix to use
  73638. * @param projection defines the projection matrix to use
  73639. * @returns the new Vector3
  73640. */
  73641. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  73642. /**
  73643. * Unproject from screen space to object space
  73644. * @param source defines the screen space Vector3 to use
  73645. * @param viewportWidth defines the current width of the viewport
  73646. * @param viewportHeight defines the current height of the viewport
  73647. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73648. * @param view defines the view matrix to use
  73649. * @param projection defines the projection matrix to use
  73650. * @param result defines the Vector3 where to store the result
  73651. */
  73652. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73653. /**
  73654. * Unproject from screen space to object space
  73655. * @param sourceX defines the screen space x coordinate to use
  73656. * @param sourceY defines the screen space y coordinate to use
  73657. * @param sourceZ defines the screen space z coordinate to use
  73658. * @param viewportWidth defines the current width of the viewport
  73659. * @param viewportHeight defines the current height of the viewport
  73660. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73661. * @param view defines the view matrix to use
  73662. * @param projection defines the projection matrix to use
  73663. * @param result defines the Vector3 where to store the result
  73664. */
  73665. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73666. /**
  73667. * Gets the minimal coordinate values between two Vector3
  73668. * @param left defines the first operand
  73669. * @param right defines the second operand
  73670. * @returns the new Vector3
  73671. */
  73672. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73673. /**
  73674. * Gets the maximal coordinate values between two Vector3
  73675. * @param left defines the first operand
  73676. * @param right defines the second operand
  73677. * @returns the new Vector3
  73678. */
  73679. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73680. /**
  73681. * Returns the distance between the vectors "value1" and "value2"
  73682. * @param value1 defines the first operand
  73683. * @param value2 defines the second operand
  73684. * @returns the distance
  73685. */
  73686. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73687. /**
  73688. * Returns the squared distance between the vectors "value1" and "value2"
  73689. * @param value1 defines the first operand
  73690. * @param value2 defines the second operand
  73691. * @returns the squared distance
  73692. */
  73693. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73694. /**
  73695. * Returns a new Vector3 located at the center between "value1" and "value2"
  73696. * @param value1 defines the first operand
  73697. * @param value2 defines the second operand
  73698. * @returns the new Vector3
  73699. */
  73700. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  73701. /**
  73702. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  73703. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  73704. * to something in order to rotate it from its local system to the given target system
  73705. * Note: axis1, axis2 and axis3 are normalized during this operation
  73706. * @param axis1 defines the first axis
  73707. * @param axis2 defines the second axis
  73708. * @param axis3 defines the third axis
  73709. * @returns a new Vector3
  73710. */
  73711. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  73712. /**
  73713. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  73714. * @param axis1 defines the first axis
  73715. * @param axis2 defines the second axis
  73716. * @param axis3 defines the third axis
  73717. * @param ref defines the Vector3 where to store the result
  73718. */
  73719. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  73720. }
  73721. /**
  73722. * Vector4 class created for EulerAngle class conversion to Quaternion
  73723. */
  73724. export class Vector4 {
  73725. /** x value of the vector */
  73726. x: number;
  73727. /** y value of the vector */
  73728. y: number;
  73729. /** z value of the vector */
  73730. z: number;
  73731. /** w value of the vector */
  73732. w: number;
  73733. /**
  73734. * Creates a Vector4 object from the given floats.
  73735. * @param x x value of the vector
  73736. * @param y y value of the vector
  73737. * @param z z value of the vector
  73738. * @param w w value of the vector
  73739. */
  73740. constructor(
  73741. /** x value of the vector */
  73742. x: number,
  73743. /** y value of the vector */
  73744. y: number,
  73745. /** z value of the vector */
  73746. z: number,
  73747. /** w value of the vector */
  73748. w: number);
  73749. /**
  73750. * Returns the string with the Vector4 coordinates.
  73751. * @returns a string containing all the vector values
  73752. */
  73753. toString(): string;
  73754. /**
  73755. * Returns the string "Vector4".
  73756. * @returns "Vector4"
  73757. */
  73758. getClassName(): string;
  73759. /**
  73760. * Returns the Vector4 hash code.
  73761. * @returns a unique hash code
  73762. */
  73763. getHashCode(): number;
  73764. /**
  73765. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73766. * @returns the resulting array
  73767. */
  73768. asArray(): number[];
  73769. /**
  73770. * Populates the given array from the given index with the Vector4 coordinates.
  73771. * @param array array to populate
  73772. * @param index index of the array to start at (default: 0)
  73773. * @returns the Vector4.
  73774. */
  73775. toArray(array: FloatArray, index?: number): Vector4;
  73776. /**
  73777. * Adds the given vector to the current Vector4.
  73778. * @param otherVector the vector to add
  73779. * @returns the updated Vector4.
  73780. */
  73781. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73782. /**
  73783. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  73784. * @param otherVector the vector to add
  73785. * @returns the resulting vector
  73786. */
  73787. add(otherVector: DeepImmutable<Vector4>): Vector4;
  73788. /**
  73789. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  73790. * @param otherVector the vector to add
  73791. * @param result the vector to store the result
  73792. * @returns the current Vector4.
  73793. */
  73794. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73795. /**
  73796. * Subtract in place the given vector from the current Vector4.
  73797. * @param otherVector the vector to subtract
  73798. * @returns the updated Vector4.
  73799. */
  73800. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73801. /**
  73802. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  73803. * @param otherVector the vector to add
  73804. * @returns the new vector with the result
  73805. */
  73806. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  73807. /**
  73808. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  73809. * @param otherVector the vector to subtract
  73810. * @param result the vector to store the result
  73811. * @returns the current Vector4.
  73812. */
  73813. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73814. /**
  73815. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73816. */
  73817. /**
  73818. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73819. * @param x value to subtract
  73820. * @param y value to subtract
  73821. * @param z value to subtract
  73822. * @param w value to subtract
  73823. * @returns new vector containing the result
  73824. */
  73825. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73826. /**
  73827. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73828. * @param x value to subtract
  73829. * @param y value to subtract
  73830. * @param z value to subtract
  73831. * @param w value to subtract
  73832. * @param result the vector to store the result in
  73833. * @returns the current Vector4.
  73834. */
  73835. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  73836. /**
  73837. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  73838. * @returns a new vector with the negated values
  73839. */
  73840. negate(): Vector4;
  73841. /**
  73842. * Multiplies the current Vector4 coordinates by scale (float).
  73843. * @param scale the number to scale with
  73844. * @returns the updated Vector4.
  73845. */
  73846. scaleInPlace(scale: number): Vector4;
  73847. /**
  73848. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  73849. * @param scale the number to scale with
  73850. * @returns a new vector with the result
  73851. */
  73852. scale(scale: number): Vector4;
  73853. /**
  73854. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  73855. * @param scale the number to scale with
  73856. * @param result a vector to store the result in
  73857. * @returns the current Vector4.
  73858. */
  73859. scaleToRef(scale: number, result: Vector4): Vector4;
  73860. /**
  73861. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  73862. * @param scale defines the scale factor
  73863. * @param result defines the Vector4 object where to store the result
  73864. * @returns the unmodified current Vector4
  73865. */
  73866. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  73867. /**
  73868. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73869. * @param otherVector the vector to compare against
  73870. * @returns true if they are equal
  73871. */
  73872. equals(otherVector: DeepImmutable<Vector4>): boolean;
  73873. /**
  73874. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73875. * @param otherVector vector to compare against
  73876. * @param epsilon (Default: very small number)
  73877. * @returns true if they are equal
  73878. */
  73879. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  73880. /**
  73881. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73882. * @param x x value to compare against
  73883. * @param y y value to compare against
  73884. * @param z z value to compare against
  73885. * @param w w value to compare against
  73886. * @returns true if equal
  73887. */
  73888. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  73889. /**
  73890. * Multiplies in place the current Vector4 by the given one.
  73891. * @param otherVector vector to multiple with
  73892. * @returns the updated Vector4.
  73893. */
  73894. multiplyInPlace(otherVector: Vector4): Vector4;
  73895. /**
  73896. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73897. * @param otherVector vector to multiple with
  73898. * @returns resulting new vector
  73899. */
  73900. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  73901. /**
  73902. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73903. * @param otherVector vector to multiple with
  73904. * @param result vector to store the result
  73905. * @returns the current Vector4.
  73906. */
  73907. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73908. /**
  73909. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73910. * @param x x value multiply with
  73911. * @param y y value multiply with
  73912. * @param z z value multiply with
  73913. * @param w w value multiply with
  73914. * @returns resulting new vector
  73915. */
  73916. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  73917. /**
  73918. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73919. * @param otherVector vector to devide with
  73920. * @returns resulting new vector
  73921. */
  73922. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  73923. /**
  73924. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73925. * @param otherVector vector to devide with
  73926. * @param result vector to store the result
  73927. * @returns the current Vector4.
  73928. */
  73929. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73930. /**
  73931. * Divides the current Vector3 coordinates by the given ones.
  73932. * @param otherVector vector to devide with
  73933. * @returns the updated Vector3.
  73934. */
  73935. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73936. /**
  73937. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73938. * @param other defines the second operand
  73939. * @returns the current updated Vector4
  73940. */
  73941. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73942. /**
  73943. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73944. * @param other defines the second operand
  73945. * @returns the current updated Vector4
  73946. */
  73947. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73948. /**
  73949. * Gets a new Vector4 from current Vector4 floored values
  73950. * @returns a new Vector4
  73951. */
  73952. floor(): Vector4;
  73953. /**
  73954. * Gets a new Vector4 from current Vector3 floored values
  73955. * @returns a new Vector4
  73956. */
  73957. fract(): Vector4;
  73958. /**
  73959. * Returns the Vector4 length (float).
  73960. * @returns the length
  73961. */
  73962. length(): number;
  73963. /**
  73964. * Returns the Vector4 squared length (float).
  73965. * @returns the length squared
  73966. */
  73967. lengthSquared(): number;
  73968. /**
  73969. * Normalizes in place the Vector4.
  73970. * @returns the updated Vector4.
  73971. */
  73972. normalize(): Vector4;
  73973. /**
  73974. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  73975. * @returns this converted to a new vector3
  73976. */
  73977. toVector3(): Vector3;
  73978. /**
  73979. * Returns a new Vector4 copied from the current one.
  73980. * @returns the new cloned vector
  73981. */
  73982. clone(): Vector4;
  73983. /**
  73984. * Updates the current Vector4 with the given one coordinates.
  73985. * @param source the source vector to copy from
  73986. * @returns the updated Vector4.
  73987. */
  73988. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  73989. /**
  73990. * Updates the current Vector4 coordinates with the given floats.
  73991. * @param x float to copy from
  73992. * @param y float to copy from
  73993. * @param z float to copy from
  73994. * @param w float to copy from
  73995. * @returns the updated Vector4.
  73996. */
  73997. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73998. /**
  73999. * Updates the current Vector4 coordinates with the given floats.
  74000. * @param x float to set from
  74001. * @param y float to set from
  74002. * @param z float to set from
  74003. * @param w float to set from
  74004. * @returns the updated Vector4.
  74005. */
  74006. set(x: number, y: number, z: number, w: number): Vector4;
  74007. /**
  74008. * Copies the given float to the current Vector3 coordinates
  74009. * @param v defines the x, y, z and w coordinates of the operand
  74010. * @returns the current updated Vector3
  74011. */
  74012. setAll(v: number): Vector4;
  74013. /**
  74014. * Returns a new Vector4 set from the starting index of the given array.
  74015. * @param array the array to pull values from
  74016. * @param offset the offset into the array to start at
  74017. * @returns the new vector
  74018. */
  74019. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  74020. /**
  74021. * Updates the given vector "result" from the starting index of the given array.
  74022. * @param array the array to pull values from
  74023. * @param offset the offset into the array to start at
  74024. * @param result the vector to store the result in
  74025. */
  74026. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  74027. /**
  74028. * Updates the given vector "result" from the starting index of the given Float32Array.
  74029. * @param array the array to pull values from
  74030. * @param offset the offset into the array to start at
  74031. * @param result the vector to store the result in
  74032. */
  74033. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  74034. /**
  74035. * Updates the given vector "result" coordinates from the given floats.
  74036. * @param x float to set from
  74037. * @param y float to set from
  74038. * @param z float to set from
  74039. * @param w float to set from
  74040. * @param result the vector to the floats in
  74041. */
  74042. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  74043. /**
  74044. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  74045. * @returns the new vector
  74046. */
  74047. static Zero(): Vector4;
  74048. /**
  74049. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  74050. * @returns the new vector
  74051. */
  74052. static One(): Vector4;
  74053. /**
  74054. * Returns a new normalized Vector4 from the given one.
  74055. * @param vector the vector to normalize
  74056. * @returns the vector
  74057. */
  74058. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  74059. /**
  74060. * Updates the given vector "result" from the normalization of the given one.
  74061. * @param vector the vector to normalize
  74062. * @param result the vector to store the result in
  74063. */
  74064. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  74065. /**
  74066. * Returns a vector with the minimum values from the left and right vectors
  74067. * @param left left vector to minimize
  74068. * @param right right vector to minimize
  74069. * @returns a new vector with the minimum of the left and right vector values
  74070. */
  74071. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74072. /**
  74073. * Returns a vector with the maximum values from the left and right vectors
  74074. * @param left left vector to maximize
  74075. * @param right right vector to maximize
  74076. * @returns a new vector with the maximum of the left and right vector values
  74077. */
  74078. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74079. /**
  74080. * Returns the distance (float) between the vectors "value1" and "value2".
  74081. * @param value1 value to calulate the distance between
  74082. * @param value2 value to calulate the distance between
  74083. * @return the distance between the two vectors
  74084. */
  74085. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74086. /**
  74087. * Returns the squared distance (float) between the vectors "value1" and "value2".
  74088. * @param value1 value to calulate the distance between
  74089. * @param value2 value to calulate the distance between
  74090. * @return the distance between the two vectors squared
  74091. */
  74092. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74093. /**
  74094. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  74095. * @param value1 value to calulate the center between
  74096. * @param value2 value to calulate the center between
  74097. * @return the center between the two vectors
  74098. */
  74099. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  74100. /**
  74101. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  74102. * This methods computes transformed normalized direction vectors only.
  74103. * @param vector the vector to transform
  74104. * @param transformation the transformation matrix to apply
  74105. * @returns the new vector
  74106. */
  74107. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  74108. /**
  74109. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  74110. * This methods computes transformed normalized direction vectors only.
  74111. * @param vector the vector to transform
  74112. * @param transformation the transformation matrix to apply
  74113. * @param result the vector to store the result in
  74114. */
  74115. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74116. /**
  74117. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  74118. * This methods computes transformed normalized direction vectors only.
  74119. * @param x value to transform
  74120. * @param y value to transform
  74121. * @param z value to transform
  74122. * @param w value to transform
  74123. * @param transformation the transformation matrix to apply
  74124. * @param result the vector to store the results in
  74125. */
  74126. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74127. /**
  74128. * Creates a new Vector4 from a Vector3
  74129. * @param source defines the source data
  74130. * @param w defines the 4th component (default is 0)
  74131. * @returns a new Vector4
  74132. */
  74133. static FromVector3(source: Vector3, w?: number): Vector4;
  74134. }
  74135. /**
  74136. * Class used to store quaternion data
  74137. * @see https://en.wikipedia.org/wiki/Quaternion
  74138. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74139. */
  74140. export class Quaternion {
  74141. /** defines the first component (0 by default) */
  74142. x: number;
  74143. /** defines the second component (0 by default) */
  74144. y: number;
  74145. /** defines the third component (0 by default) */
  74146. z: number;
  74147. /** defines the fourth component (1.0 by default) */
  74148. w: number;
  74149. /**
  74150. * Creates a new Quaternion from the given floats
  74151. * @param x defines the first component (0 by default)
  74152. * @param y defines the second component (0 by default)
  74153. * @param z defines the third component (0 by default)
  74154. * @param w defines the fourth component (1.0 by default)
  74155. */
  74156. constructor(
  74157. /** defines the first component (0 by default) */
  74158. x?: number,
  74159. /** defines the second component (0 by default) */
  74160. y?: number,
  74161. /** defines the third component (0 by default) */
  74162. z?: number,
  74163. /** defines the fourth component (1.0 by default) */
  74164. w?: number);
  74165. /**
  74166. * Gets a string representation for the current quaternion
  74167. * @returns a string with the Quaternion coordinates
  74168. */
  74169. toString(): string;
  74170. /**
  74171. * Gets the class name of the quaternion
  74172. * @returns the string "Quaternion"
  74173. */
  74174. getClassName(): string;
  74175. /**
  74176. * Gets a hash code for this quaternion
  74177. * @returns the quaternion hash code
  74178. */
  74179. getHashCode(): number;
  74180. /**
  74181. * Copy the quaternion to an array
  74182. * @returns a new array populated with 4 elements from the quaternion coordinates
  74183. */
  74184. asArray(): number[];
  74185. /**
  74186. * Check if two quaternions are equals
  74187. * @param otherQuaternion defines the second operand
  74188. * @return true if the current quaternion and the given one coordinates are strictly equals
  74189. */
  74190. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  74191. /**
  74192. * Gets a boolean if two quaternions are equals (using an epsilon value)
  74193. * @param otherQuaternion defines the other quaternion
  74194. * @param epsilon defines the minimal distance to consider equality
  74195. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  74196. */
  74197. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  74198. /**
  74199. * Clone the current quaternion
  74200. * @returns a new quaternion copied from the current one
  74201. */
  74202. clone(): Quaternion;
  74203. /**
  74204. * Copy a quaternion to the current one
  74205. * @param other defines the other quaternion
  74206. * @returns the updated current quaternion
  74207. */
  74208. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  74209. /**
  74210. * Updates the current quaternion with the given float coordinates
  74211. * @param x defines the x coordinate
  74212. * @param y defines the y coordinate
  74213. * @param z defines the z coordinate
  74214. * @param w defines the w coordinate
  74215. * @returns the updated current quaternion
  74216. */
  74217. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  74218. /**
  74219. * Updates the current quaternion from the given float coordinates
  74220. * @param x defines the x coordinate
  74221. * @param y defines the y coordinate
  74222. * @param z defines the z coordinate
  74223. * @param w defines the w coordinate
  74224. * @returns the updated current quaternion
  74225. */
  74226. set(x: number, y: number, z: number, w: number): Quaternion;
  74227. /**
  74228. * Adds two quaternions
  74229. * @param other defines the second operand
  74230. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74231. */
  74232. add(other: DeepImmutable<Quaternion>): Quaternion;
  74233. /**
  74234. * Add a quaternion to the current one
  74235. * @param other defines the quaternion to add
  74236. * @returns the current quaternion
  74237. */
  74238. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  74239. /**
  74240. * Subtract two quaternions
  74241. * @param other defines the second operand
  74242. * @returns a new quaternion as the subtraction result of the given one from the current one
  74243. */
  74244. subtract(other: Quaternion): Quaternion;
  74245. /**
  74246. * Multiplies the current quaternion by a scale factor
  74247. * @param value defines the scale factor
  74248. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74249. */
  74250. scale(value: number): Quaternion;
  74251. /**
  74252. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74253. * @param scale defines the scale factor
  74254. * @param result defines the Quaternion object where to store the result
  74255. * @returns the unmodified current quaternion
  74256. */
  74257. scaleToRef(scale: number, result: Quaternion): Quaternion;
  74258. /**
  74259. * Multiplies in place the current quaternion by a scale factor
  74260. * @param value defines the scale factor
  74261. * @returns the current modified quaternion
  74262. */
  74263. scaleInPlace(value: number): Quaternion;
  74264. /**
  74265. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74266. * @param scale defines the scale factor
  74267. * @param result defines the Quaternion object where to store the result
  74268. * @returns the unmodified current quaternion
  74269. */
  74270. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  74271. /**
  74272. * Multiplies two quaternions
  74273. * @param q1 defines the second operand
  74274. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74275. */
  74276. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  74277. /**
  74278. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74279. * @param q1 defines the second operand
  74280. * @param result defines the target quaternion
  74281. * @returns the current quaternion
  74282. */
  74283. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  74284. /**
  74285. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74286. * @param q1 defines the second operand
  74287. * @returns the currentupdated quaternion
  74288. */
  74289. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  74290. /**
  74291. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74292. * @param ref defines the target quaternion
  74293. * @returns the current quaternion
  74294. */
  74295. conjugateToRef(ref: Quaternion): Quaternion;
  74296. /**
  74297. * Conjugates in place (1-q) the current quaternion
  74298. * @returns the current updated quaternion
  74299. */
  74300. conjugateInPlace(): Quaternion;
  74301. /**
  74302. * Conjugates in place (1-q) the current quaternion
  74303. * @returns a new quaternion
  74304. */
  74305. conjugate(): Quaternion;
  74306. /**
  74307. * Gets length of current quaternion
  74308. * @returns the quaternion length (float)
  74309. */
  74310. length(): number;
  74311. /**
  74312. * Normalize in place the current quaternion
  74313. * @returns the current updated quaternion
  74314. */
  74315. normalize(): Quaternion;
  74316. /**
  74317. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  74318. * @param order is a reserved parameter and is ignore for now
  74319. * @returns a new Vector3 containing the Euler angles
  74320. */
  74321. toEulerAngles(order?: string): Vector3;
  74322. /**
  74323. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  74324. * @param result defines the vector which will be filled with the Euler angles
  74325. * @param order is a reserved parameter and is ignore for now
  74326. * @returns the current unchanged quaternion
  74327. */
  74328. toEulerAnglesToRef(result: Vector3): Quaternion;
  74329. /**
  74330. * Updates the given rotation matrix with the current quaternion values
  74331. * @param result defines the target matrix
  74332. * @returns the current unchanged quaternion
  74333. */
  74334. toRotationMatrix(result: Matrix): Quaternion;
  74335. /**
  74336. * Updates the current quaternion from the given rotation matrix values
  74337. * @param matrix defines the source matrix
  74338. * @returns the current updated quaternion
  74339. */
  74340. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74341. /**
  74342. * Creates a new quaternion from a rotation matrix
  74343. * @param matrix defines the source matrix
  74344. * @returns a new quaternion created from the given rotation matrix values
  74345. */
  74346. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74347. /**
  74348. * Updates the given quaternion with the given rotation matrix values
  74349. * @param matrix defines the source matrix
  74350. * @param result defines the target quaternion
  74351. */
  74352. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  74353. /**
  74354. * Returns the dot product (float) between the quaternions "left" and "right"
  74355. * @param left defines the left operand
  74356. * @param right defines the right operand
  74357. * @returns the dot product
  74358. */
  74359. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  74360. /**
  74361. * Checks if the two quaternions are close to each other
  74362. * @param quat0 defines the first quaternion to check
  74363. * @param quat1 defines the second quaternion to check
  74364. * @returns true if the two quaternions are close to each other
  74365. */
  74366. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  74367. /**
  74368. * Creates an empty quaternion
  74369. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  74370. */
  74371. static Zero(): Quaternion;
  74372. /**
  74373. * Inverse a given quaternion
  74374. * @param q defines the source quaternion
  74375. * @returns a new quaternion as the inverted current quaternion
  74376. */
  74377. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  74378. /**
  74379. * Inverse a given quaternion
  74380. * @param q defines the source quaternion
  74381. * @param result the quaternion the result will be stored in
  74382. * @returns the result quaternion
  74383. */
  74384. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  74385. /**
  74386. * Creates an identity quaternion
  74387. * @returns the identity quaternion
  74388. */
  74389. static Identity(): Quaternion;
  74390. /**
  74391. * Gets a boolean indicating if the given quaternion is identity
  74392. * @param quaternion defines the quaternion to check
  74393. * @returns true if the quaternion is identity
  74394. */
  74395. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  74396. /**
  74397. * Creates a quaternion from a rotation around an axis
  74398. * @param axis defines the axis to use
  74399. * @param angle defines the angle to use
  74400. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  74401. */
  74402. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  74403. /**
  74404. * Creates a rotation around an axis and stores it into the given quaternion
  74405. * @param axis defines the axis to use
  74406. * @param angle defines the angle to use
  74407. * @param result defines the target quaternion
  74408. * @returns the target quaternion
  74409. */
  74410. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  74411. /**
  74412. * Creates a new quaternion from data stored into an array
  74413. * @param array defines the data source
  74414. * @param offset defines the offset in the source array where the data starts
  74415. * @returns a new quaternion
  74416. */
  74417. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  74418. /**
  74419. * Create a quaternion from Euler rotation angles
  74420. * @param x Pitch
  74421. * @param y Yaw
  74422. * @param z Roll
  74423. * @returns the new Quaternion
  74424. */
  74425. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  74426. /**
  74427. * Updates a quaternion from Euler rotation angles
  74428. * @param x Pitch
  74429. * @param y Yaw
  74430. * @param z Roll
  74431. * @param result the quaternion to store the result
  74432. * @returns the updated quaternion
  74433. */
  74434. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  74435. /**
  74436. * Create a quaternion from Euler rotation vector
  74437. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74438. * @returns the new Quaternion
  74439. */
  74440. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  74441. /**
  74442. * Updates a quaternion from Euler rotation vector
  74443. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74444. * @param result the quaternion to store the result
  74445. * @returns the updated quaternion
  74446. */
  74447. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  74448. /**
  74449. * Creates a new quaternion from the given Euler float angles (y, x, z)
  74450. * @param yaw defines the rotation around Y axis
  74451. * @param pitch defines the rotation around X axis
  74452. * @param roll defines the rotation around Z axis
  74453. * @returns the new quaternion
  74454. */
  74455. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  74456. /**
  74457. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  74458. * @param yaw defines the rotation around Y axis
  74459. * @param pitch defines the rotation around X axis
  74460. * @param roll defines the rotation around Z axis
  74461. * @param result defines the target quaternion
  74462. */
  74463. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  74464. /**
  74465. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  74466. * @param alpha defines the rotation around first axis
  74467. * @param beta defines the rotation around second axis
  74468. * @param gamma defines the rotation around third axis
  74469. * @returns the new quaternion
  74470. */
  74471. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  74472. /**
  74473. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  74474. * @param alpha defines the rotation around first axis
  74475. * @param beta defines the rotation around second axis
  74476. * @param gamma defines the rotation around third axis
  74477. * @param result defines the target quaternion
  74478. */
  74479. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  74480. /**
  74481. * 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)
  74482. * @param axis1 defines the first axis
  74483. * @param axis2 defines the second axis
  74484. * @param axis3 defines the third axis
  74485. * @returns the new quaternion
  74486. */
  74487. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  74488. /**
  74489. * 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
  74490. * @param axis1 defines the first axis
  74491. * @param axis2 defines the second axis
  74492. * @param axis3 defines the third axis
  74493. * @param ref defines the target quaternion
  74494. */
  74495. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  74496. /**
  74497. * Interpolates between two quaternions
  74498. * @param left defines first quaternion
  74499. * @param right defines second quaternion
  74500. * @param amount defines the gradient to use
  74501. * @returns the new interpolated quaternion
  74502. */
  74503. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74504. /**
  74505. * Interpolates between two quaternions and stores it into a target quaternion
  74506. * @param left defines first quaternion
  74507. * @param right defines second quaternion
  74508. * @param amount defines the gradient to use
  74509. * @param result defines the target quaternion
  74510. */
  74511. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  74512. /**
  74513. * Interpolate between two quaternions using Hermite interpolation
  74514. * @param value1 defines first quaternion
  74515. * @param tangent1 defines the incoming tangent
  74516. * @param value2 defines second quaternion
  74517. * @param tangent2 defines the outgoing tangent
  74518. * @param amount defines the target quaternion
  74519. * @returns the new interpolated quaternion
  74520. */
  74521. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74522. }
  74523. /**
  74524. * Class used to store matrix data (4x4)
  74525. */
  74526. export class Matrix {
  74527. private static _updateFlagSeed;
  74528. private static _identityReadOnly;
  74529. private _isIdentity;
  74530. private _isIdentityDirty;
  74531. private _isIdentity3x2;
  74532. private _isIdentity3x2Dirty;
  74533. /**
  74534. * Gets the update flag of the matrix which is an unique number for the matrix.
  74535. * It will be incremented every time the matrix data change.
  74536. * You can use it to speed the comparison between two versions of the same matrix.
  74537. */
  74538. updateFlag: number;
  74539. private readonly _m;
  74540. /**
  74541. * Gets the internal data of the matrix
  74542. */
  74543. get m(): DeepImmutable<Float32Array>;
  74544. /** @hidden */
  74545. _markAsUpdated(): void;
  74546. /** @hidden */
  74547. private _updateIdentityStatus;
  74548. /**
  74549. * Creates an empty matrix (filled with zeros)
  74550. */
  74551. constructor();
  74552. /**
  74553. * Check if the current matrix is identity
  74554. * @returns true is the matrix is the identity matrix
  74555. */
  74556. isIdentity(): boolean;
  74557. /**
  74558. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  74559. * @returns true is the matrix is the identity matrix
  74560. */
  74561. isIdentityAs3x2(): boolean;
  74562. /**
  74563. * Gets the determinant of the matrix
  74564. * @returns the matrix determinant
  74565. */
  74566. determinant(): number;
  74567. /**
  74568. * Returns the matrix as a Float32Array
  74569. * @returns the matrix underlying array
  74570. */
  74571. toArray(): DeepImmutable<Float32Array>;
  74572. /**
  74573. * Returns the matrix as a Float32Array
  74574. * @returns the matrix underlying array.
  74575. */
  74576. asArray(): DeepImmutable<Float32Array>;
  74577. /**
  74578. * Inverts the current matrix in place
  74579. * @returns the current inverted matrix
  74580. */
  74581. invert(): Matrix;
  74582. /**
  74583. * Sets all the matrix elements to zero
  74584. * @returns the current matrix
  74585. */
  74586. reset(): Matrix;
  74587. /**
  74588. * Adds the current matrix with a second one
  74589. * @param other defines the matrix to add
  74590. * @returns a new matrix as the addition of the current matrix and the given one
  74591. */
  74592. add(other: DeepImmutable<Matrix>): Matrix;
  74593. /**
  74594. * Sets the given matrix "result" to the addition of the current matrix and the given one
  74595. * @param other defines the matrix to add
  74596. * @param result defines the target matrix
  74597. * @returns the current matrix
  74598. */
  74599. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74600. /**
  74601. * Adds in place the given matrix to the current matrix
  74602. * @param other defines the second operand
  74603. * @returns the current updated matrix
  74604. */
  74605. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  74606. /**
  74607. * Sets the given matrix to the current inverted Matrix
  74608. * @param other defines the target matrix
  74609. * @returns the unmodified current matrix
  74610. */
  74611. invertToRef(other: Matrix): Matrix;
  74612. /**
  74613. * add a value at the specified position in the current Matrix
  74614. * @param index the index of the value within the matrix. between 0 and 15.
  74615. * @param value the value to be added
  74616. * @returns the current updated matrix
  74617. */
  74618. addAtIndex(index: number, value: number): Matrix;
  74619. /**
  74620. * mutiply the specified position in the current Matrix by a value
  74621. * @param index the index of the value within the matrix. between 0 and 15.
  74622. * @param value the value to be added
  74623. * @returns the current updated matrix
  74624. */
  74625. multiplyAtIndex(index: number, value: number): Matrix;
  74626. /**
  74627. * Inserts the translation vector (using 3 floats) in the current matrix
  74628. * @param x defines the 1st component of the translation
  74629. * @param y defines the 2nd component of the translation
  74630. * @param z defines the 3rd component of the translation
  74631. * @returns the current updated matrix
  74632. */
  74633. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74634. /**
  74635. * Adds the translation vector (using 3 floats) in the current matrix
  74636. * @param x defines the 1st component of the translation
  74637. * @param y defines the 2nd component of the translation
  74638. * @param z defines the 3rd component of the translation
  74639. * @returns the current updated matrix
  74640. */
  74641. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74642. /**
  74643. * Inserts the translation vector in the current matrix
  74644. * @param vector3 defines the translation to insert
  74645. * @returns the current updated matrix
  74646. */
  74647. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  74648. /**
  74649. * Gets the translation value of the current matrix
  74650. * @returns a new Vector3 as the extracted translation from the matrix
  74651. */
  74652. getTranslation(): Vector3;
  74653. /**
  74654. * Fill a Vector3 with the extracted translation from the matrix
  74655. * @param result defines the Vector3 where to store the translation
  74656. * @returns the current matrix
  74657. */
  74658. getTranslationToRef(result: Vector3): Matrix;
  74659. /**
  74660. * Remove rotation and scaling part from the matrix
  74661. * @returns the updated matrix
  74662. */
  74663. removeRotationAndScaling(): Matrix;
  74664. /**
  74665. * Multiply two matrices
  74666. * @param other defines the second operand
  74667. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  74668. */
  74669. multiply(other: DeepImmutable<Matrix>): Matrix;
  74670. /**
  74671. * Copy the current matrix from the given one
  74672. * @param other defines the source matrix
  74673. * @returns the current updated matrix
  74674. */
  74675. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  74676. /**
  74677. * Populates the given array from the starting index with the current matrix values
  74678. * @param array defines the target array
  74679. * @param offset defines the offset in the target array where to start storing values
  74680. * @returns the current matrix
  74681. */
  74682. copyToArray(array: Float32Array, offset?: number): Matrix;
  74683. /**
  74684. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  74685. * @param other defines the second operand
  74686. * @param result defines the matrix where to store the multiplication
  74687. * @returns the current matrix
  74688. */
  74689. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74690. /**
  74691. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  74692. * @param other defines the second operand
  74693. * @param result defines the array where to store the multiplication
  74694. * @param offset defines the offset in the target array where to start storing values
  74695. * @returns the current matrix
  74696. */
  74697. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  74698. /**
  74699. * Check equality between this matrix and a second one
  74700. * @param value defines the second matrix to compare
  74701. * @returns true is the current matrix and the given one values are strictly equal
  74702. */
  74703. equals(value: DeepImmutable<Matrix>): boolean;
  74704. /**
  74705. * Clone the current matrix
  74706. * @returns a new matrix from the current matrix
  74707. */
  74708. clone(): Matrix;
  74709. /**
  74710. * Returns the name of the current matrix class
  74711. * @returns the string "Matrix"
  74712. */
  74713. getClassName(): string;
  74714. /**
  74715. * Gets the hash code of the current matrix
  74716. * @returns the hash code
  74717. */
  74718. getHashCode(): number;
  74719. /**
  74720. * Decomposes the current Matrix into a translation, rotation and scaling components
  74721. * @param scale defines the scale vector3 given as a reference to update
  74722. * @param rotation defines the rotation quaternion given as a reference to update
  74723. * @param translation defines the translation vector3 given as a reference to update
  74724. * @returns true if operation was successful
  74725. */
  74726. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  74727. /**
  74728. * Gets specific row of the matrix
  74729. * @param index defines the number of the row to get
  74730. * @returns the index-th row of the current matrix as a new Vector4
  74731. */
  74732. getRow(index: number): Nullable<Vector4>;
  74733. /**
  74734. * Sets the index-th row of the current matrix to the vector4 values
  74735. * @param index defines the number of the row to set
  74736. * @param row defines the target vector4
  74737. * @returns the updated current matrix
  74738. */
  74739. setRow(index: number, row: Vector4): Matrix;
  74740. /**
  74741. * Compute the transpose of the matrix
  74742. * @returns the new transposed matrix
  74743. */
  74744. transpose(): Matrix;
  74745. /**
  74746. * Compute the transpose of the matrix and store it in a given matrix
  74747. * @param result defines the target matrix
  74748. * @returns the current matrix
  74749. */
  74750. transposeToRef(result: Matrix): Matrix;
  74751. /**
  74752. * Sets the index-th row of the current matrix with the given 4 x float values
  74753. * @param index defines the row index
  74754. * @param x defines the x component to set
  74755. * @param y defines the y component to set
  74756. * @param z defines the z component to set
  74757. * @param w defines the w component to set
  74758. * @returns the updated current matrix
  74759. */
  74760. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  74761. /**
  74762. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  74763. * @param scale defines the scale factor
  74764. * @returns a new matrix
  74765. */
  74766. scale(scale: number): Matrix;
  74767. /**
  74768. * Scale the current matrix values by a factor to a given result matrix
  74769. * @param scale defines the scale factor
  74770. * @param result defines the matrix to store the result
  74771. * @returns the current matrix
  74772. */
  74773. scaleToRef(scale: number, result: Matrix): Matrix;
  74774. /**
  74775. * Scale the current matrix values by a factor and add the result to a given matrix
  74776. * @param scale defines the scale factor
  74777. * @param result defines the Matrix to store the result
  74778. * @returns the current matrix
  74779. */
  74780. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  74781. /**
  74782. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  74783. * @param ref matrix to store the result
  74784. */
  74785. toNormalMatrix(ref: Matrix): void;
  74786. /**
  74787. * Gets only rotation part of the current matrix
  74788. * @returns a new matrix sets to the extracted rotation matrix from the current one
  74789. */
  74790. getRotationMatrix(): Matrix;
  74791. /**
  74792. * Extracts the rotation matrix from the current one and sets it as the given "result"
  74793. * @param result defines the target matrix to store data to
  74794. * @returns the current matrix
  74795. */
  74796. getRotationMatrixToRef(result: Matrix): Matrix;
  74797. /**
  74798. * Toggles model matrix from being right handed to left handed in place and vice versa
  74799. */
  74800. toggleModelMatrixHandInPlace(): void;
  74801. /**
  74802. * Toggles projection matrix from being right handed to left handed in place and vice versa
  74803. */
  74804. toggleProjectionMatrixHandInPlace(): void;
  74805. /**
  74806. * Creates a matrix from an array
  74807. * @param array defines the source array
  74808. * @param offset defines an offset in the source array
  74809. * @returns a new Matrix set from the starting index of the given array
  74810. */
  74811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  74812. /**
  74813. * Copy the content of an array into a given matrix
  74814. * @param array defines the source array
  74815. * @param offset defines an offset in the source array
  74816. * @param result defines the target matrix
  74817. */
  74818. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  74819. /**
  74820. * Stores an array into a matrix after having multiplied each component by a given factor
  74821. * @param array defines the source array
  74822. * @param offset defines the offset in the source array
  74823. * @param scale defines the scaling factor
  74824. * @param result defines the target matrix
  74825. */
  74826. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  74827. /**
  74828. * Gets an identity matrix that must not be updated
  74829. */
  74830. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  74831. /**
  74832. * Stores a list of values (16) inside a given matrix
  74833. * @param initialM11 defines 1st value of 1st row
  74834. * @param initialM12 defines 2nd value of 1st row
  74835. * @param initialM13 defines 3rd value of 1st row
  74836. * @param initialM14 defines 4th value of 1st row
  74837. * @param initialM21 defines 1st value of 2nd row
  74838. * @param initialM22 defines 2nd value of 2nd row
  74839. * @param initialM23 defines 3rd value of 2nd row
  74840. * @param initialM24 defines 4th value of 2nd row
  74841. * @param initialM31 defines 1st value of 3rd row
  74842. * @param initialM32 defines 2nd value of 3rd row
  74843. * @param initialM33 defines 3rd value of 3rd row
  74844. * @param initialM34 defines 4th value of 3rd row
  74845. * @param initialM41 defines 1st value of 4th row
  74846. * @param initialM42 defines 2nd value of 4th row
  74847. * @param initialM43 defines 3rd value of 4th row
  74848. * @param initialM44 defines 4th value of 4th row
  74849. * @param result defines the target matrix
  74850. */
  74851. 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;
  74852. /**
  74853. * Creates new matrix from a list of values (16)
  74854. * @param initialM11 defines 1st value of 1st row
  74855. * @param initialM12 defines 2nd value of 1st row
  74856. * @param initialM13 defines 3rd value of 1st row
  74857. * @param initialM14 defines 4th value of 1st row
  74858. * @param initialM21 defines 1st value of 2nd row
  74859. * @param initialM22 defines 2nd value of 2nd row
  74860. * @param initialM23 defines 3rd value of 2nd row
  74861. * @param initialM24 defines 4th value of 2nd row
  74862. * @param initialM31 defines 1st value of 3rd row
  74863. * @param initialM32 defines 2nd value of 3rd row
  74864. * @param initialM33 defines 3rd value of 3rd row
  74865. * @param initialM34 defines 4th value of 3rd row
  74866. * @param initialM41 defines 1st value of 4th row
  74867. * @param initialM42 defines 2nd value of 4th row
  74868. * @param initialM43 defines 3rd value of 4th row
  74869. * @param initialM44 defines 4th value of 4th row
  74870. * @returns the new matrix
  74871. */
  74872. 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;
  74873. /**
  74874. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74875. * @param scale defines the scale vector3
  74876. * @param rotation defines the rotation quaternion
  74877. * @param translation defines the translation vector3
  74878. * @returns a new matrix
  74879. */
  74880. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  74881. /**
  74882. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74883. * @param scale defines the scale vector3
  74884. * @param rotation defines the rotation quaternion
  74885. * @param translation defines the translation vector3
  74886. * @param result defines the target matrix
  74887. */
  74888. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  74889. /**
  74890. * Creates a new identity matrix
  74891. * @returns a new identity matrix
  74892. */
  74893. static Identity(): Matrix;
  74894. /**
  74895. * Creates a new identity matrix and stores the result in a given matrix
  74896. * @param result defines the target matrix
  74897. */
  74898. static IdentityToRef(result: Matrix): void;
  74899. /**
  74900. * Creates a new zero matrix
  74901. * @returns a new zero matrix
  74902. */
  74903. static Zero(): Matrix;
  74904. /**
  74905. * Creates a new rotation matrix for "angle" radians around the X axis
  74906. * @param angle defines the angle (in radians) to use
  74907. * @return the new matrix
  74908. */
  74909. static RotationX(angle: number): Matrix;
  74910. /**
  74911. * Creates a new matrix as the invert of a given matrix
  74912. * @param source defines the source matrix
  74913. * @returns the new matrix
  74914. */
  74915. static Invert(source: DeepImmutable<Matrix>): Matrix;
  74916. /**
  74917. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  74918. * @param angle defines the angle (in radians) to use
  74919. * @param result defines the target matrix
  74920. */
  74921. static RotationXToRef(angle: number, result: Matrix): void;
  74922. /**
  74923. * Creates a new rotation matrix for "angle" radians around the Y axis
  74924. * @param angle defines the angle (in radians) to use
  74925. * @return the new matrix
  74926. */
  74927. static RotationY(angle: number): Matrix;
  74928. /**
  74929. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  74930. * @param angle defines the angle (in radians) to use
  74931. * @param result defines the target matrix
  74932. */
  74933. static RotationYToRef(angle: number, result: Matrix): void;
  74934. /**
  74935. * Creates a new rotation matrix for "angle" radians around the Z axis
  74936. * @param angle defines the angle (in radians) to use
  74937. * @return the new matrix
  74938. */
  74939. static RotationZ(angle: number): Matrix;
  74940. /**
  74941. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  74942. * @param angle defines the angle (in radians) to use
  74943. * @param result defines the target matrix
  74944. */
  74945. static RotationZToRef(angle: number, result: Matrix): void;
  74946. /**
  74947. * Creates a new rotation matrix for "angle" radians around the given axis
  74948. * @param axis defines the axis to use
  74949. * @param angle defines the angle (in radians) to use
  74950. * @return the new matrix
  74951. */
  74952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  74953. /**
  74954. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  74955. * @param axis defines the axis to use
  74956. * @param angle defines the angle (in radians) to use
  74957. * @param result defines the target matrix
  74958. */
  74959. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  74960. /**
  74961. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  74962. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  74963. * @param from defines the vector to align
  74964. * @param to defines the vector to align to
  74965. * @param result defines the target matrix
  74966. */
  74967. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  74968. /**
  74969. * Creates a rotation matrix
  74970. * @param yaw defines the yaw angle in radians (Y axis)
  74971. * @param pitch defines the pitch angle in radians (X axis)
  74972. * @param roll defines the roll angle in radians (X axis)
  74973. * @returns the new rotation matrix
  74974. */
  74975. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  74976. /**
  74977. * Creates a rotation matrix and stores it in a given matrix
  74978. * @param yaw defines the yaw angle in radians (Y axis)
  74979. * @param pitch defines the pitch angle in radians (X axis)
  74980. * @param roll defines the roll angle in radians (X axis)
  74981. * @param result defines the target matrix
  74982. */
  74983. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  74984. /**
  74985. * Creates a scaling matrix
  74986. * @param x defines the scale factor on X axis
  74987. * @param y defines the scale factor on Y axis
  74988. * @param z defines the scale factor on Z axis
  74989. * @returns the new matrix
  74990. */
  74991. static Scaling(x: number, y: number, z: number): Matrix;
  74992. /**
  74993. * Creates a scaling matrix and stores it in a given matrix
  74994. * @param x defines the scale factor on X axis
  74995. * @param y defines the scale factor on Y axis
  74996. * @param z defines the scale factor on Z axis
  74997. * @param result defines the target matrix
  74998. */
  74999. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  75000. /**
  75001. * Creates a translation matrix
  75002. * @param x defines the translation on X axis
  75003. * @param y defines the translation on Y axis
  75004. * @param z defines the translationon Z axis
  75005. * @returns the new matrix
  75006. */
  75007. static Translation(x: number, y: number, z: number): Matrix;
  75008. /**
  75009. * Creates a translation matrix and stores it in a given matrix
  75010. * @param x defines the translation on X axis
  75011. * @param y defines the translation on Y axis
  75012. * @param z defines the translationon Z axis
  75013. * @param result defines the target matrix
  75014. */
  75015. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  75016. /**
  75017. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75018. * @param startValue defines the start value
  75019. * @param endValue defines the end value
  75020. * @param gradient defines the gradient factor
  75021. * @returns the new matrix
  75022. */
  75023. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  75024. /**
  75025. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75026. * @param startValue defines the start value
  75027. * @param endValue defines the end value
  75028. * @param gradient defines the gradient factor
  75029. * @param result defines the Matrix object where to store data
  75030. */
  75031. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  75032. /**
  75033. * Builds a new matrix whose values are computed by:
  75034. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75035. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75036. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75037. * @param startValue defines the first matrix
  75038. * @param endValue defines the second matrix
  75039. * @param gradient defines the gradient between the two matrices
  75040. * @returns the new matrix
  75041. */
  75042. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  75043. /**
  75044. * Update a matrix to values which are computed by:
  75045. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75046. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75047. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75048. * @param startValue defines the first matrix
  75049. * @param endValue defines the second matrix
  75050. * @param gradient defines the gradient between the two matrices
  75051. * @param result defines the target matrix
  75052. */
  75053. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  75054. /**
  75055. * 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"
  75056. * This function works in left handed mode
  75057. * @param eye defines the final position of the entity
  75058. * @param target defines where the entity should look at
  75059. * @param up defines the up vector for the entity
  75060. * @returns the new matrix
  75061. */
  75062. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75063. /**
  75064. * 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".
  75065. * This function works in left handed mode
  75066. * @param eye defines the final position of the entity
  75067. * @param target defines where the entity should look at
  75068. * @param up defines the up vector for the entity
  75069. * @param result defines the target matrix
  75070. */
  75071. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75072. /**
  75073. * 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"
  75074. * This function works in right handed mode
  75075. * @param eye defines the final position of the entity
  75076. * @param target defines where the entity should look at
  75077. * @param up defines the up vector for the entity
  75078. * @returns the new matrix
  75079. */
  75080. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75081. /**
  75082. * 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".
  75083. * This function works in right handed mode
  75084. * @param eye defines the final position of the entity
  75085. * @param target defines where the entity should look at
  75086. * @param up defines the up vector for the entity
  75087. * @param result defines the target matrix
  75088. */
  75089. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75090. /**
  75091. * Create a left-handed orthographic projection matrix
  75092. * @param width defines the viewport width
  75093. * @param height defines the viewport height
  75094. * @param znear defines the near clip plane
  75095. * @param zfar defines the far clip plane
  75096. * @returns a new matrix as a left-handed orthographic projection matrix
  75097. */
  75098. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75099. /**
  75100. * Store a left-handed orthographic projection to a given matrix
  75101. * @param width defines the viewport width
  75102. * @param height defines the viewport height
  75103. * @param znear defines the near clip plane
  75104. * @param zfar defines the far clip plane
  75105. * @param result defines the target matrix
  75106. */
  75107. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  75108. /**
  75109. * Create a left-handed orthographic projection matrix
  75110. * @param left defines the viewport left coordinate
  75111. * @param right defines the viewport right coordinate
  75112. * @param bottom defines the viewport bottom coordinate
  75113. * @param top defines the viewport top coordinate
  75114. * @param znear defines the near clip plane
  75115. * @param zfar defines the far clip plane
  75116. * @returns a new matrix as a left-handed orthographic projection matrix
  75117. */
  75118. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75119. /**
  75120. * Stores a left-handed orthographic projection into a given matrix
  75121. * @param left defines the viewport left coordinate
  75122. * @param right defines the viewport right coordinate
  75123. * @param bottom defines the viewport bottom coordinate
  75124. * @param top defines the viewport top coordinate
  75125. * @param znear defines the near clip plane
  75126. * @param zfar defines the far clip plane
  75127. * @param result defines the target matrix
  75128. */
  75129. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75130. /**
  75131. * Creates a right-handed orthographic projection matrix
  75132. * @param left defines the viewport left coordinate
  75133. * @param right defines the viewport right coordinate
  75134. * @param bottom defines the viewport bottom coordinate
  75135. * @param top defines the viewport top coordinate
  75136. * @param znear defines the near clip plane
  75137. * @param zfar defines the far clip plane
  75138. * @returns a new matrix as a right-handed orthographic projection matrix
  75139. */
  75140. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75141. /**
  75142. * Stores a right-handed orthographic projection into a given matrix
  75143. * @param left defines the viewport left coordinate
  75144. * @param right defines the viewport right coordinate
  75145. * @param bottom defines the viewport bottom coordinate
  75146. * @param top defines the viewport top coordinate
  75147. * @param znear defines the near clip plane
  75148. * @param zfar defines the far clip plane
  75149. * @param result defines the target matrix
  75150. */
  75151. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75152. /**
  75153. * Creates a left-handed perspective projection matrix
  75154. * @param width defines the viewport width
  75155. * @param height defines the viewport height
  75156. * @param znear defines the near clip plane
  75157. * @param zfar defines the far clip plane
  75158. * @returns a new matrix as a left-handed perspective projection matrix
  75159. */
  75160. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75161. /**
  75162. * Creates a left-handed perspective projection matrix
  75163. * @param fov defines the horizontal field of view
  75164. * @param aspect defines the aspect ratio
  75165. * @param znear defines the near clip plane
  75166. * @param zfar defines the far clip plane
  75167. * @returns a new matrix as a left-handed perspective projection matrix
  75168. */
  75169. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75170. /**
  75171. * Stores a left-handed perspective projection into a given matrix
  75172. * @param fov defines the horizontal field of view
  75173. * @param aspect defines the aspect ratio
  75174. * @param znear defines the near clip plane
  75175. * @param zfar defines the far clip plane
  75176. * @param result defines the target matrix
  75177. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75178. */
  75179. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75180. /**
  75181. * Stores a left-handed perspective projection into a given matrix with depth reversed
  75182. * @param fov defines the horizontal field of view
  75183. * @param aspect defines the aspect ratio
  75184. * @param znear defines the near clip plane
  75185. * @param zfar not used as infinity is used as far clip
  75186. * @param result defines the target matrix
  75187. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75188. */
  75189. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75190. /**
  75191. * Creates a right-handed perspective projection matrix
  75192. * @param fov defines the horizontal field of view
  75193. * @param aspect defines the aspect ratio
  75194. * @param znear defines the near clip plane
  75195. * @param zfar defines the far clip plane
  75196. * @returns a new matrix as a right-handed perspective projection matrix
  75197. */
  75198. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75199. /**
  75200. * Stores a right-handed perspective projection into a given matrix
  75201. * @param fov defines the horizontal field of view
  75202. * @param aspect defines the aspect ratio
  75203. * @param znear defines the near clip plane
  75204. * @param zfar defines the far clip plane
  75205. * @param result defines the target matrix
  75206. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75207. */
  75208. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75209. /**
  75210. * Stores a right-handed perspective projection into a given matrix
  75211. * @param fov defines the horizontal field of view
  75212. * @param aspect defines the aspect ratio
  75213. * @param znear defines the near clip plane
  75214. * @param zfar not used as infinity is used as far clip
  75215. * @param result defines the target matrix
  75216. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75217. */
  75218. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75219. /**
  75220. * Stores a perspective projection for WebVR info a given matrix
  75221. * @param fov defines the field of view
  75222. * @param znear defines the near clip plane
  75223. * @param zfar defines the far clip plane
  75224. * @param result defines the target matrix
  75225. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75226. */
  75227. static PerspectiveFovWebVRToRef(fov: {
  75228. upDegrees: number;
  75229. downDegrees: number;
  75230. leftDegrees: number;
  75231. rightDegrees: number;
  75232. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  75233. /**
  75234. * Computes a complete transformation matrix
  75235. * @param viewport defines the viewport to use
  75236. * @param world defines the world matrix
  75237. * @param view defines the view matrix
  75238. * @param projection defines the projection matrix
  75239. * @param zmin defines the near clip plane
  75240. * @param zmax defines the far clip plane
  75241. * @returns the transformation matrix
  75242. */
  75243. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  75244. /**
  75245. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75246. * @param matrix defines the matrix to use
  75247. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75248. */
  75249. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  75250. /**
  75251. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75252. * @param matrix defines the matrix to use
  75253. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75254. */
  75255. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  75256. /**
  75257. * Compute the transpose of a given matrix
  75258. * @param matrix defines the matrix to transpose
  75259. * @returns the new matrix
  75260. */
  75261. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  75262. /**
  75263. * Compute the transpose of a matrix and store it in a target matrix
  75264. * @param matrix defines the matrix to transpose
  75265. * @param result defines the target matrix
  75266. */
  75267. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  75268. /**
  75269. * Computes a reflection matrix from a plane
  75270. * @param plane defines the reflection plane
  75271. * @returns a new matrix
  75272. */
  75273. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  75274. /**
  75275. * Computes a reflection matrix from a plane
  75276. * @param plane defines the reflection plane
  75277. * @param result defines the target matrix
  75278. */
  75279. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  75280. /**
  75281. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75282. * @param xaxis defines the value of the 1st axis
  75283. * @param yaxis defines the value of the 2nd axis
  75284. * @param zaxis defines the value of the 3rd axis
  75285. * @param result defines the target matrix
  75286. */
  75287. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  75288. /**
  75289. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  75290. * @param quat defines the quaternion to use
  75291. * @param result defines the target matrix
  75292. */
  75293. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  75294. }
  75295. /**
  75296. * @hidden
  75297. */
  75298. export class TmpVectors {
  75299. static Vector2: Vector2[];
  75300. static Vector3: Vector3[];
  75301. static Vector4: Vector4[];
  75302. static Quaternion: Quaternion[];
  75303. static Matrix: Matrix[];
  75304. }
  75305. }
  75306. declare module BABYLON {
  75307. /**
  75308. * Defines potential orientation for back face culling
  75309. */
  75310. export enum Orientation {
  75311. /**
  75312. * Clockwise
  75313. */
  75314. CW = 0,
  75315. /** Counter clockwise */
  75316. CCW = 1
  75317. }
  75318. /** Class used to represent a Bezier curve */
  75319. export class BezierCurve {
  75320. /**
  75321. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  75322. * @param t defines the time
  75323. * @param x1 defines the left coordinate on X axis
  75324. * @param y1 defines the left coordinate on Y axis
  75325. * @param x2 defines the right coordinate on X axis
  75326. * @param y2 defines the right coordinate on Y axis
  75327. * @returns the interpolated value
  75328. */
  75329. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  75330. }
  75331. /**
  75332. * Defines angle representation
  75333. */
  75334. export class Angle {
  75335. private _radians;
  75336. /**
  75337. * Creates an Angle object of "radians" radians (float).
  75338. * @param radians the angle in radians
  75339. */
  75340. constructor(radians: number);
  75341. /**
  75342. * Get value in degrees
  75343. * @returns the Angle value in degrees (float)
  75344. */
  75345. degrees(): number;
  75346. /**
  75347. * Get value in radians
  75348. * @returns the Angle value in radians (float)
  75349. */
  75350. radians(): number;
  75351. /**
  75352. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  75353. * @param a defines first vector
  75354. * @param b defines second vector
  75355. * @returns a new Angle
  75356. */
  75357. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  75358. /**
  75359. * Gets a new Angle object from the given float in radians
  75360. * @param radians defines the angle value in radians
  75361. * @returns a new Angle
  75362. */
  75363. static FromRadians(radians: number): Angle;
  75364. /**
  75365. * Gets a new Angle object from the given float in degrees
  75366. * @param degrees defines the angle value in degrees
  75367. * @returns a new Angle
  75368. */
  75369. static FromDegrees(degrees: number): Angle;
  75370. }
  75371. /**
  75372. * This represents an arc in a 2d space.
  75373. */
  75374. export class Arc2 {
  75375. /** Defines the start point of the arc */
  75376. startPoint: Vector2;
  75377. /** Defines the mid point of the arc */
  75378. midPoint: Vector2;
  75379. /** Defines the end point of the arc */
  75380. endPoint: Vector2;
  75381. /**
  75382. * Defines the center point of the arc.
  75383. */
  75384. centerPoint: Vector2;
  75385. /**
  75386. * Defines the radius of the arc.
  75387. */
  75388. radius: number;
  75389. /**
  75390. * Defines the angle of the arc (from mid point to end point).
  75391. */
  75392. angle: Angle;
  75393. /**
  75394. * Defines the start angle of the arc (from start point to middle point).
  75395. */
  75396. startAngle: Angle;
  75397. /**
  75398. * Defines the orientation of the arc (clock wise/counter clock wise).
  75399. */
  75400. orientation: Orientation;
  75401. /**
  75402. * Creates an Arc object from the three given points : start, middle and end.
  75403. * @param startPoint Defines the start point of the arc
  75404. * @param midPoint Defines the midlle point of the arc
  75405. * @param endPoint Defines the end point of the arc
  75406. */
  75407. constructor(
  75408. /** Defines the start point of the arc */
  75409. startPoint: Vector2,
  75410. /** Defines the mid point of the arc */
  75411. midPoint: Vector2,
  75412. /** Defines the end point of the arc */
  75413. endPoint: Vector2);
  75414. }
  75415. /**
  75416. * Represents a 2D path made up of multiple 2D points
  75417. */
  75418. export class Path2 {
  75419. private _points;
  75420. private _length;
  75421. /**
  75422. * If the path start and end point are the same
  75423. */
  75424. closed: boolean;
  75425. /**
  75426. * Creates a Path2 object from the starting 2D coordinates x and y.
  75427. * @param x the starting points x value
  75428. * @param y the starting points y value
  75429. */
  75430. constructor(x: number, y: number);
  75431. /**
  75432. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  75433. * @param x the added points x value
  75434. * @param y the added points y value
  75435. * @returns the updated Path2.
  75436. */
  75437. addLineTo(x: number, y: number): Path2;
  75438. /**
  75439. * 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.
  75440. * @param midX middle point x value
  75441. * @param midY middle point y value
  75442. * @param endX end point x value
  75443. * @param endY end point y value
  75444. * @param numberOfSegments (default: 36)
  75445. * @returns the updated Path2.
  75446. */
  75447. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  75448. /**
  75449. * Closes the Path2.
  75450. * @returns the Path2.
  75451. */
  75452. close(): Path2;
  75453. /**
  75454. * Gets the sum of the distance between each sequential point in the path
  75455. * @returns the Path2 total length (float).
  75456. */
  75457. length(): number;
  75458. /**
  75459. * Gets the points which construct the path
  75460. * @returns the Path2 internal array of points.
  75461. */
  75462. getPoints(): Vector2[];
  75463. /**
  75464. * Retreives the point at the distance aways from the starting point
  75465. * @param normalizedLengthPosition the length along the path to retreive the point from
  75466. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  75467. */
  75468. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  75469. /**
  75470. * Creates a new path starting from an x and y position
  75471. * @param x starting x value
  75472. * @param y starting y value
  75473. * @returns a new Path2 starting at the coordinates (x, y).
  75474. */
  75475. static StartingAt(x: number, y: number): Path2;
  75476. }
  75477. /**
  75478. * Represents a 3D path made up of multiple 3D points
  75479. */
  75480. export class Path3D {
  75481. /**
  75482. * an array of Vector3, the curve axis of the Path3D
  75483. */
  75484. path: Vector3[];
  75485. private _curve;
  75486. private _distances;
  75487. private _tangents;
  75488. private _normals;
  75489. private _binormals;
  75490. private _raw;
  75491. private _alignTangentsWithPath;
  75492. private readonly _pointAtData;
  75493. /**
  75494. * new Path3D(path, normal, raw)
  75495. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  75496. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  75497. * @param path an array of Vector3, the curve axis of the Path3D
  75498. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  75499. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  75500. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  75501. */
  75502. constructor(
  75503. /**
  75504. * an array of Vector3, the curve axis of the Path3D
  75505. */
  75506. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  75507. /**
  75508. * Returns the Path3D array of successive Vector3 designing its curve.
  75509. * @returns the Path3D array of successive Vector3 designing its curve.
  75510. */
  75511. getCurve(): Vector3[];
  75512. /**
  75513. * Returns the Path3D array of successive Vector3 designing its curve.
  75514. * @returns the Path3D array of successive Vector3 designing its curve.
  75515. */
  75516. getPoints(): Vector3[];
  75517. /**
  75518. * @returns the computed length (float) of the path.
  75519. */
  75520. length(): number;
  75521. /**
  75522. * Returns an array populated with tangent vectors on each Path3D curve point.
  75523. * @returns an array populated with tangent vectors on each Path3D curve point.
  75524. */
  75525. getTangents(): Vector3[];
  75526. /**
  75527. * Returns an array populated with normal vectors on each Path3D curve point.
  75528. * @returns an array populated with normal vectors on each Path3D curve point.
  75529. */
  75530. getNormals(): Vector3[];
  75531. /**
  75532. * Returns an array populated with binormal vectors on each Path3D curve point.
  75533. * @returns an array populated with binormal vectors on each Path3D curve point.
  75534. */
  75535. getBinormals(): Vector3[];
  75536. /**
  75537. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  75538. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  75539. */
  75540. getDistances(): number[];
  75541. /**
  75542. * Returns an interpolated point along this path
  75543. * @param position the position of the point along this path, from 0.0 to 1.0
  75544. * @returns a new Vector3 as the point
  75545. */
  75546. getPointAt(position: number): Vector3;
  75547. /**
  75548. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75549. * @param position the position of the point along this path, from 0.0 to 1.0
  75550. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  75551. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  75552. */
  75553. getTangentAt(position: number, interpolated?: boolean): Vector3;
  75554. /**
  75555. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75556. * @param position the position of the point along this path, from 0.0 to 1.0
  75557. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  75558. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  75559. */
  75560. getNormalAt(position: number, interpolated?: boolean): Vector3;
  75561. /**
  75562. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  75563. * @param position the position of the point along this path, from 0.0 to 1.0
  75564. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  75565. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  75566. */
  75567. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  75568. /**
  75569. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  75570. * @param position the position of the point along this path, from 0.0 to 1.0
  75571. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  75572. */
  75573. getDistanceAt(position: number): number;
  75574. /**
  75575. * Returns the array index of the previous point of an interpolated point along this path
  75576. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75577. * @returns the array index
  75578. */
  75579. getPreviousPointIndexAt(position: number): number;
  75580. /**
  75581. * 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)
  75582. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75583. * @returns the sub position
  75584. */
  75585. getSubPositionAt(position: number): number;
  75586. /**
  75587. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  75588. * @param target the vector of which to get the closest position to
  75589. * @returns the position of the closest virtual point on this path to the target vector
  75590. */
  75591. getClosestPositionTo(target: Vector3): number;
  75592. /**
  75593. * Returns a sub path (slice) of this path
  75594. * @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
  75595. * @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
  75596. * @returns a sub path (slice) of this path
  75597. */
  75598. slice(start?: number, end?: number): Path3D;
  75599. /**
  75600. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  75601. * @param path path which all values are copied into the curves points
  75602. * @param firstNormal which should be projected onto the curve
  75603. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  75604. * @returns the same object updated.
  75605. */
  75606. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  75607. private _compute;
  75608. private _getFirstNonNullVector;
  75609. private _getLastNonNullVector;
  75610. private _normalVector;
  75611. /**
  75612. * Updates the point at data for an interpolated point along this curve
  75613. * @param position the position of the point along this curve, from 0.0 to 1.0
  75614. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  75615. * @returns the (updated) point at data
  75616. */
  75617. private _updatePointAtData;
  75618. /**
  75619. * Updates the point at data from the specified parameters
  75620. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  75621. * @param point the interpolated point
  75622. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  75623. */
  75624. private _setPointAtData;
  75625. /**
  75626. * Updates the point at interpolation matrix for the tangents, normals and binormals
  75627. */
  75628. private _updateInterpolationMatrix;
  75629. }
  75630. /**
  75631. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75632. * A Curve3 is designed from a series of successive Vector3.
  75633. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  75634. */
  75635. export class Curve3 {
  75636. private _points;
  75637. private _length;
  75638. /**
  75639. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  75640. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  75641. * @param v1 (Vector3) the control point
  75642. * @param v2 (Vector3) the end point of the Quadratic Bezier
  75643. * @param nbPoints (integer) the wanted number of points in the curve
  75644. * @returns the created Curve3
  75645. */
  75646. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75647. /**
  75648. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  75649. * @param v0 (Vector3) the origin point of the Cubic Bezier
  75650. * @param v1 (Vector3) the first control point
  75651. * @param v2 (Vector3) the second control point
  75652. * @param v3 (Vector3) the end point of the Cubic Bezier
  75653. * @param nbPoints (integer) the wanted number of points in the curve
  75654. * @returns the created Curve3
  75655. */
  75656. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75657. /**
  75658. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  75659. * @param p1 (Vector3) the origin point of the Hermite Spline
  75660. * @param t1 (Vector3) the tangent vector at the origin point
  75661. * @param p2 (Vector3) the end point of the Hermite Spline
  75662. * @param t2 (Vector3) the tangent vector at the end point
  75663. * @param nbPoints (integer) the wanted number of points in the curve
  75664. * @returns the created Curve3
  75665. */
  75666. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75667. /**
  75668. * Returns a Curve3 object along a CatmullRom Spline curve :
  75669. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  75670. * @param nbPoints (integer) the wanted number of points between each curve control points
  75671. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  75672. * @returns the created Curve3
  75673. */
  75674. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  75675. /**
  75676. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75677. * A Curve3 is designed from a series of successive Vector3.
  75678. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  75679. * @param points points which make up the curve
  75680. */
  75681. constructor(points: Vector3[]);
  75682. /**
  75683. * @returns the Curve3 stored array of successive Vector3
  75684. */
  75685. getPoints(): Vector3[];
  75686. /**
  75687. * @returns the computed length (float) of the curve.
  75688. */
  75689. length(): number;
  75690. /**
  75691. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  75692. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  75693. * curveA and curveB keep unchanged.
  75694. * @param curve the curve to continue from this curve
  75695. * @returns the newly constructed curve
  75696. */
  75697. continue(curve: DeepImmutable<Curve3>): Curve3;
  75698. private _computeLength;
  75699. }
  75700. }
  75701. declare module BABYLON {
  75702. /**
  75703. * This represents the main contract an easing function should follow.
  75704. * Easing functions are used throughout the animation system.
  75705. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75706. */
  75707. export interface IEasingFunction {
  75708. /**
  75709. * Given an input gradient between 0 and 1, this returns the corrseponding value
  75710. * of the easing function.
  75711. * The link below provides some of the most common examples of easing functions.
  75712. * @see https://easings.net/
  75713. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75714. * @returns the corresponding value on the curve defined by the easing function
  75715. */
  75716. ease(gradient: number): number;
  75717. }
  75718. /**
  75719. * Base class used for every default easing function.
  75720. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75721. */
  75722. export class EasingFunction implements IEasingFunction {
  75723. /**
  75724. * Interpolation follows the mathematical formula associated with the easing function.
  75725. */
  75726. static readonly EASINGMODE_EASEIN: number;
  75727. /**
  75728. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  75729. */
  75730. static readonly EASINGMODE_EASEOUT: number;
  75731. /**
  75732. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  75733. */
  75734. static readonly EASINGMODE_EASEINOUT: number;
  75735. private _easingMode;
  75736. /**
  75737. * Sets the easing mode of the current function.
  75738. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  75739. */
  75740. setEasingMode(easingMode: number): void;
  75741. /**
  75742. * Gets the current easing mode.
  75743. * @returns the easing mode
  75744. */
  75745. getEasingMode(): number;
  75746. /**
  75747. * @hidden
  75748. */
  75749. easeInCore(gradient: number): number;
  75750. /**
  75751. * Given an input gradient between 0 and 1, this returns the corresponding value
  75752. * of the easing function.
  75753. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75754. * @returns the corresponding value on the curve defined by the easing function
  75755. */
  75756. ease(gradient: number): number;
  75757. }
  75758. /**
  75759. * Easing function with a circle shape (see link below).
  75760. * @see https://easings.net/#easeInCirc
  75761. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75762. */
  75763. export class CircleEase extends EasingFunction implements IEasingFunction {
  75764. /** @hidden */
  75765. easeInCore(gradient: number): number;
  75766. }
  75767. /**
  75768. * Easing function with a ease back shape (see link below).
  75769. * @see https://easings.net/#easeInBack
  75770. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75771. */
  75772. export class BackEase extends EasingFunction implements IEasingFunction {
  75773. /** Defines the amplitude of the function */
  75774. amplitude: number;
  75775. /**
  75776. * Instantiates a back ease easing
  75777. * @see https://easings.net/#easeInBack
  75778. * @param amplitude Defines the amplitude of the function
  75779. */
  75780. constructor(
  75781. /** Defines the amplitude of the function */
  75782. amplitude?: number);
  75783. /** @hidden */
  75784. easeInCore(gradient: number): number;
  75785. }
  75786. /**
  75787. * Easing function with a bouncing shape (see link below).
  75788. * @see https://easings.net/#easeInBounce
  75789. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75790. */
  75791. export class BounceEase extends EasingFunction implements IEasingFunction {
  75792. /** Defines the number of bounces */
  75793. bounces: number;
  75794. /** Defines the amplitude of the bounce */
  75795. bounciness: number;
  75796. /**
  75797. * Instantiates a bounce easing
  75798. * @see https://easings.net/#easeInBounce
  75799. * @param bounces Defines the number of bounces
  75800. * @param bounciness Defines the amplitude of the bounce
  75801. */
  75802. constructor(
  75803. /** Defines the number of bounces */
  75804. bounces?: number,
  75805. /** Defines the amplitude of the bounce */
  75806. bounciness?: number);
  75807. /** @hidden */
  75808. easeInCore(gradient: number): number;
  75809. }
  75810. /**
  75811. * Easing function with a power of 3 shape (see link below).
  75812. * @see https://easings.net/#easeInCubic
  75813. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75814. */
  75815. export class CubicEase extends EasingFunction implements IEasingFunction {
  75816. /** @hidden */
  75817. easeInCore(gradient: number): number;
  75818. }
  75819. /**
  75820. * Easing function with an elastic shape (see link below).
  75821. * @see https://easings.net/#easeInElastic
  75822. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75823. */
  75824. export class ElasticEase extends EasingFunction implements IEasingFunction {
  75825. /** Defines the number of oscillations*/
  75826. oscillations: number;
  75827. /** Defines the amplitude of the oscillations*/
  75828. springiness: number;
  75829. /**
  75830. * Instantiates an elastic easing function
  75831. * @see https://easings.net/#easeInElastic
  75832. * @param oscillations Defines the number of oscillations
  75833. * @param springiness Defines the amplitude of the oscillations
  75834. */
  75835. constructor(
  75836. /** Defines the number of oscillations*/
  75837. oscillations?: number,
  75838. /** Defines the amplitude of the oscillations*/
  75839. springiness?: number);
  75840. /** @hidden */
  75841. easeInCore(gradient: number): number;
  75842. }
  75843. /**
  75844. * Easing function with an exponential shape (see link below).
  75845. * @see https://easings.net/#easeInExpo
  75846. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75847. */
  75848. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  75849. /** Defines the exponent of the function */
  75850. exponent: number;
  75851. /**
  75852. * Instantiates an exponential easing function
  75853. * @see https://easings.net/#easeInExpo
  75854. * @param exponent Defines the exponent of the function
  75855. */
  75856. constructor(
  75857. /** Defines the exponent of the function */
  75858. exponent?: number);
  75859. /** @hidden */
  75860. easeInCore(gradient: number): number;
  75861. }
  75862. /**
  75863. * Easing function with a power shape (see link below).
  75864. * @see https://easings.net/#easeInQuad
  75865. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75866. */
  75867. export class PowerEase extends EasingFunction implements IEasingFunction {
  75868. /** Defines the power of the function */
  75869. power: number;
  75870. /**
  75871. * Instantiates an power base easing function
  75872. * @see https://easings.net/#easeInQuad
  75873. * @param power Defines the power of the function
  75874. */
  75875. constructor(
  75876. /** Defines the power of the function */
  75877. power?: number);
  75878. /** @hidden */
  75879. easeInCore(gradient: number): number;
  75880. }
  75881. /**
  75882. * Easing function with a power of 2 shape (see link below).
  75883. * @see https://easings.net/#easeInQuad
  75884. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75885. */
  75886. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  75887. /** @hidden */
  75888. easeInCore(gradient: number): number;
  75889. }
  75890. /**
  75891. * Easing function with a power of 4 shape (see link below).
  75892. * @see https://easings.net/#easeInQuart
  75893. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75894. */
  75895. export class QuarticEase extends EasingFunction implements IEasingFunction {
  75896. /** @hidden */
  75897. easeInCore(gradient: number): number;
  75898. }
  75899. /**
  75900. * Easing function with a power of 5 shape (see link below).
  75901. * @see https://easings.net/#easeInQuint
  75902. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75903. */
  75904. export class QuinticEase extends EasingFunction implements IEasingFunction {
  75905. /** @hidden */
  75906. easeInCore(gradient: number): number;
  75907. }
  75908. /**
  75909. * Easing function with a sin shape (see link below).
  75910. * @see https://easings.net/#easeInSine
  75911. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75912. */
  75913. export class SineEase extends EasingFunction implements IEasingFunction {
  75914. /** @hidden */
  75915. easeInCore(gradient: number): number;
  75916. }
  75917. /**
  75918. * Easing function with a bezier shape (see link below).
  75919. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75920. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75921. */
  75922. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  75923. /** Defines the x component of the start tangent in the bezier curve */
  75924. x1: number;
  75925. /** Defines the y component of the start tangent in the bezier curve */
  75926. y1: number;
  75927. /** Defines the x component of the end tangent in the bezier curve */
  75928. x2: number;
  75929. /** Defines the y component of the end tangent in the bezier curve */
  75930. y2: number;
  75931. /**
  75932. * Instantiates a bezier function
  75933. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75934. * @param x1 Defines the x component of the start tangent in the bezier curve
  75935. * @param y1 Defines the y component of the start tangent in the bezier curve
  75936. * @param x2 Defines the x component of the end tangent in the bezier curve
  75937. * @param y2 Defines the y component of the end tangent in the bezier curve
  75938. */
  75939. constructor(
  75940. /** Defines the x component of the start tangent in the bezier curve */
  75941. x1?: number,
  75942. /** Defines the y component of the start tangent in the bezier curve */
  75943. y1?: number,
  75944. /** Defines the x component of the end tangent in the bezier curve */
  75945. x2?: number,
  75946. /** Defines the y component of the end tangent in the bezier curve */
  75947. y2?: number);
  75948. /** @hidden */
  75949. easeInCore(gradient: number): number;
  75950. }
  75951. }
  75952. declare module BABYLON {
  75953. /**
  75954. * Class used to hold a RBG color
  75955. */
  75956. export class Color3 {
  75957. /**
  75958. * Defines the red component (between 0 and 1, default is 0)
  75959. */
  75960. r: number;
  75961. /**
  75962. * Defines the green component (between 0 and 1, default is 0)
  75963. */
  75964. g: number;
  75965. /**
  75966. * Defines the blue component (between 0 and 1, default is 0)
  75967. */
  75968. b: number;
  75969. /**
  75970. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  75971. * @param r defines the red component (between 0 and 1, default is 0)
  75972. * @param g defines the green component (between 0 and 1, default is 0)
  75973. * @param b defines the blue component (between 0 and 1, default is 0)
  75974. */
  75975. constructor(
  75976. /**
  75977. * Defines the red component (between 0 and 1, default is 0)
  75978. */
  75979. r?: number,
  75980. /**
  75981. * Defines the green component (between 0 and 1, default is 0)
  75982. */
  75983. g?: number,
  75984. /**
  75985. * Defines the blue component (between 0 and 1, default is 0)
  75986. */
  75987. b?: number);
  75988. /**
  75989. * Creates a string with the Color3 current values
  75990. * @returns the string representation of the Color3 object
  75991. */
  75992. toString(): string;
  75993. /**
  75994. * Returns the string "Color3"
  75995. * @returns "Color3"
  75996. */
  75997. getClassName(): string;
  75998. /**
  75999. * Compute the Color3 hash code
  76000. * @returns an unique number that can be used to hash Color3 objects
  76001. */
  76002. getHashCode(): number;
  76003. /**
  76004. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  76005. * @param array defines the array where to store the r,g,b components
  76006. * @param index defines an optional index in the target array to define where to start storing values
  76007. * @returns the current Color3 object
  76008. */
  76009. toArray(array: FloatArray, index?: number): Color3;
  76010. /**
  76011. * Returns a new Color4 object from the current Color3 and the given alpha
  76012. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  76013. * @returns a new Color4 object
  76014. */
  76015. toColor4(alpha?: number): Color4;
  76016. /**
  76017. * Returns a new array populated with 3 numeric elements : red, green and blue values
  76018. * @returns the new array
  76019. */
  76020. asArray(): number[];
  76021. /**
  76022. * Returns the luminance value
  76023. * @returns a float value
  76024. */
  76025. toLuminance(): number;
  76026. /**
  76027. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  76028. * @param otherColor defines the second operand
  76029. * @returns the new Color3 object
  76030. */
  76031. multiply(otherColor: DeepImmutable<Color3>): Color3;
  76032. /**
  76033. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  76034. * @param otherColor defines the second operand
  76035. * @param result defines the Color3 object where to store the result
  76036. * @returns the current Color3
  76037. */
  76038. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76039. /**
  76040. * Determines equality between Color3 objects
  76041. * @param otherColor defines the second operand
  76042. * @returns true if the rgb values are equal to the given ones
  76043. */
  76044. equals(otherColor: DeepImmutable<Color3>): boolean;
  76045. /**
  76046. * Determines equality between the current Color3 object and a set of r,b,g values
  76047. * @param r defines the red component to check
  76048. * @param g defines the green component to check
  76049. * @param b defines the blue component to check
  76050. * @returns true if the rgb values are equal to the given ones
  76051. */
  76052. equalsFloats(r: number, g: number, b: number): boolean;
  76053. /**
  76054. * Multiplies in place each rgb value by scale
  76055. * @param scale defines the scaling factor
  76056. * @returns the updated Color3
  76057. */
  76058. scale(scale: number): Color3;
  76059. /**
  76060. * Multiplies the rgb values by scale and stores the result into "result"
  76061. * @param scale defines the scaling factor
  76062. * @param result defines the Color3 object where to store the result
  76063. * @returns the unmodified current Color3
  76064. */
  76065. scaleToRef(scale: number, result: Color3): Color3;
  76066. /**
  76067. * Scale the current Color3 values by a factor and add the result to a given Color3
  76068. * @param scale defines the scale factor
  76069. * @param result defines color to store the result into
  76070. * @returns the unmodified current Color3
  76071. */
  76072. scaleAndAddToRef(scale: number, result: Color3): Color3;
  76073. /**
  76074. * Clamps the rgb values by the min and max values and stores the result into "result"
  76075. * @param min defines minimum clamping value (default is 0)
  76076. * @param max defines maximum clamping value (default is 1)
  76077. * @param result defines color to store the result into
  76078. * @returns the original Color3
  76079. */
  76080. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  76081. /**
  76082. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  76083. * @param otherColor defines the second operand
  76084. * @returns the new Color3
  76085. */
  76086. add(otherColor: DeepImmutable<Color3>): Color3;
  76087. /**
  76088. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  76089. * @param otherColor defines the second operand
  76090. * @param result defines Color3 object to store the result into
  76091. * @returns the unmodified current Color3
  76092. */
  76093. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76094. /**
  76095. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  76096. * @param otherColor defines the second operand
  76097. * @returns the new Color3
  76098. */
  76099. subtract(otherColor: DeepImmutable<Color3>): Color3;
  76100. /**
  76101. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  76102. * @param otherColor defines the second operand
  76103. * @param result defines Color3 object to store the result into
  76104. * @returns the unmodified current Color3
  76105. */
  76106. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76107. /**
  76108. * Copy the current object
  76109. * @returns a new Color3 copied the current one
  76110. */
  76111. clone(): Color3;
  76112. /**
  76113. * Copies the rgb values from the source in the current Color3
  76114. * @param source defines the source Color3 object
  76115. * @returns the updated Color3 object
  76116. */
  76117. copyFrom(source: DeepImmutable<Color3>): Color3;
  76118. /**
  76119. * Updates the Color3 rgb values from the given floats
  76120. * @param r defines the red component to read from
  76121. * @param g defines the green component to read from
  76122. * @param b defines the blue component to read from
  76123. * @returns the current Color3 object
  76124. */
  76125. copyFromFloats(r: number, g: number, b: number): Color3;
  76126. /**
  76127. * Updates the Color3 rgb values from the given floats
  76128. * @param r defines the red component to read from
  76129. * @param g defines the green component to read from
  76130. * @param b defines the blue component to read from
  76131. * @returns the current Color3 object
  76132. */
  76133. set(r: number, g: number, b: number): Color3;
  76134. /**
  76135. * Compute the Color3 hexadecimal code as a string
  76136. * @returns a string containing the hexadecimal representation of the Color3 object
  76137. */
  76138. toHexString(): string;
  76139. /**
  76140. * Computes a new Color3 converted from the current one to linear space
  76141. * @returns a new Color3 object
  76142. */
  76143. toLinearSpace(): Color3;
  76144. /**
  76145. * Converts current color in rgb space to HSV values
  76146. * @returns a new color3 representing the HSV values
  76147. */
  76148. toHSV(): Color3;
  76149. /**
  76150. * Converts current color in rgb space to HSV values
  76151. * @param result defines the Color3 where to store the HSV values
  76152. */
  76153. toHSVToRef(result: Color3): void;
  76154. /**
  76155. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  76156. * @param convertedColor defines the Color3 object where to store the linear space version
  76157. * @returns the unmodified Color3
  76158. */
  76159. toLinearSpaceToRef(convertedColor: Color3): Color3;
  76160. /**
  76161. * Computes a new Color3 converted from the current one to gamma space
  76162. * @returns a new Color3 object
  76163. */
  76164. toGammaSpace(): Color3;
  76165. /**
  76166. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  76167. * @param convertedColor defines the Color3 object where to store the gamma space version
  76168. * @returns the unmodified Color3
  76169. */
  76170. toGammaSpaceToRef(convertedColor: Color3): Color3;
  76171. private static _BlackReadOnly;
  76172. /**
  76173. * Convert Hue, saturation and value to a Color3 (RGB)
  76174. * @param hue defines the hue
  76175. * @param saturation defines the saturation
  76176. * @param value defines the value
  76177. * @param result defines the Color3 where to store the RGB values
  76178. */
  76179. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  76180. /**
  76181. * Creates a new Color3 from the string containing valid hexadecimal values
  76182. * @param hex defines a string containing valid hexadecimal values
  76183. * @returns a new Color3 object
  76184. */
  76185. static FromHexString(hex: string): Color3;
  76186. /**
  76187. * Creates a new Color3 from the starting index of the given array
  76188. * @param array defines the source array
  76189. * @param offset defines an offset in the source array
  76190. * @returns a new Color3 object
  76191. */
  76192. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  76193. /**
  76194. * Creates a new Color3 from integer values (< 256)
  76195. * @param r defines the red component to read from (value between 0 and 255)
  76196. * @param g defines the green component to read from (value between 0 and 255)
  76197. * @param b defines the blue component to read from (value between 0 and 255)
  76198. * @returns a new Color3 object
  76199. */
  76200. static FromInts(r: number, g: number, b: number): Color3;
  76201. /**
  76202. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76203. * @param start defines the start Color3 value
  76204. * @param end defines the end Color3 value
  76205. * @param amount defines the gradient value between start and end
  76206. * @returns a new Color3 object
  76207. */
  76208. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  76209. /**
  76210. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76211. * @param left defines the start value
  76212. * @param right defines the end value
  76213. * @param amount defines the gradient factor
  76214. * @param result defines the Color3 object where to store the result
  76215. */
  76216. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  76217. /**
  76218. * Returns a Color3 value containing a red color
  76219. * @returns a new Color3 object
  76220. */
  76221. static Red(): Color3;
  76222. /**
  76223. * Returns a Color3 value containing a green color
  76224. * @returns a new Color3 object
  76225. */
  76226. static Green(): Color3;
  76227. /**
  76228. * Returns a Color3 value containing a blue color
  76229. * @returns a new Color3 object
  76230. */
  76231. static Blue(): Color3;
  76232. /**
  76233. * Returns a Color3 value containing a black color
  76234. * @returns a new Color3 object
  76235. */
  76236. static Black(): Color3;
  76237. /**
  76238. * Gets a Color3 value containing a black color that must not be updated
  76239. */
  76240. static get BlackReadOnly(): DeepImmutable<Color3>;
  76241. /**
  76242. * Returns a Color3 value containing a white color
  76243. * @returns a new Color3 object
  76244. */
  76245. static White(): Color3;
  76246. /**
  76247. * Returns a Color3 value containing a purple color
  76248. * @returns a new Color3 object
  76249. */
  76250. static Purple(): Color3;
  76251. /**
  76252. * Returns a Color3 value containing a magenta color
  76253. * @returns a new Color3 object
  76254. */
  76255. static Magenta(): Color3;
  76256. /**
  76257. * Returns a Color3 value containing a yellow color
  76258. * @returns a new Color3 object
  76259. */
  76260. static Yellow(): Color3;
  76261. /**
  76262. * Returns a Color3 value containing a gray color
  76263. * @returns a new Color3 object
  76264. */
  76265. static Gray(): Color3;
  76266. /**
  76267. * Returns a Color3 value containing a teal color
  76268. * @returns a new Color3 object
  76269. */
  76270. static Teal(): Color3;
  76271. /**
  76272. * Returns a Color3 value containing a random color
  76273. * @returns a new Color3 object
  76274. */
  76275. static Random(): Color3;
  76276. }
  76277. /**
  76278. * Class used to hold a RBGA color
  76279. */
  76280. export class Color4 {
  76281. /**
  76282. * Defines the red component (between 0 and 1, default is 0)
  76283. */
  76284. r: number;
  76285. /**
  76286. * Defines the green component (between 0 and 1, default is 0)
  76287. */
  76288. g: number;
  76289. /**
  76290. * Defines the blue component (between 0 and 1, default is 0)
  76291. */
  76292. b: number;
  76293. /**
  76294. * Defines the alpha component (between 0 and 1, default is 1)
  76295. */
  76296. a: number;
  76297. /**
  76298. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  76299. * @param r defines the red component (between 0 and 1, default is 0)
  76300. * @param g defines the green component (between 0 and 1, default is 0)
  76301. * @param b defines the blue component (between 0 and 1, default is 0)
  76302. * @param a defines the alpha component (between 0 and 1, default is 1)
  76303. */
  76304. constructor(
  76305. /**
  76306. * Defines the red component (between 0 and 1, default is 0)
  76307. */
  76308. r?: number,
  76309. /**
  76310. * Defines the green component (between 0 and 1, default is 0)
  76311. */
  76312. g?: number,
  76313. /**
  76314. * Defines the blue component (between 0 and 1, default is 0)
  76315. */
  76316. b?: number,
  76317. /**
  76318. * Defines the alpha component (between 0 and 1, default is 1)
  76319. */
  76320. a?: number);
  76321. /**
  76322. * Adds in place the given Color4 values to the current Color4 object
  76323. * @param right defines the second operand
  76324. * @returns the current updated Color4 object
  76325. */
  76326. addInPlace(right: DeepImmutable<Color4>): Color4;
  76327. /**
  76328. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  76329. * @returns the new array
  76330. */
  76331. asArray(): number[];
  76332. /**
  76333. * Stores from the starting index in the given array the Color4 successive values
  76334. * @param array defines the array where to store the r,g,b components
  76335. * @param index defines an optional index in the target array to define where to start storing values
  76336. * @returns the current Color4 object
  76337. */
  76338. toArray(array: number[], index?: number): Color4;
  76339. /**
  76340. * Determines equality between Color4 objects
  76341. * @param otherColor defines the second operand
  76342. * @returns true if the rgba values are equal to the given ones
  76343. */
  76344. equals(otherColor: DeepImmutable<Color4>): boolean;
  76345. /**
  76346. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  76347. * @param right defines the second operand
  76348. * @returns a new Color4 object
  76349. */
  76350. add(right: DeepImmutable<Color4>): Color4;
  76351. /**
  76352. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  76353. * @param right defines the second operand
  76354. * @returns a new Color4 object
  76355. */
  76356. subtract(right: DeepImmutable<Color4>): Color4;
  76357. /**
  76358. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  76359. * @param right defines the second operand
  76360. * @param result defines the Color4 object where to store the result
  76361. * @returns the current Color4 object
  76362. */
  76363. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  76364. /**
  76365. * Creates a new Color4 with the current Color4 values multiplied by scale
  76366. * @param scale defines the scaling factor to apply
  76367. * @returns a new Color4 object
  76368. */
  76369. scale(scale: number): Color4;
  76370. /**
  76371. * Multiplies the current Color4 values by scale and stores the result in "result"
  76372. * @param scale defines the scaling factor to apply
  76373. * @param result defines the Color4 object where to store the result
  76374. * @returns the current unmodified Color4
  76375. */
  76376. scaleToRef(scale: number, result: Color4): Color4;
  76377. /**
  76378. * Scale the current Color4 values by a factor and add the result to a given Color4
  76379. * @param scale defines the scale factor
  76380. * @param result defines the Color4 object where to store the result
  76381. * @returns the unmodified current Color4
  76382. */
  76383. scaleAndAddToRef(scale: number, result: Color4): Color4;
  76384. /**
  76385. * Clamps the rgb values by the min and max values and stores the result into "result"
  76386. * @param min defines minimum clamping value (default is 0)
  76387. * @param max defines maximum clamping value (default is 1)
  76388. * @param result defines color to store the result into.
  76389. * @returns the cuurent Color4
  76390. */
  76391. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  76392. /**
  76393. * Multipy an Color4 value by another and return a new Color4 object
  76394. * @param color defines the Color4 value to multiply by
  76395. * @returns a new Color4 object
  76396. */
  76397. multiply(color: Color4): Color4;
  76398. /**
  76399. * Multipy a Color4 value by another and push the result in a reference value
  76400. * @param color defines the Color4 value to multiply by
  76401. * @param result defines the Color4 to fill the result in
  76402. * @returns the result Color4
  76403. */
  76404. multiplyToRef(color: Color4, result: Color4): Color4;
  76405. /**
  76406. * Creates a string with the Color4 current values
  76407. * @returns the string representation of the Color4 object
  76408. */
  76409. toString(): string;
  76410. /**
  76411. * Returns the string "Color4"
  76412. * @returns "Color4"
  76413. */
  76414. getClassName(): string;
  76415. /**
  76416. * Compute the Color4 hash code
  76417. * @returns an unique number that can be used to hash Color4 objects
  76418. */
  76419. getHashCode(): number;
  76420. /**
  76421. * Creates a new Color4 copied from the current one
  76422. * @returns a new Color4 object
  76423. */
  76424. clone(): Color4;
  76425. /**
  76426. * Copies the given Color4 values into the current one
  76427. * @param source defines the source Color4 object
  76428. * @returns the current updated Color4 object
  76429. */
  76430. copyFrom(source: Color4): Color4;
  76431. /**
  76432. * Copies the given float values into the current one
  76433. * @param r defines the red component to read from
  76434. * @param g defines the green component to read from
  76435. * @param b defines the blue component to read from
  76436. * @param a defines the alpha component to read from
  76437. * @returns the current updated Color4 object
  76438. */
  76439. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  76440. /**
  76441. * Copies the given float values into the current one
  76442. * @param r defines the red component to read from
  76443. * @param g defines the green component to read from
  76444. * @param b defines the blue component to read from
  76445. * @param a defines the alpha component to read from
  76446. * @returns the current updated Color4 object
  76447. */
  76448. set(r: number, g: number, b: number, a: number): Color4;
  76449. /**
  76450. * Compute the Color4 hexadecimal code as a string
  76451. * @returns a string containing the hexadecimal representation of the Color4 object
  76452. */
  76453. toHexString(): string;
  76454. /**
  76455. * Computes a new Color4 converted from the current one to linear space
  76456. * @returns a new Color4 object
  76457. */
  76458. toLinearSpace(): Color4;
  76459. /**
  76460. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  76461. * @param convertedColor defines the Color4 object where to store the linear space version
  76462. * @returns the unmodified Color4
  76463. */
  76464. toLinearSpaceToRef(convertedColor: Color4): Color4;
  76465. /**
  76466. * Computes a new Color4 converted from the current one to gamma space
  76467. * @returns a new Color4 object
  76468. */
  76469. toGammaSpace(): Color4;
  76470. /**
  76471. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  76472. * @param convertedColor defines the Color4 object where to store the gamma space version
  76473. * @returns the unmodified Color4
  76474. */
  76475. toGammaSpaceToRef(convertedColor: Color4): Color4;
  76476. /**
  76477. * Creates a new Color4 from the string containing valid hexadecimal values
  76478. * @param hex defines a string containing valid hexadecimal values
  76479. * @returns a new Color4 object
  76480. */
  76481. static FromHexString(hex: string): Color4;
  76482. /**
  76483. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76484. * @param left defines the start value
  76485. * @param right defines the end value
  76486. * @param amount defines the gradient factor
  76487. * @returns a new Color4 object
  76488. */
  76489. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  76490. /**
  76491. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76492. * @param left defines the start value
  76493. * @param right defines the end value
  76494. * @param amount defines the gradient factor
  76495. * @param result defines the Color4 object where to store data
  76496. */
  76497. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  76498. /**
  76499. * Creates a new Color4 from a Color3 and an alpha value
  76500. * @param color3 defines the source Color3 to read from
  76501. * @param alpha defines the alpha component (1.0 by default)
  76502. * @returns a new Color4 object
  76503. */
  76504. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  76505. /**
  76506. * Creates a new Color4 from the starting index element of the given array
  76507. * @param array defines the source array to read from
  76508. * @param offset defines the offset in the source array
  76509. * @returns a new Color4 object
  76510. */
  76511. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  76512. /**
  76513. * Creates a new Color3 from integer values (< 256)
  76514. * @param r defines the red component to read from (value between 0 and 255)
  76515. * @param g defines the green component to read from (value between 0 and 255)
  76516. * @param b defines the blue component to read from (value between 0 and 255)
  76517. * @param a defines the alpha component to read from (value between 0 and 255)
  76518. * @returns a new Color3 object
  76519. */
  76520. static FromInts(r: number, g: number, b: number, a: number): Color4;
  76521. /**
  76522. * Check the content of a given array and convert it to an array containing RGBA data
  76523. * If the original array was already containing count * 4 values then it is returned directly
  76524. * @param colors defines the array to check
  76525. * @param count defines the number of RGBA data to expect
  76526. * @returns an array containing count * 4 values (RGBA)
  76527. */
  76528. static CheckColors4(colors: number[], count: number): number[];
  76529. }
  76530. /**
  76531. * @hidden
  76532. */
  76533. export class TmpColors {
  76534. static Color3: Color3[];
  76535. static Color4: Color4[];
  76536. }
  76537. }
  76538. declare module BABYLON {
  76539. /**
  76540. * Defines an interface which represents an animation key frame
  76541. */
  76542. export interface IAnimationKey {
  76543. /**
  76544. * Frame of the key frame
  76545. */
  76546. frame: number;
  76547. /**
  76548. * Value at the specifies key frame
  76549. */
  76550. value: any;
  76551. /**
  76552. * The input tangent for the cubic hermite spline
  76553. */
  76554. inTangent?: any;
  76555. /**
  76556. * The output tangent for the cubic hermite spline
  76557. */
  76558. outTangent?: any;
  76559. /**
  76560. * The animation interpolation type
  76561. */
  76562. interpolation?: AnimationKeyInterpolation;
  76563. }
  76564. /**
  76565. * Enum for the animation key frame interpolation type
  76566. */
  76567. export enum AnimationKeyInterpolation {
  76568. /**
  76569. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  76570. */
  76571. STEP = 1
  76572. }
  76573. }
  76574. declare module BABYLON {
  76575. /**
  76576. * Represents the range of an animation
  76577. */
  76578. export class AnimationRange {
  76579. /**The name of the animation range**/
  76580. name: string;
  76581. /**The starting frame of the animation */
  76582. from: number;
  76583. /**The ending frame of the animation*/
  76584. to: number;
  76585. /**
  76586. * Initializes the range of an animation
  76587. * @param name The name of the animation range
  76588. * @param from The starting frame of the animation
  76589. * @param to The ending frame of the animation
  76590. */
  76591. constructor(
  76592. /**The name of the animation range**/
  76593. name: string,
  76594. /**The starting frame of the animation */
  76595. from: number,
  76596. /**The ending frame of the animation*/
  76597. to: number);
  76598. /**
  76599. * Makes a copy of the animation range
  76600. * @returns A copy of the animation range
  76601. */
  76602. clone(): AnimationRange;
  76603. }
  76604. }
  76605. declare module BABYLON {
  76606. /**
  76607. * Composed of a frame, and an action function
  76608. */
  76609. export class AnimationEvent {
  76610. /** The frame for which the event is triggered **/
  76611. frame: number;
  76612. /** The event to perform when triggered **/
  76613. action: (currentFrame: number) => void;
  76614. /** Specifies if the event should be triggered only once**/
  76615. onlyOnce?: boolean | undefined;
  76616. /**
  76617. * Specifies if the animation event is done
  76618. */
  76619. isDone: boolean;
  76620. /**
  76621. * Initializes the animation event
  76622. * @param frame The frame for which the event is triggered
  76623. * @param action The event to perform when triggered
  76624. * @param onlyOnce Specifies if the event should be triggered only once
  76625. */
  76626. constructor(
  76627. /** The frame for which the event is triggered **/
  76628. frame: number,
  76629. /** The event to perform when triggered **/
  76630. action: (currentFrame: number) => void,
  76631. /** Specifies if the event should be triggered only once**/
  76632. onlyOnce?: boolean | undefined);
  76633. /** @hidden */
  76634. _clone(): AnimationEvent;
  76635. }
  76636. }
  76637. declare module BABYLON {
  76638. /**
  76639. * Interface used to define a behavior
  76640. */
  76641. export interface Behavior<T> {
  76642. /** gets or sets behavior's name */
  76643. name: string;
  76644. /**
  76645. * Function called when the behavior needs to be initialized (after attaching it to a target)
  76646. */
  76647. init(): void;
  76648. /**
  76649. * Called when the behavior is attached to a target
  76650. * @param target defines the target where the behavior is attached to
  76651. */
  76652. attach(target: T): void;
  76653. /**
  76654. * Called when the behavior is detached from its target
  76655. */
  76656. detach(): void;
  76657. }
  76658. /**
  76659. * Interface implemented by classes supporting behaviors
  76660. */
  76661. export interface IBehaviorAware<T> {
  76662. /**
  76663. * Attach a behavior
  76664. * @param behavior defines the behavior to attach
  76665. * @returns the current host
  76666. */
  76667. addBehavior(behavior: Behavior<T>): T;
  76668. /**
  76669. * Remove a behavior from the current object
  76670. * @param behavior defines the behavior to detach
  76671. * @returns the current host
  76672. */
  76673. removeBehavior(behavior: Behavior<T>): T;
  76674. /**
  76675. * Gets a behavior using its name to search
  76676. * @param name defines the name to search
  76677. * @returns the behavior or null if not found
  76678. */
  76679. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  76680. }
  76681. }
  76682. declare module BABYLON {
  76683. /**
  76684. * Defines an array and its length.
  76685. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  76686. */
  76687. export interface ISmartArrayLike<T> {
  76688. /**
  76689. * The data of the array.
  76690. */
  76691. data: Array<T>;
  76692. /**
  76693. * The active length of the array.
  76694. */
  76695. length: number;
  76696. }
  76697. /**
  76698. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76699. */
  76700. export class SmartArray<T> implements ISmartArrayLike<T> {
  76701. /**
  76702. * The full set of data from the array.
  76703. */
  76704. data: Array<T>;
  76705. /**
  76706. * The active length of the array.
  76707. */
  76708. length: number;
  76709. protected _id: number;
  76710. /**
  76711. * Instantiates a Smart Array.
  76712. * @param capacity defines the default capacity of the array.
  76713. */
  76714. constructor(capacity: number);
  76715. /**
  76716. * Pushes a value at the end of the active data.
  76717. * @param value defines the object to push in the array.
  76718. */
  76719. push(value: T): void;
  76720. /**
  76721. * Iterates over the active data and apply the lambda to them.
  76722. * @param func defines the action to apply on each value.
  76723. */
  76724. forEach(func: (content: T) => void): void;
  76725. /**
  76726. * Sorts the full sets of data.
  76727. * @param compareFn defines the comparison function to apply.
  76728. */
  76729. sort(compareFn: (a: T, b: T) => number): void;
  76730. /**
  76731. * Resets the active data to an empty array.
  76732. */
  76733. reset(): void;
  76734. /**
  76735. * Releases all the data from the array as well as the array.
  76736. */
  76737. dispose(): void;
  76738. /**
  76739. * Concats the active data with a given array.
  76740. * @param array defines the data to concatenate with.
  76741. */
  76742. concat(array: any): void;
  76743. /**
  76744. * Returns the position of a value in the active data.
  76745. * @param value defines the value to find the index for
  76746. * @returns the index if found in the active data otherwise -1
  76747. */
  76748. indexOf(value: T): number;
  76749. /**
  76750. * Returns whether an element is part of the active data.
  76751. * @param value defines the value to look for
  76752. * @returns true if found in the active data otherwise false
  76753. */
  76754. contains(value: T): boolean;
  76755. private static _GlobalId;
  76756. }
  76757. /**
  76758. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76759. * The data in this array can only be present once
  76760. */
  76761. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  76762. private _duplicateId;
  76763. /**
  76764. * Pushes a value at the end of the active data.
  76765. * THIS DOES NOT PREVENT DUPPLICATE DATA
  76766. * @param value defines the object to push in the array.
  76767. */
  76768. push(value: T): void;
  76769. /**
  76770. * Pushes a value at the end of the active data.
  76771. * If the data is already present, it won t be added again
  76772. * @param value defines the object to push in the array.
  76773. * @returns true if added false if it was already present
  76774. */
  76775. pushNoDuplicate(value: T): boolean;
  76776. /**
  76777. * Resets the active data to an empty array.
  76778. */
  76779. reset(): void;
  76780. /**
  76781. * Concats the active data with a given array.
  76782. * This ensures no dupplicate will be present in the result.
  76783. * @param array defines the data to concatenate with.
  76784. */
  76785. concatWithNoDuplicate(array: any): void;
  76786. }
  76787. }
  76788. declare module BABYLON {
  76789. /**
  76790. * @ignore
  76791. * This is a list of all the different input types that are available in the application.
  76792. * Fo instance: ArcRotateCameraGamepadInput...
  76793. */
  76794. export var CameraInputTypes: {};
  76795. /**
  76796. * This is the contract to implement in order to create a new input class.
  76797. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  76798. */
  76799. export interface ICameraInput<TCamera extends Camera> {
  76800. /**
  76801. * Defines the camera the input is attached to.
  76802. */
  76803. camera: Nullable<TCamera>;
  76804. /**
  76805. * Gets the class name of the current intput.
  76806. * @returns the class name
  76807. */
  76808. getClassName(): string;
  76809. /**
  76810. * Get the friendly name associated with the input class.
  76811. * @returns the input friendly name
  76812. */
  76813. getSimpleName(): string;
  76814. /**
  76815. * Attach the input controls to a specific dom element to get the input from.
  76816. * @param element Defines the element the controls should be listened from
  76817. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76818. */
  76819. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76820. /**
  76821. * Detach the current controls from the specified dom element.
  76822. * @param element Defines the element to stop listening the inputs from
  76823. */
  76824. detachControl(element: Nullable<HTMLElement>): void;
  76825. /**
  76826. * Update the current camera state depending on the inputs that have been used this frame.
  76827. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76828. */
  76829. checkInputs?: () => void;
  76830. }
  76831. /**
  76832. * Represents a map of input types to input instance or input index to input instance.
  76833. */
  76834. export interface CameraInputsMap<TCamera extends Camera> {
  76835. /**
  76836. * Accessor to the input by input type.
  76837. */
  76838. [name: string]: ICameraInput<TCamera>;
  76839. /**
  76840. * Accessor to the input by input index.
  76841. */
  76842. [idx: number]: ICameraInput<TCamera>;
  76843. }
  76844. /**
  76845. * This represents the input manager used within a camera.
  76846. * It helps dealing with all the different kind of input attached to a camera.
  76847. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76848. */
  76849. export class CameraInputsManager<TCamera extends Camera> {
  76850. /**
  76851. * Defines the list of inputs attahed to the camera.
  76852. */
  76853. attached: CameraInputsMap<TCamera>;
  76854. /**
  76855. * Defines the dom element the camera is collecting inputs from.
  76856. * This is null if the controls have not been attached.
  76857. */
  76858. attachedElement: Nullable<HTMLElement>;
  76859. /**
  76860. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76861. */
  76862. noPreventDefault: boolean;
  76863. /**
  76864. * Defined the camera the input manager belongs to.
  76865. */
  76866. camera: TCamera;
  76867. /**
  76868. * Update the current camera state depending on the inputs that have been used this frame.
  76869. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76870. */
  76871. checkInputs: () => void;
  76872. /**
  76873. * Instantiate a new Camera Input Manager.
  76874. * @param camera Defines the camera the input manager blongs to
  76875. */
  76876. constructor(camera: TCamera);
  76877. /**
  76878. * Add an input method to a camera
  76879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76880. * @param input camera input method
  76881. */
  76882. add(input: ICameraInput<TCamera>): void;
  76883. /**
  76884. * Remove a specific input method from a camera
  76885. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  76886. * @param inputToRemove camera input method
  76887. */
  76888. remove(inputToRemove: ICameraInput<TCamera>): void;
  76889. /**
  76890. * Remove a specific input type from a camera
  76891. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  76892. * @param inputType the type of the input to remove
  76893. */
  76894. removeByType(inputType: string): void;
  76895. private _addCheckInputs;
  76896. /**
  76897. * Attach the input controls to the currently attached dom element to listen the events from.
  76898. * @param input Defines the input to attach
  76899. */
  76900. attachInput(input: ICameraInput<TCamera>): void;
  76901. /**
  76902. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  76903. * @param element Defines the dom element to collect the events from
  76904. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76905. */
  76906. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  76907. /**
  76908. * Detach the current manager inputs controls from a specific dom element.
  76909. * @param element Defines the dom element to collect the events from
  76910. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  76911. */
  76912. detachElement(element: HTMLElement, disconnect?: boolean): void;
  76913. /**
  76914. * Rebuild the dynamic inputCheck function from the current list of
  76915. * defined inputs in the manager.
  76916. */
  76917. rebuildInputCheck(): void;
  76918. /**
  76919. * Remove all attached input methods from a camera
  76920. */
  76921. clear(): void;
  76922. /**
  76923. * Serialize the current input manager attached to a camera.
  76924. * This ensures than once parsed,
  76925. * the input associated to the camera will be identical to the current ones
  76926. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  76927. */
  76928. serialize(serializedCamera: any): void;
  76929. /**
  76930. * Parses an input manager serialized JSON to restore the previous list of inputs
  76931. * and states associated to a camera.
  76932. * @param parsedCamera Defines the JSON to parse
  76933. */
  76934. parse(parsedCamera: any): void;
  76935. }
  76936. }
  76937. declare module BABYLON {
  76938. /**
  76939. * Class used to store data that will be store in GPU memory
  76940. */
  76941. export class Buffer {
  76942. private _engine;
  76943. private _buffer;
  76944. /** @hidden */
  76945. _data: Nullable<DataArray>;
  76946. private _updatable;
  76947. private _instanced;
  76948. private _divisor;
  76949. /**
  76950. * Gets the byte stride.
  76951. */
  76952. readonly byteStride: number;
  76953. /**
  76954. * Constructor
  76955. * @param engine the engine
  76956. * @param data the data to use for this buffer
  76957. * @param updatable whether the data is updatable
  76958. * @param stride the stride (optional)
  76959. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76960. * @param instanced whether the buffer is instanced (optional)
  76961. * @param useBytes set to true if the stride in in bytes (optional)
  76962. * @param divisor sets an optional divisor for instances (1 by default)
  76963. */
  76964. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  76965. /**
  76966. * Create a new VertexBuffer based on the current buffer
  76967. * @param kind defines the vertex buffer kind (position, normal, etc.)
  76968. * @param offset defines offset in the buffer (0 by default)
  76969. * @param size defines the size in floats of attributes (position is 3 for instance)
  76970. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  76971. * @param instanced defines if the vertex buffer contains indexed data
  76972. * @param useBytes defines if the offset and stride are in bytes *
  76973. * @param divisor sets an optional divisor for instances (1 by default)
  76974. * @returns the new vertex buffer
  76975. */
  76976. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  76977. /**
  76978. * Gets a boolean indicating if the Buffer is updatable?
  76979. * @returns true if the buffer is updatable
  76980. */
  76981. isUpdatable(): boolean;
  76982. /**
  76983. * Gets current buffer's data
  76984. * @returns a DataArray or null
  76985. */
  76986. getData(): Nullable<DataArray>;
  76987. /**
  76988. * Gets underlying native buffer
  76989. * @returns underlying native buffer
  76990. */
  76991. getBuffer(): Nullable<DataBuffer>;
  76992. /**
  76993. * Gets the stride in float32 units (i.e. byte stride / 4).
  76994. * May not be an integer if the byte stride is not divisible by 4.
  76995. * @returns the stride in float32 units
  76996. * @deprecated Please use byteStride instead.
  76997. */
  76998. getStrideSize(): number;
  76999. /**
  77000. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77001. * @param data defines the data to store
  77002. */
  77003. create(data?: Nullable<DataArray>): void;
  77004. /** @hidden */
  77005. _rebuild(): void;
  77006. /**
  77007. * Update current buffer data
  77008. * @param data defines the data to store
  77009. */
  77010. update(data: DataArray): void;
  77011. /**
  77012. * Updates the data directly.
  77013. * @param data the new data
  77014. * @param offset the new offset
  77015. * @param vertexCount the vertex count (optional)
  77016. * @param useBytes set to true if the offset is in bytes
  77017. */
  77018. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  77019. /**
  77020. * Release all resources
  77021. */
  77022. dispose(): void;
  77023. }
  77024. /**
  77025. * Specialized buffer used to store vertex data
  77026. */
  77027. export class VertexBuffer {
  77028. /** @hidden */
  77029. _buffer: Buffer;
  77030. private _kind;
  77031. private _size;
  77032. private _ownsBuffer;
  77033. private _instanced;
  77034. private _instanceDivisor;
  77035. /**
  77036. * The byte type.
  77037. */
  77038. static readonly BYTE: number;
  77039. /**
  77040. * The unsigned byte type.
  77041. */
  77042. static readonly UNSIGNED_BYTE: number;
  77043. /**
  77044. * The short type.
  77045. */
  77046. static readonly SHORT: number;
  77047. /**
  77048. * The unsigned short type.
  77049. */
  77050. static readonly UNSIGNED_SHORT: number;
  77051. /**
  77052. * The integer type.
  77053. */
  77054. static readonly INT: number;
  77055. /**
  77056. * The unsigned integer type.
  77057. */
  77058. static readonly UNSIGNED_INT: number;
  77059. /**
  77060. * The float type.
  77061. */
  77062. static readonly FLOAT: number;
  77063. /**
  77064. * Gets or sets the instance divisor when in instanced mode
  77065. */
  77066. get instanceDivisor(): number;
  77067. set instanceDivisor(value: number);
  77068. /**
  77069. * Gets the byte stride.
  77070. */
  77071. readonly byteStride: number;
  77072. /**
  77073. * Gets the byte offset.
  77074. */
  77075. readonly byteOffset: number;
  77076. /**
  77077. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  77078. */
  77079. readonly normalized: boolean;
  77080. /**
  77081. * Gets the data type of each component in the array.
  77082. */
  77083. readonly type: number;
  77084. /**
  77085. * Constructor
  77086. * @param engine the engine
  77087. * @param data the data to use for this vertex buffer
  77088. * @param kind the vertex buffer kind
  77089. * @param updatable whether the data is updatable
  77090. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  77091. * @param stride the stride (optional)
  77092. * @param instanced whether the buffer is instanced (optional)
  77093. * @param offset the offset of the data (optional)
  77094. * @param size the number of components (optional)
  77095. * @param type the type of the component (optional)
  77096. * @param normalized whether the data contains normalized data (optional)
  77097. * @param useBytes set to true if stride and offset are in bytes (optional)
  77098. * @param divisor defines the instance divisor to use (1 by default)
  77099. */
  77100. 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);
  77101. /** @hidden */
  77102. _rebuild(): void;
  77103. /**
  77104. * Returns the kind of the VertexBuffer (string)
  77105. * @returns a string
  77106. */
  77107. getKind(): string;
  77108. /**
  77109. * Gets a boolean indicating if the VertexBuffer is updatable?
  77110. * @returns true if the buffer is updatable
  77111. */
  77112. isUpdatable(): boolean;
  77113. /**
  77114. * Gets current buffer's data
  77115. * @returns a DataArray or null
  77116. */
  77117. getData(): Nullable<DataArray>;
  77118. /**
  77119. * Gets underlying native buffer
  77120. * @returns underlying native buffer
  77121. */
  77122. getBuffer(): Nullable<DataBuffer>;
  77123. /**
  77124. * Gets the stride in float32 units (i.e. byte stride / 4).
  77125. * May not be an integer if the byte stride is not divisible by 4.
  77126. * @returns the stride in float32 units
  77127. * @deprecated Please use byteStride instead.
  77128. */
  77129. getStrideSize(): number;
  77130. /**
  77131. * Returns the offset as a multiple of the type byte length.
  77132. * @returns the offset in bytes
  77133. * @deprecated Please use byteOffset instead.
  77134. */
  77135. getOffset(): number;
  77136. /**
  77137. * Returns the number of components per vertex attribute (integer)
  77138. * @returns the size in float
  77139. */
  77140. getSize(): number;
  77141. /**
  77142. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  77143. * @returns true if this buffer is instanced
  77144. */
  77145. getIsInstanced(): boolean;
  77146. /**
  77147. * Returns the instancing divisor, zero for non-instanced (integer).
  77148. * @returns a number
  77149. */
  77150. getInstanceDivisor(): number;
  77151. /**
  77152. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77153. * @param data defines the data to store
  77154. */
  77155. create(data?: DataArray): void;
  77156. /**
  77157. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  77158. * This function will create a new buffer if the current one is not updatable
  77159. * @param data defines the data to store
  77160. */
  77161. update(data: DataArray): void;
  77162. /**
  77163. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  77164. * Returns the directly updated WebGLBuffer.
  77165. * @param data the new data
  77166. * @param offset the new offset
  77167. * @param useBytes set to true if the offset is in bytes
  77168. */
  77169. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  77170. /**
  77171. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  77172. */
  77173. dispose(): void;
  77174. /**
  77175. * Enumerates each value of this vertex buffer as numbers.
  77176. * @param count the number of values to enumerate
  77177. * @param callback the callback function called for each value
  77178. */
  77179. forEach(count: number, callback: (value: number, index: number) => void): void;
  77180. /**
  77181. * Positions
  77182. */
  77183. static readonly PositionKind: string;
  77184. /**
  77185. * Normals
  77186. */
  77187. static readonly NormalKind: string;
  77188. /**
  77189. * Tangents
  77190. */
  77191. static readonly TangentKind: string;
  77192. /**
  77193. * Texture coordinates
  77194. */
  77195. static readonly UVKind: string;
  77196. /**
  77197. * Texture coordinates 2
  77198. */
  77199. static readonly UV2Kind: string;
  77200. /**
  77201. * Texture coordinates 3
  77202. */
  77203. static readonly UV3Kind: string;
  77204. /**
  77205. * Texture coordinates 4
  77206. */
  77207. static readonly UV4Kind: string;
  77208. /**
  77209. * Texture coordinates 5
  77210. */
  77211. static readonly UV5Kind: string;
  77212. /**
  77213. * Texture coordinates 6
  77214. */
  77215. static readonly UV6Kind: string;
  77216. /**
  77217. * Colors
  77218. */
  77219. static readonly ColorKind: string;
  77220. /**
  77221. * Matrix indices (for bones)
  77222. */
  77223. static readonly MatricesIndicesKind: string;
  77224. /**
  77225. * Matrix weights (for bones)
  77226. */
  77227. static readonly MatricesWeightsKind: string;
  77228. /**
  77229. * Additional matrix indices (for bones)
  77230. */
  77231. static readonly MatricesIndicesExtraKind: string;
  77232. /**
  77233. * Additional matrix weights (for bones)
  77234. */
  77235. static readonly MatricesWeightsExtraKind: string;
  77236. /**
  77237. * Deduces the stride given a kind.
  77238. * @param kind The kind string to deduce
  77239. * @returns The deduced stride
  77240. */
  77241. static DeduceStride(kind: string): number;
  77242. /**
  77243. * Gets the byte length of the given type.
  77244. * @param type the type
  77245. * @returns the number of bytes
  77246. */
  77247. static GetTypeByteLength(type: number): number;
  77248. /**
  77249. * Enumerates each value of the given parameters as numbers.
  77250. * @param data the data to enumerate
  77251. * @param byteOffset the byte offset of the data
  77252. * @param byteStride the byte stride of the data
  77253. * @param componentCount the number of components per element
  77254. * @param componentType the type of the component
  77255. * @param count the number of values to enumerate
  77256. * @param normalized whether the data is normalized
  77257. * @param callback the callback function called for each value
  77258. */
  77259. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  77260. private static _GetFloatValue;
  77261. }
  77262. }
  77263. declare module BABYLON {
  77264. /**
  77265. * @hidden
  77266. */
  77267. export class IntersectionInfo {
  77268. bu: Nullable<number>;
  77269. bv: Nullable<number>;
  77270. distance: number;
  77271. faceId: number;
  77272. subMeshId: number;
  77273. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  77274. }
  77275. }
  77276. declare module BABYLON {
  77277. /**
  77278. * Represens a plane by the equation ax + by + cz + d = 0
  77279. */
  77280. export class Plane {
  77281. private static _TmpMatrix;
  77282. /**
  77283. * Normal of the plane (a,b,c)
  77284. */
  77285. normal: Vector3;
  77286. /**
  77287. * d component of the plane
  77288. */
  77289. d: number;
  77290. /**
  77291. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77292. * @param a a component of the plane
  77293. * @param b b component of the plane
  77294. * @param c c component of the plane
  77295. * @param d d component of the plane
  77296. */
  77297. constructor(a: number, b: number, c: number, d: number);
  77298. /**
  77299. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77300. */
  77301. asArray(): number[];
  77302. /**
  77303. * @returns a new plane copied from the current Plane.
  77304. */
  77305. clone(): Plane;
  77306. /**
  77307. * @returns the string "Plane".
  77308. */
  77309. getClassName(): string;
  77310. /**
  77311. * @returns the Plane hash code.
  77312. */
  77313. getHashCode(): number;
  77314. /**
  77315. * Normalize the current Plane in place.
  77316. * @returns the updated Plane.
  77317. */
  77318. normalize(): Plane;
  77319. /**
  77320. * Applies a transformation the plane and returns the result
  77321. * @param transformation the transformation matrix to be applied to the plane
  77322. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77323. */
  77324. transform(transformation: DeepImmutable<Matrix>): Plane;
  77325. /**
  77326. * Calcualtte the dot product between the point and the plane normal
  77327. * @param point point to calculate the dot product with
  77328. * @returns the dot product (float) of the point coordinates and the plane normal.
  77329. */
  77330. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77331. /**
  77332. * Updates the current Plane from the plane defined by the three given points.
  77333. * @param point1 one of the points used to contruct the plane
  77334. * @param point2 one of the points used to contruct the plane
  77335. * @param point3 one of the points used to contruct the plane
  77336. * @returns the updated Plane.
  77337. */
  77338. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77339. /**
  77340. * Checks if the plane is facing a given direction
  77341. * @param direction the direction to check if the plane is facing
  77342. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77343. * @returns True is the vector "direction" is the same side than the plane normal.
  77344. */
  77345. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77346. /**
  77347. * Calculates the distance to a point
  77348. * @param point point to calculate distance to
  77349. * @returns the signed distance (float) from the given point to the Plane.
  77350. */
  77351. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77352. /**
  77353. * Creates a plane from an array
  77354. * @param array the array to create a plane from
  77355. * @returns a new Plane from the given array.
  77356. */
  77357. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77358. /**
  77359. * Creates a plane from three points
  77360. * @param point1 point used to create the plane
  77361. * @param point2 point used to create the plane
  77362. * @param point3 point used to create the plane
  77363. * @returns a new Plane defined by the three given points.
  77364. */
  77365. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77366. /**
  77367. * Creates a plane from an origin point and a normal
  77368. * @param origin origin of the plane to be constructed
  77369. * @param normal normal of the plane to be constructed
  77370. * @returns a new Plane the normal vector to this plane at the given origin point.
  77371. * Note : the vector "normal" is updated because normalized.
  77372. */
  77373. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77374. /**
  77375. * Calculates the distance from a plane and a point
  77376. * @param origin origin of the plane to be constructed
  77377. * @param normal normal of the plane to be constructed
  77378. * @param point point to calculate distance to
  77379. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77380. */
  77381. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77382. }
  77383. }
  77384. declare module BABYLON {
  77385. /**
  77386. * Class used to store bounding sphere information
  77387. */
  77388. export class BoundingSphere {
  77389. /**
  77390. * Gets the center of the bounding sphere in local space
  77391. */
  77392. readonly center: Vector3;
  77393. /**
  77394. * Radius of the bounding sphere in local space
  77395. */
  77396. radius: number;
  77397. /**
  77398. * Gets the center of the bounding sphere in world space
  77399. */
  77400. readonly centerWorld: Vector3;
  77401. /**
  77402. * Radius of the bounding sphere in world space
  77403. */
  77404. radiusWorld: number;
  77405. /**
  77406. * Gets the minimum vector in local space
  77407. */
  77408. readonly minimum: Vector3;
  77409. /**
  77410. * Gets the maximum vector in local space
  77411. */
  77412. readonly maximum: Vector3;
  77413. private _worldMatrix;
  77414. private static readonly TmpVector3;
  77415. /**
  77416. * Creates a new bounding sphere
  77417. * @param min defines the minimum vector (in local space)
  77418. * @param max defines the maximum vector (in local space)
  77419. * @param worldMatrix defines the new world matrix
  77420. */
  77421. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77422. /**
  77423. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  77424. * @param min defines the new minimum vector (in local space)
  77425. * @param max defines the new maximum vector (in local space)
  77426. * @param worldMatrix defines the new world matrix
  77427. */
  77428. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77429. /**
  77430. * Scale the current bounding sphere by applying a scale factor
  77431. * @param factor defines the scale factor to apply
  77432. * @returns the current bounding box
  77433. */
  77434. scale(factor: number): BoundingSphere;
  77435. /**
  77436. * Gets the world matrix of the bounding box
  77437. * @returns a matrix
  77438. */
  77439. getWorldMatrix(): DeepImmutable<Matrix>;
  77440. /** @hidden */
  77441. _update(worldMatrix: DeepImmutable<Matrix>): void;
  77442. /**
  77443. * Tests if the bounding sphere is intersecting the frustum planes
  77444. * @param frustumPlanes defines the frustum planes to test
  77445. * @returns true if there is an intersection
  77446. */
  77447. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77448. /**
  77449. * Tests if the bounding sphere center is in between the frustum planes.
  77450. * Used for optimistic fast inclusion.
  77451. * @param frustumPlanes defines the frustum planes to test
  77452. * @returns true if the sphere center is in between the frustum planes
  77453. */
  77454. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77455. /**
  77456. * Tests if a point is inside the bounding sphere
  77457. * @param point defines the point to test
  77458. * @returns true if the point is inside the bounding sphere
  77459. */
  77460. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77461. /**
  77462. * Checks if two sphere intersct
  77463. * @param sphere0 sphere 0
  77464. * @param sphere1 sphere 1
  77465. * @returns true if the speres intersect
  77466. */
  77467. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  77468. }
  77469. }
  77470. declare module BABYLON {
  77471. /**
  77472. * Class used to store bounding box information
  77473. */
  77474. export class BoundingBox implements ICullable {
  77475. /**
  77476. * Gets the 8 vectors representing the bounding box in local space
  77477. */
  77478. readonly vectors: Vector3[];
  77479. /**
  77480. * Gets the center of the bounding box in local space
  77481. */
  77482. readonly center: Vector3;
  77483. /**
  77484. * Gets the center of the bounding box in world space
  77485. */
  77486. readonly centerWorld: Vector3;
  77487. /**
  77488. * Gets the extend size in local space
  77489. */
  77490. readonly extendSize: Vector3;
  77491. /**
  77492. * Gets the extend size in world space
  77493. */
  77494. readonly extendSizeWorld: Vector3;
  77495. /**
  77496. * Gets the OBB (object bounding box) directions
  77497. */
  77498. readonly directions: Vector3[];
  77499. /**
  77500. * Gets the 8 vectors representing the bounding box in world space
  77501. */
  77502. readonly vectorsWorld: Vector3[];
  77503. /**
  77504. * Gets the minimum vector in world space
  77505. */
  77506. readonly minimumWorld: Vector3;
  77507. /**
  77508. * Gets the maximum vector in world space
  77509. */
  77510. readonly maximumWorld: Vector3;
  77511. /**
  77512. * Gets the minimum vector in local space
  77513. */
  77514. readonly minimum: Vector3;
  77515. /**
  77516. * Gets the maximum vector in local space
  77517. */
  77518. readonly maximum: Vector3;
  77519. private _worldMatrix;
  77520. private static readonly TmpVector3;
  77521. /**
  77522. * @hidden
  77523. */
  77524. _tag: number;
  77525. /**
  77526. * Creates a new bounding box
  77527. * @param min defines the minimum vector (in local space)
  77528. * @param max defines the maximum vector (in local space)
  77529. * @param worldMatrix defines the new world matrix
  77530. */
  77531. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77532. /**
  77533. * Recreates the entire bounding box from scratch as if we call the constructor in place
  77534. * @param min defines the new minimum vector (in local space)
  77535. * @param max defines the new maximum vector (in local space)
  77536. * @param worldMatrix defines the new world matrix
  77537. */
  77538. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77539. /**
  77540. * Scale the current bounding box by applying a scale factor
  77541. * @param factor defines the scale factor to apply
  77542. * @returns the current bounding box
  77543. */
  77544. scale(factor: number): BoundingBox;
  77545. /**
  77546. * Gets the world matrix of the bounding box
  77547. * @returns a matrix
  77548. */
  77549. getWorldMatrix(): DeepImmutable<Matrix>;
  77550. /** @hidden */
  77551. _update(world: DeepImmutable<Matrix>): void;
  77552. /**
  77553. * Tests if the bounding box is intersecting the frustum planes
  77554. * @param frustumPlanes defines the frustum planes to test
  77555. * @returns true if there is an intersection
  77556. */
  77557. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77558. /**
  77559. * Tests if the bounding box is entirely inside the frustum planes
  77560. * @param frustumPlanes defines the frustum planes to test
  77561. * @returns true if there is an inclusion
  77562. */
  77563. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77564. /**
  77565. * Tests if a point is inside the bounding box
  77566. * @param point defines the point to test
  77567. * @returns true if the point is inside the bounding box
  77568. */
  77569. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77570. /**
  77571. * Tests if the bounding box intersects with a bounding sphere
  77572. * @param sphere defines the sphere to test
  77573. * @returns true if there is an intersection
  77574. */
  77575. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  77576. /**
  77577. * Tests if the bounding box intersects with a box defined by a min and max vectors
  77578. * @param min defines the min vector to use
  77579. * @param max defines the max vector to use
  77580. * @returns true if there is an intersection
  77581. */
  77582. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  77583. /**
  77584. * Tests if two bounding boxes are intersections
  77585. * @param box0 defines the first box to test
  77586. * @param box1 defines the second box to test
  77587. * @returns true if there is an intersection
  77588. */
  77589. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  77590. /**
  77591. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  77592. * @param minPoint defines the minimum vector of the bounding box
  77593. * @param maxPoint defines the maximum vector of the bounding box
  77594. * @param sphereCenter defines the sphere center
  77595. * @param sphereRadius defines the sphere radius
  77596. * @returns true if there is an intersection
  77597. */
  77598. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  77599. /**
  77600. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  77601. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77602. * @param frustumPlanes defines the frustum planes to test
  77603. * @return true if there is an inclusion
  77604. */
  77605. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77606. /**
  77607. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  77608. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77609. * @param frustumPlanes defines the frustum planes to test
  77610. * @return true if there is an intersection
  77611. */
  77612. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77613. }
  77614. }
  77615. declare module BABYLON {
  77616. /** @hidden */
  77617. export class Collider {
  77618. /** Define if a collision was found */
  77619. collisionFound: boolean;
  77620. /**
  77621. * Define last intersection point in local space
  77622. */
  77623. intersectionPoint: Vector3;
  77624. /**
  77625. * Define last collided mesh
  77626. */
  77627. collidedMesh: Nullable<AbstractMesh>;
  77628. private _collisionPoint;
  77629. private _planeIntersectionPoint;
  77630. private _tempVector;
  77631. private _tempVector2;
  77632. private _tempVector3;
  77633. private _tempVector4;
  77634. private _edge;
  77635. private _baseToVertex;
  77636. private _destinationPoint;
  77637. private _slidePlaneNormal;
  77638. private _displacementVector;
  77639. /** @hidden */
  77640. _radius: Vector3;
  77641. /** @hidden */
  77642. _retry: number;
  77643. private _velocity;
  77644. private _basePoint;
  77645. private _epsilon;
  77646. /** @hidden */
  77647. _velocityWorldLength: number;
  77648. /** @hidden */
  77649. _basePointWorld: Vector3;
  77650. private _velocityWorld;
  77651. private _normalizedVelocity;
  77652. /** @hidden */
  77653. _initialVelocity: Vector3;
  77654. /** @hidden */
  77655. _initialPosition: Vector3;
  77656. private _nearestDistance;
  77657. private _collisionMask;
  77658. get collisionMask(): number;
  77659. set collisionMask(mask: number);
  77660. /**
  77661. * Gets the plane normal used to compute the sliding response (in local space)
  77662. */
  77663. get slidePlaneNormal(): Vector3;
  77664. /** @hidden */
  77665. _initialize(source: Vector3, dir: Vector3, e: number): void;
  77666. /** @hidden */
  77667. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  77668. /** @hidden */
  77669. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  77670. /** @hidden */
  77671. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77672. /** @hidden */
  77673. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77674. /** @hidden */
  77675. _getResponse(pos: Vector3, vel: Vector3): void;
  77676. }
  77677. }
  77678. declare module BABYLON {
  77679. /**
  77680. * Interface for cullable objects
  77681. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  77682. */
  77683. export interface ICullable {
  77684. /**
  77685. * Checks if the object or part of the object is in the frustum
  77686. * @param frustumPlanes Camera near/planes
  77687. * @returns true if the object is in frustum otherwise false
  77688. */
  77689. isInFrustum(frustumPlanes: Plane[]): boolean;
  77690. /**
  77691. * Checks if a cullable object (mesh...) is in the camera frustum
  77692. * Unlike isInFrustum this cheks the full bounding box
  77693. * @param frustumPlanes Camera near/planes
  77694. * @returns true if the object is in frustum otherwise false
  77695. */
  77696. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77697. }
  77698. /**
  77699. * Info for a bounding data of a mesh
  77700. */
  77701. export class BoundingInfo implements ICullable {
  77702. /**
  77703. * Bounding box for the mesh
  77704. */
  77705. readonly boundingBox: BoundingBox;
  77706. /**
  77707. * Bounding sphere for the mesh
  77708. */
  77709. readonly boundingSphere: BoundingSphere;
  77710. private _isLocked;
  77711. private static readonly TmpVector3;
  77712. /**
  77713. * Constructs bounding info
  77714. * @param minimum min vector of the bounding box/sphere
  77715. * @param maximum max vector of the bounding box/sphere
  77716. * @param worldMatrix defines the new world matrix
  77717. */
  77718. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77719. /**
  77720. * Recreates the entire bounding info from scratch as if we call the constructor in place
  77721. * @param min defines the new minimum vector (in local space)
  77722. * @param max defines the new maximum vector (in local space)
  77723. * @param worldMatrix defines the new world matrix
  77724. */
  77725. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77726. /**
  77727. * min vector of the bounding box/sphere
  77728. */
  77729. get minimum(): Vector3;
  77730. /**
  77731. * max vector of the bounding box/sphere
  77732. */
  77733. get maximum(): Vector3;
  77734. /**
  77735. * If the info is locked and won't be updated to avoid perf overhead
  77736. */
  77737. get isLocked(): boolean;
  77738. set isLocked(value: boolean);
  77739. /**
  77740. * Updates the bounding sphere and box
  77741. * @param world world matrix to be used to update
  77742. */
  77743. update(world: DeepImmutable<Matrix>): void;
  77744. /**
  77745. * Recreate the bounding info to be centered around a specific point given a specific extend.
  77746. * @param center New center of the bounding info
  77747. * @param extend New extend of the bounding info
  77748. * @returns the current bounding info
  77749. */
  77750. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  77751. /**
  77752. * Scale the current bounding info by applying a scale factor
  77753. * @param factor defines the scale factor to apply
  77754. * @returns the current bounding info
  77755. */
  77756. scale(factor: number): BoundingInfo;
  77757. /**
  77758. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  77759. * @param frustumPlanes defines the frustum to test
  77760. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  77761. * @returns true if the bounding info is in the frustum planes
  77762. */
  77763. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  77764. /**
  77765. * Gets the world distance between the min and max points of the bounding box
  77766. */
  77767. get diagonalLength(): number;
  77768. /**
  77769. * Checks if a cullable object (mesh...) is in the camera frustum
  77770. * Unlike isInFrustum this cheks the full bounding box
  77771. * @param frustumPlanes Camera near/planes
  77772. * @returns true if the object is in frustum otherwise false
  77773. */
  77774. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77775. /** @hidden */
  77776. _checkCollision(collider: Collider): boolean;
  77777. /**
  77778. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  77779. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77780. * @param point the point to check intersection with
  77781. * @returns if the point intersects
  77782. */
  77783. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77784. /**
  77785. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  77786. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77787. * @param boundingInfo the bounding info to check intersection with
  77788. * @param precise if the intersection should be done using OBB
  77789. * @returns if the bounding info intersects
  77790. */
  77791. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  77792. }
  77793. }
  77794. declare module BABYLON {
  77795. /**
  77796. * Extracts minimum and maximum values from a list of indexed positions
  77797. * @param positions defines the positions to use
  77798. * @param indices defines the indices to the positions
  77799. * @param indexStart defines the start index
  77800. * @param indexCount defines the end index
  77801. * @param bias defines bias value to add to the result
  77802. * @return minimum and maximum values
  77803. */
  77804. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  77805. minimum: Vector3;
  77806. maximum: Vector3;
  77807. };
  77808. /**
  77809. * Extracts minimum and maximum values from a list of positions
  77810. * @param positions defines the positions to use
  77811. * @param start defines the start index in the positions array
  77812. * @param count defines the number of positions to handle
  77813. * @param bias defines bias value to add to the result
  77814. * @param stride defines the stride size to use (distance between two positions in the positions array)
  77815. * @return minimum and maximum values
  77816. */
  77817. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  77818. minimum: Vector3;
  77819. maximum: Vector3;
  77820. };
  77821. }
  77822. declare module BABYLON {
  77823. /** @hidden */
  77824. export class WebGLDataBuffer extends DataBuffer {
  77825. private _buffer;
  77826. constructor(resource: WebGLBuffer);
  77827. get underlyingResource(): any;
  77828. }
  77829. }
  77830. declare module BABYLON {
  77831. /** @hidden */
  77832. export class WebGLPipelineContext implements IPipelineContext {
  77833. engine: ThinEngine;
  77834. program: Nullable<WebGLProgram>;
  77835. context?: WebGLRenderingContext;
  77836. vertexShader?: WebGLShader;
  77837. fragmentShader?: WebGLShader;
  77838. isParallelCompiled: boolean;
  77839. onCompiled?: () => void;
  77840. transformFeedback?: WebGLTransformFeedback | null;
  77841. vertexCompilationError: Nullable<string>;
  77842. fragmentCompilationError: Nullable<string>;
  77843. programLinkError: Nullable<string>;
  77844. programValidationError: Nullable<string>;
  77845. get isAsync(): boolean;
  77846. get isReady(): boolean;
  77847. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  77848. }
  77849. }
  77850. declare module BABYLON {
  77851. interface ThinEngine {
  77852. /**
  77853. * Create an uniform buffer
  77854. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77855. * @param elements defines the content of the uniform buffer
  77856. * @returns the webGL uniform buffer
  77857. */
  77858. createUniformBuffer(elements: FloatArray): DataBuffer;
  77859. /**
  77860. * Create a dynamic uniform buffer
  77861. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77862. * @param elements defines the content of the uniform buffer
  77863. * @returns the webGL uniform buffer
  77864. */
  77865. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  77866. /**
  77867. * Update an existing uniform buffer
  77868. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77869. * @param uniformBuffer defines the target uniform buffer
  77870. * @param elements defines the content to update
  77871. * @param offset defines the offset in the uniform buffer where update should start
  77872. * @param count defines the size of the data to update
  77873. */
  77874. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  77875. /**
  77876. * Bind an uniform buffer to the current webGL context
  77877. * @param buffer defines the buffer to bind
  77878. */
  77879. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  77880. /**
  77881. * Bind a buffer to the current webGL context at a given location
  77882. * @param buffer defines the buffer to bind
  77883. * @param location defines the index where to bind the buffer
  77884. */
  77885. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  77886. /**
  77887. * Bind a specific block at a given index in a specific shader program
  77888. * @param pipelineContext defines the pipeline context to use
  77889. * @param blockName defines the block name
  77890. * @param index defines the index where to bind the block
  77891. */
  77892. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  77893. }
  77894. }
  77895. declare module BABYLON {
  77896. /**
  77897. * Uniform buffer objects.
  77898. *
  77899. * Handles blocks of uniform on the GPU.
  77900. *
  77901. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77902. *
  77903. * For more information, please refer to :
  77904. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77905. */
  77906. export class UniformBuffer {
  77907. private _engine;
  77908. private _buffer;
  77909. private _data;
  77910. private _bufferData;
  77911. private _dynamic?;
  77912. private _uniformLocations;
  77913. private _uniformSizes;
  77914. private _uniformLocationPointer;
  77915. private _needSync;
  77916. private _noUBO;
  77917. private _currentEffect;
  77918. /** @hidden */
  77919. _alreadyBound: boolean;
  77920. private static _MAX_UNIFORM_SIZE;
  77921. private static _tempBuffer;
  77922. /**
  77923. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  77924. * This is dynamic to allow compat with webgl 1 and 2.
  77925. * You will need to pass the name of the uniform as well as the value.
  77926. */
  77927. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  77928. /**
  77929. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  77930. * This is dynamic to allow compat with webgl 1 and 2.
  77931. * You will need to pass the name of the uniform as well as the value.
  77932. */
  77933. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  77934. /**
  77935. * Lambda to Update a single float in a uniform buffer.
  77936. * This is dynamic to allow compat with webgl 1 and 2.
  77937. * You will need to pass the name of the uniform as well as the value.
  77938. */
  77939. updateFloat: (name: string, x: number) => void;
  77940. /**
  77941. * Lambda to Update a vec2 of float in a uniform buffer.
  77942. * This is dynamic to allow compat with webgl 1 and 2.
  77943. * You will need to pass the name of the uniform as well as the value.
  77944. */
  77945. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  77946. /**
  77947. * Lambda to Update a vec3 of float in a uniform buffer.
  77948. * This is dynamic to allow compat with webgl 1 and 2.
  77949. * You will need to pass the name of the uniform as well as the value.
  77950. */
  77951. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  77952. /**
  77953. * Lambda to Update a vec4 of float in a uniform buffer.
  77954. * This is dynamic to allow compat with webgl 1 and 2.
  77955. * You will need to pass the name of the uniform as well as the value.
  77956. */
  77957. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  77958. /**
  77959. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  77960. * This is dynamic to allow compat with webgl 1 and 2.
  77961. * You will need to pass the name of the uniform as well as the value.
  77962. */
  77963. updateMatrix: (name: string, mat: Matrix) => void;
  77964. /**
  77965. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  77966. * This is dynamic to allow compat with webgl 1 and 2.
  77967. * You will need to pass the name of the uniform as well as the value.
  77968. */
  77969. updateVector3: (name: string, vector: Vector3) => void;
  77970. /**
  77971. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  77972. * This is dynamic to allow compat with webgl 1 and 2.
  77973. * You will need to pass the name of the uniform as well as the value.
  77974. */
  77975. updateVector4: (name: string, vector: Vector4) => void;
  77976. /**
  77977. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  77978. * This is dynamic to allow compat with webgl 1 and 2.
  77979. * You will need to pass the name of the uniform as well as the value.
  77980. */
  77981. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  77982. /**
  77983. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  77984. * This is dynamic to allow compat with webgl 1 and 2.
  77985. * You will need to pass the name of the uniform as well as the value.
  77986. */
  77987. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  77988. /**
  77989. * Instantiates a new Uniform buffer objects.
  77990. *
  77991. * Handles blocks of uniform on the GPU.
  77992. *
  77993. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77994. *
  77995. * For more information, please refer to :
  77996. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77997. * @param engine Define the engine the buffer is associated with
  77998. * @param data Define the data contained in the buffer
  77999. * @param dynamic Define if the buffer is updatable
  78000. */
  78001. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  78002. /**
  78003. * Indicates if the buffer is using the WebGL2 UBO implementation,
  78004. * or just falling back on setUniformXXX calls.
  78005. */
  78006. get useUbo(): boolean;
  78007. /**
  78008. * Indicates if the WebGL underlying uniform buffer is in sync
  78009. * with the javascript cache data.
  78010. */
  78011. get isSync(): boolean;
  78012. /**
  78013. * Indicates if the WebGL underlying uniform buffer is dynamic.
  78014. * Also, a dynamic UniformBuffer will disable cache verification and always
  78015. * update the underlying WebGL uniform buffer to the GPU.
  78016. * @returns if Dynamic, otherwise false
  78017. */
  78018. isDynamic(): boolean;
  78019. /**
  78020. * The data cache on JS side.
  78021. * @returns the underlying data as a float array
  78022. */
  78023. getData(): Float32Array;
  78024. /**
  78025. * The underlying WebGL Uniform buffer.
  78026. * @returns the webgl buffer
  78027. */
  78028. getBuffer(): Nullable<DataBuffer>;
  78029. /**
  78030. * std140 layout specifies how to align data within an UBO structure.
  78031. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  78032. * for specs.
  78033. */
  78034. private _fillAlignment;
  78035. /**
  78036. * Adds an uniform in the buffer.
  78037. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  78038. * for the layout to be correct !
  78039. * @param name Name of the uniform, as used in the uniform block in the shader.
  78040. * @param size Data size, or data directly.
  78041. */
  78042. addUniform(name: string, size: number | number[]): void;
  78043. /**
  78044. * Adds a Matrix 4x4 to the uniform buffer.
  78045. * @param name Name of the uniform, as used in the uniform block in the shader.
  78046. * @param mat A 4x4 matrix.
  78047. */
  78048. addMatrix(name: string, mat: Matrix): void;
  78049. /**
  78050. * Adds a vec2 to the uniform buffer.
  78051. * @param name Name of the uniform, as used in the uniform block in the shader.
  78052. * @param x Define the x component value of the vec2
  78053. * @param y Define the y component value of the vec2
  78054. */
  78055. addFloat2(name: string, x: number, y: number): void;
  78056. /**
  78057. * Adds a vec3 to the uniform buffer.
  78058. * @param name Name of the uniform, as used in the uniform block in the shader.
  78059. * @param x Define the x component value of the vec3
  78060. * @param y Define the y component value of the vec3
  78061. * @param z Define the z component value of the vec3
  78062. */
  78063. addFloat3(name: string, x: number, y: number, z: number): void;
  78064. /**
  78065. * Adds a vec3 to the uniform buffer.
  78066. * @param name Name of the uniform, as used in the uniform block in the shader.
  78067. * @param color Define the vec3 from a Color
  78068. */
  78069. addColor3(name: string, color: Color3): void;
  78070. /**
  78071. * Adds a vec4 to the uniform buffer.
  78072. * @param name Name of the uniform, as used in the uniform block in the shader.
  78073. * @param color Define the rgb components from a Color
  78074. * @param alpha Define the a component of the vec4
  78075. */
  78076. addColor4(name: string, color: Color3, alpha: number): void;
  78077. /**
  78078. * Adds a vec3 to the uniform buffer.
  78079. * @param name Name of the uniform, as used in the uniform block in the shader.
  78080. * @param vector Define the vec3 components from a Vector
  78081. */
  78082. addVector3(name: string, vector: Vector3): void;
  78083. /**
  78084. * Adds a Matrix 3x3 to the uniform buffer.
  78085. * @param name Name of the uniform, as used in the uniform block in the shader.
  78086. */
  78087. addMatrix3x3(name: string): void;
  78088. /**
  78089. * Adds a Matrix 2x2 to the uniform buffer.
  78090. * @param name Name of the uniform, as used in the uniform block in the shader.
  78091. */
  78092. addMatrix2x2(name: string): void;
  78093. /**
  78094. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  78095. */
  78096. create(): void;
  78097. /** @hidden */
  78098. _rebuild(): void;
  78099. /**
  78100. * Updates the WebGL Uniform Buffer on the GPU.
  78101. * If the `dynamic` flag is set to true, no cache comparison is done.
  78102. * Otherwise, the buffer will be updated only if the cache differs.
  78103. */
  78104. update(): void;
  78105. /**
  78106. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  78107. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78108. * @param data Define the flattened data
  78109. * @param size Define the size of the data.
  78110. */
  78111. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  78112. private _valueCache;
  78113. private _cacheMatrix;
  78114. private _updateMatrix3x3ForUniform;
  78115. private _updateMatrix3x3ForEffect;
  78116. private _updateMatrix2x2ForEffect;
  78117. private _updateMatrix2x2ForUniform;
  78118. private _updateFloatForEffect;
  78119. private _updateFloatForUniform;
  78120. private _updateFloat2ForEffect;
  78121. private _updateFloat2ForUniform;
  78122. private _updateFloat3ForEffect;
  78123. private _updateFloat3ForUniform;
  78124. private _updateFloat4ForEffect;
  78125. private _updateFloat4ForUniform;
  78126. private _updateMatrixForEffect;
  78127. private _updateMatrixForUniform;
  78128. private _updateVector3ForEffect;
  78129. private _updateVector3ForUniform;
  78130. private _updateVector4ForEffect;
  78131. private _updateVector4ForUniform;
  78132. private _updateColor3ForEffect;
  78133. private _updateColor3ForUniform;
  78134. private _updateColor4ForEffect;
  78135. private _updateColor4ForUniform;
  78136. /**
  78137. * Sets a sampler uniform on the effect.
  78138. * @param name Define the name of the sampler.
  78139. * @param texture Define the texture to set in the sampler
  78140. */
  78141. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  78142. /**
  78143. * Directly updates the value of the uniform in the cache AND on the GPU.
  78144. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78145. * @param data Define the flattened data
  78146. */
  78147. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  78148. /**
  78149. * Binds this uniform buffer to an effect.
  78150. * @param effect Define the effect to bind the buffer to
  78151. * @param name Name of the uniform block in the shader.
  78152. */
  78153. bindToEffect(effect: Effect, name: string): void;
  78154. /**
  78155. * Disposes the uniform buffer.
  78156. */
  78157. dispose(): void;
  78158. }
  78159. }
  78160. declare module BABYLON {
  78161. /**
  78162. * Enum that determines the text-wrapping mode to use.
  78163. */
  78164. export enum InspectableType {
  78165. /**
  78166. * Checkbox for booleans
  78167. */
  78168. Checkbox = 0,
  78169. /**
  78170. * Sliders for numbers
  78171. */
  78172. Slider = 1,
  78173. /**
  78174. * Vector3
  78175. */
  78176. Vector3 = 2,
  78177. /**
  78178. * Quaternions
  78179. */
  78180. Quaternion = 3,
  78181. /**
  78182. * Color3
  78183. */
  78184. Color3 = 4,
  78185. /**
  78186. * String
  78187. */
  78188. String = 5
  78189. }
  78190. /**
  78191. * Interface used to define custom inspectable properties.
  78192. * This interface is used by the inspector to display custom property grids
  78193. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78194. */
  78195. export interface IInspectable {
  78196. /**
  78197. * Gets the label to display
  78198. */
  78199. label: string;
  78200. /**
  78201. * Gets the name of the property to edit
  78202. */
  78203. propertyName: string;
  78204. /**
  78205. * Gets the type of the editor to use
  78206. */
  78207. type: InspectableType;
  78208. /**
  78209. * Gets the minimum value of the property when using in "slider" mode
  78210. */
  78211. min?: number;
  78212. /**
  78213. * Gets the maximum value of the property when using in "slider" mode
  78214. */
  78215. max?: number;
  78216. /**
  78217. * Gets the setp to use when using in "slider" mode
  78218. */
  78219. step?: number;
  78220. }
  78221. }
  78222. declare module BABYLON {
  78223. /**
  78224. * Class used to provide helper for timing
  78225. */
  78226. export class TimingTools {
  78227. /**
  78228. * Polyfill for setImmediate
  78229. * @param action defines the action to execute after the current execution block
  78230. */
  78231. static SetImmediate(action: () => void): void;
  78232. }
  78233. }
  78234. declare module BABYLON {
  78235. /**
  78236. * Class used to enable instatition of objects by class name
  78237. */
  78238. export class InstantiationTools {
  78239. /**
  78240. * Use this object to register external classes like custom textures or material
  78241. * to allow the laoders to instantiate them
  78242. */
  78243. static RegisteredExternalClasses: {
  78244. [key: string]: Object;
  78245. };
  78246. /**
  78247. * Tries to instantiate a new object from a given class name
  78248. * @param className defines the class name to instantiate
  78249. * @returns the new object or null if the system was not able to do the instantiation
  78250. */
  78251. static Instantiate(className: string): any;
  78252. }
  78253. }
  78254. declare module BABYLON {
  78255. /**
  78256. * Define options used to create a depth texture
  78257. */
  78258. export class DepthTextureCreationOptions {
  78259. /** Specifies whether or not a stencil should be allocated in the texture */
  78260. generateStencil?: boolean;
  78261. /** Specifies whether or not bilinear filtering is enable on the texture */
  78262. bilinearFiltering?: boolean;
  78263. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  78264. comparisonFunction?: number;
  78265. /** Specifies if the created texture is a cube texture */
  78266. isCube?: boolean;
  78267. }
  78268. }
  78269. declare module BABYLON {
  78270. interface ThinEngine {
  78271. /**
  78272. * Creates a depth stencil cube texture.
  78273. * This is only available in WebGL 2.
  78274. * @param size The size of face edge in the cube texture.
  78275. * @param options The options defining the cube texture.
  78276. * @returns The cube texture
  78277. */
  78278. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  78279. /**
  78280. * Creates a cube texture
  78281. * @param rootUrl defines the url where the files to load is located
  78282. * @param scene defines the current scene
  78283. * @param files defines the list of files to load (1 per face)
  78284. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78285. * @param onLoad defines an optional callback raised when the texture is loaded
  78286. * @param onError defines an optional callback raised if there is an issue to load the texture
  78287. * @param format defines the format of the data
  78288. * @param forcedExtension defines the extension to use to pick the right loader
  78289. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78290. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78291. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78292. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  78293. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  78294. * @returns the cube texture as an InternalTexture
  78295. */
  78296. 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;
  78297. /**
  78298. * Creates a cube texture
  78299. * @param rootUrl defines the url where the files to load is located
  78300. * @param scene defines the current scene
  78301. * @param files defines the list of files to load (1 per face)
  78302. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78303. * @param onLoad defines an optional callback raised when the texture is loaded
  78304. * @param onError defines an optional callback raised if there is an issue to load the texture
  78305. * @param format defines the format of the data
  78306. * @param forcedExtension defines the extension to use to pick the right loader
  78307. * @returns the cube texture as an InternalTexture
  78308. */
  78309. 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;
  78310. /**
  78311. * Creates a cube texture
  78312. * @param rootUrl defines the url where the files to load is located
  78313. * @param scene defines the current scene
  78314. * @param files defines the list of files to load (1 per face)
  78315. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78316. * @param onLoad defines an optional callback raised when the texture is loaded
  78317. * @param onError defines an optional callback raised if there is an issue to load the texture
  78318. * @param format defines the format of the data
  78319. * @param forcedExtension defines the extension to use to pick the right loader
  78320. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78321. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78322. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78323. * @returns the cube texture as an InternalTexture
  78324. */
  78325. 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;
  78326. /** @hidden */
  78327. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  78328. /** @hidden */
  78329. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  78330. /** @hidden */
  78331. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78332. /** @hidden */
  78333. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78334. /**
  78335. * @hidden
  78336. */
  78337. _setCubeMapTextureParams(loadMipmap: boolean): void;
  78338. }
  78339. }
  78340. declare module BABYLON {
  78341. /**
  78342. * Class for creating a cube texture
  78343. */
  78344. export class CubeTexture extends BaseTexture {
  78345. private _delayedOnLoad;
  78346. /**
  78347. * The url of the texture
  78348. */
  78349. url: string;
  78350. /**
  78351. * Gets or sets the center of the bounding box associated with the cube texture.
  78352. * It must define where the camera used to render the texture was set
  78353. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78354. */
  78355. boundingBoxPosition: Vector3;
  78356. private _boundingBoxSize;
  78357. /**
  78358. * Gets or sets the size of the bounding box associated with the cube texture
  78359. * When defined, the cubemap will switch to local mode
  78360. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  78361. * @example https://www.babylonjs-playground.com/#RNASML
  78362. */
  78363. set boundingBoxSize(value: Vector3);
  78364. /**
  78365. * Returns the bounding box size
  78366. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78367. */
  78368. get boundingBoxSize(): Vector3;
  78369. protected _rotationY: number;
  78370. /**
  78371. * Sets texture matrix rotation angle around Y axis in radians.
  78372. */
  78373. set rotationY(value: number);
  78374. /**
  78375. * Gets texture matrix rotation angle around Y axis radians.
  78376. */
  78377. get rotationY(): number;
  78378. /**
  78379. * Are mip maps generated for this texture or not.
  78380. */
  78381. get noMipmap(): boolean;
  78382. private _noMipmap;
  78383. private _files;
  78384. protected _forcedExtension: Nullable<string>;
  78385. private _extensions;
  78386. private _textureMatrix;
  78387. private _format;
  78388. private _createPolynomials;
  78389. /** @hidden */
  78390. _prefiltered: boolean;
  78391. /**
  78392. * Creates a cube texture from an array of image urls
  78393. * @param files defines an array of image urls
  78394. * @param scene defines the hosting scene
  78395. * @param noMipmap specifies if mip maps are not used
  78396. * @returns a cube texture
  78397. */
  78398. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  78399. /**
  78400. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  78401. * @param url defines the url of the prefiltered texture
  78402. * @param scene defines the scene the texture is attached to
  78403. * @param forcedExtension defines the extension of the file if different from the url
  78404. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78405. * @return the prefiltered texture
  78406. */
  78407. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  78408. /**
  78409. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  78410. * as prefiltered data.
  78411. * @param rootUrl defines the url of the texture or the root name of the six images
  78412. * @param scene defines the scene the texture is attached to
  78413. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  78414. * @param noMipmap defines if mipmaps should be created or not
  78415. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  78416. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  78417. * @param onError defines a callback triggered in case of error during load
  78418. * @param format defines the internal format to use for the texture once loaded
  78419. * @param prefiltered defines whether or not the texture is created from prefiltered data
  78420. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  78421. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78422. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78423. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78424. * @return the cube texture
  78425. */
  78426. 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);
  78427. /**
  78428. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  78429. */
  78430. get isPrefiltered(): boolean;
  78431. /**
  78432. * Get the current class name of the texture useful for serialization or dynamic coding.
  78433. * @returns "CubeTexture"
  78434. */
  78435. getClassName(): string;
  78436. /**
  78437. * Update the url (and optional buffer) of this texture if url was null during construction.
  78438. * @param url the url of the texture
  78439. * @param forcedExtension defines the extension to use
  78440. * @param onLoad callback called when the texture is loaded (defaults to null)
  78441. * @param prefiltered Defines whether the updated texture is prefiltered or not
  78442. */
  78443. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  78444. /**
  78445. * Delays loading of the cube texture
  78446. * @param forcedExtension defines the extension to use
  78447. */
  78448. delayLoad(forcedExtension?: string): void;
  78449. /**
  78450. * Returns the reflection texture matrix
  78451. * @returns the reflection texture matrix
  78452. */
  78453. getReflectionTextureMatrix(): Matrix;
  78454. /**
  78455. * Sets the reflection texture matrix
  78456. * @param value Reflection texture matrix
  78457. */
  78458. setReflectionTextureMatrix(value: Matrix): void;
  78459. /**
  78460. * Parses text to create a cube texture
  78461. * @param parsedTexture define the serialized text to read from
  78462. * @param scene defines the hosting scene
  78463. * @param rootUrl defines the root url of the cube texture
  78464. * @returns a cube texture
  78465. */
  78466. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  78467. /**
  78468. * Makes a clone, or deep copy, of the cube texture
  78469. * @returns a new cube texture
  78470. */
  78471. clone(): CubeTexture;
  78472. }
  78473. }
  78474. declare module BABYLON {
  78475. /**
  78476. * Manages the defines for the Material
  78477. */
  78478. export class MaterialDefines {
  78479. /** @hidden */
  78480. protected _keys: string[];
  78481. private _isDirty;
  78482. /** @hidden */
  78483. _renderId: number;
  78484. /** @hidden */
  78485. _areLightsDirty: boolean;
  78486. /** @hidden */
  78487. _areLightsDisposed: boolean;
  78488. /** @hidden */
  78489. _areAttributesDirty: boolean;
  78490. /** @hidden */
  78491. _areTexturesDirty: boolean;
  78492. /** @hidden */
  78493. _areFresnelDirty: boolean;
  78494. /** @hidden */
  78495. _areMiscDirty: boolean;
  78496. /** @hidden */
  78497. _areImageProcessingDirty: boolean;
  78498. /** @hidden */
  78499. _normals: boolean;
  78500. /** @hidden */
  78501. _uvs: boolean;
  78502. /** @hidden */
  78503. _needNormals: boolean;
  78504. /** @hidden */
  78505. _needUVs: boolean;
  78506. [id: string]: any;
  78507. /**
  78508. * Specifies if the material needs to be re-calculated
  78509. */
  78510. get isDirty(): boolean;
  78511. /**
  78512. * Marks the material to indicate that it has been re-calculated
  78513. */
  78514. markAsProcessed(): void;
  78515. /**
  78516. * Marks the material to indicate that it needs to be re-calculated
  78517. */
  78518. markAsUnprocessed(): void;
  78519. /**
  78520. * Marks the material to indicate all of its defines need to be re-calculated
  78521. */
  78522. markAllAsDirty(): void;
  78523. /**
  78524. * Marks the material to indicate that image processing needs to be re-calculated
  78525. */
  78526. markAsImageProcessingDirty(): void;
  78527. /**
  78528. * Marks the material to indicate the lights need to be re-calculated
  78529. * @param disposed Defines whether the light is dirty due to dispose or not
  78530. */
  78531. markAsLightDirty(disposed?: boolean): void;
  78532. /**
  78533. * Marks the attribute state as changed
  78534. */
  78535. markAsAttributesDirty(): void;
  78536. /**
  78537. * Marks the texture state as changed
  78538. */
  78539. markAsTexturesDirty(): void;
  78540. /**
  78541. * Marks the fresnel state as changed
  78542. */
  78543. markAsFresnelDirty(): void;
  78544. /**
  78545. * Marks the misc state as changed
  78546. */
  78547. markAsMiscDirty(): void;
  78548. /**
  78549. * Rebuilds the material defines
  78550. */
  78551. rebuild(): void;
  78552. /**
  78553. * Specifies if two material defines are equal
  78554. * @param other - A material define instance to compare to
  78555. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  78556. */
  78557. isEqual(other: MaterialDefines): boolean;
  78558. /**
  78559. * Clones this instance's defines to another instance
  78560. * @param other - material defines to clone values to
  78561. */
  78562. cloneTo(other: MaterialDefines): void;
  78563. /**
  78564. * Resets the material define values
  78565. */
  78566. reset(): void;
  78567. /**
  78568. * Converts the material define values to a string
  78569. * @returns - String of material define information
  78570. */
  78571. toString(): string;
  78572. }
  78573. }
  78574. declare module BABYLON {
  78575. /**
  78576. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  78577. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  78578. * 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;
  78579. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  78580. */
  78581. export class ColorCurves {
  78582. private _dirty;
  78583. private _tempColor;
  78584. private _globalCurve;
  78585. private _highlightsCurve;
  78586. private _midtonesCurve;
  78587. private _shadowsCurve;
  78588. private _positiveCurve;
  78589. private _negativeCurve;
  78590. private _globalHue;
  78591. private _globalDensity;
  78592. private _globalSaturation;
  78593. private _globalExposure;
  78594. /**
  78595. * Gets the global Hue value.
  78596. * 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).
  78597. */
  78598. get globalHue(): number;
  78599. /**
  78600. * Sets the global Hue value.
  78601. * 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).
  78602. */
  78603. set globalHue(value: number);
  78604. /**
  78605. * Gets the global Density value.
  78606. * 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.
  78607. * Values less than zero provide a filter of opposite hue.
  78608. */
  78609. get globalDensity(): number;
  78610. /**
  78611. * Sets the global Density value.
  78612. * 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.
  78613. * Values less than zero provide a filter of opposite hue.
  78614. */
  78615. set globalDensity(value: number);
  78616. /**
  78617. * Gets the global Saturation value.
  78618. * 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.
  78619. */
  78620. get globalSaturation(): number;
  78621. /**
  78622. * Sets the global Saturation value.
  78623. * 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.
  78624. */
  78625. set globalSaturation(value: number);
  78626. /**
  78627. * Gets the global Exposure value.
  78628. * 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.
  78629. */
  78630. get globalExposure(): number;
  78631. /**
  78632. * Sets the global Exposure value.
  78633. * 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.
  78634. */
  78635. set globalExposure(value: number);
  78636. private _highlightsHue;
  78637. private _highlightsDensity;
  78638. private _highlightsSaturation;
  78639. private _highlightsExposure;
  78640. /**
  78641. * Gets the highlights Hue value.
  78642. * 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).
  78643. */
  78644. get highlightsHue(): number;
  78645. /**
  78646. * Sets the highlights Hue value.
  78647. * 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).
  78648. */
  78649. set highlightsHue(value: number);
  78650. /**
  78651. * Gets the highlights Density value.
  78652. * 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.
  78653. * Values less than zero provide a filter of opposite hue.
  78654. */
  78655. get highlightsDensity(): number;
  78656. /**
  78657. * Sets the highlights Density value.
  78658. * 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.
  78659. * Values less than zero provide a filter of opposite hue.
  78660. */
  78661. set highlightsDensity(value: number);
  78662. /**
  78663. * Gets the highlights Saturation value.
  78664. * 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.
  78665. */
  78666. get highlightsSaturation(): number;
  78667. /**
  78668. * Sets the highlights Saturation value.
  78669. * 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.
  78670. */
  78671. set highlightsSaturation(value: number);
  78672. /**
  78673. * Gets the highlights Exposure value.
  78674. * 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.
  78675. */
  78676. get highlightsExposure(): number;
  78677. /**
  78678. * Sets the highlights Exposure value.
  78679. * 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.
  78680. */
  78681. set highlightsExposure(value: number);
  78682. private _midtonesHue;
  78683. private _midtonesDensity;
  78684. private _midtonesSaturation;
  78685. private _midtonesExposure;
  78686. /**
  78687. * Gets the midtones Hue value.
  78688. * 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).
  78689. */
  78690. get midtonesHue(): number;
  78691. /**
  78692. * Sets the midtones Hue value.
  78693. * 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).
  78694. */
  78695. set midtonesHue(value: number);
  78696. /**
  78697. * Gets the midtones Density value.
  78698. * 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.
  78699. * Values less than zero provide a filter of opposite hue.
  78700. */
  78701. get midtonesDensity(): number;
  78702. /**
  78703. * Sets the midtones Density value.
  78704. * 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.
  78705. * Values less than zero provide a filter of opposite hue.
  78706. */
  78707. set midtonesDensity(value: number);
  78708. /**
  78709. * Gets the midtones Saturation value.
  78710. * 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.
  78711. */
  78712. get midtonesSaturation(): number;
  78713. /**
  78714. * Sets the midtones Saturation value.
  78715. * 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.
  78716. */
  78717. set midtonesSaturation(value: number);
  78718. /**
  78719. * Gets the midtones Exposure value.
  78720. * 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.
  78721. */
  78722. get midtonesExposure(): number;
  78723. /**
  78724. * Sets the midtones Exposure value.
  78725. * 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.
  78726. */
  78727. set midtonesExposure(value: number);
  78728. private _shadowsHue;
  78729. private _shadowsDensity;
  78730. private _shadowsSaturation;
  78731. private _shadowsExposure;
  78732. /**
  78733. * Gets the shadows Hue value.
  78734. * 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).
  78735. */
  78736. get shadowsHue(): number;
  78737. /**
  78738. * Sets the shadows Hue value.
  78739. * 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).
  78740. */
  78741. set shadowsHue(value: number);
  78742. /**
  78743. * Gets the shadows Density value.
  78744. * 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.
  78745. * Values less than zero provide a filter of opposite hue.
  78746. */
  78747. get shadowsDensity(): number;
  78748. /**
  78749. * Sets the shadows Density value.
  78750. * 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.
  78751. * Values less than zero provide a filter of opposite hue.
  78752. */
  78753. set shadowsDensity(value: number);
  78754. /**
  78755. * Gets the shadows Saturation value.
  78756. * 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.
  78757. */
  78758. get shadowsSaturation(): number;
  78759. /**
  78760. * Sets the shadows Saturation value.
  78761. * 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.
  78762. */
  78763. set shadowsSaturation(value: number);
  78764. /**
  78765. * Gets the shadows Exposure value.
  78766. * 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.
  78767. */
  78768. get shadowsExposure(): number;
  78769. /**
  78770. * Sets the shadows Exposure value.
  78771. * 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.
  78772. */
  78773. set shadowsExposure(value: number);
  78774. /**
  78775. * Returns the class name
  78776. * @returns The class name
  78777. */
  78778. getClassName(): string;
  78779. /**
  78780. * Binds the color curves to the shader.
  78781. * @param colorCurves The color curve to bind
  78782. * @param effect The effect to bind to
  78783. * @param positiveUniform The positive uniform shader parameter
  78784. * @param neutralUniform The neutral uniform shader parameter
  78785. * @param negativeUniform The negative uniform shader parameter
  78786. */
  78787. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  78788. /**
  78789. * Prepare the list of uniforms associated with the ColorCurves effects.
  78790. * @param uniformsList The list of uniforms used in the effect
  78791. */
  78792. static PrepareUniforms(uniformsList: string[]): void;
  78793. /**
  78794. * Returns color grading data based on a hue, density, saturation and exposure value.
  78795. * @param filterHue The hue of the color filter.
  78796. * @param filterDensity The density of the color filter.
  78797. * @param saturation The saturation.
  78798. * @param exposure The exposure.
  78799. * @param result The result data container.
  78800. */
  78801. private getColorGradingDataToRef;
  78802. /**
  78803. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  78804. * @param value The input slider value in range [-100,100].
  78805. * @returns Adjusted value.
  78806. */
  78807. private static applyColorGradingSliderNonlinear;
  78808. /**
  78809. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  78810. * @param hue The hue (H) input.
  78811. * @param saturation The saturation (S) input.
  78812. * @param brightness The brightness (B) input.
  78813. * @result An RGBA color represented as Vector4.
  78814. */
  78815. private static fromHSBToRef;
  78816. /**
  78817. * Returns a value clamped between min and max
  78818. * @param value The value to clamp
  78819. * @param min The minimum of value
  78820. * @param max The maximum of value
  78821. * @returns The clamped value.
  78822. */
  78823. private static clamp;
  78824. /**
  78825. * Clones the current color curve instance.
  78826. * @return The cloned curves
  78827. */
  78828. clone(): ColorCurves;
  78829. /**
  78830. * Serializes the current color curve instance to a json representation.
  78831. * @return a JSON representation
  78832. */
  78833. serialize(): any;
  78834. /**
  78835. * Parses the color curve from a json representation.
  78836. * @param source the JSON source to parse
  78837. * @return The parsed curves
  78838. */
  78839. static Parse(source: any): ColorCurves;
  78840. }
  78841. }
  78842. declare module BABYLON {
  78843. /**
  78844. * Interface to follow in your material defines to integrate easily the
  78845. * Image proccessing functions.
  78846. * @hidden
  78847. */
  78848. export interface IImageProcessingConfigurationDefines {
  78849. IMAGEPROCESSING: boolean;
  78850. VIGNETTE: boolean;
  78851. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78852. VIGNETTEBLENDMODEOPAQUE: boolean;
  78853. TONEMAPPING: boolean;
  78854. TONEMAPPING_ACES: boolean;
  78855. CONTRAST: boolean;
  78856. EXPOSURE: boolean;
  78857. COLORCURVES: boolean;
  78858. COLORGRADING: boolean;
  78859. COLORGRADING3D: boolean;
  78860. SAMPLER3DGREENDEPTH: boolean;
  78861. SAMPLER3DBGRMAP: boolean;
  78862. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78863. }
  78864. /**
  78865. * @hidden
  78866. */
  78867. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  78868. IMAGEPROCESSING: boolean;
  78869. VIGNETTE: boolean;
  78870. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78871. VIGNETTEBLENDMODEOPAQUE: boolean;
  78872. TONEMAPPING: boolean;
  78873. TONEMAPPING_ACES: boolean;
  78874. CONTRAST: boolean;
  78875. COLORCURVES: boolean;
  78876. COLORGRADING: boolean;
  78877. COLORGRADING3D: boolean;
  78878. SAMPLER3DGREENDEPTH: boolean;
  78879. SAMPLER3DBGRMAP: boolean;
  78880. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78881. EXPOSURE: boolean;
  78882. constructor();
  78883. }
  78884. /**
  78885. * This groups together the common properties used for image processing either in direct forward pass
  78886. * or through post processing effect depending on the use of the image processing pipeline in your scene
  78887. * or not.
  78888. */
  78889. export class ImageProcessingConfiguration {
  78890. /**
  78891. * Default tone mapping applied in BabylonJS.
  78892. */
  78893. static readonly TONEMAPPING_STANDARD: number;
  78894. /**
  78895. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  78896. * to other engines rendering to increase portability.
  78897. */
  78898. static readonly TONEMAPPING_ACES: number;
  78899. /**
  78900. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  78901. */
  78902. colorCurves: Nullable<ColorCurves>;
  78903. private _colorCurvesEnabled;
  78904. /**
  78905. * Gets wether the color curves effect is enabled.
  78906. */
  78907. get colorCurvesEnabled(): boolean;
  78908. /**
  78909. * Sets wether the color curves effect is enabled.
  78910. */
  78911. set colorCurvesEnabled(value: boolean);
  78912. private _colorGradingTexture;
  78913. /**
  78914. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78915. */
  78916. get colorGradingTexture(): Nullable<BaseTexture>;
  78917. /**
  78918. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78919. */
  78920. set colorGradingTexture(value: Nullable<BaseTexture>);
  78921. private _colorGradingEnabled;
  78922. /**
  78923. * Gets wether the color grading effect is enabled.
  78924. */
  78925. get colorGradingEnabled(): boolean;
  78926. /**
  78927. * Sets wether the color grading effect is enabled.
  78928. */
  78929. set colorGradingEnabled(value: boolean);
  78930. private _colorGradingWithGreenDepth;
  78931. /**
  78932. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  78933. */
  78934. get colorGradingWithGreenDepth(): boolean;
  78935. /**
  78936. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  78937. */
  78938. set colorGradingWithGreenDepth(value: boolean);
  78939. private _colorGradingBGR;
  78940. /**
  78941. * Gets wether the color grading texture contains BGR values.
  78942. */
  78943. get colorGradingBGR(): boolean;
  78944. /**
  78945. * Sets wether the color grading texture contains BGR values.
  78946. */
  78947. set colorGradingBGR(value: boolean);
  78948. /** @hidden */
  78949. _exposure: number;
  78950. /**
  78951. * Gets the Exposure used in the effect.
  78952. */
  78953. get exposure(): number;
  78954. /**
  78955. * Sets the Exposure used in the effect.
  78956. */
  78957. set exposure(value: number);
  78958. private _toneMappingEnabled;
  78959. /**
  78960. * Gets wether the tone mapping effect is enabled.
  78961. */
  78962. get toneMappingEnabled(): boolean;
  78963. /**
  78964. * Sets wether the tone mapping effect is enabled.
  78965. */
  78966. set toneMappingEnabled(value: boolean);
  78967. private _toneMappingType;
  78968. /**
  78969. * Gets the type of tone mapping effect.
  78970. */
  78971. get toneMappingType(): number;
  78972. /**
  78973. * Sets the type of tone mapping effect used in BabylonJS.
  78974. */
  78975. set toneMappingType(value: number);
  78976. protected _contrast: number;
  78977. /**
  78978. * Gets the contrast used in the effect.
  78979. */
  78980. get contrast(): number;
  78981. /**
  78982. * Sets the contrast used in the effect.
  78983. */
  78984. set contrast(value: number);
  78985. /**
  78986. * Vignette stretch size.
  78987. */
  78988. vignetteStretch: number;
  78989. /**
  78990. * Vignette centre X Offset.
  78991. */
  78992. vignetteCentreX: number;
  78993. /**
  78994. * Vignette centre Y Offset.
  78995. */
  78996. vignetteCentreY: number;
  78997. /**
  78998. * Vignette weight or intensity of the vignette effect.
  78999. */
  79000. vignetteWeight: number;
  79001. /**
  79002. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  79003. * if vignetteEnabled is set to true.
  79004. */
  79005. vignetteColor: Color4;
  79006. /**
  79007. * Camera field of view used by the Vignette effect.
  79008. */
  79009. vignetteCameraFov: number;
  79010. private _vignetteBlendMode;
  79011. /**
  79012. * Gets the vignette blend mode allowing different kind of effect.
  79013. */
  79014. get vignetteBlendMode(): number;
  79015. /**
  79016. * Sets the vignette blend mode allowing different kind of effect.
  79017. */
  79018. set vignetteBlendMode(value: number);
  79019. private _vignetteEnabled;
  79020. /**
  79021. * Gets wether the vignette effect is enabled.
  79022. */
  79023. get vignetteEnabled(): boolean;
  79024. /**
  79025. * Sets wether the vignette effect is enabled.
  79026. */
  79027. set vignetteEnabled(value: boolean);
  79028. private _applyByPostProcess;
  79029. /**
  79030. * Gets wether the image processing is applied through a post process or not.
  79031. */
  79032. get applyByPostProcess(): boolean;
  79033. /**
  79034. * Sets wether the image processing is applied through a post process or not.
  79035. */
  79036. set applyByPostProcess(value: boolean);
  79037. private _isEnabled;
  79038. /**
  79039. * Gets wether the image processing is enabled or not.
  79040. */
  79041. get isEnabled(): boolean;
  79042. /**
  79043. * Sets wether the image processing is enabled or not.
  79044. */
  79045. set isEnabled(value: boolean);
  79046. /**
  79047. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  79048. */
  79049. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  79050. /**
  79051. * Method called each time the image processing information changes requires to recompile the effect.
  79052. */
  79053. protected _updateParameters(): void;
  79054. /**
  79055. * Gets the current class name.
  79056. * @return "ImageProcessingConfiguration"
  79057. */
  79058. getClassName(): string;
  79059. /**
  79060. * Prepare the list of uniforms associated with the Image Processing effects.
  79061. * @param uniforms The list of uniforms used in the effect
  79062. * @param defines the list of defines currently in use
  79063. */
  79064. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  79065. /**
  79066. * Prepare the list of samplers associated with the Image Processing effects.
  79067. * @param samplersList The list of uniforms used in the effect
  79068. * @param defines the list of defines currently in use
  79069. */
  79070. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  79071. /**
  79072. * Prepare the list of defines associated to the shader.
  79073. * @param defines the list of defines to complete
  79074. * @param forPostProcess Define if we are currently in post process mode or not
  79075. */
  79076. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  79077. /**
  79078. * Returns true if all the image processing information are ready.
  79079. * @returns True if ready, otherwise, false
  79080. */
  79081. isReady(): boolean;
  79082. /**
  79083. * Binds the image processing to the shader.
  79084. * @param effect The effect to bind to
  79085. * @param overrideAspectRatio Override the aspect ratio of the effect
  79086. */
  79087. bind(effect: Effect, overrideAspectRatio?: number): void;
  79088. /**
  79089. * Clones the current image processing instance.
  79090. * @return The cloned image processing
  79091. */
  79092. clone(): ImageProcessingConfiguration;
  79093. /**
  79094. * Serializes the current image processing instance to a json representation.
  79095. * @return a JSON representation
  79096. */
  79097. serialize(): any;
  79098. /**
  79099. * Parses the image processing from a json representation.
  79100. * @param source the JSON source to parse
  79101. * @return The parsed image processing
  79102. */
  79103. static Parse(source: any): ImageProcessingConfiguration;
  79104. private static _VIGNETTEMODE_MULTIPLY;
  79105. private static _VIGNETTEMODE_OPAQUE;
  79106. /**
  79107. * Used to apply the vignette as a mix with the pixel color.
  79108. */
  79109. static get VIGNETTEMODE_MULTIPLY(): number;
  79110. /**
  79111. * Used to apply the vignette as a replacement of the pixel color.
  79112. */
  79113. static get VIGNETTEMODE_OPAQUE(): number;
  79114. }
  79115. }
  79116. declare module BABYLON {
  79117. /** @hidden */
  79118. export var postprocessVertexShader: {
  79119. name: string;
  79120. shader: string;
  79121. };
  79122. }
  79123. declare module BABYLON {
  79124. interface ThinEngine {
  79125. /**
  79126. * Creates a new render target texture
  79127. * @param size defines the size of the texture
  79128. * @param options defines the options used to create the texture
  79129. * @returns a new render target texture stored in an InternalTexture
  79130. */
  79131. createRenderTargetTexture(size: number | {
  79132. width: number;
  79133. height: number;
  79134. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  79135. /**
  79136. * Creates a depth stencil texture.
  79137. * This is only available in WebGL 2 or with the depth texture extension available.
  79138. * @param size The size of face edge in the texture.
  79139. * @param options The options defining the texture.
  79140. * @returns The texture
  79141. */
  79142. createDepthStencilTexture(size: number | {
  79143. width: number;
  79144. height: number;
  79145. }, options: DepthTextureCreationOptions): InternalTexture;
  79146. /** @hidden */
  79147. _createDepthStencilTexture(size: number | {
  79148. width: number;
  79149. height: number;
  79150. }, options: DepthTextureCreationOptions): InternalTexture;
  79151. }
  79152. }
  79153. declare module BABYLON {
  79154. /** Defines supported spaces */
  79155. export enum Space {
  79156. /** Local (object) space */
  79157. LOCAL = 0,
  79158. /** World space */
  79159. WORLD = 1,
  79160. /** Bone space */
  79161. BONE = 2
  79162. }
  79163. /** Defines the 3 main axes */
  79164. export class Axis {
  79165. /** X axis */
  79166. static X: Vector3;
  79167. /** Y axis */
  79168. static Y: Vector3;
  79169. /** Z axis */
  79170. static Z: Vector3;
  79171. }
  79172. }
  79173. declare module BABYLON {
  79174. /**
  79175. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  79176. * This is the base of the follow, arc rotate cameras and Free camera
  79177. * @see http://doc.babylonjs.com/features/cameras
  79178. */
  79179. export class TargetCamera extends Camera {
  79180. private static _RigCamTransformMatrix;
  79181. private static _TargetTransformMatrix;
  79182. private static _TargetFocalPoint;
  79183. /**
  79184. * Define the current direction the camera is moving to
  79185. */
  79186. cameraDirection: Vector3;
  79187. /**
  79188. * Define the current rotation the camera is rotating to
  79189. */
  79190. cameraRotation: Vector2;
  79191. /**
  79192. * When set, the up vector of the camera will be updated by the rotation of the camera
  79193. */
  79194. updateUpVectorFromRotation: boolean;
  79195. private _tmpQuaternion;
  79196. /**
  79197. * Define the current rotation of the camera
  79198. */
  79199. rotation: Vector3;
  79200. /**
  79201. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  79202. */
  79203. rotationQuaternion: Quaternion;
  79204. /**
  79205. * Define the current speed of the camera
  79206. */
  79207. speed: number;
  79208. /**
  79209. * Add constraint to the camera to prevent it to move freely in all directions and
  79210. * around all axis.
  79211. */
  79212. noRotationConstraint: boolean;
  79213. /**
  79214. * Define the current target of the camera as an object or a position.
  79215. */
  79216. lockedTarget: any;
  79217. /** @hidden */
  79218. _currentTarget: Vector3;
  79219. /** @hidden */
  79220. _initialFocalDistance: number;
  79221. /** @hidden */
  79222. _viewMatrix: Matrix;
  79223. /** @hidden */
  79224. _camMatrix: Matrix;
  79225. /** @hidden */
  79226. _cameraTransformMatrix: Matrix;
  79227. /** @hidden */
  79228. _cameraRotationMatrix: Matrix;
  79229. /** @hidden */
  79230. _referencePoint: Vector3;
  79231. /** @hidden */
  79232. _transformedReferencePoint: Vector3;
  79233. protected _globalCurrentTarget: Vector3;
  79234. protected _globalCurrentUpVector: Vector3;
  79235. /** @hidden */
  79236. _reset: () => void;
  79237. private _defaultUp;
  79238. /**
  79239. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  79240. * This is the base of the follow, arc rotate cameras and Free camera
  79241. * @see http://doc.babylonjs.com/features/cameras
  79242. * @param name Defines the name of the camera in the scene
  79243. * @param position Defines the start position of the camera in the scene
  79244. * @param scene Defines the scene the camera belongs to
  79245. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79246. */
  79247. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79248. /**
  79249. * Gets the position in front of the camera at a given distance.
  79250. * @param distance The distance from the camera we want the position to be
  79251. * @returns the position
  79252. */
  79253. getFrontPosition(distance: number): Vector3;
  79254. /** @hidden */
  79255. _getLockedTargetPosition(): Nullable<Vector3>;
  79256. private _storedPosition;
  79257. private _storedRotation;
  79258. private _storedRotationQuaternion;
  79259. /**
  79260. * Store current camera state of the camera (fov, position, rotation, etc..)
  79261. * @returns the camera
  79262. */
  79263. storeState(): Camera;
  79264. /**
  79265. * Restored camera state. You must call storeState() first
  79266. * @returns whether it was successful or not
  79267. * @hidden
  79268. */
  79269. _restoreStateValues(): boolean;
  79270. /** @hidden */
  79271. _initCache(): void;
  79272. /** @hidden */
  79273. _updateCache(ignoreParentClass?: boolean): void;
  79274. /** @hidden */
  79275. _isSynchronizedViewMatrix(): boolean;
  79276. /** @hidden */
  79277. _computeLocalCameraSpeed(): number;
  79278. /**
  79279. * Defines the target the camera should look at.
  79280. * @param target Defines the new target as a Vector or a mesh
  79281. */
  79282. setTarget(target: Vector3): void;
  79283. /**
  79284. * Return the current target position of the camera. This value is expressed in local space.
  79285. * @returns the target position
  79286. */
  79287. getTarget(): Vector3;
  79288. /** @hidden */
  79289. _decideIfNeedsToMove(): boolean;
  79290. /** @hidden */
  79291. _updatePosition(): void;
  79292. /** @hidden */
  79293. _checkInputs(): void;
  79294. protected _updateCameraRotationMatrix(): void;
  79295. /**
  79296. * 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)
  79297. * @returns the current camera
  79298. */
  79299. private _rotateUpVectorWithCameraRotationMatrix;
  79300. private _cachedRotationZ;
  79301. private _cachedQuaternionRotationZ;
  79302. /** @hidden */
  79303. _getViewMatrix(): Matrix;
  79304. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  79305. /**
  79306. * @hidden
  79307. */
  79308. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  79309. /**
  79310. * @hidden
  79311. */
  79312. _updateRigCameras(): void;
  79313. private _getRigCamPositionAndTarget;
  79314. /**
  79315. * Gets the current object class name.
  79316. * @return the class name
  79317. */
  79318. getClassName(): string;
  79319. }
  79320. }
  79321. declare module BABYLON {
  79322. /**
  79323. * Gather the list of keyboard event types as constants.
  79324. */
  79325. export class KeyboardEventTypes {
  79326. /**
  79327. * The keydown event is fired when a key becomes active (pressed).
  79328. */
  79329. static readonly KEYDOWN: number;
  79330. /**
  79331. * The keyup event is fired when a key has been released.
  79332. */
  79333. static readonly KEYUP: number;
  79334. }
  79335. /**
  79336. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79337. */
  79338. export class KeyboardInfo {
  79339. /**
  79340. * Defines the type of event (KeyboardEventTypes)
  79341. */
  79342. type: number;
  79343. /**
  79344. * Defines the related dom event
  79345. */
  79346. event: KeyboardEvent;
  79347. /**
  79348. * Instantiates a new keyboard info.
  79349. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79350. * @param type Defines the type of event (KeyboardEventTypes)
  79351. * @param event Defines the related dom event
  79352. */
  79353. constructor(
  79354. /**
  79355. * Defines the type of event (KeyboardEventTypes)
  79356. */
  79357. type: number,
  79358. /**
  79359. * Defines the related dom event
  79360. */
  79361. event: KeyboardEvent);
  79362. }
  79363. /**
  79364. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79365. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  79366. */
  79367. export class KeyboardInfoPre extends KeyboardInfo {
  79368. /**
  79369. * Defines the type of event (KeyboardEventTypes)
  79370. */
  79371. type: number;
  79372. /**
  79373. * Defines the related dom event
  79374. */
  79375. event: KeyboardEvent;
  79376. /**
  79377. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  79378. */
  79379. skipOnPointerObservable: boolean;
  79380. /**
  79381. * Instantiates a new keyboard pre info.
  79382. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79383. * @param type Defines the type of event (KeyboardEventTypes)
  79384. * @param event Defines the related dom event
  79385. */
  79386. constructor(
  79387. /**
  79388. * Defines the type of event (KeyboardEventTypes)
  79389. */
  79390. type: number,
  79391. /**
  79392. * Defines the related dom event
  79393. */
  79394. event: KeyboardEvent);
  79395. }
  79396. }
  79397. declare module BABYLON {
  79398. /**
  79399. * Manage the keyboard inputs to control the movement of a free camera.
  79400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79401. */
  79402. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  79403. /**
  79404. * Defines the camera the input is attached to.
  79405. */
  79406. camera: FreeCamera;
  79407. /**
  79408. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79409. */
  79410. keysUp: number[];
  79411. /**
  79412. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79413. */
  79414. keysDown: number[];
  79415. /**
  79416. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79417. */
  79418. keysLeft: number[];
  79419. /**
  79420. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79421. */
  79422. keysRight: number[];
  79423. private _keys;
  79424. private _onCanvasBlurObserver;
  79425. private _onKeyboardObserver;
  79426. private _engine;
  79427. private _scene;
  79428. /**
  79429. * Attach the input controls to a specific dom element to get the input from.
  79430. * @param element Defines the element the controls should be listened from
  79431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79432. */
  79433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79434. /**
  79435. * Detach the current controls from the specified dom element.
  79436. * @param element Defines the element to stop listening the inputs from
  79437. */
  79438. detachControl(element: Nullable<HTMLElement>): void;
  79439. /**
  79440. * Update the current camera state depending on the inputs that have been used this frame.
  79441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79442. */
  79443. checkInputs(): void;
  79444. /**
  79445. * Gets the class name of the current intput.
  79446. * @returns the class name
  79447. */
  79448. getClassName(): string;
  79449. /** @hidden */
  79450. _onLostFocus(): void;
  79451. /**
  79452. * Get the friendly name associated with the input class.
  79453. * @returns the input friendly name
  79454. */
  79455. getSimpleName(): string;
  79456. }
  79457. }
  79458. declare module BABYLON {
  79459. /**
  79460. * Interface describing all the common properties and methods a shadow light needs to implement.
  79461. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  79462. * as well as binding the different shadow properties to the effects.
  79463. */
  79464. export interface IShadowLight extends Light {
  79465. /**
  79466. * The light id in the scene (used in scene.findLighById for instance)
  79467. */
  79468. id: string;
  79469. /**
  79470. * The position the shdow will be casted from.
  79471. */
  79472. position: Vector3;
  79473. /**
  79474. * In 2d mode (needCube being false), the direction used to cast the shadow.
  79475. */
  79476. direction: Vector3;
  79477. /**
  79478. * The transformed position. Position of the light in world space taking parenting in account.
  79479. */
  79480. transformedPosition: Vector3;
  79481. /**
  79482. * The transformed direction. Direction of the light in world space taking parenting in account.
  79483. */
  79484. transformedDirection: Vector3;
  79485. /**
  79486. * The friendly name of the light in the scene.
  79487. */
  79488. name: string;
  79489. /**
  79490. * Defines the shadow projection clipping minimum z value.
  79491. */
  79492. shadowMinZ: number;
  79493. /**
  79494. * Defines the shadow projection clipping maximum z value.
  79495. */
  79496. shadowMaxZ: number;
  79497. /**
  79498. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79499. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79500. */
  79501. computeTransformedInformation(): boolean;
  79502. /**
  79503. * Gets the scene the light belongs to.
  79504. * @returns The scene
  79505. */
  79506. getScene(): Scene;
  79507. /**
  79508. * Callback defining a custom Projection Matrix Builder.
  79509. * This can be used to override the default projection matrix computation.
  79510. */
  79511. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79512. /**
  79513. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79514. * @param matrix The materix to updated with the projection information
  79515. * @param viewMatrix The transform matrix of the light
  79516. * @param renderList The list of mesh to render in the map
  79517. * @returns The current light
  79518. */
  79519. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79520. /**
  79521. * Gets the current depth scale used in ESM.
  79522. * @returns The scale
  79523. */
  79524. getDepthScale(): number;
  79525. /**
  79526. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79527. * @returns true if a cube texture needs to be use
  79528. */
  79529. needCube(): boolean;
  79530. /**
  79531. * Detects if the projection matrix requires to be recomputed this frame.
  79532. * @returns true if it requires to be recomputed otherwise, false.
  79533. */
  79534. needProjectionMatrixCompute(): boolean;
  79535. /**
  79536. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79537. */
  79538. forceProjectionMatrixCompute(): void;
  79539. /**
  79540. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79541. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79542. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79543. */
  79544. getShadowDirection(faceIndex?: number): Vector3;
  79545. /**
  79546. * Gets the minZ used for shadow according to both the scene and the light.
  79547. * @param activeCamera The camera we are returning the min for
  79548. * @returns the depth min z
  79549. */
  79550. getDepthMinZ(activeCamera: Camera): number;
  79551. /**
  79552. * Gets the maxZ used for shadow according to both the scene and the light.
  79553. * @param activeCamera The camera we are returning the max for
  79554. * @returns the depth max z
  79555. */
  79556. getDepthMaxZ(activeCamera: Camera): number;
  79557. }
  79558. /**
  79559. * Base implementation IShadowLight
  79560. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  79561. */
  79562. export abstract class ShadowLight extends Light implements IShadowLight {
  79563. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  79564. protected _position: Vector3;
  79565. protected _setPosition(value: Vector3): void;
  79566. /**
  79567. * Sets the position the shadow will be casted from. Also use as the light position for both
  79568. * point and spot lights.
  79569. */
  79570. get position(): Vector3;
  79571. /**
  79572. * Sets the position the shadow will be casted from. Also use as the light position for both
  79573. * point and spot lights.
  79574. */
  79575. set position(value: Vector3);
  79576. protected _direction: Vector3;
  79577. protected _setDirection(value: Vector3): void;
  79578. /**
  79579. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  79580. * Also use as the light direction on spot and directional lights.
  79581. */
  79582. get direction(): Vector3;
  79583. /**
  79584. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  79585. * Also use as the light direction on spot and directional lights.
  79586. */
  79587. set direction(value: Vector3);
  79588. protected _shadowMinZ: number;
  79589. /**
  79590. * Gets the shadow projection clipping minimum z value.
  79591. */
  79592. get shadowMinZ(): number;
  79593. /**
  79594. * Sets the shadow projection clipping minimum z value.
  79595. */
  79596. set shadowMinZ(value: number);
  79597. protected _shadowMaxZ: number;
  79598. /**
  79599. * Sets the shadow projection clipping maximum z value.
  79600. */
  79601. get shadowMaxZ(): number;
  79602. /**
  79603. * Gets the shadow projection clipping maximum z value.
  79604. */
  79605. set shadowMaxZ(value: number);
  79606. /**
  79607. * Callback defining a custom Projection Matrix Builder.
  79608. * This can be used to override the default projection matrix computation.
  79609. */
  79610. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79611. /**
  79612. * The transformed position. Position of the light in world space taking parenting in account.
  79613. */
  79614. transformedPosition: Vector3;
  79615. /**
  79616. * The transformed direction. Direction of the light in world space taking parenting in account.
  79617. */
  79618. transformedDirection: Vector3;
  79619. private _needProjectionMatrixCompute;
  79620. /**
  79621. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79622. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79623. */
  79624. computeTransformedInformation(): boolean;
  79625. /**
  79626. * Return the depth scale used for the shadow map.
  79627. * @returns the depth scale.
  79628. */
  79629. getDepthScale(): number;
  79630. /**
  79631. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79632. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79633. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79634. */
  79635. getShadowDirection(faceIndex?: number): Vector3;
  79636. /**
  79637. * Returns the ShadowLight absolute position in the World.
  79638. * @returns the position vector in world space
  79639. */
  79640. getAbsolutePosition(): Vector3;
  79641. /**
  79642. * Sets the ShadowLight direction toward the passed target.
  79643. * @param target The point to target in local space
  79644. * @returns the updated ShadowLight direction
  79645. */
  79646. setDirectionToTarget(target: Vector3): Vector3;
  79647. /**
  79648. * Returns the light rotation in euler definition.
  79649. * @returns the x y z rotation in local space.
  79650. */
  79651. getRotation(): Vector3;
  79652. /**
  79653. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79654. * @returns true if a cube texture needs to be use
  79655. */
  79656. needCube(): boolean;
  79657. /**
  79658. * Detects if the projection matrix requires to be recomputed this frame.
  79659. * @returns true if it requires to be recomputed otherwise, false.
  79660. */
  79661. needProjectionMatrixCompute(): boolean;
  79662. /**
  79663. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79664. */
  79665. forceProjectionMatrixCompute(): void;
  79666. /** @hidden */
  79667. _initCache(): void;
  79668. /** @hidden */
  79669. _isSynchronized(): boolean;
  79670. /**
  79671. * Computes the world matrix of the node
  79672. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79673. * @returns the world matrix
  79674. */
  79675. computeWorldMatrix(force?: boolean): Matrix;
  79676. /**
  79677. * Gets the minZ used for shadow according to both the scene and the light.
  79678. * @param activeCamera The camera we are returning the min for
  79679. * @returns the depth min z
  79680. */
  79681. getDepthMinZ(activeCamera: Camera): number;
  79682. /**
  79683. * Gets the maxZ used for shadow according to both the scene and the light.
  79684. * @param activeCamera The camera we are returning the max for
  79685. * @returns the depth max z
  79686. */
  79687. getDepthMaxZ(activeCamera: Camera): number;
  79688. /**
  79689. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79690. * @param matrix The materix to updated with the projection information
  79691. * @param viewMatrix The transform matrix of the light
  79692. * @param renderList The list of mesh to render in the map
  79693. * @returns The current light
  79694. */
  79695. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79696. }
  79697. }
  79698. declare module BABYLON {
  79699. /**
  79700. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  79701. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  79702. */
  79703. export class EffectFallbacks implements IEffectFallbacks {
  79704. private _defines;
  79705. private _currentRank;
  79706. private _maxRank;
  79707. private _mesh;
  79708. /**
  79709. * Removes the fallback from the bound mesh.
  79710. */
  79711. unBindMesh(): void;
  79712. /**
  79713. * Adds a fallback on the specified property.
  79714. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79715. * @param define The name of the define in the shader
  79716. */
  79717. addFallback(rank: number, define: string): void;
  79718. /**
  79719. * Sets the mesh to use CPU skinning when needing to fallback.
  79720. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79721. * @param mesh The mesh to use the fallbacks.
  79722. */
  79723. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  79724. /**
  79725. * Checks to see if more fallbacks are still availible.
  79726. */
  79727. get hasMoreFallbacks(): boolean;
  79728. /**
  79729. * Removes the defines that should be removed when falling back.
  79730. * @param currentDefines defines the current define statements for the shader.
  79731. * @param effect defines the current effect we try to compile
  79732. * @returns The resulting defines with defines of the current rank removed.
  79733. */
  79734. reduce(currentDefines: string, effect: Effect): string;
  79735. }
  79736. }
  79737. declare module BABYLON {
  79738. /**
  79739. * "Static Class" containing the most commonly used helper while dealing with material for
  79740. * rendering purpose.
  79741. *
  79742. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  79743. *
  79744. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  79745. */
  79746. export class MaterialHelper {
  79747. /**
  79748. * Bind the current view position to an effect.
  79749. * @param effect The effect to be bound
  79750. * @param scene The scene the eyes position is used from
  79751. */
  79752. static BindEyePosition(effect: Effect, scene: Scene): void;
  79753. /**
  79754. * Helps preparing the defines values about the UVs in used in the effect.
  79755. * UVs are shared as much as we can accross channels in the shaders.
  79756. * @param texture The texture we are preparing the UVs for
  79757. * @param defines The defines to update
  79758. * @param key The channel key "diffuse", "specular"... used in the shader
  79759. */
  79760. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  79761. /**
  79762. * Binds a texture matrix value to its corrsponding uniform
  79763. * @param texture The texture to bind the matrix for
  79764. * @param uniformBuffer The uniform buffer receivin the data
  79765. * @param key The channel key "diffuse", "specular"... used in the shader
  79766. */
  79767. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  79768. /**
  79769. * Gets the current status of the fog (should it be enabled?)
  79770. * @param mesh defines the mesh to evaluate for fog support
  79771. * @param scene defines the hosting scene
  79772. * @returns true if fog must be enabled
  79773. */
  79774. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  79775. /**
  79776. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  79777. * @param mesh defines the current mesh
  79778. * @param scene defines the current scene
  79779. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  79780. * @param pointsCloud defines if point cloud rendering has to be turned on
  79781. * @param fogEnabled defines if fog has to be turned on
  79782. * @param alphaTest defines if alpha testing has to be turned on
  79783. * @param defines defines the current list of defines
  79784. */
  79785. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  79786. /**
  79787. * Helper used to prepare the list of defines associated with frame values for shader compilation
  79788. * @param scene defines the current scene
  79789. * @param engine defines the current engine
  79790. * @param defines specifies the list of active defines
  79791. * @param useInstances defines if instances have to be turned on
  79792. * @param useClipPlane defines if clip plane have to be turned on
  79793. */
  79794. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  79795. /**
  79796. * Prepares the defines for bones
  79797. * @param mesh The mesh containing the geometry data we will draw
  79798. * @param defines The defines to update
  79799. */
  79800. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  79801. /**
  79802. * Prepares the defines for morph targets
  79803. * @param mesh The mesh containing the geometry data we will draw
  79804. * @param defines The defines to update
  79805. */
  79806. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  79807. /**
  79808. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  79809. * @param mesh The mesh containing the geometry data we will draw
  79810. * @param defines The defines to update
  79811. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  79812. * @param useBones Precise whether bones should be used or not (override mesh info)
  79813. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  79814. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  79815. * @returns false if defines are considered not dirty and have not been checked
  79816. */
  79817. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  79818. /**
  79819. * Prepares the defines related to multiview
  79820. * @param scene The scene we are intending to draw
  79821. * @param defines The defines to update
  79822. */
  79823. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  79824. /**
  79825. * Prepares the defines related to the light information passed in parameter
  79826. * @param scene The scene we are intending to draw
  79827. * @param mesh The mesh the effect is compiling for
  79828. * @param light The light the effect is compiling for
  79829. * @param lightIndex The index of the light
  79830. * @param defines The defines to update
  79831. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79832. * @param state Defines the current state regarding what is needed (normals, etc...)
  79833. */
  79834. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  79835. needNormals: boolean;
  79836. needRebuild: boolean;
  79837. shadowEnabled: boolean;
  79838. specularEnabled: boolean;
  79839. lightmapMode: boolean;
  79840. }): void;
  79841. /**
  79842. * Prepares the defines related to the light information passed in parameter
  79843. * @param scene The scene we are intending to draw
  79844. * @param mesh The mesh the effect is compiling for
  79845. * @param defines The defines to update
  79846. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79847. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  79848. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  79849. * @returns true if normals will be required for the rest of the effect
  79850. */
  79851. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  79852. /**
  79853. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  79854. * @param lightIndex defines the light index
  79855. * @param uniformsList The uniform list
  79856. * @param samplersList The sampler list
  79857. * @param projectedLightTexture defines if projected texture must be used
  79858. * @param uniformBuffersList defines an optional list of uniform buffers
  79859. */
  79860. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  79861. /**
  79862. * Prepares the uniforms and samplers list to be used in the effect
  79863. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  79864. * @param samplersList The sampler list
  79865. * @param defines The defines helping in the list generation
  79866. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  79867. */
  79868. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  79869. /**
  79870. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  79871. * @param defines The defines to update while falling back
  79872. * @param fallbacks The authorized effect fallbacks
  79873. * @param maxSimultaneousLights The maximum number of lights allowed
  79874. * @param rank the current rank of the Effect
  79875. * @returns The newly affected rank
  79876. */
  79877. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  79878. private static _TmpMorphInfluencers;
  79879. /**
  79880. * Prepares the list of attributes required for morph targets according to the effect defines.
  79881. * @param attribs The current list of supported attribs
  79882. * @param mesh The mesh to prepare the morph targets attributes for
  79883. * @param influencers The number of influencers
  79884. */
  79885. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  79886. /**
  79887. * Prepares the list of attributes required for morph targets according to the effect defines.
  79888. * @param attribs The current list of supported attribs
  79889. * @param mesh The mesh to prepare the morph targets attributes for
  79890. * @param defines The current Defines of the effect
  79891. */
  79892. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  79893. /**
  79894. * Prepares the list of attributes required for bones according to the effect defines.
  79895. * @param attribs The current list of supported attribs
  79896. * @param mesh The mesh to prepare the bones attributes for
  79897. * @param defines The current Defines of the effect
  79898. * @param fallbacks The current efffect fallback strategy
  79899. */
  79900. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  79901. /**
  79902. * Check and prepare the list of attributes required for instances according to the effect defines.
  79903. * @param attribs The current list of supported attribs
  79904. * @param defines The current MaterialDefines of the effect
  79905. */
  79906. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  79907. /**
  79908. * Add the list of attributes required for instances to the attribs array.
  79909. * @param attribs The current list of supported attribs
  79910. */
  79911. static PushAttributesForInstances(attribs: string[]): void;
  79912. /**
  79913. * Binds the light information to the effect.
  79914. * @param light The light containing the generator
  79915. * @param effect The effect we are binding the data to
  79916. * @param lightIndex The light index in the effect used to render
  79917. */
  79918. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  79919. /**
  79920. * Binds the lights information from the scene to the effect for the given mesh.
  79921. * @param light Light to bind
  79922. * @param lightIndex Light index
  79923. * @param scene The scene where the light belongs to
  79924. * @param effect The effect we are binding the data to
  79925. * @param useSpecular Defines if specular is supported
  79926. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79927. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79928. */
  79929. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79930. /**
  79931. * Binds the lights information from the scene to the effect for the given mesh.
  79932. * @param scene The scene the lights belongs to
  79933. * @param mesh The mesh we are binding the information to render
  79934. * @param effect The effect we are binding the data to
  79935. * @param defines The generated defines for the effect
  79936. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  79937. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79938. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79939. */
  79940. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79941. private static _tempFogColor;
  79942. /**
  79943. * Binds the fog information from the scene to the effect for the given mesh.
  79944. * @param scene The scene the lights belongs to
  79945. * @param mesh The mesh we are binding the information to render
  79946. * @param effect The effect we are binding the data to
  79947. * @param linearSpace Defines if the fog effect is applied in linear space
  79948. */
  79949. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  79950. /**
  79951. * Binds the bones information from the mesh to the effect.
  79952. * @param mesh The mesh we are binding the information to render
  79953. * @param effect The effect we are binding the data to
  79954. */
  79955. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  79956. /**
  79957. * Binds the morph targets information from the mesh to the effect.
  79958. * @param abstractMesh The mesh we are binding the information to render
  79959. * @param effect The effect we are binding the data to
  79960. */
  79961. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  79962. /**
  79963. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  79964. * @param defines The generated defines used in the effect
  79965. * @param effect The effect we are binding the data to
  79966. * @param scene The scene we are willing to render with logarithmic scale for
  79967. */
  79968. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  79969. /**
  79970. * Binds the clip plane information from the scene to the effect.
  79971. * @param scene The scene the clip plane information are extracted from
  79972. * @param effect The effect we are binding the data to
  79973. */
  79974. static BindClipPlane(effect: Effect, scene: Scene): void;
  79975. }
  79976. }
  79977. declare module BABYLON {
  79978. /** @hidden */
  79979. export var packingFunctions: {
  79980. name: string;
  79981. shader: string;
  79982. };
  79983. }
  79984. declare module BABYLON {
  79985. /** @hidden */
  79986. export var shadowMapPixelShader: {
  79987. name: string;
  79988. shader: string;
  79989. };
  79990. }
  79991. declare module BABYLON {
  79992. /** @hidden */
  79993. export var bonesDeclaration: {
  79994. name: string;
  79995. shader: string;
  79996. };
  79997. }
  79998. declare module BABYLON {
  79999. /** @hidden */
  80000. export var morphTargetsVertexGlobalDeclaration: {
  80001. name: string;
  80002. shader: string;
  80003. };
  80004. }
  80005. declare module BABYLON {
  80006. /** @hidden */
  80007. export var morphTargetsVertexDeclaration: {
  80008. name: string;
  80009. shader: string;
  80010. };
  80011. }
  80012. declare module BABYLON {
  80013. /** @hidden */
  80014. export var instancesDeclaration: {
  80015. name: string;
  80016. shader: string;
  80017. };
  80018. }
  80019. declare module BABYLON {
  80020. /** @hidden */
  80021. export var helperFunctions: {
  80022. name: string;
  80023. shader: string;
  80024. };
  80025. }
  80026. declare module BABYLON {
  80027. /** @hidden */
  80028. export var morphTargetsVertex: {
  80029. name: string;
  80030. shader: string;
  80031. };
  80032. }
  80033. declare module BABYLON {
  80034. /** @hidden */
  80035. export var instancesVertex: {
  80036. name: string;
  80037. shader: string;
  80038. };
  80039. }
  80040. declare module BABYLON {
  80041. /** @hidden */
  80042. export var bonesVertex: {
  80043. name: string;
  80044. shader: string;
  80045. };
  80046. }
  80047. declare module BABYLON {
  80048. /** @hidden */
  80049. export var shadowMapVertexShader: {
  80050. name: string;
  80051. shader: string;
  80052. };
  80053. }
  80054. declare module BABYLON {
  80055. /** @hidden */
  80056. export var depthBoxBlurPixelShader: {
  80057. name: string;
  80058. shader: string;
  80059. };
  80060. }
  80061. declare module BABYLON {
  80062. /**
  80063. * Defines the options associated with the creation of a custom shader for a shadow generator.
  80064. */
  80065. export interface ICustomShaderOptions {
  80066. /**
  80067. * Gets or sets the custom shader name to use
  80068. */
  80069. shaderName: string;
  80070. /**
  80071. * The list of attribute names used in the shader
  80072. */
  80073. attributes?: string[];
  80074. /**
  80075. * The list of unifrom names used in the shader
  80076. */
  80077. uniforms?: string[];
  80078. /**
  80079. * The list of sampler names used in the shader
  80080. */
  80081. samplers?: string[];
  80082. /**
  80083. * The list of defines used in the shader
  80084. */
  80085. defines?: string[];
  80086. }
  80087. /**
  80088. * Interface to implement to create a shadow generator compatible with BJS.
  80089. */
  80090. export interface IShadowGenerator {
  80091. /**
  80092. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80093. * @returns The render target texture if present otherwise, null
  80094. */
  80095. getShadowMap(): Nullable<RenderTargetTexture>;
  80096. /**
  80097. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80098. * @returns The render target texture if the shadow map is present otherwise, null
  80099. */
  80100. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80101. /**
  80102. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80103. * @param subMesh The submesh we want to render in the shadow map
  80104. * @param useInstances Defines wether will draw in the map using instances
  80105. * @returns true if ready otherwise, false
  80106. */
  80107. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80108. /**
  80109. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80110. * @param defines Defines of the material we want to update
  80111. * @param lightIndex Index of the light in the enabled light list of the material
  80112. */
  80113. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  80114. /**
  80115. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80116. * defined in the generator but impacting the effect).
  80117. * It implies the unifroms available on the materials are the standard BJS ones.
  80118. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80119. * @param effect The effect we are binfing the information for
  80120. */
  80121. bindShadowLight(lightIndex: string, effect: Effect): void;
  80122. /**
  80123. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80124. * (eq to shadow prjection matrix * light transform matrix)
  80125. * @returns The transform matrix used to create the shadow map
  80126. */
  80127. getTransformMatrix(): Matrix;
  80128. /**
  80129. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80130. * Cube and 2D textures for instance.
  80131. */
  80132. recreateShadowMap(): void;
  80133. /**
  80134. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80135. * @param onCompiled Callback triggered at the and of the effects compilation
  80136. * @param options Sets of optional options forcing the compilation with different modes
  80137. */
  80138. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80139. useInstances: boolean;
  80140. }>): void;
  80141. /**
  80142. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80143. * @param options Sets of optional options forcing the compilation with different modes
  80144. * @returns A promise that resolves when the compilation completes
  80145. */
  80146. forceCompilationAsync(options?: Partial<{
  80147. useInstances: boolean;
  80148. }>): Promise<void>;
  80149. /**
  80150. * Serializes the shadow generator setup to a json object.
  80151. * @returns The serialized JSON object
  80152. */
  80153. serialize(): any;
  80154. /**
  80155. * Disposes the Shadow map and related Textures and effects.
  80156. */
  80157. dispose(): void;
  80158. }
  80159. /**
  80160. * Default implementation IShadowGenerator.
  80161. * This is the main object responsible of generating shadows in the framework.
  80162. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  80163. */
  80164. export class ShadowGenerator implements IShadowGenerator {
  80165. /**
  80166. * Shadow generator mode None: no filtering applied.
  80167. */
  80168. static readonly FILTER_NONE: number;
  80169. /**
  80170. * Shadow generator mode ESM: Exponential Shadow Mapping.
  80171. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80172. */
  80173. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  80174. /**
  80175. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  80176. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  80177. */
  80178. static readonly FILTER_POISSONSAMPLING: number;
  80179. /**
  80180. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  80181. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80182. */
  80183. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  80184. /**
  80185. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  80186. * edge artifacts on steep falloff.
  80187. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80188. */
  80189. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  80190. /**
  80191. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  80192. * edge artifacts on steep falloff.
  80193. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80194. */
  80195. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  80196. /**
  80197. * Shadow generator mode PCF: Percentage Closer Filtering
  80198. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80199. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  80200. */
  80201. static readonly FILTER_PCF: number;
  80202. /**
  80203. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  80204. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80205. * Contact Hardening
  80206. */
  80207. static readonly FILTER_PCSS: number;
  80208. /**
  80209. * Reserved for PCF and PCSS
  80210. * Highest Quality.
  80211. *
  80212. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  80213. *
  80214. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  80215. */
  80216. static readonly QUALITY_HIGH: number;
  80217. /**
  80218. * Reserved for PCF and PCSS
  80219. * Good tradeoff for quality/perf cross devices
  80220. *
  80221. * Execute PCF on a 3*3 kernel.
  80222. *
  80223. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  80224. */
  80225. static readonly QUALITY_MEDIUM: number;
  80226. /**
  80227. * Reserved for PCF and PCSS
  80228. * The lowest quality but the fastest.
  80229. *
  80230. * Execute PCF on a 1*1 kernel.
  80231. *
  80232. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  80233. */
  80234. static readonly QUALITY_LOW: number;
  80235. /** Gets or sets the custom shader name to use */
  80236. customShaderOptions: ICustomShaderOptions;
  80237. /**
  80238. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  80239. */
  80240. onBeforeShadowMapRenderObservable: Observable<Effect>;
  80241. /**
  80242. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  80243. */
  80244. onAfterShadowMapRenderObservable: Observable<Effect>;
  80245. /**
  80246. * Observable triggered before a mesh is rendered in the shadow map.
  80247. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  80248. */
  80249. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  80250. /**
  80251. * Observable triggered after a mesh is rendered in the shadow map.
  80252. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  80253. */
  80254. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  80255. private _bias;
  80256. /**
  80257. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  80258. */
  80259. get bias(): number;
  80260. /**
  80261. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  80262. */
  80263. set bias(bias: number);
  80264. private _normalBias;
  80265. /**
  80266. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80267. */
  80268. get normalBias(): number;
  80269. /**
  80270. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80271. */
  80272. set normalBias(normalBias: number);
  80273. private _blurBoxOffset;
  80274. /**
  80275. * Gets the blur box offset: offset applied during the blur pass.
  80276. * Only useful if useKernelBlur = false
  80277. */
  80278. get blurBoxOffset(): number;
  80279. /**
  80280. * Sets the blur box offset: offset applied during the blur pass.
  80281. * Only useful if useKernelBlur = false
  80282. */
  80283. set blurBoxOffset(value: number);
  80284. private _blurScale;
  80285. /**
  80286. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  80287. * 2 means half of the size.
  80288. */
  80289. get blurScale(): number;
  80290. /**
  80291. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  80292. * 2 means half of the size.
  80293. */
  80294. set blurScale(value: number);
  80295. private _blurKernel;
  80296. /**
  80297. * Gets the blur kernel: kernel size of the blur pass.
  80298. * Only useful if useKernelBlur = true
  80299. */
  80300. get blurKernel(): number;
  80301. /**
  80302. * Sets the blur kernel: kernel size of the blur pass.
  80303. * Only useful if useKernelBlur = true
  80304. */
  80305. set blurKernel(value: number);
  80306. private _useKernelBlur;
  80307. /**
  80308. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  80309. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80310. */
  80311. get useKernelBlur(): boolean;
  80312. /**
  80313. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  80314. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80315. */
  80316. set useKernelBlur(value: boolean);
  80317. private _depthScale;
  80318. /**
  80319. * Gets the depth scale used in ESM mode.
  80320. */
  80321. get depthScale(): number;
  80322. /**
  80323. * Sets the depth scale used in ESM mode.
  80324. * This can override the scale stored on the light.
  80325. */
  80326. set depthScale(value: number);
  80327. private _filter;
  80328. /**
  80329. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  80330. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80331. */
  80332. get filter(): number;
  80333. /**
  80334. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  80335. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80336. */
  80337. set filter(value: number);
  80338. /**
  80339. * Gets if the current filter is set to Poisson Sampling.
  80340. */
  80341. get usePoissonSampling(): boolean;
  80342. /**
  80343. * Sets the current filter to Poisson Sampling.
  80344. */
  80345. set usePoissonSampling(value: boolean);
  80346. /**
  80347. * Gets if the current filter is set to ESM.
  80348. */
  80349. get useExponentialShadowMap(): boolean;
  80350. /**
  80351. * Sets the current filter is to ESM.
  80352. */
  80353. set useExponentialShadowMap(value: boolean);
  80354. /**
  80355. * Gets if the current filter is set to filtered ESM.
  80356. */
  80357. get useBlurExponentialShadowMap(): boolean;
  80358. /**
  80359. * Gets if the current filter is set to filtered ESM.
  80360. */
  80361. set useBlurExponentialShadowMap(value: boolean);
  80362. /**
  80363. * Gets if the current filter is set to "close ESM" (using the inverse of the
  80364. * exponential to prevent steep falloff artifacts).
  80365. */
  80366. get useCloseExponentialShadowMap(): boolean;
  80367. /**
  80368. * Sets the current filter to "close ESM" (using the inverse of the
  80369. * exponential to prevent steep falloff artifacts).
  80370. */
  80371. set useCloseExponentialShadowMap(value: boolean);
  80372. /**
  80373. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  80374. * exponential to prevent steep falloff artifacts).
  80375. */
  80376. get useBlurCloseExponentialShadowMap(): boolean;
  80377. /**
  80378. * Sets the current filter to filtered "close ESM" (using the inverse of the
  80379. * exponential to prevent steep falloff artifacts).
  80380. */
  80381. set useBlurCloseExponentialShadowMap(value: boolean);
  80382. /**
  80383. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  80384. */
  80385. get usePercentageCloserFiltering(): boolean;
  80386. /**
  80387. * Sets the current filter to "PCF" (percentage closer filtering).
  80388. */
  80389. set usePercentageCloserFiltering(value: boolean);
  80390. private _filteringQuality;
  80391. /**
  80392. * Gets the PCF or PCSS Quality.
  80393. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80394. */
  80395. get filteringQuality(): number;
  80396. /**
  80397. * Sets the PCF or PCSS Quality.
  80398. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80399. */
  80400. set filteringQuality(filteringQuality: number);
  80401. /**
  80402. * Gets if the current filter is set to "PCSS" (contact hardening).
  80403. */
  80404. get useContactHardeningShadow(): boolean;
  80405. /**
  80406. * Sets the current filter to "PCSS" (contact hardening).
  80407. */
  80408. set useContactHardeningShadow(value: boolean);
  80409. private _contactHardeningLightSizeUVRatio;
  80410. /**
  80411. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80412. * Using a ratio helps keeping shape stability independently of the map size.
  80413. *
  80414. * It does not account for the light projection as it was having too much
  80415. * instability during the light setup or during light position changes.
  80416. *
  80417. * Only valid if useContactHardeningShadow is true.
  80418. */
  80419. get contactHardeningLightSizeUVRatio(): number;
  80420. /**
  80421. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80422. * Using a ratio helps keeping shape stability independently of the map size.
  80423. *
  80424. * It does not account for the light projection as it was having too much
  80425. * instability during the light setup or during light position changes.
  80426. *
  80427. * Only valid if useContactHardeningShadow is true.
  80428. */
  80429. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  80430. private _darkness;
  80431. /** Gets or sets the actual darkness of a shadow */
  80432. get darkness(): number;
  80433. set darkness(value: number);
  80434. /**
  80435. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  80436. * 0 means strongest and 1 would means no shadow.
  80437. * @returns the darkness.
  80438. */
  80439. getDarkness(): number;
  80440. /**
  80441. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  80442. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  80443. * @returns the shadow generator allowing fluent coding.
  80444. */
  80445. setDarkness(darkness: number): ShadowGenerator;
  80446. private _transparencyShadow;
  80447. /** Gets or sets the ability to have transparent shadow */
  80448. get transparencyShadow(): boolean;
  80449. set transparencyShadow(value: boolean);
  80450. /**
  80451. * Sets the ability to have transparent shadow (boolean).
  80452. * @param transparent True if transparent else False
  80453. * @returns the shadow generator allowing fluent coding
  80454. */
  80455. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  80456. private _shadowMap;
  80457. private _shadowMap2;
  80458. /**
  80459. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80460. * @returns The render target texture if present otherwise, null
  80461. */
  80462. getShadowMap(): Nullable<RenderTargetTexture>;
  80463. /**
  80464. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80465. * @returns The render target texture if the shadow map is present otherwise, null
  80466. */
  80467. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80468. /**
  80469. * Gets the class name of that object
  80470. * @returns "ShadowGenerator"
  80471. */
  80472. getClassName(): string;
  80473. /**
  80474. * Helper function to add a mesh and its descendants to the list of shadow casters.
  80475. * @param mesh Mesh to add
  80476. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  80477. * @returns the Shadow Generator itself
  80478. */
  80479. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80480. /**
  80481. * Helper function to remove a mesh and its descendants from the list of shadow casters
  80482. * @param mesh Mesh to remove
  80483. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  80484. * @returns the Shadow Generator itself
  80485. */
  80486. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80487. /**
  80488. * Controls the extent to which the shadows fade out at the edge of the frustum
  80489. * Used only by directionals and spots
  80490. */
  80491. frustumEdgeFalloff: number;
  80492. private _light;
  80493. /**
  80494. * Returns the associated light object.
  80495. * @returns the light generating the shadow
  80496. */
  80497. getLight(): IShadowLight;
  80498. /**
  80499. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  80500. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  80501. * It might on the other hand introduce peter panning.
  80502. */
  80503. forceBackFacesOnly: boolean;
  80504. private _scene;
  80505. private _lightDirection;
  80506. private _effect;
  80507. private _viewMatrix;
  80508. private _projectionMatrix;
  80509. private _transformMatrix;
  80510. private _cachedPosition;
  80511. private _cachedDirection;
  80512. private _cachedDefines;
  80513. private _currentRenderID;
  80514. private _boxBlurPostprocess;
  80515. private _kernelBlurXPostprocess;
  80516. private _kernelBlurYPostprocess;
  80517. private _blurPostProcesses;
  80518. private _mapSize;
  80519. private _currentFaceIndex;
  80520. private _currentFaceIndexCache;
  80521. private _textureType;
  80522. private _defaultTextureMatrix;
  80523. private _storedUniqueId;
  80524. /** @hidden */
  80525. static _SceneComponentInitialization: (scene: Scene) => void;
  80526. /**
  80527. * Creates a ShadowGenerator object.
  80528. * A ShadowGenerator is the required tool to use the shadows.
  80529. * Each light casting shadows needs to use its own ShadowGenerator.
  80530. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  80531. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  80532. * @param light The light object generating the shadows.
  80533. * @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.
  80534. */
  80535. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  80536. private _initializeGenerator;
  80537. private _initializeShadowMap;
  80538. private _initializeBlurRTTAndPostProcesses;
  80539. private _renderForShadowMap;
  80540. private _renderSubMeshForShadowMap;
  80541. private _applyFilterValues;
  80542. /**
  80543. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80544. * @param onCompiled Callback triggered at the and of the effects compilation
  80545. * @param options Sets of optional options forcing the compilation with different modes
  80546. */
  80547. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80548. useInstances: boolean;
  80549. }>): void;
  80550. /**
  80551. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80552. * @param options Sets of optional options forcing the compilation with different modes
  80553. * @returns A promise that resolves when the compilation completes
  80554. */
  80555. forceCompilationAsync(options?: Partial<{
  80556. useInstances: boolean;
  80557. }>): Promise<void>;
  80558. /**
  80559. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80560. * @param subMesh The submesh we want to render in the shadow map
  80561. * @param useInstances Defines wether will draw in the map using instances
  80562. * @returns true if ready otherwise, false
  80563. */
  80564. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80565. /**
  80566. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80567. * @param defines Defines of the material we want to update
  80568. * @param lightIndex Index of the light in the enabled light list of the material
  80569. */
  80570. prepareDefines(defines: any, lightIndex: number): void;
  80571. /**
  80572. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80573. * defined in the generator but impacting the effect).
  80574. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80575. * @param effect The effect we are binfing the information for
  80576. */
  80577. bindShadowLight(lightIndex: string, effect: Effect): void;
  80578. /**
  80579. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80580. * (eq to shadow prjection matrix * light transform matrix)
  80581. * @returns The transform matrix used to create the shadow map
  80582. */
  80583. getTransformMatrix(): Matrix;
  80584. /**
  80585. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80586. * Cube and 2D textures for instance.
  80587. */
  80588. recreateShadowMap(): void;
  80589. private _disposeBlurPostProcesses;
  80590. private _disposeRTTandPostProcesses;
  80591. /**
  80592. * Disposes the ShadowGenerator.
  80593. * Returns nothing.
  80594. */
  80595. dispose(): void;
  80596. /**
  80597. * Serializes the shadow generator setup to a json object.
  80598. * @returns The serialized JSON object
  80599. */
  80600. serialize(): any;
  80601. /**
  80602. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  80603. * @param parsedShadowGenerator The JSON object to parse
  80604. * @param scene The scene to create the shadow map for
  80605. * @returns The parsed shadow generator
  80606. */
  80607. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  80608. }
  80609. }
  80610. declare module BABYLON {
  80611. /**
  80612. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  80613. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  80614. * 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.
  80615. */
  80616. export abstract class Light extends Node {
  80617. /**
  80618. * Falloff Default: light is falling off following the material specification:
  80619. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  80620. */
  80621. static readonly FALLOFF_DEFAULT: number;
  80622. /**
  80623. * Falloff Physical: light is falling off following the inverse squared distance law.
  80624. */
  80625. static readonly FALLOFF_PHYSICAL: number;
  80626. /**
  80627. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  80628. * to enhance interoperability with other engines.
  80629. */
  80630. static readonly FALLOFF_GLTF: number;
  80631. /**
  80632. * Falloff Standard: light is falling off like in the standard material
  80633. * to enhance interoperability with other materials.
  80634. */
  80635. static readonly FALLOFF_STANDARD: number;
  80636. /**
  80637. * If every light affecting the material is in this lightmapMode,
  80638. * material.lightmapTexture adds or multiplies
  80639. * (depends on material.useLightmapAsShadowmap)
  80640. * after every other light calculations.
  80641. */
  80642. static readonly LIGHTMAP_DEFAULT: number;
  80643. /**
  80644. * material.lightmapTexture as only diffuse lighting from this light
  80645. * adds only specular lighting from this light
  80646. * adds dynamic shadows
  80647. */
  80648. static readonly LIGHTMAP_SPECULAR: number;
  80649. /**
  80650. * material.lightmapTexture as only lighting
  80651. * no light calculation from this light
  80652. * only adds dynamic shadows from this light
  80653. */
  80654. static readonly LIGHTMAP_SHADOWSONLY: number;
  80655. /**
  80656. * Each light type uses the default quantity according to its type:
  80657. * point/spot lights use luminous intensity
  80658. * directional lights use illuminance
  80659. */
  80660. static readonly INTENSITYMODE_AUTOMATIC: number;
  80661. /**
  80662. * lumen (lm)
  80663. */
  80664. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  80665. /**
  80666. * candela (lm/sr)
  80667. */
  80668. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  80669. /**
  80670. * lux (lm/m^2)
  80671. */
  80672. static readonly INTENSITYMODE_ILLUMINANCE: number;
  80673. /**
  80674. * nit (cd/m^2)
  80675. */
  80676. static readonly INTENSITYMODE_LUMINANCE: number;
  80677. /**
  80678. * Light type const id of the point light.
  80679. */
  80680. static readonly LIGHTTYPEID_POINTLIGHT: number;
  80681. /**
  80682. * Light type const id of the directional light.
  80683. */
  80684. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  80685. /**
  80686. * Light type const id of the spot light.
  80687. */
  80688. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  80689. /**
  80690. * Light type const id of the hemispheric light.
  80691. */
  80692. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  80693. /**
  80694. * Diffuse gives the basic color to an object.
  80695. */
  80696. diffuse: Color3;
  80697. /**
  80698. * Specular produces a highlight color on an object.
  80699. * Note: This is note affecting PBR materials.
  80700. */
  80701. specular: Color3;
  80702. /**
  80703. * Defines the falloff type for this light. This lets overrriding how punctual light are
  80704. * falling off base on range or angle.
  80705. * This can be set to any values in Light.FALLOFF_x.
  80706. *
  80707. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  80708. * other types of materials.
  80709. */
  80710. falloffType: number;
  80711. /**
  80712. * Strength of the light.
  80713. * Note: By default it is define in the framework own unit.
  80714. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  80715. */
  80716. intensity: number;
  80717. private _range;
  80718. protected _inverseSquaredRange: number;
  80719. /**
  80720. * Defines how far from the source the light is impacting in scene units.
  80721. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80722. */
  80723. get range(): number;
  80724. /**
  80725. * Defines how far from the source the light is impacting in scene units.
  80726. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80727. */
  80728. set range(value: number);
  80729. /**
  80730. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  80731. * of light.
  80732. */
  80733. private _photometricScale;
  80734. private _intensityMode;
  80735. /**
  80736. * Gets the photometric scale used to interpret the intensity.
  80737. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80738. */
  80739. get intensityMode(): number;
  80740. /**
  80741. * Sets the photometric scale used to interpret the intensity.
  80742. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80743. */
  80744. set intensityMode(value: number);
  80745. private _radius;
  80746. /**
  80747. * Gets the light radius used by PBR Materials to simulate soft area lights.
  80748. */
  80749. get radius(): number;
  80750. /**
  80751. * sets the light radius used by PBR Materials to simulate soft area lights.
  80752. */
  80753. set radius(value: number);
  80754. private _renderPriority;
  80755. /**
  80756. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  80757. * exceeding the number allowed of the materials.
  80758. */
  80759. renderPriority: number;
  80760. private _shadowEnabled;
  80761. /**
  80762. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80763. * the current shadow generator.
  80764. */
  80765. get shadowEnabled(): boolean;
  80766. /**
  80767. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80768. * the current shadow generator.
  80769. */
  80770. set shadowEnabled(value: boolean);
  80771. private _includedOnlyMeshes;
  80772. /**
  80773. * Gets the only meshes impacted by this light.
  80774. */
  80775. get includedOnlyMeshes(): AbstractMesh[];
  80776. /**
  80777. * Sets the only meshes impacted by this light.
  80778. */
  80779. set includedOnlyMeshes(value: AbstractMesh[]);
  80780. private _excludedMeshes;
  80781. /**
  80782. * Gets the meshes not impacted by this light.
  80783. */
  80784. get excludedMeshes(): AbstractMesh[];
  80785. /**
  80786. * Sets the meshes not impacted by this light.
  80787. */
  80788. set excludedMeshes(value: AbstractMesh[]);
  80789. private _excludeWithLayerMask;
  80790. /**
  80791. * Gets the layer id use to find what meshes are not impacted by the light.
  80792. * Inactive if 0
  80793. */
  80794. get excludeWithLayerMask(): number;
  80795. /**
  80796. * Sets the layer id use to find what meshes are not impacted by the light.
  80797. * Inactive if 0
  80798. */
  80799. set excludeWithLayerMask(value: number);
  80800. private _includeOnlyWithLayerMask;
  80801. /**
  80802. * Gets the layer id use to find what meshes are impacted by the light.
  80803. * Inactive if 0
  80804. */
  80805. get includeOnlyWithLayerMask(): number;
  80806. /**
  80807. * Sets the layer id use to find what meshes are impacted by the light.
  80808. * Inactive if 0
  80809. */
  80810. set includeOnlyWithLayerMask(value: number);
  80811. private _lightmapMode;
  80812. /**
  80813. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80814. */
  80815. get lightmapMode(): number;
  80816. /**
  80817. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80818. */
  80819. set lightmapMode(value: number);
  80820. /**
  80821. * Shadow generator associted to the light.
  80822. * @hidden Internal use only.
  80823. */
  80824. _shadowGenerator: Nullable<IShadowGenerator>;
  80825. /**
  80826. * @hidden Internal use only.
  80827. */
  80828. _excludedMeshesIds: string[];
  80829. /**
  80830. * @hidden Internal use only.
  80831. */
  80832. _includedOnlyMeshesIds: string[];
  80833. /**
  80834. * The current light unifom buffer.
  80835. * @hidden Internal use only.
  80836. */
  80837. _uniformBuffer: UniformBuffer;
  80838. /** @hidden */
  80839. _renderId: number;
  80840. /**
  80841. * Creates a Light object in the scene.
  80842. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80843. * @param name The firendly name of the light
  80844. * @param scene The scene the light belongs too
  80845. */
  80846. constructor(name: string, scene: Scene);
  80847. protected abstract _buildUniformLayout(): void;
  80848. /**
  80849. * Sets the passed Effect "effect" with the Light information.
  80850. * @param effect The effect to update
  80851. * @param lightIndex The index of the light in the effect to update
  80852. * @returns The light
  80853. */
  80854. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  80855. /**
  80856. * Sets the passed Effect "effect" with the Light textures.
  80857. * @param effect The effect to update
  80858. * @param lightIndex The index of the light in the effect to update
  80859. * @returns The light
  80860. */
  80861. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  80862. /**
  80863. * Binds the lights information from the scene to the effect for the given mesh.
  80864. * @param lightIndex Light index
  80865. * @param scene The scene where the light belongs to
  80866. * @param effect The effect we are binding the data to
  80867. * @param useSpecular Defines if specular is supported
  80868. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  80869. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80870. */
  80871. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  80872. /**
  80873. * Sets the passed Effect "effect" with the Light information.
  80874. * @param effect The effect to update
  80875. * @param lightDataUniformName The uniform used to store light data (position or direction)
  80876. * @returns The light
  80877. */
  80878. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  80879. /**
  80880. * Returns the string "Light".
  80881. * @returns the class name
  80882. */
  80883. getClassName(): string;
  80884. /** @hidden */
  80885. readonly _isLight: boolean;
  80886. /**
  80887. * Converts the light information to a readable string for debug purpose.
  80888. * @param fullDetails Supports for multiple levels of logging within scene loading
  80889. * @returns the human readable light info
  80890. */
  80891. toString(fullDetails?: boolean): string;
  80892. /** @hidden */
  80893. protected _syncParentEnabledState(): void;
  80894. /**
  80895. * Set the enabled state of this node.
  80896. * @param value - the new enabled state
  80897. */
  80898. setEnabled(value: boolean): void;
  80899. /**
  80900. * Returns the Light associated shadow generator if any.
  80901. * @return the associated shadow generator.
  80902. */
  80903. getShadowGenerator(): Nullable<IShadowGenerator>;
  80904. /**
  80905. * Returns a Vector3, the absolute light position in the World.
  80906. * @returns the world space position of the light
  80907. */
  80908. getAbsolutePosition(): Vector3;
  80909. /**
  80910. * Specifies if the light will affect the passed mesh.
  80911. * @param mesh The mesh to test against the light
  80912. * @return true the mesh is affected otherwise, false.
  80913. */
  80914. canAffectMesh(mesh: AbstractMesh): boolean;
  80915. /**
  80916. * Sort function to order lights for rendering.
  80917. * @param a First Light object to compare to second.
  80918. * @param b Second Light object to compare first.
  80919. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  80920. */
  80921. static CompareLightsPriority(a: Light, b: Light): number;
  80922. /**
  80923. * Releases resources associated with this node.
  80924. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80925. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80926. */
  80927. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80928. /**
  80929. * Returns the light type ID (integer).
  80930. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80931. */
  80932. getTypeID(): number;
  80933. /**
  80934. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  80935. * @returns the scaled intensity in intensity mode unit
  80936. */
  80937. getScaledIntensity(): number;
  80938. /**
  80939. * Returns a new Light object, named "name", from the current one.
  80940. * @param name The name of the cloned light
  80941. * @returns the new created light
  80942. */
  80943. clone(name: string): Nullable<Light>;
  80944. /**
  80945. * Serializes the current light into a Serialization object.
  80946. * @returns the serialized object.
  80947. */
  80948. serialize(): any;
  80949. /**
  80950. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  80951. * This new light is named "name" and added to the passed scene.
  80952. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  80953. * @param name The friendly name of the light
  80954. * @param scene The scene the new light will belong to
  80955. * @returns the constructor function
  80956. */
  80957. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  80958. /**
  80959. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  80960. * @param parsedLight The JSON representation of the light
  80961. * @param scene The scene to create the parsed light in
  80962. * @returns the created light after parsing
  80963. */
  80964. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  80965. private _hookArrayForExcluded;
  80966. private _hookArrayForIncludedOnly;
  80967. private _resyncMeshes;
  80968. /**
  80969. * Forces the meshes to update their light related information in their rendering used effects
  80970. * @hidden Internal Use Only
  80971. */
  80972. _markMeshesAsLightDirty(): void;
  80973. /**
  80974. * Recomputes the cached photometric scale if needed.
  80975. */
  80976. private _computePhotometricScale;
  80977. /**
  80978. * Returns the Photometric Scale according to the light type and intensity mode.
  80979. */
  80980. private _getPhotometricScale;
  80981. /**
  80982. * Reorder the light in the scene according to their defined priority.
  80983. * @hidden Internal Use Only
  80984. */
  80985. _reorderLightsInScene(): void;
  80986. /**
  80987. * Prepares the list of defines specific to the light type.
  80988. * @param defines the list of defines
  80989. * @param lightIndex defines the index of the light for the effect
  80990. */
  80991. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80992. }
  80993. }
  80994. declare module BABYLON {
  80995. /**
  80996. * Interface used to define Action
  80997. */
  80998. export interface IAction {
  80999. /**
  81000. * Trigger for the action
  81001. */
  81002. trigger: number;
  81003. /** Options of the trigger */
  81004. triggerOptions: any;
  81005. /**
  81006. * Gets the trigger parameters
  81007. * @returns the trigger parameters
  81008. */
  81009. getTriggerParameter(): any;
  81010. /**
  81011. * Internal only - executes current action event
  81012. * @hidden
  81013. */
  81014. _executeCurrent(evt?: ActionEvent): void;
  81015. /**
  81016. * Serialize placeholder for child classes
  81017. * @param parent of child
  81018. * @returns the serialized object
  81019. */
  81020. serialize(parent: any): any;
  81021. /**
  81022. * Internal only
  81023. * @hidden
  81024. */
  81025. _prepare(): void;
  81026. /**
  81027. * Internal only - manager for action
  81028. * @hidden
  81029. */
  81030. _actionManager: AbstractActionManager;
  81031. /**
  81032. * Adds action to chain of actions, may be a DoNothingAction
  81033. * @param action defines the next action to execute
  81034. * @returns The action passed in
  81035. * @see https://www.babylonjs-playground.com/#1T30HR#0
  81036. */
  81037. then(action: IAction): IAction;
  81038. }
  81039. /**
  81040. * The action to be carried out following a trigger
  81041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  81042. */
  81043. export class Action implements IAction {
  81044. /** the trigger, with or without parameters, for the action */
  81045. triggerOptions: any;
  81046. /**
  81047. * Trigger for the action
  81048. */
  81049. trigger: number;
  81050. /**
  81051. * Internal only - manager for action
  81052. * @hidden
  81053. */
  81054. _actionManager: ActionManager;
  81055. private _nextActiveAction;
  81056. private _child;
  81057. private _condition?;
  81058. private _triggerParameter;
  81059. /**
  81060. * An event triggered prior to action being executed.
  81061. */
  81062. onBeforeExecuteObservable: Observable<Action>;
  81063. /**
  81064. * Creates a new Action
  81065. * @param triggerOptions the trigger, with or without parameters, for the action
  81066. * @param condition an optional determinant of action
  81067. */
  81068. constructor(
  81069. /** the trigger, with or without parameters, for the action */
  81070. triggerOptions: any, condition?: Condition);
  81071. /**
  81072. * Internal only
  81073. * @hidden
  81074. */
  81075. _prepare(): void;
  81076. /**
  81077. * Gets the trigger parameters
  81078. * @returns the trigger parameters
  81079. */
  81080. getTriggerParameter(): any;
  81081. /**
  81082. * Internal only - executes current action event
  81083. * @hidden
  81084. */
  81085. _executeCurrent(evt?: ActionEvent): void;
  81086. /**
  81087. * Execute placeholder for child classes
  81088. * @param evt optional action event
  81089. */
  81090. execute(evt?: ActionEvent): void;
  81091. /**
  81092. * Skips to next active action
  81093. */
  81094. skipToNextActiveAction(): void;
  81095. /**
  81096. * Adds action to chain of actions, may be a DoNothingAction
  81097. * @param action defines the next action to execute
  81098. * @returns The action passed in
  81099. * @see https://www.babylonjs-playground.com/#1T30HR#0
  81100. */
  81101. then(action: Action): Action;
  81102. /**
  81103. * Internal only
  81104. * @hidden
  81105. */
  81106. _getProperty(propertyPath: string): string;
  81107. /**
  81108. * Internal only
  81109. * @hidden
  81110. */
  81111. _getEffectiveTarget(target: any, propertyPath: string): any;
  81112. /**
  81113. * Serialize placeholder for child classes
  81114. * @param parent of child
  81115. * @returns the serialized object
  81116. */
  81117. serialize(parent: any): any;
  81118. /**
  81119. * Internal only called by serialize
  81120. * @hidden
  81121. */
  81122. protected _serialize(serializedAction: any, parent?: any): any;
  81123. /**
  81124. * Internal only
  81125. * @hidden
  81126. */
  81127. static _SerializeValueAsString: (value: any) => string;
  81128. /**
  81129. * Internal only
  81130. * @hidden
  81131. */
  81132. static _GetTargetProperty: (target: Node | Scene) => {
  81133. name: string;
  81134. targetType: string;
  81135. value: string;
  81136. };
  81137. }
  81138. }
  81139. declare module BABYLON {
  81140. /**
  81141. * A Condition applied to an Action
  81142. */
  81143. export class Condition {
  81144. /**
  81145. * Internal only - manager for action
  81146. * @hidden
  81147. */
  81148. _actionManager: ActionManager;
  81149. /**
  81150. * Internal only
  81151. * @hidden
  81152. */
  81153. _evaluationId: number;
  81154. /**
  81155. * Internal only
  81156. * @hidden
  81157. */
  81158. _currentResult: boolean;
  81159. /**
  81160. * Creates a new Condition
  81161. * @param actionManager the manager of the action the condition is applied to
  81162. */
  81163. constructor(actionManager: ActionManager);
  81164. /**
  81165. * Check if the current condition is valid
  81166. * @returns a boolean
  81167. */
  81168. isValid(): boolean;
  81169. /**
  81170. * Internal only
  81171. * @hidden
  81172. */
  81173. _getProperty(propertyPath: string): string;
  81174. /**
  81175. * Internal only
  81176. * @hidden
  81177. */
  81178. _getEffectiveTarget(target: any, propertyPath: string): any;
  81179. /**
  81180. * Serialize placeholder for child classes
  81181. * @returns the serialized object
  81182. */
  81183. serialize(): any;
  81184. /**
  81185. * Internal only
  81186. * @hidden
  81187. */
  81188. protected _serialize(serializedCondition: any): any;
  81189. }
  81190. /**
  81191. * Defines specific conditional operators as extensions of Condition
  81192. */
  81193. export class ValueCondition extends Condition {
  81194. /** path to specify the property of the target the conditional operator uses */
  81195. propertyPath: string;
  81196. /** the value compared by the conditional operator against the current value of the property */
  81197. value: any;
  81198. /** the conditional operator, default ValueCondition.IsEqual */
  81199. operator: number;
  81200. /**
  81201. * Internal only
  81202. * @hidden
  81203. */
  81204. private static _IsEqual;
  81205. /**
  81206. * Internal only
  81207. * @hidden
  81208. */
  81209. private static _IsDifferent;
  81210. /**
  81211. * Internal only
  81212. * @hidden
  81213. */
  81214. private static _IsGreater;
  81215. /**
  81216. * Internal only
  81217. * @hidden
  81218. */
  81219. private static _IsLesser;
  81220. /**
  81221. * returns the number for IsEqual
  81222. */
  81223. static get IsEqual(): number;
  81224. /**
  81225. * Returns the number for IsDifferent
  81226. */
  81227. static get IsDifferent(): number;
  81228. /**
  81229. * Returns the number for IsGreater
  81230. */
  81231. static get IsGreater(): number;
  81232. /**
  81233. * Returns the number for IsLesser
  81234. */
  81235. static get IsLesser(): number;
  81236. /**
  81237. * Internal only The action manager for the condition
  81238. * @hidden
  81239. */
  81240. _actionManager: ActionManager;
  81241. /**
  81242. * Internal only
  81243. * @hidden
  81244. */
  81245. private _target;
  81246. /**
  81247. * Internal only
  81248. * @hidden
  81249. */
  81250. private _effectiveTarget;
  81251. /**
  81252. * Internal only
  81253. * @hidden
  81254. */
  81255. private _property;
  81256. /**
  81257. * Creates a new ValueCondition
  81258. * @param actionManager manager for the action the condition applies to
  81259. * @param target for the action
  81260. * @param propertyPath path to specify the property of the target the conditional operator uses
  81261. * @param value the value compared by the conditional operator against the current value of the property
  81262. * @param operator the conditional operator, default ValueCondition.IsEqual
  81263. */
  81264. constructor(actionManager: ActionManager, target: any,
  81265. /** path to specify the property of the target the conditional operator uses */
  81266. propertyPath: string,
  81267. /** the value compared by the conditional operator against the current value of the property */
  81268. value: any,
  81269. /** the conditional operator, default ValueCondition.IsEqual */
  81270. operator?: number);
  81271. /**
  81272. * Compares the given value with the property value for the specified conditional operator
  81273. * @returns the result of the comparison
  81274. */
  81275. isValid(): boolean;
  81276. /**
  81277. * Serialize the ValueCondition into a JSON compatible object
  81278. * @returns serialization object
  81279. */
  81280. serialize(): any;
  81281. /**
  81282. * Gets the name of the conditional operator for the ValueCondition
  81283. * @param operator the conditional operator
  81284. * @returns the name
  81285. */
  81286. static GetOperatorName(operator: number): string;
  81287. }
  81288. /**
  81289. * Defines a predicate condition as an extension of Condition
  81290. */
  81291. export class PredicateCondition extends Condition {
  81292. /** defines the predicate function used to validate the condition */
  81293. predicate: () => boolean;
  81294. /**
  81295. * Internal only - manager for action
  81296. * @hidden
  81297. */
  81298. _actionManager: ActionManager;
  81299. /**
  81300. * Creates a new PredicateCondition
  81301. * @param actionManager manager for the action the condition applies to
  81302. * @param predicate defines the predicate function used to validate the condition
  81303. */
  81304. constructor(actionManager: ActionManager,
  81305. /** defines the predicate function used to validate the condition */
  81306. predicate: () => boolean);
  81307. /**
  81308. * @returns the validity of the predicate condition
  81309. */
  81310. isValid(): boolean;
  81311. }
  81312. /**
  81313. * Defines a state condition as an extension of Condition
  81314. */
  81315. export class StateCondition extends Condition {
  81316. /** Value to compare with target state */
  81317. value: string;
  81318. /**
  81319. * Internal only - manager for action
  81320. * @hidden
  81321. */
  81322. _actionManager: ActionManager;
  81323. /**
  81324. * Internal only
  81325. * @hidden
  81326. */
  81327. private _target;
  81328. /**
  81329. * Creates a new StateCondition
  81330. * @param actionManager manager for the action the condition applies to
  81331. * @param target of the condition
  81332. * @param value to compare with target state
  81333. */
  81334. constructor(actionManager: ActionManager, target: any,
  81335. /** Value to compare with target state */
  81336. value: string);
  81337. /**
  81338. * Gets a boolean indicating if the current condition is met
  81339. * @returns the validity of the state
  81340. */
  81341. isValid(): boolean;
  81342. /**
  81343. * Serialize the StateCondition into a JSON compatible object
  81344. * @returns serialization object
  81345. */
  81346. serialize(): any;
  81347. }
  81348. }
  81349. declare module BABYLON {
  81350. /**
  81351. * This defines an action responsible to toggle a boolean once triggered.
  81352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81353. */
  81354. export class SwitchBooleanAction extends Action {
  81355. /**
  81356. * The path to the boolean property in the target object
  81357. */
  81358. propertyPath: string;
  81359. private _target;
  81360. private _effectiveTarget;
  81361. private _property;
  81362. /**
  81363. * Instantiate the action
  81364. * @param triggerOptions defines the trigger options
  81365. * @param target defines the object containing the boolean
  81366. * @param propertyPath defines the path to the boolean property in the target object
  81367. * @param condition defines the trigger related conditions
  81368. */
  81369. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  81370. /** @hidden */
  81371. _prepare(): void;
  81372. /**
  81373. * Execute the action toggle the boolean value.
  81374. */
  81375. execute(): void;
  81376. /**
  81377. * Serializes the actions and its related information.
  81378. * @param parent defines the object to serialize in
  81379. * @returns the serialized object
  81380. */
  81381. serialize(parent: any): any;
  81382. }
  81383. /**
  81384. * This defines an action responsible to set a the state field of the target
  81385. * to a desired value once triggered.
  81386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81387. */
  81388. export class SetStateAction extends Action {
  81389. /**
  81390. * The value to store in the state field.
  81391. */
  81392. value: string;
  81393. private _target;
  81394. /**
  81395. * Instantiate the action
  81396. * @param triggerOptions defines the trigger options
  81397. * @param target defines the object containing the state property
  81398. * @param value defines the value to store in the state field
  81399. * @param condition defines the trigger related conditions
  81400. */
  81401. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  81402. /**
  81403. * Execute the action and store the value on the target state property.
  81404. */
  81405. execute(): void;
  81406. /**
  81407. * Serializes the actions and its related information.
  81408. * @param parent defines the object to serialize in
  81409. * @returns the serialized object
  81410. */
  81411. serialize(parent: any): any;
  81412. }
  81413. /**
  81414. * This defines an action responsible to set a property of the target
  81415. * to a desired value once triggered.
  81416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81417. */
  81418. export class SetValueAction extends Action {
  81419. /**
  81420. * The path of the property to set in the target.
  81421. */
  81422. propertyPath: string;
  81423. /**
  81424. * The value to set in the property
  81425. */
  81426. value: any;
  81427. private _target;
  81428. private _effectiveTarget;
  81429. private _property;
  81430. /**
  81431. * Instantiate the action
  81432. * @param triggerOptions defines the trigger options
  81433. * @param target defines the object containing the property
  81434. * @param propertyPath defines the path of the property to set in the target
  81435. * @param value defines the value to set in the property
  81436. * @param condition defines the trigger related conditions
  81437. */
  81438. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81439. /** @hidden */
  81440. _prepare(): void;
  81441. /**
  81442. * Execute the action and set the targetted property to the desired value.
  81443. */
  81444. execute(): void;
  81445. /**
  81446. * Serializes the actions and its related information.
  81447. * @param parent defines the object to serialize in
  81448. * @returns the serialized object
  81449. */
  81450. serialize(parent: any): any;
  81451. }
  81452. /**
  81453. * This defines an action responsible to increment the target value
  81454. * to a desired value once triggered.
  81455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81456. */
  81457. export class IncrementValueAction extends Action {
  81458. /**
  81459. * The path of the property to increment in the target.
  81460. */
  81461. propertyPath: string;
  81462. /**
  81463. * The value we should increment the property by.
  81464. */
  81465. value: any;
  81466. private _target;
  81467. private _effectiveTarget;
  81468. private _property;
  81469. /**
  81470. * Instantiate the action
  81471. * @param triggerOptions defines the trigger options
  81472. * @param target defines the object containing the property
  81473. * @param propertyPath defines the path of the property to increment in the target
  81474. * @param value defines the value value we should increment the property by
  81475. * @param condition defines the trigger related conditions
  81476. */
  81477. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81478. /** @hidden */
  81479. _prepare(): void;
  81480. /**
  81481. * Execute the action and increment the target of the value amount.
  81482. */
  81483. execute(): void;
  81484. /**
  81485. * Serializes the actions and its related information.
  81486. * @param parent defines the object to serialize in
  81487. * @returns the serialized object
  81488. */
  81489. serialize(parent: any): any;
  81490. }
  81491. /**
  81492. * This defines an action responsible to start an animation once triggered.
  81493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81494. */
  81495. export class PlayAnimationAction extends Action {
  81496. /**
  81497. * Where the animation should start (animation frame)
  81498. */
  81499. from: number;
  81500. /**
  81501. * Where the animation should stop (animation frame)
  81502. */
  81503. to: number;
  81504. /**
  81505. * Define if the animation should loop or stop after the first play.
  81506. */
  81507. loop?: boolean;
  81508. private _target;
  81509. /**
  81510. * Instantiate the action
  81511. * @param triggerOptions defines the trigger options
  81512. * @param target defines the target animation or animation name
  81513. * @param from defines from where the animation should start (animation frame)
  81514. * @param end defines where the animation should stop (animation frame)
  81515. * @param loop defines if the animation should loop or stop after the first play
  81516. * @param condition defines the trigger related conditions
  81517. */
  81518. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  81519. /** @hidden */
  81520. _prepare(): void;
  81521. /**
  81522. * Execute the action and play the animation.
  81523. */
  81524. execute(): void;
  81525. /**
  81526. * Serializes the actions and its related information.
  81527. * @param parent defines the object to serialize in
  81528. * @returns the serialized object
  81529. */
  81530. serialize(parent: any): any;
  81531. }
  81532. /**
  81533. * This defines an action responsible to stop an animation once triggered.
  81534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81535. */
  81536. export class StopAnimationAction extends Action {
  81537. private _target;
  81538. /**
  81539. * Instantiate the action
  81540. * @param triggerOptions defines the trigger options
  81541. * @param target defines the target animation or animation name
  81542. * @param condition defines the trigger related conditions
  81543. */
  81544. constructor(triggerOptions: any, target: any, condition?: Condition);
  81545. /** @hidden */
  81546. _prepare(): void;
  81547. /**
  81548. * Execute the action and stop the animation.
  81549. */
  81550. execute(): void;
  81551. /**
  81552. * Serializes the actions and its related information.
  81553. * @param parent defines the object to serialize in
  81554. * @returns the serialized object
  81555. */
  81556. serialize(parent: any): any;
  81557. }
  81558. /**
  81559. * This defines an action responsible that does nothing once triggered.
  81560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81561. */
  81562. export class DoNothingAction extends Action {
  81563. /**
  81564. * Instantiate the action
  81565. * @param triggerOptions defines the trigger options
  81566. * @param condition defines the trigger related conditions
  81567. */
  81568. constructor(triggerOptions?: any, condition?: Condition);
  81569. /**
  81570. * Execute the action and do nothing.
  81571. */
  81572. execute(): void;
  81573. /**
  81574. * Serializes the actions and its related information.
  81575. * @param parent defines the object to serialize in
  81576. * @returns the serialized object
  81577. */
  81578. serialize(parent: any): any;
  81579. }
  81580. /**
  81581. * This defines an action responsible to trigger several actions once triggered.
  81582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81583. */
  81584. export class CombineAction extends Action {
  81585. /**
  81586. * The list of aggregated animations to run.
  81587. */
  81588. children: Action[];
  81589. /**
  81590. * Instantiate the action
  81591. * @param triggerOptions defines the trigger options
  81592. * @param children defines the list of aggregated animations to run
  81593. * @param condition defines the trigger related conditions
  81594. */
  81595. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  81596. /** @hidden */
  81597. _prepare(): void;
  81598. /**
  81599. * Execute the action and executes all the aggregated actions.
  81600. */
  81601. execute(evt: ActionEvent): void;
  81602. /**
  81603. * Serializes the actions and its related information.
  81604. * @param parent defines the object to serialize in
  81605. * @returns the serialized object
  81606. */
  81607. serialize(parent: any): any;
  81608. }
  81609. /**
  81610. * This defines an action responsible to run code (external event) once triggered.
  81611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81612. */
  81613. export class ExecuteCodeAction extends Action {
  81614. /**
  81615. * The callback function to run.
  81616. */
  81617. func: (evt: ActionEvent) => void;
  81618. /**
  81619. * Instantiate the action
  81620. * @param triggerOptions defines the trigger options
  81621. * @param func defines the callback function to run
  81622. * @param condition defines the trigger related conditions
  81623. */
  81624. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  81625. /**
  81626. * Execute the action and run the attached code.
  81627. */
  81628. execute(evt: ActionEvent): void;
  81629. }
  81630. /**
  81631. * This defines an action responsible to set the parent property of the target once triggered.
  81632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81633. */
  81634. export class SetParentAction extends Action {
  81635. private _parent;
  81636. private _target;
  81637. /**
  81638. * Instantiate the action
  81639. * @param triggerOptions defines the trigger options
  81640. * @param target defines the target containing the parent property
  81641. * @param parent defines from where the animation should start (animation frame)
  81642. * @param condition defines the trigger related conditions
  81643. */
  81644. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  81645. /** @hidden */
  81646. _prepare(): void;
  81647. /**
  81648. * Execute the action and set the parent property.
  81649. */
  81650. execute(): void;
  81651. /**
  81652. * Serializes the actions and its related information.
  81653. * @param parent defines the object to serialize in
  81654. * @returns the serialized object
  81655. */
  81656. serialize(parent: any): any;
  81657. }
  81658. }
  81659. declare module BABYLON {
  81660. /**
  81661. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  81662. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  81663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81664. */
  81665. export class ActionManager extends AbstractActionManager {
  81666. /**
  81667. * Nothing
  81668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81669. */
  81670. static readonly NothingTrigger: number;
  81671. /**
  81672. * On pick
  81673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81674. */
  81675. static readonly OnPickTrigger: number;
  81676. /**
  81677. * On left pick
  81678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81679. */
  81680. static readonly OnLeftPickTrigger: number;
  81681. /**
  81682. * On right pick
  81683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81684. */
  81685. static readonly OnRightPickTrigger: number;
  81686. /**
  81687. * On center pick
  81688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81689. */
  81690. static readonly OnCenterPickTrigger: number;
  81691. /**
  81692. * On pick down
  81693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81694. */
  81695. static readonly OnPickDownTrigger: number;
  81696. /**
  81697. * On double pick
  81698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81699. */
  81700. static readonly OnDoublePickTrigger: number;
  81701. /**
  81702. * On pick up
  81703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81704. */
  81705. static readonly OnPickUpTrigger: number;
  81706. /**
  81707. * On pick out.
  81708. * This trigger will only be raised if you also declared a OnPickDown
  81709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81710. */
  81711. static readonly OnPickOutTrigger: number;
  81712. /**
  81713. * On long press
  81714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81715. */
  81716. static readonly OnLongPressTrigger: number;
  81717. /**
  81718. * On pointer over
  81719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81720. */
  81721. static readonly OnPointerOverTrigger: number;
  81722. /**
  81723. * On pointer out
  81724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81725. */
  81726. static readonly OnPointerOutTrigger: number;
  81727. /**
  81728. * On every frame
  81729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81730. */
  81731. static readonly OnEveryFrameTrigger: number;
  81732. /**
  81733. * On intersection enter
  81734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81735. */
  81736. static readonly OnIntersectionEnterTrigger: number;
  81737. /**
  81738. * On intersection exit
  81739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81740. */
  81741. static readonly OnIntersectionExitTrigger: number;
  81742. /**
  81743. * On key down
  81744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81745. */
  81746. static readonly OnKeyDownTrigger: number;
  81747. /**
  81748. * On key up
  81749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81750. */
  81751. static readonly OnKeyUpTrigger: number;
  81752. private _scene;
  81753. /**
  81754. * Creates a new action manager
  81755. * @param scene defines the hosting scene
  81756. */
  81757. constructor(scene: Scene);
  81758. /**
  81759. * Releases all associated resources
  81760. */
  81761. dispose(): void;
  81762. /**
  81763. * Gets hosting scene
  81764. * @returns the hosting scene
  81765. */
  81766. getScene(): Scene;
  81767. /**
  81768. * Does this action manager handles actions of any of the given triggers
  81769. * @param triggers defines the triggers to be tested
  81770. * @return a boolean indicating whether one (or more) of the triggers is handled
  81771. */
  81772. hasSpecificTriggers(triggers: number[]): boolean;
  81773. /**
  81774. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81775. * speed.
  81776. * @param triggerA defines the trigger to be tested
  81777. * @param triggerB defines the trigger to be tested
  81778. * @return a boolean indicating whether one (or more) of the triggers is handled
  81779. */
  81780. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81781. /**
  81782. * Does this action manager handles actions of a given trigger
  81783. * @param trigger defines the trigger to be tested
  81784. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81785. * @return whether the trigger is handled
  81786. */
  81787. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81788. /**
  81789. * Does this action manager has pointer triggers
  81790. */
  81791. get hasPointerTriggers(): boolean;
  81792. /**
  81793. * Does this action manager has pick triggers
  81794. */
  81795. get hasPickTriggers(): boolean;
  81796. /**
  81797. * Registers an action to this action manager
  81798. * @param action defines the action to be registered
  81799. * @return the action amended (prepared) after registration
  81800. */
  81801. registerAction(action: IAction): Nullable<IAction>;
  81802. /**
  81803. * Unregisters an action to this action manager
  81804. * @param action defines the action to be unregistered
  81805. * @return a boolean indicating whether the action has been unregistered
  81806. */
  81807. unregisterAction(action: IAction): Boolean;
  81808. /**
  81809. * Process a specific trigger
  81810. * @param trigger defines the trigger to process
  81811. * @param evt defines the event details to be processed
  81812. */
  81813. processTrigger(trigger: number, evt?: IActionEvent): void;
  81814. /** @hidden */
  81815. _getEffectiveTarget(target: any, propertyPath: string): any;
  81816. /** @hidden */
  81817. _getProperty(propertyPath: string): string;
  81818. /**
  81819. * Serialize this manager to a JSON object
  81820. * @param name defines the property name to store this manager
  81821. * @returns a JSON representation of this manager
  81822. */
  81823. serialize(name: string): any;
  81824. /**
  81825. * Creates a new ActionManager from a JSON data
  81826. * @param parsedActions defines the JSON data to read from
  81827. * @param object defines the hosting mesh
  81828. * @param scene defines the hosting scene
  81829. */
  81830. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  81831. /**
  81832. * Get a trigger name by index
  81833. * @param trigger defines the trigger index
  81834. * @returns a trigger name
  81835. */
  81836. static GetTriggerName(trigger: number): string;
  81837. }
  81838. }
  81839. declare module BABYLON {
  81840. /**
  81841. * Class representing a ray with position and direction
  81842. */
  81843. export class Ray {
  81844. /** origin point */
  81845. origin: Vector3;
  81846. /** direction */
  81847. direction: Vector3;
  81848. /** length of the ray */
  81849. length: number;
  81850. private static readonly TmpVector3;
  81851. private _tmpRay;
  81852. /**
  81853. * Creates a new ray
  81854. * @param origin origin point
  81855. * @param direction direction
  81856. * @param length length of the ray
  81857. */
  81858. constructor(
  81859. /** origin point */
  81860. origin: Vector3,
  81861. /** direction */
  81862. direction: Vector3,
  81863. /** length of the ray */
  81864. length?: number);
  81865. /**
  81866. * Checks if the ray intersects a box
  81867. * @param minimum bound of the box
  81868. * @param maximum bound of the box
  81869. * @param intersectionTreshold extra extend to be added to the box in all direction
  81870. * @returns if the box was hit
  81871. */
  81872. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  81873. /**
  81874. * Checks if the ray intersects a box
  81875. * @param box the bounding box to check
  81876. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  81877. * @returns if the box was hit
  81878. */
  81879. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  81880. /**
  81881. * If the ray hits a sphere
  81882. * @param sphere the bounding sphere to check
  81883. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  81884. * @returns true if it hits the sphere
  81885. */
  81886. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  81887. /**
  81888. * If the ray hits a triange
  81889. * @param vertex0 triangle vertex
  81890. * @param vertex1 triangle vertex
  81891. * @param vertex2 triangle vertex
  81892. * @returns intersection information if hit
  81893. */
  81894. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  81895. /**
  81896. * Checks if ray intersects a plane
  81897. * @param plane the plane to check
  81898. * @returns the distance away it was hit
  81899. */
  81900. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  81901. /**
  81902. * Calculate the intercept of a ray on a given axis
  81903. * @param axis to check 'x' | 'y' | 'z'
  81904. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  81905. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  81906. */
  81907. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  81908. /**
  81909. * Checks if ray intersects a mesh
  81910. * @param mesh the mesh to check
  81911. * @param fastCheck if only the bounding box should checked
  81912. * @returns picking info of the intersecton
  81913. */
  81914. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  81915. /**
  81916. * Checks if ray intersects a mesh
  81917. * @param meshes the meshes to check
  81918. * @param fastCheck if only the bounding box should checked
  81919. * @param results array to store result in
  81920. * @returns Array of picking infos
  81921. */
  81922. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  81923. private _comparePickingInfo;
  81924. private static smallnum;
  81925. private static rayl;
  81926. /**
  81927. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  81928. * @param sega the first point of the segment to test the intersection against
  81929. * @param segb the second point of the segment to test the intersection against
  81930. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  81931. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  81932. */
  81933. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  81934. /**
  81935. * Update the ray from viewport position
  81936. * @param x position
  81937. * @param y y position
  81938. * @param viewportWidth viewport width
  81939. * @param viewportHeight viewport height
  81940. * @param world world matrix
  81941. * @param view view matrix
  81942. * @param projection projection matrix
  81943. * @returns this ray updated
  81944. */
  81945. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81946. /**
  81947. * Creates a ray with origin and direction of 0,0,0
  81948. * @returns the new ray
  81949. */
  81950. static Zero(): Ray;
  81951. /**
  81952. * Creates a new ray from screen space and viewport
  81953. * @param x position
  81954. * @param y y position
  81955. * @param viewportWidth viewport width
  81956. * @param viewportHeight viewport height
  81957. * @param world world matrix
  81958. * @param view view matrix
  81959. * @param projection projection matrix
  81960. * @returns new ray
  81961. */
  81962. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81963. /**
  81964. * 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
  81965. * transformed to the given world matrix.
  81966. * @param origin The origin point
  81967. * @param end The end point
  81968. * @param world a matrix to transform the ray to. Default is the identity matrix.
  81969. * @returns the new ray
  81970. */
  81971. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  81972. /**
  81973. * Transforms a ray by a matrix
  81974. * @param ray ray to transform
  81975. * @param matrix matrix to apply
  81976. * @returns the resulting new ray
  81977. */
  81978. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  81979. /**
  81980. * Transforms a ray by a matrix
  81981. * @param ray ray to transform
  81982. * @param matrix matrix to apply
  81983. * @param result ray to store result in
  81984. */
  81985. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  81986. /**
  81987. * Unproject a ray from screen space to object space
  81988. * @param sourceX defines the screen space x coordinate to use
  81989. * @param sourceY defines the screen space y coordinate to use
  81990. * @param viewportWidth defines the current width of the viewport
  81991. * @param viewportHeight defines the current height of the viewport
  81992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81993. * @param view defines the view matrix to use
  81994. * @param projection defines the projection matrix to use
  81995. */
  81996. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  81997. }
  81998. /**
  81999. * Type used to define predicate used to select faces when a mesh intersection is detected
  82000. */
  82001. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82002. interface Scene {
  82003. /** @hidden */
  82004. _tempPickingRay: Nullable<Ray>;
  82005. /** @hidden */
  82006. _cachedRayForTransform: Ray;
  82007. /** @hidden */
  82008. _pickWithRayInverseMatrix: Matrix;
  82009. /** @hidden */
  82010. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82011. /** @hidden */
  82012. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82013. }
  82014. }
  82015. declare module BABYLON {
  82016. /**
  82017. * Groups all the scene component constants in one place to ease maintenance.
  82018. * @hidden
  82019. */
  82020. export class SceneComponentConstants {
  82021. static readonly NAME_EFFECTLAYER: string;
  82022. static readonly NAME_LAYER: string;
  82023. static readonly NAME_LENSFLARESYSTEM: string;
  82024. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82025. static readonly NAME_PARTICLESYSTEM: string;
  82026. static readonly NAME_GAMEPAD: string;
  82027. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82028. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82029. static readonly NAME_DEPTHRENDERER: string;
  82030. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82031. static readonly NAME_SPRITE: string;
  82032. static readonly NAME_OUTLINERENDERER: string;
  82033. static readonly NAME_PROCEDURALTEXTURE: string;
  82034. static readonly NAME_SHADOWGENERATOR: string;
  82035. static readonly NAME_OCTREE: string;
  82036. static readonly NAME_PHYSICSENGINE: string;
  82037. static readonly NAME_AUDIO: string;
  82038. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82039. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82040. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82041. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82042. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82043. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82044. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82045. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82046. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82047. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82048. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82049. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82050. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82051. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82052. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82053. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82054. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82055. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82056. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82057. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82058. static readonly STEP_AFTERRENDER_AUDIO: number;
  82059. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82060. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82061. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82062. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82063. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82064. static readonly STEP_POINTERMOVE_SPRITE: number;
  82065. static readonly STEP_POINTERDOWN_SPRITE: number;
  82066. static readonly STEP_POINTERUP_SPRITE: number;
  82067. }
  82068. /**
  82069. * This represents a scene component.
  82070. *
  82071. * This is used to decouple the dependency the scene is having on the different workloads like
  82072. * layers, post processes...
  82073. */
  82074. export interface ISceneComponent {
  82075. /**
  82076. * The name of the component. Each component must have a unique name.
  82077. */
  82078. name: string;
  82079. /**
  82080. * The scene the component belongs to.
  82081. */
  82082. scene: Scene;
  82083. /**
  82084. * Register the component to one instance of a scene.
  82085. */
  82086. register(): void;
  82087. /**
  82088. * Rebuilds the elements related to this component in case of
  82089. * context lost for instance.
  82090. */
  82091. rebuild(): void;
  82092. /**
  82093. * Disposes the component and the associated ressources.
  82094. */
  82095. dispose(): void;
  82096. }
  82097. /**
  82098. * This represents a SERIALIZABLE scene component.
  82099. *
  82100. * This extends Scene Component to add Serialization methods on top.
  82101. */
  82102. export interface ISceneSerializableComponent extends ISceneComponent {
  82103. /**
  82104. * Adds all the elements from the container to the scene
  82105. * @param container the container holding the elements
  82106. */
  82107. addFromContainer(container: AbstractScene): void;
  82108. /**
  82109. * Removes all the elements in the container from the scene
  82110. * @param container contains the elements to remove
  82111. * @param dispose if the removed element should be disposed (default: false)
  82112. */
  82113. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82114. /**
  82115. * Serializes the component data to the specified json object
  82116. * @param serializationObject The object to serialize to
  82117. */
  82118. serialize(serializationObject: any): void;
  82119. }
  82120. /**
  82121. * Strong typing of a Mesh related stage step action
  82122. */
  82123. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82124. /**
  82125. * Strong typing of a Evaluate Sub Mesh related stage step action
  82126. */
  82127. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82128. /**
  82129. * Strong typing of a Active Mesh related stage step action
  82130. */
  82131. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82132. /**
  82133. * Strong typing of a Camera related stage step action
  82134. */
  82135. export type CameraStageAction = (camera: Camera) => void;
  82136. /**
  82137. * Strong typing of a Camera Frame buffer related stage step action
  82138. */
  82139. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82140. /**
  82141. * Strong typing of a Render Target related stage step action
  82142. */
  82143. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82144. /**
  82145. * Strong typing of a RenderingGroup related stage step action
  82146. */
  82147. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82148. /**
  82149. * Strong typing of a Mesh Render related stage step action
  82150. */
  82151. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82152. /**
  82153. * Strong typing of a simple stage step action
  82154. */
  82155. export type SimpleStageAction = () => void;
  82156. /**
  82157. * Strong typing of a render target action.
  82158. */
  82159. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82160. /**
  82161. * Strong typing of a pointer move action.
  82162. */
  82163. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82164. /**
  82165. * Strong typing of a pointer up/down action.
  82166. */
  82167. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82168. /**
  82169. * Representation of a stage in the scene (Basically a list of ordered steps)
  82170. * @hidden
  82171. */
  82172. export class Stage<T extends Function> extends Array<{
  82173. index: number;
  82174. component: ISceneComponent;
  82175. action: T;
  82176. }> {
  82177. /**
  82178. * Hide ctor from the rest of the world.
  82179. * @param items The items to add.
  82180. */
  82181. private constructor();
  82182. /**
  82183. * Creates a new Stage.
  82184. * @returns A new instance of a Stage
  82185. */
  82186. static Create<T extends Function>(): Stage<T>;
  82187. /**
  82188. * Registers a step in an ordered way in the targeted stage.
  82189. * @param index Defines the position to register the step in
  82190. * @param component Defines the component attached to the step
  82191. * @param action Defines the action to launch during the step
  82192. */
  82193. registerStep(index: number, component: ISceneComponent, action: T): void;
  82194. /**
  82195. * Clears all the steps from the stage.
  82196. */
  82197. clear(): void;
  82198. }
  82199. }
  82200. declare module BABYLON {
  82201. interface Scene {
  82202. /** @hidden */
  82203. _pointerOverSprite: Nullable<Sprite>;
  82204. /** @hidden */
  82205. _pickedDownSprite: Nullable<Sprite>;
  82206. /** @hidden */
  82207. _tempSpritePickingRay: Nullable<Ray>;
  82208. /**
  82209. * All of the sprite managers added to this scene
  82210. * @see http://doc.babylonjs.com/babylon101/sprites
  82211. */
  82212. spriteManagers: Array<ISpriteManager>;
  82213. /**
  82214. * An event triggered when sprites rendering is about to start
  82215. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82216. */
  82217. onBeforeSpritesRenderingObservable: Observable<Scene>;
  82218. /**
  82219. * An event triggered when sprites rendering is done
  82220. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82221. */
  82222. onAfterSpritesRenderingObservable: Observable<Scene>;
  82223. /** @hidden */
  82224. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82225. /** Launch a ray to try to pick a sprite in the scene
  82226. * @param x position on screen
  82227. * @param y position on screen
  82228. * @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
  82229. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82230. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82231. * @returns a PickingInfo
  82232. */
  82233. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82234. /** Use the given ray to pick a sprite in the scene
  82235. * @param ray The ray (in world space) to use to pick meshes
  82236. * @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
  82237. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82238. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82239. * @returns a PickingInfo
  82240. */
  82241. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82242. /** @hidden */
  82243. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82244. /** Launch a ray to try to pick sprites in the scene
  82245. * @param x position on screen
  82246. * @param y position on screen
  82247. * @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
  82248. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82249. * @returns a PickingInfo array
  82250. */
  82251. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82252. /** Use the given ray to pick sprites in the scene
  82253. * @param ray The ray (in world space) to use to pick meshes
  82254. * @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
  82255. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82256. * @returns a PickingInfo array
  82257. */
  82258. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82259. /**
  82260. * Force the sprite under the pointer
  82261. * @param sprite defines the sprite to use
  82262. */
  82263. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  82264. /**
  82265. * Gets the sprite under the pointer
  82266. * @returns a Sprite or null if no sprite is under the pointer
  82267. */
  82268. getPointerOverSprite(): Nullable<Sprite>;
  82269. }
  82270. /**
  82271. * Defines the sprite scene component responsible to manage sprites
  82272. * in a given scene.
  82273. */
  82274. export class SpriteSceneComponent implements ISceneComponent {
  82275. /**
  82276. * The component name helpfull to identify the component in the list of scene components.
  82277. */
  82278. readonly name: string;
  82279. /**
  82280. * The scene the component belongs to.
  82281. */
  82282. scene: Scene;
  82283. /** @hidden */
  82284. private _spritePredicate;
  82285. /**
  82286. * Creates a new instance of the component for the given scene
  82287. * @param scene Defines the scene to register the component in
  82288. */
  82289. constructor(scene: Scene);
  82290. /**
  82291. * Registers the component in a given scene
  82292. */
  82293. register(): void;
  82294. /**
  82295. * Rebuilds the elements related to this component in case of
  82296. * context lost for instance.
  82297. */
  82298. rebuild(): void;
  82299. /**
  82300. * Disposes the component and the associated ressources.
  82301. */
  82302. dispose(): void;
  82303. private _pickSpriteButKeepRay;
  82304. private _pointerMove;
  82305. private _pointerDown;
  82306. private _pointerUp;
  82307. }
  82308. }
  82309. declare module BABYLON {
  82310. /** @hidden */
  82311. export var fogFragmentDeclaration: {
  82312. name: string;
  82313. shader: string;
  82314. };
  82315. }
  82316. declare module BABYLON {
  82317. /** @hidden */
  82318. export var fogFragment: {
  82319. name: string;
  82320. shader: string;
  82321. };
  82322. }
  82323. declare module BABYLON {
  82324. /** @hidden */
  82325. export var spritesPixelShader: {
  82326. name: string;
  82327. shader: string;
  82328. };
  82329. }
  82330. declare module BABYLON {
  82331. /** @hidden */
  82332. export var fogVertexDeclaration: {
  82333. name: string;
  82334. shader: string;
  82335. };
  82336. }
  82337. declare module BABYLON {
  82338. /** @hidden */
  82339. export var spritesVertexShader: {
  82340. name: string;
  82341. shader: string;
  82342. };
  82343. }
  82344. declare module BABYLON {
  82345. /**
  82346. * Defines the minimum interface to fullfil in order to be a sprite manager.
  82347. */
  82348. export interface ISpriteManager extends IDisposable {
  82349. /**
  82350. * Restricts the camera to viewing objects with the same layerMask.
  82351. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  82352. */
  82353. layerMask: number;
  82354. /**
  82355. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82356. */
  82357. isPickable: boolean;
  82358. /**
  82359. * Specifies the rendering group id for this mesh (0 by default)
  82360. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82361. */
  82362. renderingGroupId: number;
  82363. /**
  82364. * Defines the list of sprites managed by the manager.
  82365. */
  82366. sprites: Array<Sprite>;
  82367. /**
  82368. * Tests the intersection of a sprite with a specific ray.
  82369. * @param ray The ray we are sending to test the collision
  82370. * @param camera The camera space we are sending rays in
  82371. * @param predicate A predicate allowing excluding sprites from the list of object to test
  82372. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  82373. * @returns picking info or null.
  82374. */
  82375. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82376. /**
  82377. * Intersects the sprites with a ray
  82378. * @param ray defines the ray to intersect with
  82379. * @param camera defines the current active camera
  82380. * @param predicate defines a predicate used to select candidate sprites
  82381. * @returns null if no hit or a PickingInfo array
  82382. */
  82383. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82384. /**
  82385. * Renders the list of sprites on screen.
  82386. */
  82387. render(): void;
  82388. }
  82389. /**
  82390. * Class used to manage multiple sprites on the same spritesheet
  82391. * @see http://doc.babylonjs.com/babylon101/sprites
  82392. */
  82393. export class SpriteManager implements ISpriteManager {
  82394. /** defines the manager's name */
  82395. name: string;
  82396. /** Gets the list of sprites */
  82397. sprites: Sprite[];
  82398. /** Gets or sets the rendering group id (0 by default) */
  82399. renderingGroupId: number;
  82400. /** Gets or sets camera layer mask */
  82401. layerMask: number;
  82402. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  82403. fogEnabled: boolean;
  82404. /** Gets or sets a boolean indicating if the sprites are pickable */
  82405. isPickable: boolean;
  82406. /** Defines the default width of a cell in the spritesheet */
  82407. cellWidth: number;
  82408. /** Defines the default height of a cell in the spritesheet */
  82409. cellHeight: number;
  82410. /** Associative array from JSON sprite data file */
  82411. private _cellData;
  82412. /** Array of sprite names from JSON sprite data file */
  82413. private _spriteMap;
  82414. /** True when packed cell data from JSON file is ready*/
  82415. private _packedAndReady;
  82416. /**
  82417. * An event triggered when the manager is disposed.
  82418. */
  82419. onDisposeObservable: Observable<SpriteManager>;
  82420. private _onDisposeObserver;
  82421. /**
  82422. * Callback called when the manager is disposed
  82423. */
  82424. set onDispose(callback: () => void);
  82425. private _capacity;
  82426. private _fromPacked;
  82427. private _spriteTexture;
  82428. private _epsilon;
  82429. private _scene;
  82430. private _vertexData;
  82431. private _buffer;
  82432. private _vertexBuffers;
  82433. private _indexBuffer;
  82434. private _effectBase;
  82435. private _effectFog;
  82436. /**
  82437. * Gets or sets the spritesheet texture
  82438. */
  82439. get texture(): Texture;
  82440. set texture(value: Texture);
  82441. /**
  82442. * Creates a new sprite manager
  82443. * @param name defines the manager's name
  82444. * @param imgUrl defines the sprite sheet url
  82445. * @param capacity defines the maximum allowed number of sprites
  82446. * @param cellSize defines the size of a sprite cell
  82447. * @param scene defines the hosting scene
  82448. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  82449. * @param samplingMode defines the smapling mode to use with spritesheet
  82450. * @param fromPacked set to false; do not alter
  82451. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  82452. */
  82453. constructor(
  82454. /** defines the manager's name */
  82455. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  82456. private _makePacked;
  82457. private _appendSpriteVertex;
  82458. /**
  82459. * Intersects the sprites with a ray
  82460. * @param ray defines the ray to intersect with
  82461. * @param camera defines the current active camera
  82462. * @param predicate defines a predicate used to select candidate sprites
  82463. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  82464. * @returns null if no hit or a PickingInfo
  82465. */
  82466. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82467. /**
  82468. * Intersects the sprites with a ray
  82469. * @param ray defines the ray to intersect with
  82470. * @param camera defines the current active camera
  82471. * @param predicate defines a predicate used to select candidate sprites
  82472. * @returns null if no hit or a PickingInfo array
  82473. */
  82474. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82475. /**
  82476. * Render all child sprites
  82477. */
  82478. render(): void;
  82479. /**
  82480. * Release associated resources
  82481. */
  82482. dispose(): void;
  82483. }
  82484. }
  82485. declare module BABYLON {
  82486. /**
  82487. * Class used to represent a sprite
  82488. * @see http://doc.babylonjs.com/babylon101/sprites
  82489. */
  82490. export class Sprite {
  82491. /** defines the name */
  82492. name: string;
  82493. /** Gets or sets the current world position */
  82494. position: Vector3;
  82495. /** Gets or sets the main color */
  82496. color: Color4;
  82497. /** Gets or sets the width */
  82498. width: number;
  82499. /** Gets or sets the height */
  82500. height: number;
  82501. /** Gets or sets rotation angle */
  82502. angle: number;
  82503. /** Gets or sets the cell index in the sprite sheet */
  82504. cellIndex: number;
  82505. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  82506. cellRef: string;
  82507. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  82508. invertU: number;
  82509. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  82510. invertV: number;
  82511. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  82512. disposeWhenFinishedAnimating: boolean;
  82513. /** Gets the list of attached animations */
  82514. animations: Animation[];
  82515. /** Gets or sets a boolean indicating if the sprite can be picked */
  82516. isPickable: boolean;
  82517. /**
  82518. * Gets or sets the associated action manager
  82519. */
  82520. actionManager: Nullable<ActionManager>;
  82521. private _animationStarted;
  82522. private _loopAnimation;
  82523. private _fromIndex;
  82524. private _toIndex;
  82525. private _delay;
  82526. private _direction;
  82527. private _manager;
  82528. private _time;
  82529. private _onAnimationEnd;
  82530. /**
  82531. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  82532. */
  82533. isVisible: boolean;
  82534. /**
  82535. * Gets or sets the sprite size
  82536. */
  82537. get size(): number;
  82538. set size(value: number);
  82539. /**
  82540. * Creates a new Sprite
  82541. * @param name defines the name
  82542. * @param manager defines the manager
  82543. */
  82544. constructor(
  82545. /** defines the name */
  82546. name: string, manager: ISpriteManager);
  82547. /**
  82548. * Starts an animation
  82549. * @param from defines the initial key
  82550. * @param to defines the end key
  82551. * @param loop defines if the animation must loop
  82552. * @param delay defines the start delay (in ms)
  82553. * @param onAnimationEnd defines a callback to call when animation ends
  82554. */
  82555. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  82556. /** Stops current animation (if any) */
  82557. stopAnimation(): void;
  82558. /** @hidden */
  82559. _animate(deltaTime: number): void;
  82560. /** Release associated resources */
  82561. dispose(): void;
  82562. }
  82563. }
  82564. declare module BABYLON {
  82565. /**
  82566. * Information about the result of picking within a scene
  82567. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  82568. */
  82569. export class PickingInfo {
  82570. /** @hidden */
  82571. _pickingUnavailable: boolean;
  82572. /**
  82573. * If the pick collided with an object
  82574. */
  82575. hit: boolean;
  82576. /**
  82577. * Distance away where the pick collided
  82578. */
  82579. distance: number;
  82580. /**
  82581. * The location of pick collision
  82582. */
  82583. pickedPoint: Nullable<Vector3>;
  82584. /**
  82585. * The mesh corresponding the the pick collision
  82586. */
  82587. pickedMesh: Nullable<AbstractMesh>;
  82588. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  82589. bu: number;
  82590. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  82591. bv: number;
  82592. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  82593. faceId: number;
  82594. /** Id of the the submesh that was picked */
  82595. subMeshId: number;
  82596. /** If a sprite was picked, this will be the sprite the pick collided with */
  82597. pickedSprite: Nullable<Sprite>;
  82598. /**
  82599. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  82600. */
  82601. originMesh: Nullable<AbstractMesh>;
  82602. /**
  82603. * The ray that was used to perform the picking.
  82604. */
  82605. ray: Nullable<Ray>;
  82606. /**
  82607. * Gets the normal correspodning to the face the pick collided with
  82608. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  82609. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  82610. * @returns The normal correspodning to the face the pick collided with
  82611. */
  82612. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  82613. /**
  82614. * Gets the texture coordinates of where the pick occured
  82615. * @returns the vector containing the coordnates of the texture
  82616. */
  82617. getTextureCoordinates(): Nullable<Vector2>;
  82618. }
  82619. }
  82620. declare module BABYLON {
  82621. /**
  82622. * Gather the list of pointer event types as constants.
  82623. */
  82624. export class PointerEventTypes {
  82625. /**
  82626. * 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.
  82627. */
  82628. static readonly POINTERDOWN: number;
  82629. /**
  82630. * The pointerup event is fired when a pointer is no longer active.
  82631. */
  82632. static readonly POINTERUP: number;
  82633. /**
  82634. * The pointermove event is fired when a pointer changes coordinates.
  82635. */
  82636. static readonly POINTERMOVE: number;
  82637. /**
  82638. * The pointerwheel event is fired when a mouse wheel has been rotated.
  82639. */
  82640. static readonly POINTERWHEEL: number;
  82641. /**
  82642. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  82643. */
  82644. static readonly POINTERPICK: number;
  82645. /**
  82646. * The pointertap event is fired when a the object has been touched and released without drag.
  82647. */
  82648. static readonly POINTERTAP: number;
  82649. /**
  82650. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  82651. */
  82652. static readonly POINTERDOUBLETAP: number;
  82653. }
  82654. /**
  82655. * Base class of pointer info types.
  82656. */
  82657. export class PointerInfoBase {
  82658. /**
  82659. * Defines the type of event (PointerEventTypes)
  82660. */
  82661. type: number;
  82662. /**
  82663. * Defines the related dom event
  82664. */
  82665. event: PointerEvent | MouseWheelEvent;
  82666. /**
  82667. * Instantiates the base class of pointers info.
  82668. * @param type Defines the type of event (PointerEventTypes)
  82669. * @param event Defines the related dom event
  82670. */
  82671. constructor(
  82672. /**
  82673. * Defines the type of event (PointerEventTypes)
  82674. */
  82675. type: number,
  82676. /**
  82677. * Defines the related dom event
  82678. */
  82679. event: PointerEvent | MouseWheelEvent);
  82680. }
  82681. /**
  82682. * This class is used to store pointer related info for the onPrePointerObservable event.
  82683. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  82684. */
  82685. export class PointerInfoPre extends PointerInfoBase {
  82686. /**
  82687. * Ray from a pointer if availible (eg. 6dof controller)
  82688. */
  82689. ray: Nullable<Ray>;
  82690. /**
  82691. * Defines the local position of the pointer on the canvas.
  82692. */
  82693. localPosition: Vector2;
  82694. /**
  82695. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  82696. */
  82697. skipOnPointerObservable: boolean;
  82698. /**
  82699. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  82700. * @param type Defines the type of event (PointerEventTypes)
  82701. * @param event Defines the related dom event
  82702. * @param localX Defines the local x coordinates of the pointer when the event occured
  82703. * @param localY Defines the local y coordinates of the pointer when the event occured
  82704. */
  82705. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  82706. }
  82707. /**
  82708. * This type contains all the data related to a pointer event in Babylon.js.
  82709. * 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.
  82710. */
  82711. export class PointerInfo extends PointerInfoBase {
  82712. /**
  82713. * Defines the picking info associated to the info (if any)\
  82714. */
  82715. pickInfo: Nullable<PickingInfo>;
  82716. /**
  82717. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  82718. * @param type Defines the type of event (PointerEventTypes)
  82719. * @param event Defines the related dom event
  82720. * @param pickInfo Defines the picking info associated to the info (if any)\
  82721. */
  82722. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  82723. /**
  82724. * Defines the picking info associated to the info (if any)\
  82725. */
  82726. pickInfo: Nullable<PickingInfo>);
  82727. }
  82728. /**
  82729. * Data relating to a touch event on the screen.
  82730. */
  82731. export interface PointerTouch {
  82732. /**
  82733. * X coordinate of touch.
  82734. */
  82735. x: number;
  82736. /**
  82737. * Y coordinate of touch.
  82738. */
  82739. y: number;
  82740. /**
  82741. * Id of touch. Unique for each finger.
  82742. */
  82743. pointerId: number;
  82744. /**
  82745. * Event type passed from DOM.
  82746. */
  82747. type: any;
  82748. }
  82749. }
  82750. declare module BABYLON {
  82751. /**
  82752. * Manage the mouse inputs to control the movement of a free camera.
  82753. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82754. */
  82755. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  82756. /**
  82757. * Define if touch is enabled in the mouse input
  82758. */
  82759. touchEnabled: boolean;
  82760. /**
  82761. * Defines the camera the input is attached to.
  82762. */
  82763. camera: FreeCamera;
  82764. /**
  82765. * Defines the buttons associated with the input to handle camera move.
  82766. */
  82767. buttons: number[];
  82768. /**
  82769. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  82770. */
  82771. angularSensibility: number;
  82772. private _pointerInput;
  82773. private _onMouseMove;
  82774. private _observer;
  82775. private previousPosition;
  82776. /**
  82777. * Observable for when a pointer move event occurs containing the move offset
  82778. */
  82779. onPointerMovedObservable: Observable<{
  82780. offsetX: number;
  82781. offsetY: number;
  82782. }>;
  82783. /**
  82784. * @hidden
  82785. * If the camera should be rotated automatically based on pointer movement
  82786. */
  82787. _allowCameraRotation: boolean;
  82788. /**
  82789. * Manage the mouse inputs to control the movement of a free camera.
  82790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82791. * @param touchEnabled Defines if touch is enabled or not
  82792. */
  82793. constructor(
  82794. /**
  82795. * Define if touch is enabled in the mouse input
  82796. */
  82797. touchEnabled?: boolean);
  82798. /**
  82799. * Attach the input controls to a specific dom element to get the input from.
  82800. * @param element Defines the element the controls should be listened from
  82801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82802. */
  82803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82804. /**
  82805. * Called on JS contextmenu event.
  82806. * Override this method to provide functionality.
  82807. */
  82808. protected onContextMenu(evt: PointerEvent): void;
  82809. /**
  82810. * Detach the current controls from the specified dom element.
  82811. * @param element Defines the element to stop listening the inputs from
  82812. */
  82813. detachControl(element: Nullable<HTMLElement>): void;
  82814. /**
  82815. * Gets the class name of the current intput.
  82816. * @returns the class name
  82817. */
  82818. getClassName(): string;
  82819. /**
  82820. * Get the friendly name associated with the input class.
  82821. * @returns the input friendly name
  82822. */
  82823. getSimpleName(): string;
  82824. }
  82825. }
  82826. declare module BABYLON {
  82827. /**
  82828. * Manage the touch inputs to control the movement of a free camera.
  82829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82830. */
  82831. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  82832. /**
  82833. * Defines the camera the input is attached to.
  82834. */
  82835. camera: FreeCamera;
  82836. /**
  82837. * Defines the touch sensibility for rotation.
  82838. * The higher the faster.
  82839. */
  82840. touchAngularSensibility: number;
  82841. /**
  82842. * Defines the touch sensibility for move.
  82843. * The higher the faster.
  82844. */
  82845. touchMoveSensibility: number;
  82846. private _offsetX;
  82847. private _offsetY;
  82848. private _pointerPressed;
  82849. private _pointerInput;
  82850. private _observer;
  82851. private _onLostFocus;
  82852. /**
  82853. * Attach the input controls to a specific dom element to get the input from.
  82854. * @param element Defines the element the controls should be listened from
  82855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82856. */
  82857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82858. /**
  82859. * Detach the current controls from the specified dom element.
  82860. * @param element Defines the element to stop listening the inputs from
  82861. */
  82862. detachControl(element: Nullable<HTMLElement>): void;
  82863. /**
  82864. * Update the current camera state depending on the inputs that have been used this frame.
  82865. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82866. */
  82867. checkInputs(): void;
  82868. /**
  82869. * Gets the class name of the current intput.
  82870. * @returns the class name
  82871. */
  82872. getClassName(): string;
  82873. /**
  82874. * Get the friendly name associated with the input class.
  82875. * @returns the input friendly name
  82876. */
  82877. getSimpleName(): string;
  82878. }
  82879. }
  82880. declare module BABYLON {
  82881. /**
  82882. * Default Inputs manager for the FreeCamera.
  82883. * It groups all the default supported inputs for ease of use.
  82884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82885. */
  82886. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  82887. /**
  82888. * @hidden
  82889. */
  82890. _mouseInput: Nullable<FreeCameraMouseInput>;
  82891. /**
  82892. * Instantiates a new FreeCameraInputsManager.
  82893. * @param camera Defines the camera the inputs belong to
  82894. */
  82895. constructor(camera: FreeCamera);
  82896. /**
  82897. * Add keyboard input support to the input manager.
  82898. * @returns the current input manager
  82899. */
  82900. addKeyboard(): FreeCameraInputsManager;
  82901. /**
  82902. * Add mouse input support to the input manager.
  82903. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  82904. * @returns the current input manager
  82905. */
  82906. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  82907. /**
  82908. * Removes the mouse input support from the manager
  82909. * @returns the current input manager
  82910. */
  82911. removeMouse(): FreeCameraInputsManager;
  82912. /**
  82913. * Add touch input support to the input manager.
  82914. * @returns the current input manager
  82915. */
  82916. addTouch(): FreeCameraInputsManager;
  82917. /**
  82918. * Remove all attached input methods from a camera
  82919. */
  82920. clear(): void;
  82921. }
  82922. }
  82923. declare module BABYLON {
  82924. /**
  82925. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82926. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  82927. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82928. */
  82929. export class FreeCamera extends TargetCamera {
  82930. /**
  82931. * Define the collision ellipsoid of the camera.
  82932. * This is helpful to simulate a camera body like the player body around the camera
  82933. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  82934. */
  82935. ellipsoid: Vector3;
  82936. /**
  82937. * Define an offset for the position of the ellipsoid around the camera.
  82938. * This can be helpful to determine the center of the body near the gravity center of the body
  82939. * instead of its head.
  82940. */
  82941. ellipsoidOffset: Vector3;
  82942. /**
  82943. * Enable or disable collisions of the camera with the rest of the scene objects.
  82944. */
  82945. checkCollisions: boolean;
  82946. /**
  82947. * Enable or disable gravity on the camera.
  82948. */
  82949. applyGravity: boolean;
  82950. /**
  82951. * Define the input manager associated to the camera.
  82952. */
  82953. inputs: FreeCameraInputsManager;
  82954. /**
  82955. * Gets the input sensibility for a mouse input. (default is 2000.0)
  82956. * Higher values reduce sensitivity.
  82957. */
  82958. get angularSensibility(): number;
  82959. /**
  82960. * Sets the input sensibility for a mouse input. (default is 2000.0)
  82961. * Higher values reduce sensitivity.
  82962. */
  82963. set angularSensibility(value: number);
  82964. /**
  82965. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82966. */
  82967. get keysUp(): number[];
  82968. set keysUp(value: number[]);
  82969. /**
  82970. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82971. */
  82972. get keysDown(): number[];
  82973. set keysDown(value: number[]);
  82974. /**
  82975. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82976. */
  82977. get keysLeft(): number[];
  82978. set keysLeft(value: number[]);
  82979. /**
  82980. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82981. */
  82982. get keysRight(): number[];
  82983. set keysRight(value: number[]);
  82984. /**
  82985. * Event raised when the camera collide with a mesh in the scene.
  82986. */
  82987. onCollide: (collidedMesh: AbstractMesh) => void;
  82988. private _collider;
  82989. private _needMoveForGravity;
  82990. private _oldPosition;
  82991. private _diffPosition;
  82992. private _newPosition;
  82993. /** @hidden */
  82994. _localDirection: Vector3;
  82995. /** @hidden */
  82996. _transformedDirection: Vector3;
  82997. /**
  82998. * Instantiates a Free Camera.
  82999. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  83000. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  83001. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  83002. * @param name Define the name of the camera in the scene
  83003. * @param position Define the start position of the camera in the scene
  83004. * @param scene Define the scene the camera belongs to
  83005. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  83006. */
  83007. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  83008. /**
  83009. * Attached controls to the current camera.
  83010. * @param element Defines the element the controls should be listened from
  83011. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83012. */
  83013. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83014. /**
  83015. * Detach the current controls from the camera.
  83016. * The camera will stop reacting to inputs.
  83017. * @param element Defines the element to stop listening the inputs from
  83018. */
  83019. detachControl(element: HTMLElement): void;
  83020. private _collisionMask;
  83021. /**
  83022. * Define a collision mask to limit the list of object the camera can collide with
  83023. */
  83024. get collisionMask(): number;
  83025. set collisionMask(mask: number);
  83026. /** @hidden */
  83027. _collideWithWorld(displacement: Vector3): void;
  83028. private _onCollisionPositionChange;
  83029. /** @hidden */
  83030. _checkInputs(): void;
  83031. /** @hidden */
  83032. _decideIfNeedsToMove(): boolean;
  83033. /** @hidden */
  83034. _updatePosition(): void;
  83035. /**
  83036. * Destroy the camera and release the current resources hold by it.
  83037. */
  83038. dispose(): void;
  83039. /**
  83040. * Gets the current object class name.
  83041. * @return the class name
  83042. */
  83043. getClassName(): string;
  83044. }
  83045. }
  83046. declare module BABYLON {
  83047. /**
  83048. * Represents a gamepad control stick position
  83049. */
  83050. export class StickValues {
  83051. /**
  83052. * The x component of the control stick
  83053. */
  83054. x: number;
  83055. /**
  83056. * The y component of the control stick
  83057. */
  83058. y: number;
  83059. /**
  83060. * Initializes the gamepad x and y control stick values
  83061. * @param x The x component of the gamepad control stick value
  83062. * @param y The y component of the gamepad control stick value
  83063. */
  83064. constructor(
  83065. /**
  83066. * The x component of the control stick
  83067. */
  83068. x: number,
  83069. /**
  83070. * The y component of the control stick
  83071. */
  83072. y: number);
  83073. }
  83074. /**
  83075. * An interface which manages callbacks for gamepad button changes
  83076. */
  83077. export interface GamepadButtonChanges {
  83078. /**
  83079. * Called when a gamepad has been changed
  83080. */
  83081. changed: boolean;
  83082. /**
  83083. * Called when a gamepad press event has been triggered
  83084. */
  83085. pressChanged: boolean;
  83086. /**
  83087. * Called when a touch event has been triggered
  83088. */
  83089. touchChanged: boolean;
  83090. /**
  83091. * Called when a value has changed
  83092. */
  83093. valueChanged: boolean;
  83094. }
  83095. /**
  83096. * Represents a gamepad
  83097. */
  83098. export class Gamepad {
  83099. /**
  83100. * The id of the gamepad
  83101. */
  83102. id: string;
  83103. /**
  83104. * The index of the gamepad
  83105. */
  83106. index: number;
  83107. /**
  83108. * The browser gamepad
  83109. */
  83110. browserGamepad: any;
  83111. /**
  83112. * Specifies what type of gamepad this represents
  83113. */
  83114. type: number;
  83115. private _leftStick;
  83116. private _rightStick;
  83117. /** @hidden */
  83118. _isConnected: boolean;
  83119. private _leftStickAxisX;
  83120. private _leftStickAxisY;
  83121. private _rightStickAxisX;
  83122. private _rightStickAxisY;
  83123. /**
  83124. * Triggered when the left control stick has been changed
  83125. */
  83126. private _onleftstickchanged;
  83127. /**
  83128. * Triggered when the right control stick has been changed
  83129. */
  83130. private _onrightstickchanged;
  83131. /**
  83132. * Represents a gamepad controller
  83133. */
  83134. static GAMEPAD: number;
  83135. /**
  83136. * Represents a generic controller
  83137. */
  83138. static GENERIC: number;
  83139. /**
  83140. * Represents an XBox controller
  83141. */
  83142. static XBOX: number;
  83143. /**
  83144. * Represents a pose-enabled controller
  83145. */
  83146. static POSE_ENABLED: number;
  83147. /**
  83148. * Represents an Dual Shock controller
  83149. */
  83150. static DUALSHOCK: number;
  83151. /**
  83152. * Specifies whether the left control stick should be Y-inverted
  83153. */
  83154. protected _invertLeftStickY: boolean;
  83155. /**
  83156. * Specifies if the gamepad has been connected
  83157. */
  83158. get isConnected(): boolean;
  83159. /**
  83160. * Initializes the gamepad
  83161. * @param id The id of the gamepad
  83162. * @param index The index of the gamepad
  83163. * @param browserGamepad The browser gamepad
  83164. * @param leftStickX The x component of the left joystick
  83165. * @param leftStickY The y component of the left joystick
  83166. * @param rightStickX The x component of the right joystick
  83167. * @param rightStickY The y component of the right joystick
  83168. */
  83169. constructor(
  83170. /**
  83171. * The id of the gamepad
  83172. */
  83173. id: string,
  83174. /**
  83175. * The index of the gamepad
  83176. */
  83177. index: number,
  83178. /**
  83179. * The browser gamepad
  83180. */
  83181. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  83182. /**
  83183. * Callback triggered when the left joystick has changed
  83184. * @param callback
  83185. */
  83186. onleftstickchanged(callback: (values: StickValues) => void): void;
  83187. /**
  83188. * Callback triggered when the right joystick has changed
  83189. * @param callback
  83190. */
  83191. onrightstickchanged(callback: (values: StickValues) => void): void;
  83192. /**
  83193. * Gets the left joystick
  83194. */
  83195. get leftStick(): StickValues;
  83196. /**
  83197. * Sets the left joystick values
  83198. */
  83199. set leftStick(newValues: StickValues);
  83200. /**
  83201. * Gets the right joystick
  83202. */
  83203. get rightStick(): StickValues;
  83204. /**
  83205. * Sets the right joystick value
  83206. */
  83207. set rightStick(newValues: StickValues);
  83208. /**
  83209. * Updates the gamepad joystick positions
  83210. */
  83211. update(): void;
  83212. /**
  83213. * Disposes the gamepad
  83214. */
  83215. dispose(): void;
  83216. }
  83217. /**
  83218. * Represents a generic gamepad
  83219. */
  83220. export class GenericPad extends Gamepad {
  83221. private _buttons;
  83222. private _onbuttondown;
  83223. private _onbuttonup;
  83224. /**
  83225. * Observable triggered when a button has been pressed
  83226. */
  83227. onButtonDownObservable: Observable<number>;
  83228. /**
  83229. * Observable triggered when a button has been released
  83230. */
  83231. onButtonUpObservable: Observable<number>;
  83232. /**
  83233. * Callback triggered when a button has been pressed
  83234. * @param callback Called when a button has been pressed
  83235. */
  83236. onbuttondown(callback: (buttonPressed: number) => void): void;
  83237. /**
  83238. * Callback triggered when a button has been released
  83239. * @param callback Called when a button has been released
  83240. */
  83241. onbuttonup(callback: (buttonReleased: number) => void): void;
  83242. /**
  83243. * Initializes the generic gamepad
  83244. * @param id The id of the generic gamepad
  83245. * @param index The index of the generic gamepad
  83246. * @param browserGamepad The browser gamepad
  83247. */
  83248. constructor(id: string, index: number, browserGamepad: any);
  83249. private _setButtonValue;
  83250. /**
  83251. * Updates the generic gamepad
  83252. */
  83253. update(): void;
  83254. /**
  83255. * Disposes the generic gamepad
  83256. */
  83257. dispose(): void;
  83258. }
  83259. }
  83260. declare module BABYLON {
  83261. interface Engine {
  83262. /**
  83263. * Creates a raw texture
  83264. * @param data defines the data to store in the texture
  83265. * @param width defines the width of the texture
  83266. * @param height defines the height of the texture
  83267. * @param format defines the format of the data
  83268. * @param generateMipMaps defines if the engine should generate the mip levels
  83269. * @param invertY defines if data must be stored with Y axis inverted
  83270. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83271. * @param compression defines the compression used (null by default)
  83272. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83273. * @returns the raw texture inside an InternalTexture
  83274. */
  83275. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83276. /**
  83277. * Update a raw texture
  83278. * @param texture defines the texture to update
  83279. * @param data defines the data to store in the texture
  83280. * @param format defines the format of the data
  83281. * @param invertY defines if data must be stored with Y axis inverted
  83282. */
  83283. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83284. /**
  83285. * Update a raw texture
  83286. * @param texture defines the texture to update
  83287. * @param data defines the data to store in the texture
  83288. * @param format defines the format of the data
  83289. * @param invertY defines if data must be stored with Y axis inverted
  83290. * @param compression defines the compression used (null by default)
  83291. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83292. */
  83293. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83294. /**
  83295. * Creates a new raw cube texture
  83296. * @param data defines the array of data to use to create each face
  83297. * @param size defines the size of the textures
  83298. * @param format defines the format of the data
  83299. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83300. * @param generateMipMaps defines if the engine should generate the mip levels
  83301. * @param invertY defines if data must be stored with Y axis inverted
  83302. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83303. * @param compression defines the compression used (null by default)
  83304. * @returns the cube texture as an InternalTexture
  83305. */
  83306. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83307. /**
  83308. * Update a raw cube texture
  83309. * @param texture defines the texture to udpdate
  83310. * @param data defines the data to store
  83311. * @param format defines the data format
  83312. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83313. * @param invertY defines if data must be stored with Y axis inverted
  83314. */
  83315. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83316. /**
  83317. * Update a raw cube texture
  83318. * @param texture defines the texture to udpdate
  83319. * @param data defines the data to store
  83320. * @param format defines the data format
  83321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83322. * @param invertY defines if data must be stored with Y axis inverted
  83323. * @param compression defines the compression used (null by default)
  83324. */
  83325. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83326. /**
  83327. * Update a raw cube texture
  83328. * @param texture defines the texture to udpdate
  83329. * @param data defines the data to store
  83330. * @param format defines the data format
  83331. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83332. * @param invertY defines if data must be stored with Y axis inverted
  83333. * @param compression defines the compression used (null by default)
  83334. * @param level defines which level of the texture to update
  83335. */
  83336. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83337. /**
  83338. * Creates a new raw cube texture from a specified url
  83339. * @param url defines the url where the data is located
  83340. * @param scene defines the current scene
  83341. * @param size defines the size of the textures
  83342. * @param format defines the format of the data
  83343. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83344. * @param noMipmap defines if the engine should avoid generating the mip levels
  83345. * @param callback defines a callback used to extract texture data from loaded data
  83346. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83347. * @param onLoad defines a callback called when texture is loaded
  83348. * @param onError defines a callback called if there is an error
  83349. * @returns the cube texture as an InternalTexture
  83350. */
  83351. 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;
  83352. /**
  83353. * Creates a new raw cube texture from a specified url
  83354. * @param url defines the url where the data is located
  83355. * @param scene defines the current scene
  83356. * @param size defines the size of the textures
  83357. * @param format defines the format of the data
  83358. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83359. * @param noMipmap defines if the engine should avoid generating the mip levels
  83360. * @param callback defines a callback used to extract texture data from loaded data
  83361. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83362. * @param onLoad defines a callback called when texture is loaded
  83363. * @param onError defines a callback called if there is an error
  83364. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83365. * @param invertY defines if data must be stored with Y axis inverted
  83366. * @returns the cube texture as an InternalTexture
  83367. */
  83368. 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;
  83369. /**
  83370. * Creates a new raw 3D texture
  83371. * @param data defines the data used to create the texture
  83372. * @param width defines the width of the texture
  83373. * @param height defines the height of the texture
  83374. * @param depth defines the depth of the texture
  83375. * @param format defines the format of the texture
  83376. * @param generateMipMaps defines if the engine must generate mip levels
  83377. * @param invertY defines if data must be stored with Y axis inverted
  83378. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83379. * @param compression defines the compressed used (can be null)
  83380. * @param textureType defines the compressed used (can be null)
  83381. * @returns a new raw 3D texture (stored in an InternalTexture)
  83382. */
  83383. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83384. /**
  83385. * Update a raw 3D texture
  83386. * @param texture defines the texture to update
  83387. * @param data defines the data to store
  83388. * @param format defines the data format
  83389. * @param invertY defines if data must be stored with Y axis inverted
  83390. */
  83391. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83392. /**
  83393. * Update a raw 3D texture
  83394. * @param texture defines the texture to update
  83395. * @param data defines the data to store
  83396. * @param format defines the data format
  83397. * @param invertY defines if data must be stored with Y axis inverted
  83398. * @param compression defines the used compression (can be null)
  83399. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83400. */
  83401. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83402. /**
  83403. * Creates a new raw 2D array texture
  83404. * @param data defines the data used to create the texture
  83405. * @param width defines the width of the texture
  83406. * @param height defines the height of the texture
  83407. * @param depth defines the number of layers of the texture
  83408. * @param format defines the format of the texture
  83409. * @param generateMipMaps defines if the engine must generate mip levels
  83410. * @param invertY defines if data must be stored with Y axis inverted
  83411. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83412. * @param compression defines the compressed used (can be null)
  83413. * @param textureType defines the compressed used (can be null)
  83414. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83415. */
  83416. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83417. /**
  83418. * Update a raw 2D array texture
  83419. * @param texture defines the texture to update
  83420. * @param data defines the data to store
  83421. * @param format defines the data format
  83422. * @param invertY defines if data must be stored with Y axis inverted
  83423. */
  83424. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83425. /**
  83426. * Update a raw 2D array texture
  83427. * @param texture defines the texture to update
  83428. * @param data defines the data to store
  83429. * @param format defines the data format
  83430. * @param invertY defines if data must be stored with Y axis inverted
  83431. * @param compression defines the used compression (can be null)
  83432. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83433. */
  83434. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83435. }
  83436. }
  83437. declare module BABYLON {
  83438. /**
  83439. * Raw texture can help creating a texture directly from an array of data.
  83440. * This can be super useful if you either get the data from an uncompressed source or
  83441. * if you wish to create your texture pixel by pixel.
  83442. */
  83443. export class RawTexture extends Texture {
  83444. /**
  83445. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83446. */
  83447. format: number;
  83448. private _engine;
  83449. /**
  83450. * Instantiates a new RawTexture.
  83451. * Raw texture can help creating a texture directly from an array of data.
  83452. * This can be super useful if you either get the data from an uncompressed source or
  83453. * if you wish to create your texture pixel by pixel.
  83454. * @param data define the array of data to use to create the texture
  83455. * @param width define the width of the texture
  83456. * @param height define the height of the texture
  83457. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83458. * @param scene define the scene the texture belongs to
  83459. * @param generateMipMaps define whether mip maps should be generated or not
  83460. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83461. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83462. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83463. */
  83464. constructor(data: ArrayBufferView, width: number, height: number,
  83465. /**
  83466. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83467. */
  83468. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83469. /**
  83470. * Updates the texture underlying data.
  83471. * @param data Define the new data of the texture
  83472. */
  83473. update(data: ArrayBufferView): void;
  83474. /**
  83475. * Creates a luminance texture from some data.
  83476. * @param data Define the texture data
  83477. * @param width Define the width of the texture
  83478. * @param height Define the height of the texture
  83479. * @param scene Define the scene the texture belongs to
  83480. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83481. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83482. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83483. * @returns the luminance texture
  83484. */
  83485. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83486. /**
  83487. * Creates a luminance alpha texture from some data.
  83488. * @param data Define the texture data
  83489. * @param width Define the width of the texture
  83490. * @param height Define the height of the texture
  83491. * @param scene Define the scene the texture belongs to
  83492. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83493. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83494. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83495. * @returns the luminance alpha texture
  83496. */
  83497. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83498. /**
  83499. * Creates an alpha texture from some data.
  83500. * @param data Define the texture data
  83501. * @param width Define the width of the texture
  83502. * @param height Define the height of the texture
  83503. * @param scene Define the scene the texture belongs to
  83504. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83505. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83506. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83507. * @returns the alpha texture
  83508. */
  83509. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83510. /**
  83511. * Creates a RGB texture from some data.
  83512. * @param data Define the texture data
  83513. * @param width Define the width of the texture
  83514. * @param height Define the height of the texture
  83515. * @param scene Define the scene the texture belongs to
  83516. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83517. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83518. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83519. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83520. * @returns the RGB alpha texture
  83521. */
  83522. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83523. /**
  83524. * Creates a RGBA texture from some data.
  83525. * @param data Define the texture data
  83526. * @param width Define the width of the texture
  83527. * @param height Define the height of the texture
  83528. * @param scene Define the scene the texture belongs to
  83529. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83530. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83531. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83532. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83533. * @returns the RGBA texture
  83534. */
  83535. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83536. /**
  83537. * Creates a R texture from some data.
  83538. * @param data Define the texture data
  83539. * @param width Define the width of the texture
  83540. * @param height Define the height of the texture
  83541. * @param scene Define the scene the texture belongs to
  83542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83545. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83546. * @returns the R texture
  83547. */
  83548. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83549. }
  83550. }
  83551. declare module BABYLON {
  83552. /**
  83553. * Interface for the size containing width and height
  83554. */
  83555. export interface ISize {
  83556. /**
  83557. * Width
  83558. */
  83559. width: number;
  83560. /**
  83561. * Heighht
  83562. */
  83563. height: number;
  83564. }
  83565. /**
  83566. * Size containing widht and height
  83567. */
  83568. export class Size implements ISize {
  83569. /**
  83570. * Width
  83571. */
  83572. width: number;
  83573. /**
  83574. * Height
  83575. */
  83576. height: number;
  83577. /**
  83578. * Creates a Size object from the given width and height (floats).
  83579. * @param width width of the new size
  83580. * @param height height of the new size
  83581. */
  83582. constructor(width: number, height: number);
  83583. /**
  83584. * Returns a string with the Size width and height
  83585. * @returns a string with the Size width and height
  83586. */
  83587. toString(): string;
  83588. /**
  83589. * "Size"
  83590. * @returns the string "Size"
  83591. */
  83592. getClassName(): string;
  83593. /**
  83594. * Returns the Size hash code.
  83595. * @returns a hash code for a unique width and height
  83596. */
  83597. getHashCode(): number;
  83598. /**
  83599. * Updates the current size from the given one.
  83600. * @param src the given size
  83601. */
  83602. copyFrom(src: Size): void;
  83603. /**
  83604. * Updates in place the current Size from the given floats.
  83605. * @param width width of the new size
  83606. * @param height height of the new size
  83607. * @returns the updated Size.
  83608. */
  83609. copyFromFloats(width: number, height: number): Size;
  83610. /**
  83611. * Updates in place the current Size from the given floats.
  83612. * @param width width to set
  83613. * @param height height to set
  83614. * @returns the updated Size.
  83615. */
  83616. set(width: number, height: number): Size;
  83617. /**
  83618. * Multiplies the width and height by numbers
  83619. * @param w factor to multiple the width by
  83620. * @param h factor to multiple the height by
  83621. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83622. */
  83623. multiplyByFloats(w: number, h: number): Size;
  83624. /**
  83625. * Clones the size
  83626. * @returns a new Size copied from the given one.
  83627. */
  83628. clone(): Size;
  83629. /**
  83630. * True if the current Size and the given one width and height are strictly equal.
  83631. * @param other the other size to compare against
  83632. * @returns True if the current Size and the given one width and height are strictly equal.
  83633. */
  83634. equals(other: Size): boolean;
  83635. /**
  83636. * The surface of the Size : width * height (float).
  83637. */
  83638. get surface(): number;
  83639. /**
  83640. * Create a new size of zero
  83641. * @returns a new Size set to (0.0, 0.0)
  83642. */
  83643. static Zero(): Size;
  83644. /**
  83645. * Sums the width and height of two sizes
  83646. * @param otherSize size to add to this size
  83647. * @returns a new Size set as the addition result of the current Size and the given one.
  83648. */
  83649. add(otherSize: Size): Size;
  83650. /**
  83651. * Subtracts the width and height of two
  83652. * @param otherSize size to subtract to this size
  83653. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83654. */
  83655. subtract(otherSize: Size): Size;
  83656. /**
  83657. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83658. * @param start starting size to lerp between
  83659. * @param end end size to lerp between
  83660. * @param amount amount to lerp between the start and end values
  83661. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83662. */
  83663. static Lerp(start: Size, end: Size, amount: number): Size;
  83664. }
  83665. }
  83666. declare module BABYLON {
  83667. /**
  83668. * Defines a runtime animation
  83669. */
  83670. export class RuntimeAnimation {
  83671. private _events;
  83672. /**
  83673. * The current frame of the runtime animation
  83674. */
  83675. private _currentFrame;
  83676. /**
  83677. * The animation used by the runtime animation
  83678. */
  83679. private _animation;
  83680. /**
  83681. * The target of the runtime animation
  83682. */
  83683. private _target;
  83684. /**
  83685. * The initiating animatable
  83686. */
  83687. private _host;
  83688. /**
  83689. * The original value of the runtime animation
  83690. */
  83691. private _originalValue;
  83692. /**
  83693. * The original blend value of the runtime animation
  83694. */
  83695. private _originalBlendValue;
  83696. /**
  83697. * The offsets cache of the runtime animation
  83698. */
  83699. private _offsetsCache;
  83700. /**
  83701. * The high limits cache of the runtime animation
  83702. */
  83703. private _highLimitsCache;
  83704. /**
  83705. * Specifies if the runtime animation has been stopped
  83706. */
  83707. private _stopped;
  83708. /**
  83709. * The blending factor of the runtime animation
  83710. */
  83711. private _blendingFactor;
  83712. /**
  83713. * The BabylonJS scene
  83714. */
  83715. private _scene;
  83716. /**
  83717. * The current value of the runtime animation
  83718. */
  83719. private _currentValue;
  83720. /** @hidden */
  83721. _animationState: _IAnimationState;
  83722. /**
  83723. * The active target of the runtime animation
  83724. */
  83725. private _activeTargets;
  83726. private _currentActiveTarget;
  83727. private _directTarget;
  83728. /**
  83729. * The target path of the runtime animation
  83730. */
  83731. private _targetPath;
  83732. /**
  83733. * The weight of the runtime animation
  83734. */
  83735. private _weight;
  83736. /**
  83737. * The ratio offset of the runtime animation
  83738. */
  83739. private _ratioOffset;
  83740. /**
  83741. * The previous delay of the runtime animation
  83742. */
  83743. private _previousDelay;
  83744. /**
  83745. * The previous ratio of the runtime animation
  83746. */
  83747. private _previousRatio;
  83748. private _enableBlending;
  83749. private _keys;
  83750. private _minFrame;
  83751. private _maxFrame;
  83752. private _minValue;
  83753. private _maxValue;
  83754. private _targetIsArray;
  83755. /**
  83756. * Gets the current frame of the runtime animation
  83757. */
  83758. get currentFrame(): number;
  83759. /**
  83760. * Gets the weight of the runtime animation
  83761. */
  83762. get weight(): number;
  83763. /**
  83764. * Gets the current value of the runtime animation
  83765. */
  83766. get currentValue(): any;
  83767. /**
  83768. * Gets the target path of the runtime animation
  83769. */
  83770. get targetPath(): string;
  83771. /**
  83772. * Gets the actual target of the runtime animation
  83773. */
  83774. get target(): any;
  83775. /** @hidden */
  83776. _onLoop: () => void;
  83777. /**
  83778. * Create a new RuntimeAnimation object
  83779. * @param target defines the target of the animation
  83780. * @param animation defines the source animation object
  83781. * @param scene defines the hosting scene
  83782. * @param host defines the initiating Animatable
  83783. */
  83784. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  83785. private _preparePath;
  83786. /**
  83787. * Gets the animation from the runtime animation
  83788. */
  83789. get animation(): Animation;
  83790. /**
  83791. * Resets the runtime animation to the beginning
  83792. * @param restoreOriginal defines whether to restore the target property to the original value
  83793. */
  83794. reset(restoreOriginal?: boolean): void;
  83795. /**
  83796. * Specifies if the runtime animation is stopped
  83797. * @returns Boolean specifying if the runtime animation is stopped
  83798. */
  83799. isStopped(): boolean;
  83800. /**
  83801. * Disposes of the runtime animation
  83802. */
  83803. dispose(): void;
  83804. /**
  83805. * Apply the interpolated value to the target
  83806. * @param currentValue defines the value computed by the animation
  83807. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  83808. */
  83809. setValue(currentValue: any, weight: number): void;
  83810. private _getOriginalValues;
  83811. private _setValue;
  83812. /**
  83813. * Gets the loop pmode of the runtime animation
  83814. * @returns Loop Mode
  83815. */
  83816. private _getCorrectLoopMode;
  83817. /**
  83818. * Move the current animation to a given frame
  83819. * @param frame defines the frame to move to
  83820. */
  83821. goToFrame(frame: number): void;
  83822. /**
  83823. * @hidden Internal use only
  83824. */
  83825. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  83826. /**
  83827. * Execute the current animation
  83828. * @param delay defines the delay to add to the current frame
  83829. * @param from defines the lower bound of the animation range
  83830. * @param to defines the upper bound of the animation range
  83831. * @param loop defines if the current animation must loop
  83832. * @param speedRatio defines the current speed ratio
  83833. * @param weight defines the weight of the animation (default is -1 so no weight)
  83834. * @param onLoop optional callback called when animation loops
  83835. * @returns a boolean indicating if the animation is running
  83836. */
  83837. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  83838. }
  83839. }
  83840. declare module BABYLON {
  83841. /**
  83842. * Class used to store an actual running animation
  83843. */
  83844. export class Animatable {
  83845. /** defines the target object */
  83846. target: any;
  83847. /** defines the starting frame number (default is 0) */
  83848. fromFrame: number;
  83849. /** defines the ending frame number (default is 100) */
  83850. toFrame: number;
  83851. /** defines if the animation must loop (default is false) */
  83852. loopAnimation: boolean;
  83853. /** defines a callback to call when animation ends if it is not looping */
  83854. onAnimationEnd?: (() => void) | null | undefined;
  83855. /** defines a callback to call when animation loops */
  83856. onAnimationLoop?: (() => void) | null | undefined;
  83857. private _localDelayOffset;
  83858. private _pausedDelay;
  83859. private _runtimeAnimations;
  83860. private _paused;
  83861. private _scene;
  83862. private _speedRatio;
  83863. private _weight;
  83864. private _syncRoot;
  83865. /**
  83866. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  83867. * This will only apply for non looping animation (default is true)
  83868. */
  83869. disposeOnEnd: boolean;
  83870. /**
  83871. * Gets a boolean indicating if the animation has started
  83872. */
  83873. animationStarted: boolean;
  83874. /**
  83875. * Observer raised when the animation ends
  83876. */
  83877. onAnimationEndObservable: Observable<Animatable>;
  83878. /**
  83879. * Observer raised when the animation loops
  83880. */
  83881. onAnimationLoopObservable: Observable<Animatable>;
  83882. /**
  83883. * Gets the root Animatable used to synchronize and normalize animations
  83884. */
  83885. get syncRoot(): Nullable<Animatable>;
  83886. /**
  83887. * Gets the current frame of the first RuntimeAnimation
  83888. * Used to synchronize Animatables
  83889. */
  83890. get masterFrame(): number;
  83891. /**
  83892. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  83893. */
  83894. get weight(): number;
  83895. set weight(value: number);
  83896. /**
  83897. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  83898. */
  83899. get speedRatio(): number;
  83900. set speedRatio(value: number);
  83901. /**
  83902. * Creates a new Animatable
  83903. * @param scene defines the hosting scene
  83904. * @param target defines the target object
  83905. * @param fromFrame defines the starting frame number (default is 0)
  83906. * @param toFrame defines the ending frame number (default is 100)
  83907. * @param loopAnimation defines if the animation must loop (default is false)
  83908. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  83909. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  83910. * @param animations defines a group of animation to add to the new Animatable
  83911. * @param onAnimationLoop defines a callback to call when animation loops
  83912. */
  83913. constructor(scene: Scene,
  83914. /** defines the target object */
  83915. target: any,
  83916. /** defines the starting frame number (default is 0) */
  83917. fromFrame?: number,
  83918. /** defines the ending frame number (default is 100) */
  83919. toFrame?: number,
  83920. /** defines if the animation must loop (default is false) */
  83921. loopAnimation?: boolean, speedRatio?: number,
  83922. /** defines a callback to call when animation ends if it is not looping */
  83923. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  83924. /** defines a callback to call when animation loops */
  83925. onAnimationLoop?: (() => void) | null | undefined);
  83926. /**
  83927. * Synchronize and normalize current Animatable with a source Animatable
  83928. * This is useful when using animation weights and when animations are not of the same length
  83929. * @param root defines the root Animatable to synchronize with
  83930. * @returns the current Animatable
  83931. */
  83932. syncWith(root: Animatable): Animatable;
  83933. /**
  83934. * Gets the list of runtime animations
  83935. * @returns an array of RuntimeAnimation
  83936. */
  83937. getAnimations(): RuntimeAnimation[];
  83938. /**
  83939. * Adds more animations to the current animatable
  83940. * @param target defines the target of the animations
  83941. * @param animations defines the new animations to add
  83942. */
  83943. appendAnimations(target: any, animations: Animation[]): void;
  83944. /**
  83945. * Gets the source animation for a specific property
  83946. * @param property defines the propertyu to look for
  83947. * @returns null or the source animation for the given property
  83948. */
  83949. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  83950. /**
  83951. * Gets the runtime animation for a specific property
  83952. * @param property defines the propertyu to look for
  83953. * @returns null or the runtime animation for the given property
  83954. */
  83955. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  83956. /**
  83957. * Resets the animatable to its original state
  83958. */
  83959. reset(): void;
  83960. /**
  83961. * Allows the animatable to blend with current running animations
  83962. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83963. * @param blendingSpeed defines the blending speed to use
  83964. */
  83965. enableBlending(blendingSpeed: number): void;
  83966. /**
  83967. * Disable animation blending
  83968. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83969. */
  83970. disableBlending(): void;
  83971. /**
  83972. * Jump directly to a given frame
  83973. * @param frame defines the frame to jump to
  83974. */
  83975. goToFrame(frame: number): void;
  83976. /**
  83977. * Pause the animation
  83978. */
  83979. pause(): void;
  83980. /**
  83981. * Restart the animation
  83982. */
  83983. restart(): void;
  83984. private _raiseOnAnimationEnd;
  83985. /**
  83986. * Stop and delete the current animation
  83987. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  83988. * @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)
  83989. */
  83990. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  83991. /**
  83992. * Wait asynchronously for the animation to end
  83993. * @returns a promise which will be fullfilled when the animation ends
  83994. */
  83995. waitAsync(): Promise<Animatable>;
  83996. /** @hidden */
  83997. _animate(delay: number): boolean;
  83998. }
  83999. interface Scene {
  84000. /** @hidden */
  84001. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  84002. /** @hidden */
  84003. _processLateAnimationBindingsForMatrices(holder: {
  84004. totalWeight: number;
  84005. animations: RuntimeAnimation[];
  84006. originalValue: Matrix;
  84007. }): any;
  84008. /** @hidden */
  84009. _processLateAnimationBindingsForQuaternions(holder: {
  84010. totalWeight: number;
  84011. animations: RuntimeAnimation[];
  84012. originalValue: Quaternion;
  84013. }, refQuaternion: Quaternion): Quaternion;
  84014. /** @hidden */
  84015. _processLateAnimationBindings(): void;
  84016. /**
  84017. * Will start the animation sequence of a given target
  84018. * @param target defines the target
  84019. * @param from defines from which frame should animation start
  84020. * @param to defines until which frame should animation run.
  84021. * @param weight defines the weight to apply to the animation (1.0 by default)
  84022. * @param loop defines if the animation loops
  84023. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84024. * @param onAnimationEnd defines the function to be executed when the animation ends
  84025. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84026. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  84027. * @param onAnimationLoop defines the callback to call when an animation loops
  84028. * @returns the animatable object created for this animation
  84029. */
  84030. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  84031. /**
  84032. * Will start the animation sequence of a given target
  84033. * @param target defines the target
  84034. * @param from defines from which frame should animation start
  84035. * @param to defines until which frame should animation run.
  84036. * @param loop defines if the animation loops
  84037. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84038. * @param onAnimationEnd defines the function to be executed when the animation ends
  84039. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84040. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  84041. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  84042. * @param onAnimationLoop defines the callback to call when an animation loops
  84043. * @returns the animatable object created for this animation
  84044. */
  84045. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  84046. /**
  84047. * Will start the animation sequence of a given target and its hierarchy
  84048. * @param target defines the target
  84049. * @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.
  84050. * @param from defines from which frame should animation start
  84051. * @param to defines until which frame should animation run.
  84052. * @param loop defines if the animation loops
  84053. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84054. * @param onAnimationEnd defines the function to be executed when the animation ends
  84055. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84056. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  84057. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  84058. * @param onAnimationLoop defines the callback to call when an animation loops
  84059. * @returns the list of created animatables
  84060. */
  84061. 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[];
  84062. /**
  84063. * Begin a new animation on a given node
  84064. * @param target defines the target where the animation will take place
  84065. * @param animations defines the list of animations to start
  84066. * @param from defines the initial value
  84067. * @param to defines the final value
  84068. * @param loop defines if you want animation to loop (off by default)
  84069. * @param speedRatio defines the speed ratio to apply to all animations
  84070. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84071. * @param onAnimationLoop defines the callback to call when an animation loops
  84072. * @returns the list of created animatables
  84073. */
  84074. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  84075. /**
  84076. * Begin a new animation on a given node and its hierarchy
  84077. * @param target defines the root node where the animation will take place
  84078. * @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.
  84079. * @param animations defines the list of animations to start
  84080. * @param from defines the initial value
  84081. * @param to defines the final value
  84082. * @param loop defines if you want animation to loop (off by default)
  84083. * @param speedRatio defines the speed ratio to apply to all animations
  84084. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84085. * @param onAnimationLoop defines the callback to call when an animation loops
  84086. * @returns the list of animatables created for all nodes
  84087. */
  84088. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  84089. /**
  84090. * Gets the animatable associated with a specific target
  84091. * @param target defines the target of the animatable
  84092. * @returns the required animatable if found
  84093. */
  84094. getAnimatableByTarget(target: any): Nullable<Animatable>;
  84095. /**
  84096. * Gets all animatables associated with a given target
  84097. * @param target defines the target to look animatables for
  84098. * @returns an array of Animatables
  84099. */
  84100. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  84101. /**
  84102. * Stops and removes all animations that have been applied to the scene
  84103. */
  84104. stopAllAnimations(): void;
  84105. /**
  84106. * Gets the current delta time used by animation engine
  84107. */
  84108. deltaTime: number;
  84109. }
  84110. interface Bone {
  84111. /**
  84112. * Copy an animation range from another bone
  84113. * @param source defines the source bone
  84114. * @param rangeName defines the range name to copy
  84115. * @param frameOffset defines the frame offset
  84116. * @param rescaleAsRequired defines if rescaling must be applied if required
  84117. * @param skelDimensionsRatio defines the scaling ratio
  84118. * @returns true if operation was successful
  84119. */
  84120. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  84121. }
  84122. }
  84123. declare module BABYLON {
  84124. /**
  84125. * Class used to override all child animations of a given target
  84126. */
  84127. export class AnimationPropertiesOverride {
  84128. /**
  84129. * Gets or sets a value indicating if animation blending must be used
  84130. */
  84131. enableBlending: boolean;
  84132. /**
  84133. * Gets or sets the blending speed to use when enableBlending is true
  84134. */
  84135. blendingSpeed: number;
  84136. /**
  84137. * Gets or sets the default loop mode to use
  84138. */
  84139. loopMode: number;
  84140. }
  84141. }
  84142. declare module BABYLON {
  84143. /**
  84144. * Class used to handle skinning animations
  84145. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84146. */
  84147. export class Skeleton implements IAnimatable {
  84148. /** defines the skeleton name */
  84149. name: string;
  84150. /** defines the skeleton Id */
  84151. id: string;
  84152. /**
  84153. * Defines the list of child bones
  84154. */
  84155. bones: Bone[];
  84156. /**
  84157. * Defines an estimate of the dimension of the skeleton at rest
  84158. */
  84159. dimensionsAtRest: Vector3;
  84160. /**
  84161. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  84162. */
  84163. needInitialSkinMatrix: boolean;
  84164. /**
  84165. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  84166. */
  84167. overrideMesh: Nullable<AbstractMesh>;
  84168. /**
  84169. * Gets the list of animations attached to this skeleton
  84170. */
  84171. animations: Array<Animation>;
  84172. private _scene;
  84173. private _isDirty;
  84174. private _transformMatrices;
  84175. private _transformMatrixTexture;
  84176. private _meshesWithPoseMatrix;
  84177. private _animatables;
  84178. private _identity;
  84179. private _synchronizedWithMesh;
  84180. private _ranges;
  84181. private _lastAbsoluteTransformsUpdateId;
  84182. private _canUseTextureForBones;
  84183. private _uniqueId;
  84184. /** @hidden */
  84185. _numBonesWithLinkedTransformNode: number;
  84186. /** @hidden */
  84187. _hasWaitingData: Nullable<boolean>;
  84188. /**
  84189. * Specifies if the skeleton should be serialized
  84190. */
  84191. doNotSerialize: boolean;
  84192. private _useTextureToStoreBoneMatrices;
  84193. /**
  84194. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  84195. * Please note that this option is not available if the hardware does not support it
  84196. */
  84197. get useTextureToStoreBoneMatrices(): boolean;
  84198. set useTextureToStoreBoneMatrices(value: boolean);
  84199. private _animationPropertiesOverride;
  84200. /**
  84201. * Gets or sets the animation properties override
  84202. */
  84203. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84204. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  84205. /**
  84206. * List of inspectable custom properties (used by the Inspector)
  84207. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84208. */
  84209. inspectableCustomProperties: IInspectable[];
  84210. /**
  84211. * An observable triggered before computing the skeleton's matrices
  84212. */
  84213. onBeforeComputeObservable: Observable<Skeleton>;
  84214. /**
  84215. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  84216. */
  84217. get isUsingTextureForMatrices(): boolean;
  84218. /**
  84219. * Gets the unique ID of this skeleton
  84220. */
  84221. get uniqueId(): number;
  84222. /**
  84223. * Creates a new skeleton
  84224. * @param name defines the skeleton name
  84225. * @param id defines the skeleton Id
  84226. * @param scene defines the hosting scene
  84227. */
  84228. constructor(
  84229. /** defines the skeleton name */
  84230. name: string,
  84231. /** defines the skeleton Id */
  84232. id: string, scene: Scene);
  84233. /**
  84234. * Gets the current object class name.
  84235. * @return the class name
  84236. */
  84237. getClassName(): string;
  84238. /**
  84239. * Returns an array containing the root bones
  84240. * @returns an array containing the root bones
  84241. */
  84242. getChildren(): Array<Bone>;
  84243. /**
  84244. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  84245. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84246. * @returns a Float32Array containing matrices data
  84247. */
  84248. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  84249. /**
  84250. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  84251. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84252. * @returns a raw texture containing the data
  84253. */
  84254. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  84255. /**
  84256. * Gets the current hosting scene
  84257. * @returns a scene object
  84258. */
  84259. getScene(): Scene;
  84260. /**
  84261. * Gets a string representing the current skeleton data
  84262. * @param fullDetails defines a boolean indicating if we want a verbose version
  84263. * @returns a string representing the current skeleton data
  84264. */
  84265. toString(fullDetails?: boolean): string;
  84266. /**
  84267. * Get bone's index searching by name
  84268. * @param name defines bone's name to search for
  84269. * @return the indice of the bone. Returns -1 if not found
  84270. */
  84271. getBoneIndexByName(name: string): number;
  84272. /**
  84273. * Creater a new animation range
  84274. * @param name defines the name of the range
  84275. * @param from defines the start key
  84276. * @param to defines the end key
  84277. */
  84278. createAnimationRange(name: string, from: number, to: number): void;
  84279. /**
  84280. * Delete a specific animation range
  84281. * @param name defines the name of the range
  84282. * @param deleteFrames defines if frames must be removed as well
  84283. */
  84284. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84285. /**
  84286. * Gets a specific animation range
  84287. * @param name defines the name of the range to look for
  84288. * @returns the requested animation range or null if not found
  84289. */
  84290. getAnimationRange(name: string): Nullable<AnimationRange>;
  84291. /**
  84292. * Gets the list of all animation ranges defined on this skeleton
  84293. * @returns an array
  84294. */
  84295. getAnimationRanges(): Nullable<AnimationRange>[];
  84296. /**
  84297. * Copy animation range from a source skeleton.
  84298. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  84299. * @param source defines the source skeleton
  84300. * @param name defines the name of the range to copy
  84301. * @param rescaleAsRequired defines if rescaling must be applied if required
  84302. * @returns true if operation was successful
  84303. */
  84304. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  84305. /**
  84306. * Forces the skeleton to go to rest pose
  84307. */
  84308. returnToRest(): void;
  84309. private _getHighestAnimationFrame;
  84310. /**
  84311. * Begin a specific animation range
  84312. * @param name defines the name of the range to start
  84313. * @param loop defines if looping must be turned on (false by default)
  84314. * @param speedRatio defines the speed ratio to apply (1 by default)
  84315. * @param onAnimationEnd defines a callback which will be called when animation will end
  84316. * @returns a new animatable
  84317. */
  84318. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84319. /** @hidden */
  84320. _markAsDirty(): void;
  84321. /** @hidden */
  84322. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84323. /** @hidden */
  84324. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84325. private _computeTransformMatrices;
  84326. /**
  84327. * Build all resources required to render a skeleton
  84328. */
  84329. prepare(): void;
  84330. /**
  84331. * Gets the list of animatables currently running for this skeleton
  84332. * @returns an array of animatables
  84333. */
  84334. getAnimatables(): IAnimatable[];
  84335. /**
  84336. * Clone the current skeleton
  84337. * @param name defines the name of the new skeleton
  84338. * @param id defines the id of the new skeleton
  84339. * @returns the new skeleton
  84340. */
  84341. clone(name: string, id?: string): Skeleton;
  84342. /**
  84343. * Enable animation blending for this skeleton
  84344. * @param blendingSpeed defines the blending speed to apply
  84345. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84346. */
  84347. enableBlending(blendingSpeed?: number): void;
  84348. /**
  84349. * Releases all resources associated with the current skeleton
  84350. */
  84351. dispose(): void;
  84352. /**
  84353. * Serialize the skeleton in a JSON object
  84354. * @returns a JSON object
  84355. */
  84356. serialize(): any;
  84357. /**
  84358. * Creates a new skeleton from serialized data
  84359. * @param parsedSkeleton defines the serialized data
  84360. * @param scene defines the hosting scene
  84361. * @returns a new skeleton
  84362. */
  84363. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  84364. /**
  84365. * Compute all node absolute transforms
  84366. * @param forceUpdate defines if computation must be done even if cache is up to date
  84367. */
  84368. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  84369. /**
  84370. * Gets the root pose matrix
  84371. * @returns a matrix
  84372. */
  84373. getPoseMatrix(): Nullable<Matrix>;
  84374. /**
  84375. * Sorts bones per internal index
  84376. */
  84377. sortBones(): void;
  84378. private _sortBones;
  84379. }
  84380. }
  84381. declare module BABYLON {
  84382. /**
  84383. * Class used to store bone information
  84384. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84385. */
  84386. export class Bone extends Node {
  84387. /**
  84388. * defines the bone name
  84389. */
  84390. name: string;
  84391. private static _tmpVecs;
  84392. private static _tmpQuat;
  84393. private static _tmpMats;
  84394. /**
  84395. * Gets the list of child bones
  84396. */
  84397. children: Bone[];
  84398. /** Gets the animations associated with this bone */
  84399. animations: Animation[];
  84400. /**
  84401. * Gets or sets bone length
  84402. */
  84403. length: number;
  84404. /**
  84405. * @hidden Internal only
  84406. * Set this value to map this bone to a different index in the transform matrices
  84407. * Set this value to -1 to exclude the bone from the transform matrices
  84408. */
  84409. _index: Nullable<number>;
  84410. private _skeleton;
  84411. private _localMatrix;
  84412. private _restPose;
  84413. private _baseMatrix;
  84414. private _absoluteTransform;
  84415. private _invertedAbsoluteTransform;
  84416. private _parent;
  84417. private _scalingDeterminant;
  84418. private _worldTransform;
  84419. private _localScaling;
  84420. private _localRotation;
  84421. private _localPosition;
  84422. private _needToDecompose;
  84423. private _needToCompose;
  84424. /** @hidden */
  84425. _linkedTransformNode: Nullable<TransformNode>;
  84426. /** @hidden */
  84427. _waitingTransformNodeId: Nullable<string>;
  84428. /** @hidden */
  84429. get _matrix(): Matrix;
  84430. /** @hidden */
  84431. set _matrix(value: Matrix);
  84432. /**
  84433. * Create a new bone
  84434. * @param name defines the bone name
  84435. * @param skeleton defines the parent skeleton
  84436. * @param parentBone defines the parent (can be null if the bone is the root)
  84437. * @param localMatrix defines the local matrix
  84438. * @param restPose defines the rest pose matrix
  84439. * @param baseMatrix defines the base matrix
  84440. * @param index defines index of the bone in the hiearchy
  84441. */
  84442. constructor(
  84443. /**
  84444. * defines the bone name
  84445. */
  84446. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  84447. /**
  84448. * Gets the current object class name.
  84449. * @return the class name
  84450. */
  84451. getClassName(): string;
  84452. /**
  84453. * Gets the parent skeleton
  84454. * @returns a skeleton
  84455. */
  84456. getSkeleton(): Skeleton;
  84457. /**
  84458. * Gets parent bone
  84459. * @returns a bone or null if the bone is the root of the bone hierarchy
  84460. */
  84461. getParent(): Nullable<Bone>;
  84462. /**
  84463. * Returns an array containing the root bones
  84464. * @returns an array containing the root bones
  84465. */
  84466. getChildren(): Array<Bone>;
  84467. /**
  84468. * Gets the node index in matrix array generated for rendering
  84469. * @returns the node index
  84470. */
  84471. getIndex(): number;
  84472. /**
  84473. * Sets the parent bone
  84474. * @param parent defines the parent (can be null if the bone is the root)
  84475. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84476. */
  84477. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  84478. /**
  84479. * Gets the local matrix
  84480. * @returns a matrix
  84481. */
  84482. getLocalMatrix(): Matrix;
  84483. /**
  84484. * Gets the base matrix (initial matrix which remains unchanged)
  84485. * @returns a matrix
  84486. */
  84487. getBaseMatrix(): Matrix;
  84488. /**
  84489. * Gets the rest pose matrix
  84490. * @returns a matrix
  84491. */
  84492. getRestPose(): Matrix;
  84493. /**
  84494. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  84495. */
  84496. getWorldMatrix(): Matrix;
  84497. /**
  84498. * Sets the local matrix to rest pose matrix
  84499. */
  84500. returnToRest(): void;
  84501. /**
  84502. * Gets the inverse of the absolute transform matrix.
  84503. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  84504. * @returns a matrix
  84505. */
  84506. getInvertedAbsoluteTransform(): Matrix;
  84507. /**
  84508. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  84509. * @returns a matrix
  84510. */
  84511. getAbsoluteTransform(): Matrix;
  84512. /**
  84513. * Links with the given transform node.
  84514. * The local matrix of this bone is copied from the transform node every frame.
  84515. * @param transformNode defines the transform node to link to
  84516. */
  84517. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  84518. /**
  84519. * Gets the node used to drive the bone's transformation
  84520. * @returns a transform node or null
  84521. */
  84522. getTransformNode(): Nullable<TransformNode>;
  84523. /** Gets or sets current position (in local space) */
  84524. get position(): Vector3;
  84525. set position(newPosition: Vector3);
  84526. /** Gets or sets current rotation (in local space) */
  84527. get rotation(): Vector3;
  84528. set rotation(newRotation: Vector3);
  84529. /** Gets or sets current rotation quaternion (in local space) */
  84530. get rotationQuaternion(): Quaternion;
  84531. set rotationQuaternion(newRotation: Quaternion);
  84532. /** Gets or sets current scaling (in local space) */
  84533. get scaling(): Vector3;
  84534. set scaling(newScaling: Vector3);
  84535. /**
  84536. * Gets the animation properties override
  84537. */
  84538. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84539. private _decompose;
  84540. private _compose;
  84541. /**
  84542. * Update the base and local matrices
  84543. * @param matrix defines the new base or local matrix
  84544. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84545. * @param updateLocalMatrix defines if the local matrix should be updated
  84546. */
  84547. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  84548. /** @hidden */
  84549. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  84550. /**
  84551. * Flag the bone as dirty (Forcing it to update everything)
  84552. */
  84553. markAsDirty(): void;
  84554. /** @hidden */
  84555. _markAsDirtyAndCompose(): void;
  84556. private _markAsDirtyAndDecompose;
  84557. /**
  84558. * Translate the bone in local or world space
  84559. * @param vec The amount to translate the bone
  84560. * @param space The space that the translation is in
  84561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84562. */
  84563. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84564. /**
  84565. * Set the postion of the bone in local or world space
  84566. * @param position The position to set the bone
  84567. * @param space The space that the position is in
  84568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84569. */
  84570. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84571. /**
  84572. * Set the absolute position of the bone (world space)
  84573. * @param position The position to set the bone
  84574. * @param mesh The mesh that this bone is attached to
  84575. */
  84576. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  84577. /**
  84578. * Scale the bone on the x, y and z axes (in local space)
  84579. * @param x The amount to scale the bone on the x axis
  84580. * @param y The amount to scale the bone on the y axis
  84581. * @param z The amount to scale the bone on the z axis
  84582. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  84583. */
  84584. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  84585. /**
  84586. * Set the bone scaling in local space
  84587. * @param scale defines the scaling vector
  84588. */
  84589. setScale(scale: Vector3): void;
  84590. /**
  84591. * Gets the current scaling in local space
  84592. * @returns the current scaling vector
  84593. */
  84594. getScale(): Vector3;
  84595. /**
  84596. * Gets the current scaling in local space and stores it in a target vector
  84597. * @param result defines the target vector
  84598. */
  84599. getScaleToRef(result: Vector3): void;
  84600. /**
  84601. * Set the yaw, pitch, and roll of the bone in local or world space
  84602. * @param yaw The rotation of the bone on the y axis
  84603. * @param pitch The rotation of the bone on the x axis
  84604. * @param roll The rotation of the bone on the z axis
  84605. * @param space The space that the axes of rotation are in
  84606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84607. */
  84608. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  84609. /**
  84610. * Add a rotation to the bone on an axis in local or world space
  84611. * @param axis The axis to rotate the bone on
  84612. * @param amount The amount to rotate the bone
  84613. * @param space The space that the axis is in
  84614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84615. */
  84616. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  84617. /**
  84618. * Set the rotation of the bone to a particular axis angle in local or world space
  84619. * @param axis The axis to rotate the bone on
  84620. * @param angle The angle that the bone should be rotated to
  84621. * @param space The space that the axis is in
  84622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84623. */
  84624. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  84625. /**
  84626. * Set the euler rotation of the bone in local of world space
  84627. * @param rotation The euler rotation that the bone should be set to
  84628. * @param space The space that the rotation is in
  84629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84630. */
  84631. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84632. /**
  84633. * Set the quaternion rotation of the bone in local of world space
  84634. * @param quat The quaternion rotation that the bone should be set to
  84635. * @param space The space that the rotation is in
  84636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84637. */
  84638. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  84639. /**
  84640. * Set the rotation matrix of the bone in local of world space
  84641. * @param rotMat The rotation matrix that the bone should be set to
  84642. * @param space The space that the rotation is in
  84643. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84644. */
  84645. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  84646. private _rotateWithMatrix;
  84647. private _getNegativeRotationToRef;
  84648. /**
  84649. * Get the position of the bone in local or world space
  84650. * @param space The space that the returned position is in
  84651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84652. * @returns The position of the bone
  84653. */
  84654. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84655. /**
  84656. * Copy the position of the bone to a vector3 in local or world space
  84657. * @param space The space that the returned position is in
  84658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84659. * @param result The vector3 to copy the position to
  84660. */
  84661. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  84662. /**
  84663. * Get the absolute position of the bone (world space)
  84664. * @param mesh The mesh that this bone is attached to
  84665. * @returns The absolute position of the bone
  84666. */
  84667. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  84668. /**
  84669. * Copy the absolute position of the bone (world space) to the result param
  84670. * @param mesh The mesh that this bone is attached to
  84671. * @param result The vector3 to copy the absolute position to
  84672. */
  84673. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  84674. /**
  84675. * Compute the absolute transforms of this bone and its children
  84676. */
  84677. computeAbsoluteTransforms(): void;
  84678. /**
  84679. * Get the world direction from an axis that is in the local space of the bone
  84680. * @param localAxis The local direction that is used to compute the world direction
  84681. * @param mesh The mesh that this bone is attached to
  84682. * @returns The world direction
  84683. */
  84684. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84685. /**
  84686. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  84687. * @param localAxis The local direction that is used to compute the world direction
  84688. * @param mesh The mesh that this bone is attached to
  84689. * @param result The vector3 that the world direction will be copied to
  84690. */
  84691. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84692. /**
  84693. * Get the euler rotation of the bone in local or world space
  84694. * @param space The space that the rotation should be in
  84695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84696. * @returns The euler rotation
  84697. */
  84698. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84699. /**
  84700. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  84701. * @param space The space that the rotation should be in
  84702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84703. * @param result The vector3 that the rotation should be copied to
  84704. */
  84705. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84706. /**
  84707. * Get the quaternion rotation of the bone in either local or world space
  84708. * @param space The space that the rotation should be in
  84709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84710. * @returns The quaternion rotation
  84711. */
  84712. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  84713. /**
  84714. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  84715. * @param space The space that the rotation should be in
  84716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84717. * @param result The quaternion that the rotation should be copied to
  84718. */
  84719. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  84720. /**
  84721. * Get the rotation matrix of the bone in local or world space
  84722. * @param space The space that the rotation should be in
  84723. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84724. * @returns The rotation matrix
  84725. */
  84726. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  84727. /**
  84728. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  84729. * @param space The space that the rotation should be in
  84730. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84731. * @param result The quaternion that the rotation should be copied to
  84732. */
  84733. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  84734. /**
  84735. * Get the world position of a point that is in the local space of the bone
  84736. * @param position The local position
  84737. * @param mesh The mesh that this bone is attached to
  84738. * @returns The world position
  84739. */
  84740. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84741. /**
  84742. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  84743. * @param position The local position
  84744. * @param mesh The mesh that this bone is attached to
  84745. * @param result The vector3 that the world position should be copied to
  84746. */
  84747. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84748. /**
  84749. * Get the local position of a point that is in world space
  84750. * @param position The world position
  84751. * @param mesh The mesh that this bone is attached to
  84752. * @returns The local position
  84753. */
  84754. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84755. /**
  84756. * Get the local position of a point that is in world space and copy it to the result param
  84757. * @param position The world position
  84758. * @param mesh The mesh that this bone is attached to
  84759. * @param result The vector3 that the local position should be copied to
  84760. */
  84761. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84762. }
  84763. }
  84764. declare module BABYLON {
  84765. /**
  84766. * 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.
  84767. * @see https://doc.babylonjs.com/how_to/transformnode
  84768. */
  84769. export class TransformNode extends Node {
  84770. /**
  84771. * Object will not rotate to face the camera
  84772. */
  84773. static BILLBOARDMODE_NONE: number;
  84774. /**
  84775. * Object will rotate to face the camera but only on the x axis
  84776. */
  84777. static BILLBOARDMODE_X: number;
  84778. /**
  84779. * Object will rotate to face the camera but only on the y axis
  84780. */
  84781. static BILLBOARDMODE_Y: number;
  84782. /**
  84783. * Object will rotate to face the camera but only on the z axis
  84784. */
  84785. static BILLBOARDMODE_Z: number;
  84786. /**
  84787. * Object will rotate to face the camera
  84788. */
  84789. static BILLBOARDMODE_ALL: number;
  84790. /**
  84791. * Object will rotate to face the camera's position instead of orientation
  84792. */
  84793. static BILLBOARDMODE_USE_POSITION: number;
  84794. private _forward;
  84795. private _forwardInverted;
  84796. private _up;
  84797. private _right;
  84798. private _rightInverted;
  84799. private _position;
  84800. private _rotation;
  84801. private _rotationQuaternion;
  84802. protected _scaling: Vector3;
  84803. protected _isDirty: boolean;
  84804. private _transformToBoneReferal;
  84805. private _isAbsoluteSynced;
  84806. private _billboardMode;
  84807. /**
  84808. * Gets or sets the billboard mode. Default is 0.
  84809. *
  84810. * | Value | Type | Description |
  84811. * | --- | --- | --- |
  84812. * | 0 | BILLBOARDMODE_NONE | |
  84813. * | 1 | BILLBOARDMODE_X | |
  84814. * | 2 | BILLBOARDMODE_Y | |
  84815. * | 4 | BILLBOARDMODE_Z | |
  84816. * | 7 | BILLBOARDMODE_ALL | |
  84817. *
  84818. */
  84819. get billboardMode(): number;
  84820. set billboardMode(value: number);
  84821. private _preserveParentRotationForBillboard;
  84822. /**
  84823. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  84824. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  84825. */
  84826. get preserveParentRotationForBillboard(): boolean;
  84827. set preserveParentRotationForBillboard(value: boolean);
  84828. /**
  84829. * 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
  84830. */
  84831. scalingDeterminant: number;
  84832. private _infiniteDistance;
  84833. /**
  84834. * Gets or sets the distance of the object to max, often used by skybox
  84835. */
  84836. get infiniteDistance(): boolean;
  84837. set infiniteDistance(value: boolean);
  84838. /**
  84839. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  84840. * By default the system will update normals to compensate
  84841. */
  84842. ignoreNonUniformScaling: boolean;
  84843. /**
  84844. * 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
  84845. */
  84846. reIntegrateRotationIntoRotationQuaternion: boolean;
  84847. /** @hidden */
  84848. _poseMatrix: Nullable<Matrix>;
  84849. /** @hidden */
  84850. _localMatrix: Matrix;
  84851. private _usePivotMatrix;
  84852. private _absolutePosition;
  84853. private _absoluteScaling;
  84854. private _absoluteRotationQuaternion;
  84855. private _pivotMatrix;
  84856. private _pivotMatrixInverse;
  84857. protected _postMultiplyPivotMatrix: boolean;
  84858. protected _isWorldMatrixFrozen: boolean;
  84859. /** @hidden */
  84860. _indexInSceneTransformNodesArray: number;
  84861. /**
  84862. * An event triggered after the world matrix is updated
  84863. */
  84864. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  84865. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  84866. /**
  84867. * Gets a string identifying the name of the class
  84868. * @returns "TransformNode" string
  84869. */
  84870. getClassName(): string;
  84871. /**
  84872. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  84873. */
  84874. get position(): Vector3;
  84875. set position(newPosition: Vector3);
  84876. /**
  84877. * 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)).
  84878. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  84879. */
  84880. get rotation(): Vector3;
  84881. set rotation(newRotation: Vector3);
  84882. /**
  84883. * 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)).
  84884. */
  84885. get scaling(): Vector3;
  84886. set scaling(newScaling: Vector3);
  84887. /**
  84888. * 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).
  84889. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  84890. */
  84891. get rotationQuaternion(): Nullable<Quaternion>;
  84892. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  84893. /**
  84894. * The forward direction of that transform in world space.
  84895. */
  84896. get forward(): Vector3;
  84897. /**
  84898. * The up direction of that transform in world space.
  84899. */
  84900. get up(): Vector3;
  84901. /**
  84902. * The right direction of that transform in world space.
  84903. */
  84904. get right(): Vector3;
  84905. /**
  84906. * Copies the parameter passed Matrix into the mesh Pose matrix.
  84907. * @param matrix the matrix to copy the pose from
  84908. * @returns this TransformNode.
  84909. */
  84910. updatePoseMatrix(matrix: Matrix): TransformNode;
  84911. /**
  84912. * Returns the mesh Pose matrix.
  84913. * @returns the pose matrix
  84914. */
  84915. getPoseMatrix(): Matrix;
  84916. /** @hidden */
  84917. _isSynchronized(): boolean;
  84918. /** @hidden */
  84919. _initCache(): void;
  84920. /**
  84921. * Flag the transform node as dirty (Forcing it to update everything)
  84922. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  84923. * @returns this transform node
  84924. */
  84925. markAsDirty(property: string): TransformNode;
  84926. /**
  84927. * Returns the current mesh absolute position.
  84928. * Returns a Vector3.
  84929. */
  84930. get absolutePosition(): Vector3;
  84931. /**
  84932. * Returns the current mesh absolute scaling.
  84933. * Returns a Vector3.
  84934. */
  84935. get absoluteScaling(): Vector3;
  84936. /**
  84937. * Returns the current mesh absolute rotation.
  84938. * Returns a Quaternion.
  84939. */
  84940. get absoluteRotationQuaternion(): Quaternion;
  84941. /**
  84942. * Sets a new matrix to apply before all other transformation
  84943. * @param matrix defines the transform matrix
  84944. * @returns the current TransformNode
  84945. */
  84946. setPreTransformMatrix(matrix: Matrix): TransformNode;
  84947. /**
  84948. * Sets a new pivot matrix to the current node
  84949. * @param matrix defines the new pivot matrix to use
  84950. * @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
  84951. * @returns the current TransformNode
  84952. */
  84953. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  84954. /**
  84955. * Returns the mesh pivot matrix.
  84956. * Default : Identity.
  84957. * @returns the matrix
  84958. */
  84959. getPivotMatrix(): Matrix;
  84960. /**
  84961. * Instantiate (when possible) or clone that node with its hierarchy
  84962. * @param newParent defines the new parent to use for the instance (or clone)
  84963. * @param options defines options to configure how copy is done
  84964. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  84965. * @returns an instance (or a clone) of the current node with its hiearchy
  84966. */
  84967. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  84968. doNotInstantiate: boolean;
  84969. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  84970. /**
  84971. * Prevents the World matrix to be computed any longer
  84972. * @param newWorldMatrix defines an optional matrix to use as world matrix
  84973. * @returns the TransformNode.
  84974. */
  84975. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  84976. /**
  84977. * Allows back the World matrix computation.
  84978. * @returns the TransformNode.
  84979. */
  84980. unfreezeWorldMatrix(): this;
  84981. /**
  84982. * True if the World matrix has been frozen.
  84983. */
  84984. get isWorldMatrixFrozen(): boolean;
  84985. /**
  84986. * Retuns the mesh absolute position in the World.
  84987. * @returns a Vector3.
  84988. */
  84989. getAbsolutePosition(): Vector3;
  84990. /**
  84991. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  84992. * @param absolutePosition the absolute position to set
  84993. * @returns the TransformNode.
  84994. */
  84995. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  84996. /**
  84997. * Sets the mesh position in its local space.
  84998. * @param vector3 the position to set in localspace
  84999. * @returns the TransformNode.
  85000. */
  85001. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  85002. /**
  85003. * Returns the mesh position in the local space from the current World matrix values.
  85004. * @returns a new Vector3.
  85005. */
  85006. getPositionExpressedInLocalSpace(): Vector3;
  85007. /**
  85008. * Translates the mesh along the passed Vector3 in its local space.
  85009. * @param vector3 the distance to translate in localspace
  85010. * @returns the TransformNode.
  85011. */
  85012. locallyTranslate(vector3: Vector3): TransformNode;
  85013. private static _lookAtVectorCache;
  85014. /**
  85015. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  85016. * @param targetPoint the position (must be in same space as current mesh) to look at
  85017. * @param yawCor optional yaw (y-axis) correction in radians
  85018. * @param pitchCor optional pitch (x-axis) correction in radians
  85019. * @param rollCor optional roll (z-axis) correction in radians
  85020. * @param space the choosen space of the target
  85021. * @returns the TransformNode.
  85022. */
  85023. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  85024. /**
  85025. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  85026. * This Vector3 is expressed in the World space.
  85027. * @param localAxis axis to rotate
  85028. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  85029. */
  85030. getDirection(localAxis: Vector3): Vector3;
  85031. /**
  85032. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  85033. * localAxis is expressed in the mesh local space.
  85034. * result is computed in the Wordl space from the mesh World matrix.
  85035. * @param localAxis axis to rotate
  85036. * @param result the resulting transformnode
  85037. * @returns this TransformNode.
  85038. */
  85039. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  85040. /**
  85041. * Sets this transform node rotation to the given local axis.
  85042. * @param localAxis the axis in local space
  85043. * @param yawCor optional yaw (y-axis) correction in radians
  85044. * @param pitchCor optional pitch (x-axis) correction in radians
  85045. * @param rollCor optional roll (z-axis) correction in radians
  85046. * @returns this TransformNode
  85047. */
  85048. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  85049. /**
  85050. * Sets a new pivot point to the current node
  85051. * @param point defines the new pivot point to use
  85052. * @param space defines if the point is in world or local space (local by default)
  85053. * @returns the current TransformNode
  85054. */
  85055. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  85056. /**
  85057. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  85058. * @returns the pivot point
  85059. */
  85060. getPivotPoint(): Vector3;
  85061. /**
  85062. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  85063. * @param result the vector3 to store the result
  85064. * @returns this TransformNode.
  85065. */
  85066. getPivotPointToRef(result: Vector3): TransformNode;
  85067. /**
  85068. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  85069. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  85070. */
  85071. getAbsolutePivotPoint(): Vector3;
  85072. /**
  85073. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  85074. * @param result vector3 to store the result
  85075. * @returns this TransformNode.
  85076. */
  85077. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  85078. /**
  85079. * Defines the passed node as the parent of the current node.
  85080. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  85081. * @see https://doc.babylonjs.com/how_to/parenting
  85082. * @param node the node ot set as the parent
  85083. * @returns this TransformNode.
  85084. */
  85085. setParent(node: Nullable<Node>): TransformNode;
  85086. private _nonUniformScaling;
  85087. /**
  85088. * True if the scaling property of this object is non uniform eg. (1,2,1)
  85089. */
  85090. get nonUniformScaling(): boolean;
  85091. /** @hidden */
  85092. _updateNonUniformScalingState(value: boolean): boolean;
  85093. /**
  85094. * Attach the current TransformNode to another TransformNode associated with a bone
  85095. * @param bone Bone affecting the TransformNode
  85096. * @param affectedTransformNode TransformNode associated with the bone
  85097. * @returns this object
  85098. */
  85099. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  85100. /**
  85101. * Detach the transform node if its associated with a bone
  85102. * @returns this object
  85103. */
  85104. detachFromBone(): TransformNode;
  85105. private static _rotationAxisCache;
  85106. /**
  85107. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  85108. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85109. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85110. * The passed axis is also normalized.
  85111. * @param axis the axis to rotate around
  85112. * @param amount the amount to rotate in radians
  85113. * @param space Space to rotate in (Default: local)
  85114. * @returns the TransformNode.
  85115. */
  85116. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  85117. /**
  85118. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  85119. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85120. * The passed axis is also normalized. .
  85121. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  85122. * @param point the point to rotate around
  85123. * @param axis the axis to rotate around
  85124. * @param amount the amount to rotate in radians
  85125. * @returns the TransformNode
  85126. */
  85127. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  85128. /**
  85129. * Translates the mesh along the axis vector for the passed distance in the given space.
  85130. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85131. * @param axis the axis to translate in
  85132. * @param distance the distance to translate
  85133. * @param space Space to rotate in (Default: local)
  85134. * @returns the TransformNode.
  85135. */
  85136. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  85137. /**
  85138. * Adds a rotation step to the mesh current rotation.
  85139. * x, y, z are Euler angles expressed in radians.
  85140. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  85141. * This means this rotation is made in the mesh local space only.
  85142. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  85143. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  85144. * ```javascript
  85145. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  85146. * ```
  85147. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  85148. * 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.
  85149. * @param x Rotation to add
  85150. * @param y Rotation to add
  85151. * @param z Rotation to add
  85152. * @returns the TransformNode.
  85153. */
  85154. addRotation(x: number, y: number, z: number): TransformNode;
  85155. /**
  85156. * @hidden
  85157. */
  85158. protected _getEffectiveParent(): Nullable<Node>;
  85159. /**
  85160. * Computes the world matrix of the node
  85161. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85162. * @returns the world matrix
  85163. */
  85164. computeWorldMatrix(force?: boolean): Matrix;
  85165. protected _afterComputeWorldMatrix(): void;
  85166. /**
  85167. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  85168. * @param func callback function to add
  85169. *
  85170. * @returns the TransformNode.
  85171. */
  85172. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85173. /**
  85174. * Removes a registered callback function.
  85175. * @param func callback function to remove
  85176. * @returns the TransformNode.
  85177. */
  85178. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85179. /**
  85180. * Gets the position of the current mesh in camera space
  85181. * @param camera defines the camera to use
  85182. * @returns a position
  85183. */
  85184. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  85185. /**
  85186. * Returns the distance from the mesh to the active camera
  85187. * @param camera defines the camera to use
  85188. * @returns the distance
  85189. */
  85190. getDistanceToCamera(camera?: Nullable<Camera>): number;
  85191. /**
  85192. * Clone the current transform node
  85193. * @param name Name of the new clone
  85194. * @param newParent New parent for the clone
  85195. * @param doNotCloneChildren Do not clone children hierarchy
  85196. * @returns the new transform node
  85197. */
  85198. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  85199. /**
  85200. * Serializes the objects information.
  85201. * @param currentSerializationObject defines the object to serialize in
  85202. * @returns the serialized object
  85203. */
  85204. serialize(currentSerializationObject?: any): any;
  85205. /**
  85206. * Returns a new TransformNode object parsed from the source provided.
  85207. * @param parsedTransformNode is the source.
  85208. * @param scene the scne the object belongs to
  85209. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  85210. * @returns a new TransformNode object parsed from the source provided.
  85211. */
  85212. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  85213. /**
  85214. * Get all child-transformNodes of this node
  85215. * @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
  85216. * @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
  85217. * @returns an array of TransformNode
  85218. */
  85219. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  85220. /**
  85221. * Releases resources associated with this transform node.
  85222. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85223. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85224. */
  85225. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85226. /**
  85227. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  85228. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  85229. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  85230. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  85231. * @returns the current mesh
  85232. */
  85233. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  85234. private _syncAbsoluteScalingAndRotation;
  85235. }
  85236. }
  85237. declare module BABYLON {
  85238. /**
  85239. * Defines the types of pose enabled controllers that are supported
  85240. */
  85241. export enum PoseEnabledControllerType {
  85242. /**
  85243. * HTC Vive
  85244. */
  85245. VIVE = 0,
  85246. /**
  85247. * Oculus Rift
  85248. */
  85249. OCULUS = 1,
  85250. /**
  85251. * Windows mixed reality
  85252. */
  85253. WINDOWS = 2,
  85254. /**
  85255. * Samsung gear VR
  85256. */
  85257. GEAR_VR = 3,
  85258. /**
  85259. * Google Daydream
  85260. */
  85261. DAYDREAM = 4,
  85262. /**
  85263. * Generic
  85264. */
  85265. GENERIC = 5
  85266. }
  85267. /**
  85268. * Defines the MutableGamepadButton interface for the state of a gamepad button
  85269. */
  85270. export interface MutableGamepadButton {
  85271. /**
  85272. * Value of the button/trigger
  85273. */
  85274. value: number;
  85275. /**
  85276. * If the button/trigger is currently touched
  85277. */
  85278. touched: boolean;
  85279. /**
  85280. * If the button/trigger is currently pressed
  85281. */
  85282. pressed: boolean;
  85283. }
  85284. /**
  85285. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  85286. * @hidden
  85287. */
  85288. export interface ExtendedGamepadButton extends GamepadButton {
  85289. /**
  85290. * If the button/trigger is currently pressed
  85291. */
  85292. readonly pressed: boolean;
  85293. /**
  85294. * If the button/trigger is currently touched
  85295. */
  85296. readonly touched: boolean;
  85297. /**
  85298. * Value of the button/trigger
  85299. */
  85300. readonly value: number;
  85301. }
  85302. /** @hidden */
  85303. export interface _GamePadFactory {
  85304. /**
  85305. * Returns wether or not the current gamepad can be created for this type of controller.
  85306. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85307. * @returns true if it can be created, otherwise false
  85308. */
  85309. canCreate(gamepadInfo: any): boolean;
  85310. /**
  85311. * Creates a new instance of the Gamepad.
  85312. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85313. * @returns the new gamepad instance
  85314. */
  85315. create(gamepadInfo: any): Gamepad;
  85316. }
  85317. /**
  85318. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85319. */
  85320. export class PoseEnabledControllerHelper {
  85321. /** @hidden */
  85322. static _ControllerFactories: _GamePadFactory[];
  85323. /** @hidden */
  85324. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  85325. /**
  85326. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85327. * @param vrGamepad the gamepad to initialized
  85328. * @returns a vr controller of the type the gamepad identified as
  85329. */
  85330. static InitiateController(vrGamepad: any): Gamepad;
  85331. }
  85332. /**
  85333. * Defines the PoseEnabledController object that contains state of a vr capable controller
  85334. */
  85335. export class PoseEnabledController extends Gamepad implements PoseControlled {
  85336. /**
  85337. * If the controller is used in a webXR session
  85338. */
  85339. isXR: boolean;
  85340. private _deviceRoomPosition;
  85341. private _deviceRoomRotationQuaternion;
  85342. /**
  85343. * The device position in babylon space
  85344. */
  85345. devicePosition: Vector3;
  85346. /**
  85347. * The device rotation in babylon space
  85348. */
  85349. deviceRotationQuaternion: Quaternion;
  85350. /**
  85351. * The scale factor of the device in babylon space
  85352. */
  85353. deviceScaleFactor: number;
  85354. /**
  85355. * (Likely devicePosition should be used instead) The device position in its room space
  85356. */
  85357. position: Vector3;
  85358. /**
  85359. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  85360. */
  85361. rotationQuaternion: Quaternion;
  85362. /**
  85363. * The type of controller (Eg. Windows mixed reality)
  85364. */
  85365. controllerType: PoseEnabledControllerType;
  85366. protected _calculatedPosition: Vector3;
  85367. private _calculatedRotation;
  85368. /**
  85369. * The raw pose from the device
  85370. */
  85371. rawPose: DevicePose;
  85372. private _trackPosition;
  85373. private _maxRotationDistFromHeadset;
  85374. private _draggedRoomRotation;
  85375. /**
  85376. * @hidden
  85377. */
  85378. _disableTrackPosition(fixedPosition: Vector3): void;
  85379. /**
  85380. * Internal, the mesh attached to the controller
  85381. * @hidden
  85382. */
  85383. _mesh: Nullable<AbstractMesh>;
  85384. private _poseControlledCamera;
  85385. private _leftHandSystemQuaternion;
  85386. /**
  85387. * Internal, matrix used to convert room space to babylon space
  85388. * @hidden
  85389. */
  85390. _deviceToWorld: Matrix;
  85391. /**
  85392. * Node to be used when casting a ray from the controller
  85393. * @hidden
  85394. */
  85395. _pointingPoseNode: Nullable<TransformNode>;
  85396. /**
  85397. * Name of the child mesh that can be used to cast a ray from the controller
  85398. */
  85399. static readonly POINTING_POSE: string;
  85400. /**
  85401. * Creates a new PoseEnabledController from a gamepad
  85402. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  85403. */
  85404. constructor(browserGamepad: any);
  85405. private _workingMatrix;
  85406. /**
  85407. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  85408. */
  85409. update(): void;
  85410. /**
  85411. * Updates only the pose device and mesh without doing any button event checking
  85412. */
  85413. protected _updatePoseAndMesh(): void;
  85414. /**
  85415. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  85416. * @param poseData raw pose fromthe device
  85417. */
  85418. updateFromDevice(poseData: DevicePose): void;
  85419. /**
  85420. * @hidden
  85421. */
  85422. _meshAttachedObservable: Observable<AbstractMesh>;
  85423. /**
  85424. * Attaches a mesh to the controller
  85425. * @param mesh the mesh to be attached
  85426. */
  85427. attachToMesh(mesh: AbstractMesh): void;
  85428. /**
  85429. * Attaches the controllers mesh to a camera
  85430. * @param camera the camera the mesh should be attached to
  85431. */
  85432. attachToPoseControlledCamera(camera: TargetCamera): void;
  85433. /**
  85434. * Disposes of the controller
  85435. */
  85436. dispose(): void;
  85437. /**
  85438. * The mesh that is attached to the controller
  85439. */
  85440. get mesh(): Nullable<AbstractMesh>;
  85441. /**
  85442. * Gets the ray of the controller in the direction the controller is pointing
  85443. * @param length the length the resulting ray should be
  85444. * @returns a ray in the direction the controller is pointing
  85445. */
  85446. getForwardRay(length?: number): Ray;
  85447. }
  85448. }
  85449. declare module BABYLON {
  85450. /**
  85451. * Defines the WebVRController object that represents controllers tracked in 3D space
  85452. */
  85453. export abstract class WebVRController extends PoseEnabledController {
  85454. /**
  85455. * Internal, the default controller model for the controller
  85456. */
  85457. protected _defaultModel: Nullable<AbstractMesh>;
  85458. /**
  85459. * Fired when the trigger state has changed
  85460. */
  85461. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  85462. /**
  85463. * Fired when the main button state has changed
  85464. */
  85465. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85466. /**
  85467. * Fired when the secondary button state has changed
  85468. */
  85469. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85470. /**
  85471. * Fired when the pad state has changed
  85472. */
  85473. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  85474. /**
  85475. * Fired when controllers stick values have changed
  85476. */
  85477. onPadValuesChangedObservable: Observable<StickValues>;
  85478. /**
  85479. * Array of button availible on the controller
  85480. */
  85481. protected _buttons: Array<MutableGamepadButton>;
  85482. private _onButtonStateChange;
  85483. /**
  85484. * Fired when a controller button's state has changed
  85485. * @param callback the callback containing the button that was modified
  85486. */
  85487. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  85488. /**
  85489. * X and Y axis corresponding to the controllers joystick
  85490. */
  85491. pad: StickValues;
  85492. /**
  85493. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  85494. */
  85495. hand: string;
  85496. /**
  85497. * The default controller model for the controller
  85498. */
  85499. get defaultModel(): Nullable<AbstractMesh>;
  85500. /**
  85501. * Creates a new WebVRController from a gamepad
  85502. * @param vrGamepad the gamepad that the WebVRController should be created from
  85503. */
  85504. constructor(vrGamepad: any);
  85505. /**
  85506. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  85507. */
  85508. update(): void;
  85509. /**
  85510. * Function to be called when a button is modified
  85511. */
  85512. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  85513. /**
  85514. * Loads a mesh and attaches it to the controller
  85515. * @param scene the scene the mesh should be added to
  85516. * @param meshLoaded callback for when the mesh has been loaded
  85517. */
  85518. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  85519. private _setButtonValue;
  85520. private _changes;
  85521. private _checkChanges;
  85522. /**
  85523. * Disposes of th webVRCOntroller
  85524. */
  85525. dispose(): void;
  85526. }
  85527. }
  85528. declare module BABYLON {
  85529. /**
  85530. * The HemisphericLight simulates the ambient environment light,
  85531. * so the passed direction is the light reflection direction, not the incoming direction.
  85532. */
  85533. export class HemisphericLight extends Light {
  85534. /**
  85535. * The groundColor is the light in the opposite direction to the one specified during creation.
  85536. * 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.
  85537. */
  85538. groundColor: Color3;
  85539. /**
  85540. * The light reflection direction, not the incoming direction.
  85541. */
  85542. direction: Vector3;
  85543. /**
  85544. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  85545. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  85546. * The HemisphericLight can't cast shadows.
  85547. * Documentation : https://doc.babylonjs.com/babylon101/lights
  85548. * @param name The friendly name of the light
  85549. * @param direction The direction of the light reflection
  85550. * @param scene The scene the light belongs to
  85551. */
  85552. constructor(name: string, direction: Vector3, scene: Scene);
  85553. protected _buildUniformLayout(): void;
  85554. /**
  85555. * Returns the string "HemisphericLight".
  85556. * @return The class name
  85557. */
  85558. getClassName(): string;
  85559. /**
  85560. * Sets the HemisphericLight direction towards the passed target (Vector3).
  85561. * Returns the updated direction.
  85562. * @param target The target the direction should point to
  85563. * @return The computed direction
  85564. */
  85565. setDirectionToTarget(target: Vector3): Vector3;
  85566. /**
  85567. * Returns the shadow generator associated to the light.
  85568. * @returns Always null for hemispheric lights because it does not support shadows.
  85569. */
  85570. getShadowGenerator(): Nullable<IShadowGenerator>;
  85571. /**
  85572. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  85573. * @param effect The effect to update
  85574. * @param lightIndex The index of the light in the effect to update
  85575. * @returns The hemispheric light
  85576. */
  85577. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  85578. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  85579. /**
  85580. * Computes the world matrix of the node
  85581. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85582. * @param useWasUpdatedFlag defines a reserved property
  85583. * @returns the world matrix
  85584. */
  85585. computeWorldMatrix(): Matrix;
  85586. /**
  85587. * Returns the integer 3.
  85588. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  85589. */
  85590. getTypeID(): number;
  85591. /**
  85592. * Prepares the list of defines specific to the light type.
  85593. * @param defines the list of defines
  85594. * @param lightIndex defines the index of the light for the effect
  85595. */
  85596. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  85597. }
  85598. }
  85599. declare module BABYLON {
  85600. /** @hidden */
  85601. export var vrMultiviewToSingleviewPixelShader: {
  85602. name: string;
  85603. shader: string;
  85604. };
  85605. }
  85606. declare module BABYLON {
  85607. /**
  85608. * Renders to multiple views with a single draw call
  85609. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  85610. */
  85611. export class MultiviewRenderTarget extends RenderTargetTexture {
  85612. /**
  85613. * Creates a multiview render target
  85614. * @param scene scene used with the render target
  85615. * @param size the size of the render target (used for each view)
  85616. */
  85617. constructor(scene: Scene, size?: number | {
  85618. width: number;
  85619. height: number;
  85620. } | {
  85621. ratio: number;
  85622. });
  85623. /**
  85624. * @hidden
  85625. * @param faceIndex the face index, if its a cube texture
  85626. */
  85627. _bindFrameBuffer(faceIndex?: number): void;
  85628. /**
  85629. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85630. * @returns the view count
  85631. */
  85632. getViewCount(): number;
  85633. }
  85634. }
  85635. declare module BABYLON {
  85636. /**
  85637. * Represents a camera frustum
  85638. */
  85639. export class Frustum {
  85640. /**
  85641. * Gets the planes representing the frustum
  85642. * @param transform matrix to be applied to the returned planes
  85643. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85644. */
  85645. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85646. /**
  85647. * Gets the near frustum plane transformed by the transform matrix
  85648. * @param transform transformation matrix to be applied to the resulting frustum plane
  85649. * @param frustumPlane the resuling frustum plane
  85650. */
  85651. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85652. /**
  85653. * Gets the far frustum plane transformed by the transform matrix
  85654. * @param transform transformation matrix to be applied to the resulting frustum plane
  85655. * @param frustumPlane the resuling frustum plane
  85656. */
  85657. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85658. /**
  85659. * Gets the left frustum plane transformed by the transform matrix
  85660. * @param transform transformation matrix to be applied to the resulting frustum plane
  85661. * @param frustumPlane the resuling frustum plane
  85662. */
  85663. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85664. /**
  85665. * Gets the right frustum plane transformed by the transform matrix
  85666. * @param transform transformation matrix to be applied to the resulting frustum plane
  85667. * @param frustumPlane the resuling frustum plane
  85668. */
  85669. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85670. /**
  85671. * Gets the top frustum plane transformed by the transform matrix
  85672. * @param transform transformation matrix to be applied to the resulting frustum plane
  85673. * @param frustumPlane the resuling frustum plane
  85674. */
  85675. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85676. /**
  85677. * Gets the bottom frustum plane transformed by the transform matrix
  85678. * @param transform transformation matrix to be applied to the resulting frustum plane
  85679. * @param frustumPlane the resuling frustum plane
  85680. */
  85681. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85682. /**
  85683. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85684. * @param transform transformation matrix to be applied to the resulting frustum planes
  85685. * @param frustumPlanes the resuling frustum planes
  85686. */
  85687. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85688. }
  85689. }
  85690. declare module BABYLON {
  85691. interface Engine {
  85692. /**
  85693. * Creates a new multiview render target
  85694. * @param width defines the width of the texture
  85695. * @param height defines the height of the texture
  85696. * @returns the created multiview texture
  85697. */
  85698. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  85699. /**
  85700. * Binds a multiview framebuffer to be drawn to
  85701. * @param multiviewTexture texture to bind
  85702. */
  85703. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  85704. }
  85705. interface Camera {
  85706. /**
  85707. * @hidden
  85708. * 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)
  85709. */
  85710. _useMultiviewToSingleView: boolean;
  85711. /**
  85712. * @hidden
  85713. * 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)
  85714. */
  85715. _multiviewTexture: Nullable<RenderTargetTexture>;
  85716. /**
  85717. * @hidden
  85718. * ensures the multiview texture of the camera exists and has the specified width/height
  85719. * @param width height to set on the multiview texture
  85720. * @param height width to set on the multiview texture
  85721. */
  85722. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  85723. }
  85724. interface Scene {
  85725. /** @hidden */
  85726. _transformMatrixR: Matrix;
  85727. /** @hidden */
  85728. _multiviewSceneUbo: Nullable<UniformBuffer>;
  85729. /** @hidden */
  85730. _createMultiviewUbo(): void;
  85731. /** @hidden */
  85732. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  85733. /** @hidden */
  85734. _renderMultiviewToSingleView(camera: Camera): void;
  85735. }
  85736. }
  85737. declare module BABYLON {
  85738. /**
  85739. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  85740. * This will not be used for webXR as it supports displaying texture arrays directly
  85741. */
  85742. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  85743. /**
  85744. * Initializes a VRMultiviewToSingleview
  85745. * @param name name of the post process
  85746. * @param camera camera to be applied to
  85747. * @param scaleFactor scaling factor to the size of the output texture
  85748. */
  85749. constructor(name: string, camera: Camera, scaleFactor: number);
  85750. }
  85751. }
  85752. declare module BABYLON {
  85753. /**
  85754. * Interface used to define additional presentation attributes
  85755. */
  85756. export interface IVRPresentationAttributes {
  85757. /**
  85758. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  85759. */
  85760. highRefreshRate: boolean;
  85761. /**
  85762. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  85763. */
  85764. foveationLevel: number;
  85765. }
  85766. interface Engine {
  85767. /** @hidden */
  85768. _vrDisplay: any;
  85769. /** @hidden */
  85770. _vrSupported: boolean;
  85771. /** @hidden */
  85772. _oldSize: Size;
  85773. /** @hidden */
  85774. _oldHardwareScaleFactor: number;
  85775. /** @hidden */
  85776. _vrExclusivePointerMode: boolean;
  85777. /** @hidden */
  85778. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  85779. /** @hidden */
  85780. _onVRDisplayPointerRestricted: () => void;
  85781. /** @hidden */
  85782. _onVRDisplayPointerUnrestricted: () => void;
  85783. /** @hidden */
  85784. _onVrDisplayConnect: Nullable<(display: any) => void>;
  85785. /** @hidden */
  85786. _onVrDisplayDisconnect: Nullable<() => void>;
  85787. /** @hidden */
  85788. _onVrDisplayPresentChange: Nullable<() => void>;
  85789. /**
  85790. * Observable signaled when VR display mode changes
  85791. */
  85792. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85793. /**
  85794. * Observable signaled when VR request present is complete
  85795. */
  85796. onVRRequestPresentComplete: Observable<boolean>;
  85797. /**
  85798. * Observable signaled when VR request present starts
  85799. */
  85800. onVRRequestPresentStart: Observable<Engine>;
  85801. /**
  85802. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85803. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85804. */
  85805. isInVRExclusivePointerMode: boolean;
  85806. /**
  85807. * Gets a boolean indicating if a webVR device was detected
  85808. * @returns true if a webVR device was detected
  85809. */
  85810. isVRDevicePresent(): boolean;
  85811. /**
  85812. * Gets the current webVR device
  85813. * @returns the current webVR device (or null)
  85814. */
  85815. getVRDevice(): any;
  85816. /**
  85817. * Initializes a webVR display and starts listening to display change events
  85818. * The onVRDisplayChangedObservable will be notified upon these changes
  85819. * @returns A promise containing a VRDisplay and if vr is supported
  85820. */
  85821. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85822. /** @hidden */
  85823. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  85824. /**
  85825. * Gets or sets the presentation attributes used to configure VR rendering
  85826. */
  85827. vrPresentationAttributes?: IVRPresentationAttributes;
  85828. /**
  85829. * Call this function to switch to webVR mode
  85830. * Will do nothing if webVR is not supported or if there is no webVR device
  85831. * @param options the webvr options provided to the camera. mainly used for multiview
  85832. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85833. */
  85834. enableVR(options: WebVROptions): void;
  85835. /** @hidden */
  85836. _onVRFullScreenTriggered(): void;
  85837. }
  85838. }
  85839. declare module BABYLON {
  85840. /**
  85841. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  85842. * IMPORTANT!! The data is right-hand data.
  85843. * @export
  85844. * @interface DevicePose
  85845. */
  85846. export interface DevicePose {
  85847. /**
  85848. * The position of the device, values in array are [x,y,z].
  85849. */
  85850. readonly position: Nullable<Float32Array>;
  85851. /**
  85852. * The linearVelocity of the device, values in array are [x,y,z].
  85853. */
  85854. readonly linearVelocity: Nullable<Float32Array>;
  85855. /**
  85856. * The linearAcceleration of the device, values in array are [x,y,z].
  85857. */
  85858. readonly linearAcceleration: Nullable<Float32Array>;
  85859. /**
  85860. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  85861. */
  85862. readonly orientation: Nullable<Float32Array>;
  85863. /**
  85864. * The angularVelocity of the device, values in array are [x,y,z].
  85865. */
  85866. readonly angularVelocity: Nullable<Float32Array>;
  85867. /**
  85868. * The angularAcceleration of the device, values in array are [x,y,z].
  85869. */
  85870. readonly angularAcceleration: Nullable<Float32Array>;
  85871. }
  85872. /**
  85873. * Interface representing a pose controlled object in Babylon.
  85874. * A pose controlled object has both regular pose values as well as pose values
  85875. * from an external device such as a VR head mounted display
  85876. */
  85877. export interface PoseControlled {
  85878. /**
  85879. * The position of the object in babylon space.
  85880. */
  85881. position: Vector3;
  85882. /**
  85883. * The rotation quaternion of the object in babylon space.
  85884. */
  85885. rotationQuaternion: Quaternion;
  85886. /**
  85887. * The position of the device in babylon space.
  85888. */
  85889. devicePosition?: Vector3;
  85890. /**
  85891. * The rotation quaternion of the device in babylon space.
  85892. */
  85893. deviceRotationQuaternion: Quaternion;
  85894. /**
  85895. * The raw pose coming from the device.
  85896. */
  85897. rawPose: Nullable<DevicePose>;
  85898. /**
  85899. * The scale of the device to be used when translating from device space to babylon space.
  85900. */
  85901. deviceScaleFactor: number;
  85902. /**
  85903. * Updates the poseControlled values based on the input device pose.
  85904. * @param poseData the pose data to update the object with
  85905. */
  85906. updateFromDevice(poseData: DevicePose): void;
  85907. }
  85908. /**
  85909. * Set of options to customize the webVRCamera
  85910. */
  85911. export interface WebVROptions {
  85912. /**
  85913. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  85914. */
  85915. trackPosition?: boolean;
  85916. /**
  85917. * Sets the scale of the vrDevice in babylon space. (default: 1)
  85918. */
  85919. positionScale?: number;
  85920. /**
  85921. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  85922. */
  85923. displayName?: string;
  85924. /**
  85925. * Should the native controller meshes be initialized. (default: true)
  85926. */
  85927. controllerMeshes?: boolean;
  85928. /**
  85929. * Creating a default HemiLight only on controllers. (default: true)
  85930. */
  85931. defaultLightingOnControllers?: boolean;
  85932. /**
  85933. * If you don't want to use the default VR button of the helper. (default: false)
  85934. */
  85935. useCustomVRButton?: boolean;
  85936. /**
  85937. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  85938. */
  85939. customVRButton?: HTMLButtonElement;
  85940. /**
  85941. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  85942. */
  85943. rayLength?: number;
  85944. /**
  85945. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  85946. */
  85947. defaultHeight?: number;
  85948. /**
  85949. * If multiview should be used if availible (default: false)
  85950. */
  85951. useMultiview?: boolean;
  85952. }
  85953. /**
  85954. * This represents a WebVR camera.
  85955. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  85956. * @example http://doc.babylonjs.com/how_to/webvr_camera
  85957. */
  85958. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  85959. private webVROptions;
  85960. /**
  85961. * @hidden
  85962. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  85963. */
  85964. _vrDevice: any;
  85965. /**
  85966. * The rawPose of the vrDevice.
  85967. */
  85968. rawPose: Nullable<DevicePose>;
  85969. private _onVREnabled;
  85970. private _specsVersion;
  85971. private _attached;
  85972. private _frameData;
  85973. protected _descendants: Array<Node>;
  85974. private _deviceRoomPosition;
  85975. /** @hidden */
  85976. _deviceRoomRotationQuaternion: Quaternion;
  85977. private _standingMatrix;
  85978. /**
  85979. * Represents device position in babylon space.
  85980. */
  85981. devicePosition: Vector3;
  85982. /**
  85983. * Represents device rotation in babylon space.
  85984. */
  85985. deviceRotationQuaternion: Quaternion;
  85986. /**
  85987. * The scale of the device to be used when translating from device space to babylon space.
  85988. */
  85989. deviceScaleFactor: number;
  85990. private _deviceToWorld;
  85991. private _worldToDevice;
  85992. /**
  85993. * References to the webVR controllers for the vrDevice.
  85994. */
  85995. controllers: Array<WebVRController>;
  85996. /**
  85997. * Emits an event when a controller is attached.
  85998. */
  85999. onControllersAttachedObservable: Observable<WebVRController[]>;
  86000. /**
  86001. * Emits an event when a controller's mesh has been loaded;
  86002. */
  86003. onControllerMeshLoadedObservable: Observable<WebVRController>;
  86004. /**
  86005. * Emits an event when the HMD's pose has been updated.
  86006. */
  86007. onPoseUpdatedFromDeviceObservable: Observable<any>;
  86008. private _poseSet;
  86009. /**
  86010. * If the rig cameras be used as parent instead of this camera.
  86011. */
  86012. rigParenting: boolean;
  86013. private _lightOnControllers;
  86014. private _defaultHeight?;
  86015. /**
  86016. * Instantiates a WebVRFreeCamera.
  86017. * @param name The name of the WebVRFreeCamera
  86018. * @param position The starting anchor position for the camera
  86019. * @param scene The scene the camera belongs to
  86020. * @param webVROptions a set of customizable options for the webVRCamera
  86021. */
  86022. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  86023. /**
  86024. * Gets the device distance from the ground in meters.
  86025. * @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.
  86026. */
  86027. deviceDistanceToRoomGround(): number;
  86028. /**
  86029. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  86030. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  86031. */
  86032. useStandingMatrix(callback?: (bool: boolean) => void): void;
  86033. /**
  86034. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  86035. * @returns A promise with a boolean set to if the standing matrix is supported.
  86036. */
  86037. useStandingMatrixAsync(): Promise<boolean>;
  86038. /**
  86039. * Disposes the camera
  86040. */
  86041. dispose(): void;
  86042. /**
  86043. * Gets a vrController by name.
  86044. * @param name The name of the controller to retreive
  86045. * @returns the controller matching the name specified or null if not found
  86046. */
  86047. getControllerByName(name: string): Nullable<WebVRController>;
  86048. private _leftController;
  86049. /**
  86050. * The controller corresponding to the users left hand.
  86051. */
  86052. get leftController(): Nullable<WebVRController>;
  86053. private _rightController;
  86054. /**
  86055. * The controller corresponding to the users right hand.
  86056. */
  86057. get rightController(): Nullable<WebVRController>;
  86058. /**
  86059. * Casts a ray forward from the vrCamera's gaze.
  86060. * @param length Length of the ray (default: 100)
  86061. * @returns the ray corresponding to the gaze
  86062. */
  86063. getForwardRay(length?: number): Ray;
  86064. /**
  86065. * @hidden
  86066. * Updates the camera based on device's frame data
  86067. */
  86068. _checkInputs(): void;
  86069. /**
  86070. * Updates the poseControlled values based on the input device pose.
  86071. * @param poseData Pose coming from the device
  86072. */
  86073. updateFromDevice(poseData: DevicePose): void;
  86074. private _htmlElementAttached;
  86075. private _detachIfAttached;
  86076. /**
  86077. * WebVR's attach control will start broadcasting frames to the device.
  86078. * Note that in certain browsers (chrome for example) this function must be called
  86079. * within a user-interaction callback. Example:
  86080. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  86081. *
  86082. * @param element html element to attach the vrDevice to
  86083. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  86084. */
  86085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86086. /**
  86087. * Detaches the camera from the html element and disables VR
  86088. *
  86089. * @param element html element to detach from
  86090. */
  86091. detachControl(element: HTMLElement): void;
  86092. /**
  86093. * @returns the name of this class
  86094. */
  86095. getClassName(): string;
  86096. /**
  86097. * Calls resetPose on the vrDisplay
  86098. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  86099. */
  86100. resetToCurrentRotation(): void;
  86101. /**
  86102. * @hidden
  86103. * Updates the rig cameras (left and right eye)
  86104. */
  86105. _updateRigCameras(): void;
  86106. private _workingVector;
  86107. private _oneVector;
  86108. private _workingMatrix;
  86109. private updateCacheCalled;
  86110. private _correctPositionIfNotTrackPosition;
  86111. /**
  86112. * @hidden
  86113. * Updates the cached values of the camera
  86114. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  86115. */
  86116. _updateCache(ignoreParentClass?: boolean): void;
  86117. /**
  86118. * @hidden
  86119. * Get current device position in babylon world
  86120. */
  86121. _computeDevicePosition(): void;
  86122. /**
  86123. * Updates the current device position and rotation in the babylon world
  86124. */
  86125. update(): void;
  86126. /**
  86127. * @hidden
  86128. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  86129. * @returns an identity matrix
  86130. */
  86131. _getViewMatrix(): Matrix;
  86132. private _tmpMatrix;
  86133. /**
  86134. * This function is called by the two RIG cameras.
  86135. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  86136. * @hidden
  86137. */
  86138. _getWebVRViewMatrix(): Matrix;
  86139. /** @hidden */
  86140. _getWebVRProjectionMatrix(): Matrix;
  86141. private _onGamepadConnectedObserver;
  86142. private _onGamepadDisconnectedObserver;
  86143. private _updateCacheWhenTrackingDisabledObserver;
  86144. /**
  86145. * Initializes the controllers and their meshes
  86146. */
  86147. initControllers(): void;
  86148. }
  86149. }
  86150. declare module BABYLON {
  86151. /**
  86152. * Size options for a post process
  86153. */
  86154. export type PostProcessOptions = {
  86155. width: number;
  86156. height: number;
  86157. };
  86158. /**
  86159. * PostProcess can be used to apply a shader to a texture after it has been rendered
  86160. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86161. */
  86162. export class PostProcess {
  86163. /** Name of the PostProcess. */
  86164. name: string;
  86165. /**
  86166. * Gets or sets the unique id of the post process
  86167. */
  86168. uniqueId: number;
  86169. /**
  86170. * Width of the texture to apply the post process on
  86171. */
  86172. width: number;
  86173. /**
  86174. * Height of the texture to apply the post process on
  86175. */
  86176. height: number;
  86177. /**
  86178. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  86179. * @hidden
  86180. */
  86181. _outputTexture: Nullable<InternalTexture>;
  86182. /**
  86183. * Sampling mode used by the shader
  86184. * See https://doc.babylonjs.com/classes/3.1/texture
  86185. */
  86186. renderTargetSamplingMode: number;
  86187. /**
  86188. * Clear color to use when screen clearing
  86189. */
  86190. clearColor: Color4;
  86191. /**
  86192. * If the buffer needs to be cleared before applying the post process. (default: true)
  86193. * Should be set to false if shader will overwrite all previous pixels.
  86194. */
  86195. autoClear: boolean;
  86196. /**
  86197. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  86198. */
  86199. alphaMode: number;
  86200. /**
  86201. * Sets the setAlphaBlendConstants of the babylon engine
  86202. */
  86203. alphaConstants: Color4;
  86204. /**
  86205. * Animations to be used for the post processing
  86206. */
  86207. animations: Animation[];
  86208. /**
  86209. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  86210. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  86211. */
  86212. enablePixelPerfectMode: boolean;
  86213. /**
  86214. * Force the postprocess to be applied without taking in account viewport
  86215. */
  86216. forceFullscreenViewport: boolean;
  86217. /**
  86218. * List of inspectable custom properties (used by the Inspector)
  86219. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86220. */
  86221. inspectableCustomProperties: IInspectable[];
  86222. /**
  86223. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  86224. *
  86225. * | Value | Type | Description |
  86226. * | ----- | ----------------------------------- | ----------- |
  86227. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  86228. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  86229. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  86230. *
  86231. */
  86232. scaleMode: number;
  86233. /**
  86234. * Force textures to be a power of two (default: false)
  86235. */
  86236. alwaysForcePOT: boolean;
  86237. private _samples;
  86238. /**
  86239. * Number of sample textures (default: 1)
  86240. */
  86241. get samples(): number;
  86242. set samples(n: number);
  86243. /**
  86244. * Modify the scale of the post process to be the same as the viewport (default: false)
  86245. */
  86246. adaptScaleToCurrentViewport: boolean;
  86247. private _camera;
  86248. private _scene;
  86249. private _engine;
  86250. private _options;
  86251. private _reusable;
  86252. private _textureType;
  86253. /**
  86254. * Smart array of input and output textures for the post process.
  86255. * @hidden
  86256. */
  86257. _textures: SmartArray<InternalTexture>;
  86258. /**
  86259. * The index in _textures that corresponds to the output texture.
  86260. * @hidden
  86261. */
  86262. _currentRenderTextureInd: number;
  86263. private _effect;
  86264. private _samplers;
  86265. private _fragmentUrl;
  86266. private _vertexUrl;
  86267. private _parameters;
  86268. private _scaleRatio;
  86269. protected _indexParameters: any;
  86270. private _shareOutputWithPostProcess;
  86271. private _texelSize;
  86272. private _forcedOutputTexture;
  86273. /**
  86274. * Returns the fragment url or shader name used in the post process.
  86275. * @returns the fragment url or name in the shader store.
  86276. */
  86277. getEffectName(): string;
  86278. /**
  86279. * An event triggered when the postprocess is activated.
  86280. */
  86281. onActivateObservable: Observable<Camera>;
  86282. private _onActivateObserver;
  86283. /**
  86284. * A function that is added to the onActivateObservable
  86285. */
  86286. set onActivate(callback: Nullable<(camera: Camera) => void>);
  86287. /**
  86288. * An event triggered when the postprocess changes its size.
  86289. */
  86290. onSizeChangedObservable: Observable<PostProcess>;
  86291. private _onSizeChangedObserver;
  86292. /**
  86293. * A function that is added to the onSizeChangedObservable
  86294. */
  86295. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  86296. /**
  86297. * An event triggered when the postprocess applies its effect.
  86298. */
  86299. onApplyObservable: Observable<Effect>;
  86300. private _onApplyObserver;
  86301. /**
  86302. * A function that is added to the onApplyObservable
  86303. */
  86304. set onApply(callback: (effect: Effect) => void);
  86305. /**
  86306. * An event triggered before rendering the postprocess
  86307. */
  86308. onBeforeRenderObservable: Observable<Effect>;
  86309. private _onBeforeRenderObserver;
  86310. /**
  86311. * A function that is added to the onBeforeRenderObservable
  86312. */
  86313. set onBeforeRender(callback: (effect: Effect) => void);
  86314. /**
  86315. * An event triggered after rendering the postprocess
  86316. */
  86317. onAfterRenderObservable: Observable<Effect>;
  86318. private _onAfterRenderObserver;
  86319. /**
  86320. * A function that is added to the onAfterRenderObservable
  86321. */
  86322. set onAfterRender(callback: (efect: Effect) => void);
  86323. /**
  86324. * 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
  86325. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  86326. */
  86327. get inputTexture(): InternalTexture;
  86328. set inputTexture(value: InternalTexture);
  86329. /**
  86330. * Gets the camera which post process is applied to.
  86331. * @returns The camera the post process is applied to.
  86332. */
  86333. getCamera(): Camera;
  86334. /**
  86335. * Gets the texel size of the postprocess.
  86336. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  86337. */
  86338. get texelSize(): Vector2;
  86339. /**
  86340. * Creates a new instance PostProcess
  86341. * @param name The name of the PostProcess.
  86342. * @param fragmentUrl The url of the fragment shader to be used.
  86343. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  86344. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  86345. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86346. * @param camera The camera to apply the render pass to.
  86347. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86348. * @param engine The engine which the post process will be applied. (default: current engine)
  86349. * @param reusable If the post process can be reused on the same frame. (default: false)
  86350. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  86351. * @param textureType Type of textures used when performing the post process. (default: 0)
  86352. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  86353. * @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
  86354. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  86355. */
  86356. constructor(
  86357. /** Name of the PostProcess. */
  86358. 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);
  86359. /**
  86360. * Gets a string idenfifying the name of the class
  86361. * @returns "PostProcess" string
  86362. */
  86363. getClassName(): string;
  86364. /**
  86365. * Gets the engine which this post process belongs to.
  86366. * @returns The engine the post process was enabled with.
  86367. */
  86368. getEngine(): Engine;
  86369. /**
  86370. * The effect that is created when initializing the post process.
  86371. * @returns The created effect corresponding the the postprocess.
  86372. */
  86373. getEffect(): Effect;
  86374. /**
  86375. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  86376. * @param postProcess The post process to share the output with.
  86377. * @returns This post process.
  86378. */
  86379. shareOutputWith(postProcess: PostProcess): PostProcess;
  86380. /**
  86381. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  86382. * This should be called if the post process that shares output with this post process is disabled/disposed.
  86383. */
  86384. useOwnOutput(): void;
  86385. /**
  86386. * Updates the effect with the current post process compile time values and recompiles the shader.
  86387. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86388. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86389. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86390. * @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
  86391. * @param onCompiled Called when the shader has been compiled.
  86392. * @param onError Called if there is an error when compiling a shader.
  86393. */
  86394. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86395. /**
  86396. * The post process is reusable if it can be used multiple times within one frame.
  86397. * @returns If the post process is reusable
  86398. */
  86399. isReusable(): boolean;
  86400. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  86401. markTextureDirty(): void;
  86402. /**
  86403. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  86404. * 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.
  86405. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  86406. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  86407. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  86408. * @returns The target texture that was bound to be written to.
  86409. */
  86410. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  86411. /**
  86412. * If the post process is supported.
  86413. */
  86414. get isSupported(): boolean;
  86415. /**
  86416. * The aspect ratio of the output texture.
  86417. */
  86418. get aspectRatio(): number;
  86419. /**
  86420. * Get a value indicating if the post-process is ready to be used
  86421. * @returns true if the post-process is ready (shader is compiled)
  86422. */
  86423. isReady(): boolean;
  86424. /**
  86425. * Binds all textures and uniforms to the shader, this will be run on every pass.
  86426. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  86427. */
  86428. apply(): Nullable<Effect>;
  86429. private _disposeTextures;
  86430. /**
  86431. * Disposes the post process.
  86432. * @param camera The camera to dispose the post process on.
  86433. */
  86434. dispose(camera?: Camera): void;
  86435. }
  86436. }
  86437. declare module BABYLON {
  86438. /** @hidden */
  86439. export var kernelBlurVaryingDeclaration: {
  86440. name: string;
  86441. shader: string;
  86442. };
  86443. }
  86444. declare module BABYLON {
  86445. /** @hidden */
  86446. export var kernelBlurFragment: {
  86447. name: string;
  86448. shader: string;
  86449. };
  86450. }
  86451. declare module BABYLON {
  86452. /** @hidden */
  86453. export var kernelBlurFragment2: {
  86454. name: string;
  86455. shader: string;
  86456. };
  86457. }
  86458. declare module BABYLON {
  86459. /** @hidden */
  86460. export var kernelBlurPixelShader: {
  86461. name: string;
  86462. shader: string;
  86463. };
  86464. }
  86465. declare module BABYLON {
  86466. /** @hidden */
  86467. export var kernelBlurVertex: {
  86468. name: string;
  86469. shader: string;
  86470. };
  86471. }
  86472. declare module BABYLON {
  86473. /** @hidden */
  86474. export var kernelBlurVertexShader: {
  86475. name: string;
  86476. shader: string;
  86477. };
  86478. }
  86479. declare module BABYLON {
  86480. /**
  86481. * The Blur Post Process which blurs an image based on a kernel and direction.
  86482. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  86483. */
  86484. export class BlurPostProcess extends PostProcess {
  86485. /** The direction in which to blur the image. */
  86486. direction: Vector2;
  86487. private blockCompilation;
  86488. protected _kernel: number;
  86489. protected _idealKernel: number;
  86490. protected _packedFloat: boolean;
  86491. private _staticDefines;
  86492. /**
  86493. * Sets the length in pixels of the blur sample region
  86494. */
  86495. set kernel(v: number);
  86496. /**
  86497. * Gets the length in pixels of the blur sample region
  86498. */
  86499. get kernel(): number;
  86500. /**
  86501. * Sets wether or not the blur needs to unpack/repack floats
  86502. */
  86503. set packedFloat(v: boolean);
  86504. /**
  86505. * Gets wether or not the blur is unpacking/repacking floats
  86506. */
  86507. get packedFloat(): boolean;
  86508. /**
  86509. * Creates a new instance BlurPostProcess
  86510. * @param name The name of the effect.
  86511. * @param direction The direction in which to blur the image.
  86512. * @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.
  86513. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86514. * @param camera The camera to apply the render pass to.
  86515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86516. * @param engine The engine which the post process will be applied. (default: current engine)
  86517. * @param reusable If the post process can be reused on the same frame. (default: false)
  86518. * @param textureType Type of textures used when performing the post process. (default: 0)
  86519. * @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)
  86520. */
  86521. constructor(name: string,
  86522. /** The direction in which to blur the image. */
  86523. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  86524. /**
  86525. * Updates the effect with the current post process compile time values and recompiles the shader.
  86526. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86527. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86528. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86529. * @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
  86530. * @param onCompiled Called when the shader has been compiled.
  86531. * @param onError Called if there is an error when compiling a shader.
  86532. */
  86533. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86534. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86535. /**
  86536. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  86537. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  86538. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  86539. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  86540. * The gaps between physical kernels are compensated for in the weighting of the samples
  86541. * @param idealKernel Ideal blur kernel.
  86542. * @return Nearest best kernel.
  86543. */
  86544. protected _nearestBestKernel(idealKernel: number): number;
  86545. /**
  86546. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  86547. * @param x The point on the Gaussian distribution to sample.
  86548. * @return the value of the Gaussian function at x.
  86549. */
  86550. protected _gaussianWeight(x: number): number;
  86551. /**
  86552. * Generates a string that can be used as a floating point number in GLSL.
  86553. * @param x Value to print.
  86554. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  86555. * @return GLSL float string.
  86556. */
  86557. protected _glslFloat(x: number, decimalFigures?: number): string;
  86558. }
  86559. }
  86560. declare module BABYLON {
  86561. /**
  86562. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86563. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86564. * You can then easily use it as a reflectionTexture on a flat surface.
  86565. * In case the surface is not a plane, please consider relying on reflection probes.
  86566. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86567. */
  86568. export class MirrorTexture extends RenderTargetTexture {
  86569. private scene;
  86570. /**
  86571. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  86572. * 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.
  86573. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86574. */
  86575. mirrorPlane: Plane;
  86576. /**
  86577. * Define the blur ratio used to blur the reflection if needed.
  86578. */
  86579. set blurRatio(value: number);
  86580. get blurRatio(): number;
  86581. /**
  86582. * Define the adaptive blur kernel used to blur the reflection if needed.
  86583. * This will autocompute the closest best match for the `blurKernel`
  86584. */
  86585. set adaptiveBlurKernel(value: number);
  86586. /**
  86587. * Define the blur kernel used to blur the reflection if needed.
  86588. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86589. */
  86590. set blurKernel(value: number);
  86591. /**
  86592. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  86593. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86594. */
  86595. set blurKernelX(value: number);
  86596. get blurKernelX(): number;
  86597. /**
  86598. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  86599. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86600. */
  86601. set blurKernelY(value: number);
  86602. get blurKernelY(): number;
  86603. private _autoComputeBlurKernel;
  86604. protected _onRatioRescale(): void;
  86605. private _updateGammaSpace;
  86606. private _imageProcessingConfigChangeObserver;
  86607. private _transformMatrix;
  86608. private _mirrorMatrix;
  86609. private _savedViewMatrix;
  86610. private _blurX;
  86611. private _blurY;
  86612. private _adaptiveBlurKernel;
  86613. private _blurKernelX;
  86614. private _blurKernelY;
  86615. private _blurRatio;
  86616. /**
  86617. * Instantiates a Mirror Texture.
  86618. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86619. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86620. * You can then easily use it as a reflectionTexture on a flat surface.
  86621. * In case the surface is not a plane, please consider relying on reflection probes.
  86622. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86623. * @param name
  86624. * @param size
  86625. * @param scene
  86626. * @param generateMipMaps
  86627. * @param type
  86628. * @param samplingMode
  86629. * @param generateDepthBuffer
  86630. */
  86631. constructor(name: string, size: number | {
  86632. width: number;
  86633. height: number;
  86634. } | {
  86635. ratio: number;
  86636. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  86637. private _preparePostProcesses;
  86638. /**
  86639. * Clone the mirror texture.
  86640. * @returns the cloned texture
  86641. */
  86642. clone(): MirrorTexture;
  86643. /**
  86644. * Serialize the texture to a JSON representation you could use in Parse later on
  86645. * @returns the serialized JSON representation
  86646. */
  86647. serialize(): any;
  86648. /**
  86649. * Dispose the texture and release its associated resources.
  86650. */
  86651. dispose(): void;
  86652. }
  86653. }
  86654. declare module BABYLON {
  86655. /**
  86656. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86657. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86658. */
  86659. export class Texture extends BaseTexture {
  86660. /**
  86661. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  86662. */
  86663. static SerializeBuffers: boolean;
  86664. /** @hidden */
  86665. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  86666. /** @hidden */
  86667. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  86668. /** @hidden */
  86669. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  86670. /** nearest is mag = nearest and min = nearest and mip = linear */
  86671. static readonly NEAREST_SAMPLINGMODE: number;
  86672. /** nearest is mag = nearest and min = nearest and mip = linear */
  86673. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  86674. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86675. static readonly BILINEAR_SAMPLINGMODE: number;
  86676. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86677. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  86678. /** Trilinear is mag = linear and min = linear and mip = linear */
  86679. static readonly TRILINEAR_SAMPLINGMODE: number;
  86680. /** Trilinear is mag = linear and min = linear and mip = linear */
  86681. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  86682. /** mag = nearest and min = nearest and mip = nearest */
  86683. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  86684. /** mag = nearest and min = linear and mip = nearest */
  86685. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  86686. /** mag = nearest and min = linear and mip = linear */
  86687. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  86688. /** mag = nearest and min = linear and mip = none */
  86689. static readonly NEAREST_LINEAR: number;
  86690. /** mag = nearest and min = nearest and mip = none */
  86691. static readonly NEAREST_NEAREST: number;
  86692. /** mag = linear and min = nearest and mip = nearest */
  86693. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  86694. /** mag = linear and min = nearest and mip = linear */
  86695. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  86696. /** mag = linear and min = linear and mip = none */
  86697. static readonly LINEAR_LINEAR: number;
  86698. /** mag = linear and min = nearest and mip = none */
  86699. static readonly LINEAR_NEAREST: number;
  86700. /** Explicit coordinates mode */
  86701. static readonly EXPLICIT_MODE: number;
  86702. /** Spherical coordinates mode */
  86703. static readonly SPHERICAL_MODE: number;
  86704. /** Planar coordinates mode */
  86705. static readonly PLANAR_MODE: number;
  86706. /** Cubic coordinates mode */
  86707. static readonly CUBIC_MODE: number;
  86708. /** Projection coordinates mode */
  86709. static readonly PROJECTION_MODE: number;
  86710. /** Inverse Cubic coordinates mode */
  86711. static readonly SKYBOX_MODE: number;
  86712. /** Inverse Cubic coordinates mode */
  86713. static readonly INVCUBIC_MODE: number;
  86714. /** Equirectangular coordinates mode */
  86715. static readonly EQUIRECTANGULAR_MODE: number;
  86716. /** Equirectangular Fixed coordinates mode */
  86717. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  86718. /** Equirectangular Fixed Mirrored coordinates mode */
  86719. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86720. /** Texture is not repeating outside of 0..1 UVs */
  86721. static readonly CLAMP_ADDRESSMODE: number;
  86722. /** Texture is repeating outside of 0..1 UVs */
  86723. static readonly WRAP_ADDRESSMODE: number;
  86724. /** Texture is repeating and mirrored */
  86725. static readonly MIRROR_ADDRESSMODE: number;
  86726. /**
  86727. * 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
  86728. */
  86729. static UseSerializedUrlIfAny: boolean;
  86730. /**
  86731. * Define the url of the texture.
  86732. */
  86733. url: Nullable<string>;
  86734. /**
  86735. * Define an offset on the texture to offset the u coordinates of the UVs
  86736. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86737. */
  86738. uOffset: number;
  86739. /**
  86740. * Define an offset on the texture to offset the v coordinates of the UVs
  86741. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86742. */
  86743. vOffset: number;
  86744. /**
  86745. * Define an offset on the texture to scale the u coordinates of the UVs
  86746. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86747. */
  86748. uScale: number;
  86749. /**
  86750. * Define an offset on the texture to scale the v coordinates of the UVs
  86751. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86752. */
  86753. vScale: number;
  86754. /**
  86755. * Define an offset on the texture to rotate around the u coordinates of the UVs
  86756. * @see http://doc.babylonjs.com/how_to/more_materials
  86757. */
  86758. uAng: number;
  86759. /**
  86760. * Define an offset on the texture to rotate around the v coordinates of the UVs
  86761. * @see http://doc.babylonjs.com/how_to/more_materials
  86762. */
  86763. vAng: number;
  86764. /**
  86765. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  86766. * @see http://doc.babylonjs.com/how_to/more_materials
  86767. */
  86768. wAng: number;
  86769. /**
  86770. * Defines the center of rotation (U)
  86771. */
  86772. uRotationCenter: number;
  86773. /**
  86774. * Defines the center of rotation (V)
  86775. */
  86776. vRotationCenter: number;
  86777. /**
  86778. * Defines the center of rotation (W)
  86779. */
  86780. wRotationCenter: number;
  86781. /**
  86782. * Are mip maps generated for this texture or not.
  86783. */
  86784. get noMipmap(): boolean;
  86785. /**
  86786. * List of inspectable custom properties (used by the Inspector)
  86787. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86788. */
  86789. inspectableCustomProperties: Nullable<IInspectable[]>;
  86790. private _noMipmap;
  86791. /** @hidden */
  86792. _invertY: boolean;
  86793. private _rowGenerationMatrix;
  86794. private _cachedTextureMatrix;
  86795. private _projectionModeMatrix;
  86796. private _t0;
  86797. private _t1;
  86798. private _t2;
  86799. private _cachedUOffset;
  86800. private _cachedVOffset;
  86801. private _cachedUScale;
  86802. private _cachedVScale;
  86803. private _cachedUAng;
  86804. private _cachedVAng;
  86805. private _cachedWAng;
  86806. private _cachedProjectionMatrixId;
  86807. private _cachedCoordinatesMode;
  86808. /** @hidden */
  86809. protected _initialSamplingMode: number;
  86810. /** @hidden */
  86811. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  86812. private _deleteBuffer;
  86813. protected _format: Nullable<number>;
  86814. private _delayedOnLoad;
  86815. private _delayedOnError;
  86816. private _mimeType?;
  86817. /**
  86818. * Observable triggered once the texture has been loaded.
  86819. */
  86820. onLoadObservable: Observable<Texture>;
  86821. protected _isBlocking: boolean;
  86822. /**
  86823. * Is the texture preventing material to render while loading.
  86824. * If false, a default texture will be used instead of the loading one during the preparation step.
  86825. */
  86826. set isBlocking(value: boolean);
  86827. get isBlocking(): boolean;
  86828. /**
  86829. * Get the current sampling mode associated with the texture.
  86830. */
  86831. get samplingMode(): number;
  86832. /**
  86833. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  86834. */
  86835. get invertY(): boolean;
  86836. /**
  86837. * Instantiates a new texture.
  86838. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86839. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86840. * @param url defines the url of the picture to load as a texture
  86841. * @param scene defines the scene or engine the texture will belong to
  86842. * @param noMipmap defines if the texture will require mip maps or not
  86843. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  86844. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86845. * @param onLoad defines a callback triggered when the texture has been loaded
  86846. * @param onError defines a callback triggered when an error occurred during the loading session
  86847. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  86848. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  86849. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86850. * @param mimeType defines an optional mime type information
  86851. */
  86852. 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);
  86853. /**
  86854. * Update the url (and optional buffer) of this texture if url was null during construction.
  86855. * @param url the url of the texture
  86856. * @param buffer the buffer of the texture (defaults to null)
  86857. * @param onLoad callback called when the texture is loaded (defaults to null)
  86858. */
  86859. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  86860. /**
  86861. * Finish the loading sequence of a texture flagged as delayed load.
  86862. * @hidden
  86863. */
  86864. delayLoad(): void;
  86865. private _prepareRowForTextureGeneration;
  86866. /**
  86867. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  86868. * @returns the transform matrix of the texture.
  86869. */
  86870. getTextureMatrix(uBase?: number): Matrix;
  86871. /**
  86872. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  86873. * @returns The reflection texture transform
  86874. */
  86875. getReflectionTextureMatrix(): Matrix;
  86876. /**
  86877. * Clones the texture.
  86878. * @returns the cloned texture
  86879. */
  86880. clone(): Texture;
  86881. /**
  86882. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86883. * @returns The JSON representation of the texture
  86884. */
  86885. serialize(): any;
  86886. /**
  86887. * Get the current class name of the texture useful for serialization or dynamic coding.
  86888. * @returns "Texture"
  86889. */
  86890. getClassName(): string;
  86891. /**
  86892. * Dispose the texture and release its associated resources.
  86893. */
  86894. dispose(): void;
  86895. /**
  86896. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  86897. * @param parsedTexture Define the JSON representation of the texture
  86898. * @param scene Define the scene the parsed texture should be instantiated in
  86899. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  86900. * @returns The parsed texture if successful
  86901. */
  86902. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  86903. /**
  86904. * Creates a texture from its base 64 representation.
  86905. * @param data Define the base64 payload without the data: prefix
  86906. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86907. * @param scene Define the scene the texture should belong to
  86908. * @param noMipmap Forces the texture to not create mip map information if true
  86909. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86910. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86911. * @param onLoad define a callback triggered when the texture has been loaded
  86912. * @param onError define a callback triggered when an error occurred during the loading session
  86913. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86914. * @returns the created texture
  86915. */
  86916. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  86917. /**
  86918. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  86919. * @param data Define the base64 payload without the data: prefix
  86920. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86921. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  86922. * @param scene Define the scene the texture should belong to
  86923. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  86924. * @param noMipmap Forces the texture to not create mip map information if true
  86925. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86926. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86927. * @param onLoad define a callback triggered when the texture has been loaded
  86928. * @param onError define a callback triggered when an error occurred during the loading session
  86929. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86930. * @returns the created texture
  86931. */
  86932. 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;
  86933. }
  86934. }
  86935. declare module BABYLON {
  86936. /**
  86937. * PostProcessManager is used to manage one or more post processes or post process pipelines
  86938. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86939. */
  86940. export class PostProcessManager {
  86941. private _scene;
  86942. private _indexBuffer;
  86943. private _vertexBuffers;
  86944. /**
  86945. * Creates a new instance PostProcess
  86946. * @param scene The scene that the post process is associated with.
  86947. */
  86948. constructor(scene: Scene);
  86949. private _prepareBuffers;
  86950. private _buildIndexBuffer;
  86951. /**
  86952. * Rebuilds the vertex buffers of the manager.
  86953. * @hidden
  86954. */
  86955. _rebuild(): void;
  86956. /**
  86957. * Prepares a frame to be run through a post process.
  86958. * @param sourceTexture The input texture to the post procesess. (default: null)
  86959. * @param postProcesses An array of post processes to be run. (default: null)
  86960. * @returns True if the post processes were able to be run.
  86961. * @hidden
  86962. */
  86963. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  86964. /**
  86965. * Manually render a set of post processes to a texture.
  86966. * @param postProcesses An array of post processes to be run.
  86967. * @param targetTexture The target texture to render to.
  86968. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  86969. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  86970. * @param lodLevel defines which lod of the texture to render to
  86971. */
  86972. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  86973. /**
  86974. * Finalize the result of the output of the postprocesses.
  86975. * @param doNotPresent If true the result will not be displayed to the screen.
  86976. * @param targetTexture The target texture to render to.
  86977. * @param faceIndex The index of the face to bind the target texture to.
  86978. * @param postProcesses The array of post processes to render.
  86979. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  86980. * @hidden
  86981. */
  86982. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  86983. /**
  86984. * Disposes of the post process manager.
  86985. */
  86986. dispose(): void;
  86987. }
  86988. }
  86989. declare module BABYLON {
  86990. /** Interface used by value gradients (color, factor, ...) */
  86991. export interface IValueGradient {
  86992. /**
  86993. * Gets or sets the gradient value (between 0 and 1)
  86994. */
  86995. gradient: number;
  86996. }
  86997. /** Class used to store color4 gradient */
  86998. export class ColorGradient implements IValueGradient {
  86999. /**
  87000. * Gets or sets the gradient value (between 0 and 1)
  87001. */
  87002. gradient: number;
  87003. /**
  87004. * Gets or sets first associated color
  87005. */
  87006. color1: Color4;
  87007. /**
  87008. * Gets or sets second associated color
  87009. */
  87010. color2?: Color4;
  87011. /**
  87012. * Will get a color picked randomly between color1 and color2.
  87013. * If color2 is undefined then color1 will be used
  87014. * @param result defines the target Color4 to store the result in
  87015. */
  87016. getColorToRef(result: Color4): void;
  87017. }
  87018. /** Class used to store color 3 gradient */
  87019. export class Color3Gradient implements IValueGradient {
  87020. /**
  87021. * Gets or sets the gradient value (between 0 and 1)
  87022. */
  87023. gradient: number;
  87024. /**
  87025. * Gets or sets the associated color
  87026. */
  87027. color: Color3;
  87028. }
  87029. /** Class used to store factor gradient */
  87030. export class FactorGradient implements IValueGradient {
  87031. /**
  87032. * Gets or sets the gradient value (between 0 and 1)
  87033. */
  87034. gradient: number;
  87035. /**
  87036. * Gets or sets first associated factor
  87037. */
  87038. factor1: number;
  87039. /**
  87040. * Gets or sets second associated factor
  87041. */
  87042. factor2?: number;
  87043. /**
  87044. * Will get a number picked randomly between factor1 and factor2.
  87045. * If factor2 is undefined then factor1 will be used
  87046. * @returns the picked number
  87047. */
  87048. getFactor(): number;
  87049. }
  87050. /**
  87051. * Helper used to simplify some generic gradient tasks
  87052. */
  87053. export class GradientHelper {
  87054. /**
  87055. * Gets the current gradient from an array of IValueGradient
  87056. * @param ratio defines the current ratio to get
  87057. * @param gradients defines the array of IValueGradient
  87058. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87059. */
  87060. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87061. }
  87062. }
  87063. declare module BABYLON {
  87064. interface ThinEngine {
  87065. /**
  87066. * Creates a dynamic texture
  87067. * @param width defines the width of the texture
  87068. * @param height defines the height of the texture
  87069. * @param generateMipMaps defines if the engine should generate the mip levels
  87070. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87071. * @returns the dynamic texture inside an InternalTexture
  87072. */
  87073. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87074. /**
  87075. * Update the content of a dynamic texture
  87076. * @param texture defines the texture to update
  87077. * @param canvas defines the canvas containing the source
  87078. * @param invertY defines if data must be stored with Y axis inverted
  87079. * @param premulAlpha defines if alpha is stored as premultiplied
  87080. * @param format defines the format of the data
  87081. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87082. */
  87083. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87084. }
  87085. }
  87086. declare module BABYLON {
  87087. /**
  87088. * Helper class used to generate a canvas to manipulate images
  87089. */
  87090. export class CanvasGenerator {
  87091. /**
  87092. * Create a new canvas (or offscreen canvas depending on the context)
  87093. * @param width defines the expected width
  87094. * @param height defines the expected height
  87095. * @return a new canvas or offscreen canvas
  87096. */
  87097. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  87098. }
  87099. }
  87100. declare module BABYLON {
  87101. /**
  87102. * A class extending Texture allowing drawing on a texture
  87103. * @see http://doc.babylonjs.com/how_to/dynamictexture
  87104. */
  87105. export class DynamicTexture extends Texture {
  87106. private _generateMipMaps;
  87107. private _canvas;
  87108. private _context;
  87109. private _engine;
  87110. /**
  87111. * Creates a DynamicTexture
  87112. * @param name defines the name of the texture
  87113. * @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
  87114. * @param scene defines the scene where you want the texture
  87115. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  87116. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  87117. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  87118. */
  87119. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  87120. /**
  87121. * Get the current class name of the texture useful for serialization or dynamic coding.
  87122. * @returns "DynamicTexture"
  87123. */
  87124. getClassName(): string;
  87125. /**
  87126. * Gets the current state of canRescale
  87127. */
  87128. get canRescale(): boolean;
  87129. private _recreate;
  87130. /**
  87131. * Scales the texture
  87132. * @param ratio the scale factor to apply to both width and height
  87133. */
  87134. scale(ratio: number): void;
  87135. /**
  87136. * Resizes the texture
  87137. * @param width the new width
  87138. * @param height the new height
  87139. */
  87140. scaleTo(width: number, height: number): void;
  87141. /**
  87142. * Gets the context of the canvas used by the texture
  87143. * @returns the canvas context of the dynamic texture
  87144. */
  87145. getContext(): CanvasRenderingContext2D;
  87146. /**
  87147. * Clears the texture
  87148. */
  87149. clear(): void;
  87150. /**
  87151. * Updates the texture
  87152. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87153. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  87154. */
  87155. update(invertY?: boolean, premulAlpha?: boolean): void;
  87156. /**
  87157. * Draws text onto the texture
  87158. * @param text defines the text to be drawn
  87159. * @param x defines the placement of the text from the left
  87160. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  87161. * @param font defines the font to be used with font-style, font-size, font-name
  87162. * @param color defines the color used for the text
  87163. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  87164. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87165. * @param update defines whether texture is immediately update (default is true)
  87166. */
  87167. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  87168. /**
  87169. * Clones the texture
  87170. * @returns the clone of the texture.
  87171. */
  87172. clone(): DynamicTexture;
  87173. /**
  87174. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  87175. * @returns a serialized dynamic texture object
  87176. */
  87177. serialize(): any;
  87178. /** @hidden */
  87179. _rebuild(): void;
  87180. }
  87181. }
  87182. declare module BABYLON {
  87183. interface AbstractScene {
  87184. /**
  87185. * The list of procedural textures added to the scene
  87186. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87187. */
  87188. proceduralTextures: Array<ProceduralTexture>;
  87189. }
  87190. /**
  87191. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  87192. * in a given scene.
  87193. */
  87194. export class ProceduralTextureSceneComponent implements ISceneComponent {
  87195. /**
  87196. * The component name helpfull to identify the component in the list of scene components.
  87197. */
  87198. readonly name: string;
  87199. /**
  87200. * The scene the component belongs to.
  87201. */
  87202. scene: Scene;
  87203. /**
  87204. * Creates a new instance of the component for the given scene
  87205. * @param scene Defines the scene to register the component in
  87206. */
  87207. constructor(scene: Scene);
  87208. /**
  87209. * Registers the component in a given scene
  87210. */
  87211. register(): void;
  87212. /**
  87213. * Rebuilds the elements related to this component in case of
  87214. * context lost for instance.
  87215. */
  87216. rebuild(): void;
  87217. /**
  87218. * Disposes the component and the associated ressources.
  87219. */
  87220. dispose(): void;
  87221. private _beforeClear;
  87222. }
  87223. }
  87224. declare module BABYLON {
  87225. interface ThinEngine {
  87226. /**
  87227. * Creates a new render target cube texture
  87228. * @param size defines the size of the texture
  87229. * @param options defines the options used to create the texture
  87230. * @returns a new render target cube texture stored in an InternalTexture
  87231. */
  87232. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87233. }
  87234. }
  87235. declare module BABYLON {
  87236. /** @hidden */
  87237. export var proceduralVertexShader: {
  87238. name: string;
  87239. shader: string;
  87240. };
  87241. }
  87242. declare module BABYLON {
  87243. /**
  87244. * 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.
  87245. * This is the base class of any Procedural texture and contains most of the shareable code.
  87246. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87247. */
  87248. export class ProceduralTexture extends Texture {
  87249. isCube: boolean;
  87250. /**
  87251. * Define if the texture is enabled or not (disabled texture will not render)
  87252. */
  87253. isEnabled: boolean;
  87254. /**
  87255. * Define if the texture must be cleared before rendering (default is true)
  87256. */
  87257. autoClear: boolean;
  87258. /**
  87259. * Callback called when the texture is generated
  87260. */
  87261. onGenerated: () => void;
  87262. /**
  87263. * Event raised when the texture is generated
  87264. */
  87265. onGeneratedObservable: Observable<ProceduralTexture>;
  87266. /** @hidden */
  87267. _generateMipMaps: boolean;
  87268. /** @hidden **/
  87269. _effect: Effect;
  87270. /** @hidden */
  87271. _textures: {
  87272. [key: string]: Texture;
  87273. };
  87274. private _size;
  87275. private _currentRefreshId;
  87276. private _frameId;
  87277. private _refreshRate;
  87278. private _vertexBuffers;
  87279. private _indexBuffer;
  87280. private _uniforms;
  87281. private _samplers;
  87282. private _fragment;
  87283. private _floats;
  87284. private _ints;
  87285. private _floatsArrays;
  87286. private _colors3;
  87287. private _colors4;
  87288. private _vectors2;
  87289. private _vectors3;
  87290. private _matrices;
  87291. private _fallbackTexture;
  87292. private _fallbackTextureUsed;
  87293. private _engine;
  87294. private _cachedDefines;
  87295. private _contentUpdateId;
  87296. private _contentData;
  87297. /**
  87298. * Instantiates a new procedural texture.
  87299. * 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.
  87300. * This is the base class of any Procedural texture and contains most of the shareable code.
  87301. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87302. * @param name Define the name of the texture
  87303. * @param size Define the size of the texture to create
  87304. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  87305. * @param scene Define the scene the texture belongs to
  87306. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  87307. * @param generateMipMaps Define if the texture should creates mip maps or not
  87308. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  87309. */
  87310. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  87311. /**
  87312. * The effect that is created when initializing the post process.
  87313. * @returns The created effect corresponding the the postprocess.
  87314. */
  87315. getEffect(): Effect;
  87316. /**
  87317. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  87318. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  87319. */
  87320. getContent(): Nullable<ArrayBufferView>;
  87321. private _createIndexBuffer;
  87322. /** @hidden */
  87323. _rebuild(): void;
  87324. /**
  87325. * Resets the texture in order to recreate its associated resources.
  87326. * This can be called in case of context loss
  87327. */
  87328. reset(): void;
  87329. protected _getDefines(): string;
  87330. /**
  87331. * Is the texture ready to be used ? (rendered at least once)
  87332. * @returns true if ready, otherwise, false.
  87333. */
  87334. isReady(): boolean;
  87335. /**
  87336. * Resets the refresh counter of the texture and start bak from scratch.
  87337. * Could be useful to regenerate the texture if it is setup to render only once.
  87338. */
  87339. resetRefreshCounter(): void;
  87340. /**
  87341. * Set the fragment shader to use in order to render the texture.
  87342. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  87343. */
  87344. setFragment(fragment: any): void;
  87345. /**
  87346. * Define the refresh rate of the texture or the rendering frequency.
  87347. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87348. */
  87349. get refreshRate(): number;
  87350. set refreshRate(value: number);
  87351. /** @hidden */
  87352. _shouldRender(): boolean;
  87353. /**
  87354. * Get the size the texture is rendering at.
  87355. * @returns the size (texture is always squared)
  87356. */
  87357. getRenderSize(): number;
  87358. /**
  87359. * Resize the texture to new value.
  87360. * @param size Define the new size the texture should have
  87361. * @param generateMipMaps Define whether the new texture should create mip maps
  87362. */
  87363. resize(size: number, generateMipMaps: boolean): void;
  87364. private _checkUniform;
  87365. /**
  87366. * Set a texture in the shader program used to render.
  87367. * @param name Define the name of the uniform samplers as defined in the shader
  87368. * @param texture Define the texture to bind to this sampler
  87369. * @return the texture itself allowing "fluent" like uniform updates
  87370. */
  87371. setTexture(name: string, texture: Texture): ProceduralTexture;
  87372. /**
  87373. * Set a float in the shader.
  87374. * @param name Define the name of the uniform as defined in the shader
  87375. * @param value Define the value to give to the uniform
  87376. * @return the texture itself allowing "fluent" like uniform updates
  87377. */
  87378. setFloat(name: string, value: number): ProceduralTexture;
  87379. /**
  87380. * Set a int in the shader.
  87381. * @param name Define the name of the uniform as defined in the shader
  87382. * @param value Define the value to give to the uniform
  87383. * @return the texture itself allowing "fluent" like uniform updates
  87384. */
  87385. setInt(name: string, value: number): ProceduralTexture;
  87386. /**
  87387. * Set an array of floats in the shader.
  87388. * @param name Define the name of the uniform as defined in the shader
  87389. * @param value Define the value to give to the uniform
  87390. * @return the texture itself allowing "fluent" like uniform updates
  87391. */
  87392. setFloats(name: string, value: number[]): ProceduralTexture;
  87393. /**
  87394. * Set a vec3 in the shader from a Color3.
  87395. * @param name Define the name of the uniform as defined in the shader
  87396. * @param value Define the value to give to the uniform
  87397. * @return the texture itself allowing "fluent" like uniform updates
  87398. */
  87399. setColor3(name: string, value: Color3): ProceduralTexture;
  87400. /**
  87401. * Set a vec4 in the shader from a Color4.
  87402. * @param name Define the name of the uniform as defined in the shader
  87403. * @param value Define the value to give to the uniform
  87404. * @return the texture itself allowing "fluent" like uniform updates
  87405. */
  87406. setColor4(name: string, value: Color4): ProceduralTexture;
  87407. /**
  87408. * Set a vec2 in the shader from a Vector2.
  87409. * @param name Define the name of the uniform as defined in the shader
  87410. * @param value Define the value to give to the uniform
  87411. * @return the texture itself allowing "fluent" like uniform updates
  87412. */
  87413. setVector2(name: string, value: Vector2): ProceduralTexture;
  87414. /**
  87415. * Set a vec3 in the shader from a Vector3.
  87416. * @param name Define the name of the uniform as defined in the shader
  87417. * @param value Define the value to give to the uniform
  87418. * @return the texture itself allowing "fluent" like uniform updates
  87419. */
  87420. setVector3(name: string, value: Vector3): ProceduralTexture;
  87421. /**
  87422. * Set a mat4 in the shader from a MAtrix.
  87423. * @param name Define the name of the uniform as defined in the shader
  87424. * @param value Define the value to give to the uniform
  87425. * @return the texture itself allowing "fluent" like uniform updates
  87426. */
  87427. setMatrix(name: string, value: Matrix): ProceduralTexture;
  87428. /**
  87429. * Render the texture to its associated render target.
  87430. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  87431. */
  87432. render(useCameraPostProcess?: boolean): void;
  87433. /**
  87434. * Clone the texture.
  87435. * @returns the cloned texture
  87436. */
  87437. clone(): ProceduralTexture;
  87438. /**
  87439. * Dispose the texture and release its asoociated resources.
  87440. */
  87441. dispose(): void;
  87442. }
  87443. }
  87444. declare module BABYLON {
  87445. /**
  87446. * This represents the base class for particle system in Babylon.
  87447. * 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.
  87448. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87449. * @example https://doc.babylonjs.com/babylon101/particles
  87450. */
  87451. export class BaseParticleSystem {
  87452. /**
  87453. * Source color is added to the destination color without alpha affecting the result
  87454. */
  87455. static BLENDMODE_ONEONE: number;
  87456. /**
  87457. * Blend current color and particle color using particle’s alpha
  87458. */
  87459. static BLENDMODE_STANDARD: number;
  87460. /**
  87461. * Add current color and particle color multiplied by particle’s alpha
  87462. */
  87463. static BLENDMODE_ADD: number;
  87464. /**
  87465. * Multiply current color with particle color
  87466. */
  87467. static BLENDMODE_MULTIPLY: number;
  87468. /**
  87469. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  87470. */
  87471. static BLENDMODE_MULTIPLYADD: number;
  87472. /**
  87473. * List of animations used by the particle system.
  87474. */
  87475. animations: Animation[];
  87476. /**
  87477. * The id of the Particle system.
  87478. */
  87479. id: string;
  87480. /**
  87481. * The friendly name of the Particle system.
  87482. */
  87483. name: string;
  87484. /**
  87485. * The rendering group used by the Particle system to chose when to render.
  87486. */
  87487. renderingGroupId: number;
  87488. /**
  87489. * The emitter represents the Mesh or position we are attaching the particle system to.
  87490. */
  87491. emitter: Nullable<AbstractMesh | Vector3>;
  87492. /**
  87493. * The maximum number of particles to emit per frame
  87494. */
  87495. emitRate: number;
  87496. /**
  87497. * If you want to launch only a few particles at once, that can be done, as well.
  87498. */
  87499. manualEmitCount: number;
  87500. /**
  87501. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87502. */
  87503. updateSpeed: number;
  87504. /**
  87505. * The amount of time the particle system is running (depends of the overall update speed).
  87506. */
  87507. targetStopDuration: number;
  87508. /**
  87509. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87510. */
  87511. disposeOnStop: boolean;
  87512. /**
  87513. * Minimum power of emitting particles.
  87514. */
  87515. minEmitPower: number;
  87516. /**
  87517. * Maximum power of emitting particles.
  87518. */
  87519. maxEmitPower: number;
  87520. /**
  87521. * Minimum life time of emitting particles.
  87522. */
  87523. minLifeTime: number;
  87524. /**
  87525. * Maximum life time of emitting particles.
  87526. */
  87527. maxLifeTime: number;
  87528. /**
  87529. * Minimum Size of emitting particles.
  87530. */
  87531. minSize: number;
  87532. /**
  87533. * Maximum Size of emitting particles.
  87534. */
  87535. maxSize: number;
  87536. /**
  87537. * Minimum scale of emitting particles on X axis.
  87538. */
  87539. minScaleX: number;
  87540. /**
  87541. * Maximum scale of emitting particles on X axis.
  87542. */
  87543. maxScaleX: number;
  87544. /**
  87545. * Minimum scale of emitting particles on Y axis.
  87546. */
  87547. minScaleY: number;
  87548. /**
  87549. * Maximum scale of emitting particles on Y axis.
  87550. */
  87551. maxScaleY: number;
  87552. /**
  87553. * Gets or sets the minimal initial rotation in radians.
  87554. */
  87555. minInitialRotation: number;
  87556. /**
  87557. * Gets or sets the maximal initial rotation in radians.
  87558. */
  87559. maxInitialRotation: number;
  87560. /**
  87561. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87562. */
  87563. minAngularSpeed: number;
  87564. /**
  87565. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87566. */
  87567. maxAngularSpeed: number;
  87568. /**
  87569. * The texture used to render each particle. (this can be a spritesheet)
  87570. */
  87571. particleTexture: Nullable<Texture>;
  87572. /**
  87573. * The layer mask we are rendering the particles through.
  87574. */
  87575. layerMask: number;
  87576. /**
  87577. * This can help using your own shader to render the particle system.
  87578. * The according effect will be created
  87579. */
  87580. customShader: any;
  87581. /**
  87582. * By default particle system starts as soon as they are created. This prevents the
  87583. * automatic start to happen and let you decide when to start emitting particles.
  87584. */
  87585. preventAutoStart: boolean;
  87586. private _noiseTexture;
  87587. /**
  87588. * Gets or sets a texture used to add random noise to particle positions
  87589. */
  87590. get noiseTexture(): Nullable<ProceduralTexture>;
  87591. set noiseTexture(value: Nullable<ProceduralTexture>);
  87592. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87593. noiseStrength: Vector3;
  87594. /**
  87595. * Callback triggered when the particle animation is ending.
  87596. */
  87597. onAnimationEnd: Nullable<() => void>;
  87598. /**
  87599. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87600. */
  87601. blendMode: number;
  87602. /**
  87603. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87604. * to override the particles.
  87605. */
  87606. forceDepthWrite: boolean;
  87607. /** 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 */
  87608. preWarmCycles: number;
  87609. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87610. preWarmStepOffset: number;
  87611. /**
  87612. * 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)
  87613. */
  87614. spriteCellChangeSpeed: number;
  87615. /**
  87616. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87617. */
  87618. startSpriteCellID: number;
  87619. /**
  87620. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87621. */
  87622. endSpriteCellID: number;
  87623. /**
  87624. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87625. */
  87626. spriteCellWidth: number;
  87627. /**
  87628. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87629. */
  87630. spriteCellHeight: number;
  87631. /**
  87632. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87633. */
  87634. spriteRandomStartCell: boolean;
  87635. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87636. translationPivot: Vector2;
  87637. /** @hidden */
  87638. protected _isAnimationSheetEnabled: boolean;
  87639. /**
  87640. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87641. */
  87642. beginAnimationOnStart: boolean;
  87643. /**
  87644. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87645. */
  87646. beginAnimationFrom: number;
  87647. /**
  87648. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87649. */
  87650. beginAnimationTo: number;
  87651. /**
  87652. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87653. */
  87654. beginAnimationLoop: boolean;
  87655. /**
  87656. * Gets or sets a world offset applied to all particles
  87657. */
  87658. worldOffset: Vector3;
  87659. /**
  87660. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87661. */
  87662. get isAnimationSheetEnabled(): boolean;
  87663. set isAnimationSheetEnabled(value: boolean);
  87664. /**
  87665. * Get hosting scene
  87666. * @returns the scene
  87667. */
  87668. getScene(): Scene;
  87669. /**
  87670. * You can use gravity if you want to give an orientation to your particles.
  87671. */
  87672. gravity: Vector3;
  87673. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87674. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87675. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87676. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87677. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87678. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87679. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87680. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87681. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87682. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87683. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87684. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87685. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87686. /**
  87687. * Defines the delay in milliseconds before starting the system (0 by default)
  87688. */
  87689. startDelay: number;
  87690. /**
  87691. * Gets the current list of drag gradients.
  87692. * You must use addDragGradient and removeDragGradient to udpate this list
  87693. * @returns the list of drag gradients
  87694. */
  87695. getDragGradients(): Nullable<Array<FactorGradient>>;
  87696. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87697. limitVelocityDamping: number;
  87698. /**
  87699. * Gets the current list of limit velocity gradients.
  87700. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87701. * @returns the list of limit velocity gradients
  87702. */
  87703. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87704. /**
  87705. * Gets the current list of color gradients.
  87706. * You must use addColorGradient and removeColorGradient to udpate this list
  87707. * @returns the list of color gradients
  87708. */
  87709. getColorGradients(): Nullable<Array<ColorGradient>>;
  87710. /**
  87711. * Gets the current list of size gradients.
  87712. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87713. * @returns the list of size gradients
  87714. */
  87715. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87716. /**
  87717. * Gets the current list of color remap gradients.
  87718. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87719. * @returns the list of color remap gradients
  87720. */
  87721. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87722. /**
  87723. * Gets the current list of alpha remap gradients.
  87724. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87725. * @returns the list of alpha remap gradients
  87726. */
  87727. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87728. /**
  87729. * Gets the current list of life time gradients.
  87730. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87731. * @returns the list of life time gradients
  87732. */
  87733. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87734. /**
  87735. * Gets the current list of angular speed gradients.
  87736. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87737. * @returns the list of angular speed gradients
  87738. */
  87739. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87740. /**
  87741. * Gets the current list of velocity gradients.
  87742. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87743. * @returns the list of velocity gradients
  87744. */
  87745. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87746. /**
  87747. * Gets the current list of start size gradients.
  87748. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87749. * @returns the list of start size gradients
  87750. */
  87751. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87752. /**
  87753. * Gets the current list of emit rate gradients.
  87754. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87755. * @returns the list of emit rate gradients
  87756. */
  87757. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87758. /**
  87759. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87760. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87761. */
  87762. get direction1(): Vector3;
  87763. set direction1(value: Vector3);
  87764. /**
  87765. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87766. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87767. */
  87768. get direction2(): Vector3;
  87769. set direction2(value: Vector3);
  87770. /**
  87771. * 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.
  87772. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87773. */
  87774. get minEmitBox(): Vector3;
  87775. set minEmitBox(value: Vector3);
  87776. /**
  87777. * 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.
  87778. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87779. */
  87780. get maxEmitBox(): Vector3;
  87781. set maxEmitBox(value: Vector3);
  87782. /**
  87783. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87784. */
  87785. color1: Color4;
  87786. /**
  87787. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87788. */
  87789. color2: Color4;
  87790. /**
  87791. * Color the particle will have at the end of its lifetime
  87792. */
  87793. colorDead: Color4;
  87794. /**
  87795. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87796. */
  87797. textureMask: Color4;
  87798. /**
  87799. * The particle emitter type defines the emitter used by the particle system.
  87800. * It can be for example box, sphere, or cone...
  87801. */
  87802. particleEmitterType: IParticleEmitterType;
  87803. /** @hidden */
  87804. _isSubEmitter: boolean;
  87805. /**
  87806. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87807. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87808. */
  87809. billboardMode: number;
  87810. protected _isBillboardBased: boolean;
  87811. /**
  87812. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87813. */
  87814. get isBillboardBased(): boolean;
  87815. set isBillboardBased(value: boolean);
  87816. /**
  87817. * The scene the particle system belongs to.
  87818. */
  87819. protected _scene: Scene;
  87820. /**
  87821. * Local cache of defines for image processing.
  87822. */
  87823. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87824. /**
  87825. * Default configuration related to image processing available in the standard Material.
  87826. */
  87827. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87828. /**
  87829. * Gets the image processing configuration used either in this material.
  87830. */
  87831. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87832. /**
  87833. * Sets the Default image processing configuration used either in the this material.
  87834. *
  87835. * If sets to null, the scene one is in use.
  87836. */
  87837. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87838. /**
  87839. * Attaches a new image processing configuration to the Standard Material.
  87840. * @param configuration
  87841. */
  87842. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87843. /** @hidden */
  87844. protected _reset(): void;
  87845. /** @hidden */
  87846. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87847. /**
  87848. * Instantiates a particle system.
  87849. * 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.
  87850. * @param name The name of the particle system
  87851. */
  87852. constructor(name: string);
  87853. /**
  87854. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87855. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87856. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87857. * @returns the emitter
  87858. */
  87859. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87860. /**
  87861. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87862. * @param radius The radius of the hemisphere to emit from
  87863. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87864. * @returns the emitter
  87865. */
  87866. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87867. /**
  87868. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87869. * @param radius The radius of the sphere to emit from
  87870. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87871. * @returns the emitter
  87872. */
  87873. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87874. /**
  87875. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87876. * @param radius The radius of the sphere to emit from
  87877. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87878. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87879. * @returns the emitter
  87880. */
  87881. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87882. /**
  87883. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87884. * @param radius The radius of the emission cylinder
  87885. * @param height The height of the emission cylinder
  87886. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87887. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87888. * @returns the emitter
  87889. */
  87890. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87891. /**
  87892. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87893. * @param radius The radius of the cylinder to emit from
  87894. * @param height The height of the emission cylinder
  87895. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87896. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87897. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87898. * @returns the emitter
  87899. */
  87900. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87901. /**
  87902. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87903. * @param radius The radius of the cone to emit from
  87904. * @param angle The base angle of the cone
  87905. * @returns the emitter
  87906. */
  87907. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87908. /**
  87909. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87910. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87911. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87912. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87913. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87914. * @returns the emitter
  87915. */
  87916. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87917. }
  87918. }
  87919. declare module BABYLON {
  87920. /**
  87921. * Type of sub emitter
  87922. */
  87923. export enum SubEmitterType {
  87924. /**
  87925. * Attached to the particle over it's lifetime
  87926. */
  87927. ATTACHED = 0,
  87928. /**
  87929. * Created when the particle dies
  87930. */
  87931. END = 1
  87932. }
  87933. /**
  87934. * Sub emitter class used to emit particles from an existing particle
  87935. */
  87936. export class SubEmitter {
  87937. /**
  87938. * the particle system to be used by the sub emitter
  87939. */
  87940. particleSystem: ParticleSystem;
  87941. /**
  87942. * Type of the submitter (Default: END)
  87943. */
  87944. type: SubEmitterType;
  87945. /**
  87946. * 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)
  87947. * Note: This only is supported when using an emitter of type Mesh
  87948. */
  87949. inheritDirection: boolean;
  87950. /**
  87951. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87952. */
  87953. inheritedVelocityAmount: number;
  87954. /**
  87955. * Creates a sub emitter
  87956. * @param particleSystem the particle system to be used by the sub emitter
  87957. */
  87958. constructor(
  87959. /**
  87960. * the particle system to be used by the sub emitter
  87961. */
  87962. particleSystem: ParticleSystem);
  87963. /**
  87964. * Clones the sub emitter
  87965. * @returns the cloned sub emitter
  87966. */
  87967. clone(): SubEmitter;
  87968. /**
  87969. * Serialize current object to a JSON object
  87970. * @returns the serialized object
  87971. */
  87972. serialize(): any;
  87973. /** @hidden */
  87974. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87975. /**
  87976. * Creates a new SubEmitter from a serialized JSON version
  87977. * @param serializationObject defines the JSON object to read from
  87978. * @param scene defines the hosting scene
  87979. * @param rootUrl defines the rootUrl for data loading
  87980. * @returns a new SubEmitter
  87981. */
  87982. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87983. /** Release associated resources */
  87984. dispose(): void;
  87985. }
  87986. }
  87987. declare module BABYLON {
  87988. /** @hidden */
  87989. export var clipPlaneFragmentDeclaration: {
  87990. name: string;
  87991. shader: string;
  87992. };
  87993. }
  87994. declare module BABYLON {
  87995. /** @hidden */
  87996. export var imageProcessingDeclaration: {
  87997. name: string;
  87998. shader: string;
  87999. };
  88000. }
  88001. declare module BABYLON {
  88002. /** @hidden */
  88003. export var imageProcessingFunctions: {
  88004. name: string;
  88005. shader: string;
  88006. };
  88007. }
  88008. declare module BABYLON {
  88009. /** @hidden */
  88010. export var clipPlaneFragment: {
  88011. name: string;
  88012. shader: string;
  88013. };
  88014. }
  88015. declare module BABYLON {
  88016. /** @hidden */
  88017. export var particlesPixelShader: {
  88018. name: string;
  88019. shader: string;
  88020. };
  88021. }
  88022. declare module BABYLON {
  88023. /** @hidden */
  88024. export var clipPlaneVertexDeclaration: {
  88025. name: string;
  88026. shader: string;
  88027. };
  88028. }
  88029. declare module BABYLON {
  88030. /** @hidden */
  88031. export var clipPlaneVertex: {
  88032. name: string;
  88033. shader: string;
  88034. };
  88035. }
  88036. declare module BABYLON {
  88037. /** @hidden */
  88038. export var particlesVertexShader: {
  88039. name: string;
  88040. shader: string;
  88041. };
  88042. }
  88043. declare module BABYLON {
  88044. /**
  88045. * This represents a particle system in Babylon.
  88046. * 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.
  88047. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  88048. * @example https://doc.babylonjs.com/babylon101/particles
  88049. */
  88050. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  88051. /**
  88052. * Billboard mode will only apply to Y axis
  88053. */
  88054. static readonly BILLBOARDMODE_Y: number;
  88055. /**
  88056. * Billboard mode will apply to all axes
  88057. */
  88058. static readonly BILLBOARDMODE_ALL: number;
  88059. /**
  88060. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  88061. */
  88062. static readonly BILLBOARDMODE_STRETCHED: number;
  88063. /**
  88064. * This function can be defined to provide custom update for active particles.
  88065. * This function will be called instead of regular update (age, position, color, etc.).
  88066. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  88067. */
  88068. updateFunction: (particles: Particle[]) => void;
  88069. private _emitterWorldMatrix;
  88070. /**
  88071. * This function can be defined to specify initial direction for every new particle.
  88072. * It by default use the emitterType defined function
  88073. */
  88074. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  88075. /**
  88076. * This function can be defined to specify initial position for every new particle.
  88077. * It by default use the emitterType defined function
  88078. */
  88079. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  88080. /**
  88081. * @hidden
  88082. */
  88083. _inheritedVelocityOffset: Vector3;
  88084. /**
  88085. * An event triggered when the system is disposed
  88086. */
  88087. onDisposeObservable: Observable<ParticleSystem>;
  88088. private _onDisposeObserver;
  88089. /**
  88090. * Sets a callback that will be triggered when the system is disposed
  88091. */
  88092. set onDispose(callback: () => void);
  88093. private _particles;
  88094. private _epsilon;
  88095. private _capacity;
  88096. private _stockParticles;
  88097. private _newPartsExcess;
  88098. private _vertexData;
  88099. private _vertexBuffer;
  88100. private _vertexBuffers;
  88101. private _spriteBuffer;
  88102. private _indexBuffer;
  88103. private _effect;
  88104. private _customEffect;
  88105. private _cachedDefines;
  88106. private _scaledColorStep;
  88107. private _colorDiff;
  88108. private _scaledDirection;
  88109. private _scaledGravity;
  88110. private _currentRenderId;
  88111. private _alive;
  88112. private _useInstancing;
  88113. private _started;
  88114. private _stopped;
  88115. private _actualFrame;
  88116. private _scaledUpdateSpeed;
  88117. private _vertexBufferSize;
  88118. /** @hidden */
  88119. _currentEmitRateGradient: Nullable<FactorGradient>;
  88120. /** @hidden */
  88121. _currentEmitRate1: number;
  88122. /** @hidden */
  88123. _currentEmitRate2: number;
  88124. /** @hidden */
  88125. _currentStartSizeGradient: Nullable<FactorGradient>;
  88126. /** @hidden */
  88127. _currentStartSize1: number;
  88128. /** @hidden */
  88129. _currentStartSize2: number;
  88130. private readonly _rawTextureWidth;
  88131. private _rampGradientsTexture;
  88132. private _useRampGradients;
  88133. /** Gets or sets a boolean indicating that ramp gradients must be used
  88134. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88135. */
  88136. get useRampGradients(): boolean;
  88137. set useRampGradients(value: boolean);
  88138. /**
  88139. * 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.
  88140. * 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: [])
  88141. */
  88142. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  88143. private _subEmitters;
  88144. /**
  88145. * @hidden
  88146. * If the particle systems emitter should be disposed when the particle system is disposed
  88147. */
  88148. _disposeEmitterOnDispose: boolean;
  88149. /**
  88150. * The current active Sub-systems, this property is used by the root particle system only.
  88151. */
  88152. activeSubSystems: Array<ParticleSystem>;
  88153. private _rootParticleSystem;
  88154. /**
  88155. * Gets the current list of active particles
  88156. */
  88157. get particles(): Particle[];
  88158. /**
  88159. * Returns the string "ParticleSystem"
  88160. * @returns a string containing the class name
  88161. */
  88162. getClassName(): string;
  88163. /**
  88164. * Instantiates a particle system.
  88165. * 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.
  88166. * @param name The name of the particle system
  88167. * @param capacity The max number of particles alive at the same time
  88168. * @param scene The scene the particle system belongs to
  88169. * @param customEffect a custom effect used to change the way particles are rendered by default
  88170. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  88171. * @param epsilon Offset used to render the particles
  88172. */
  88173. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  88174. private _addFactorGradient;
  88175. private _removeFactorGradient;
  88176. /**
  88177. * Adds a new life time gradient
  88178. * @param gradient defines the gradient to use (between 0 and 1)
  88179. * @param factor defines the life time factor to affect to the specified gradient
  88180. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88181. * @returns the current particle system
  88182. */
  88183. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88184. /**
  88185. * Remove a specific life time gradient
  88186. * @param gradient defines the gradient to remove
  88187. * @returns the current particle system
  88188. */
  88189. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88190. /**
  88191. * Adds a new size gradient
  88192. * @param gradient defines the gradient to use (between 0 and 1)
  88193. * @param factor defines the size factor to affect to the specified gradient
  88194. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88195. * @returns the current particle system
  88196. */
  88197. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88198. /**
  88199. * Remove a specific size gradient
  88200. * @param gradient defines the gradient to remove
  88201. * @returns the current particle system
  88202. */
  88203. removeSizeGradient(gradient: number): IParticleSystem;
  88204. /**
  88205. * Adds a new color remap gradient
  88206. * @param gradient defines the gradient to use (between 0 and 1)
  88207. * @param min defines the color remap minimal range
  88208. * @param max defines the color remap maximal range
  88209. * @returns the current particle system
  88210. */
  88211. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88212. /**
  88213. * Remove a specific color remap gradient
  88214. * @param gradient defines the gradient to remove
  88215. * @returns the current particle system
  88216. */
  88217. removeColorRemapGradient(gradient: number): IParticleSystem;
  88218. /**
  88219. * Adds a new alpha remap gradient
  88220. * @param gradient defines the gradient to use (between 0 and 1)
  88221. * @param min defines the alpha remap minimal range
  88222. * @param max defines the alpha remap maximal range
  88223. * @returns the current particle system
  88224. */
  88225. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88226. /**
  88227. * Remove a specific alpha remap gradient
  88228. * @param gradient defines the gradient to remove
  88229. * @returns the current particle system
  88230. */
  88231. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  88232. /**
  88233. * Adds a new angular speed gradient
  88234. * @param gradient defines the gradient to use (between 0 and 1)
  88235. * @param factor defines the angular speed to affect to the specified gradient
  88236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88237. * @returns the current particle system
  88238. */
  88239. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88240. /**
  88241. * Remove a specific angular speed gradient
  88242. * @param gradient defines the gradient to remove
  88243. * @returns the current particle system
  88244. */
  88245. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88246. /**
  88247. * Adds a new velocity gradient
  88248. * @param gradient defines the gradient to use (between 0 and 1)
  88249. * @param factor defines the velocity to affect to the specified gradient
  88250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88251. * @returns the current particle system
  88252. */
  88253. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88254. /**
  88255. * Remove a specific velocity gradient
  88256. * @param gradient defines the gradient to remove
  88257. * @returns the current particle system
  88258. */
  88259. removeVelocityGradient(gradient: number): IParticleSystem;
  88260. /**
  88261. * Adds a new limit velocity gradient
  88262. * @param gradient defines the gradient to use (between 0 and 1)
  88263. * @param factor defines the limit velocity value to affect to the specified gradient
  88264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88265. * @returns the current particle system
  88266. */
  88267. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88268. /**
  88269. * Remove a specific limit velocity gradient
  88270. * @param gradient defines the gradient to remove
  88271. * @returns the current particle system
  88272. */
  88273. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88274. /**
  88275. * Adds a new drag gradient
  88276. * @param gradient defines the gradient to use (between 0 and 1)
  88277. * @param factor defines the drag value to affect to the specified gradient
  88278. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88279. * @returns the current particle system
  88280. */
  88281. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88282. /**
  88283. * Remove a specific drag gradient
  88284. * @param gradient defines the gradient to remove
  88285. * @returns the current particle system
  88286. */
  88287. removeDragGradient(gradient: number): IParticleSystem;
  88288. /**
  88289. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88290. * @param gradient defines the gradient to use (between 0 and 1)
  88291. * @param factor defines the emit rate value to affect to the specified gradient
  88292. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88293. * @returns the current particle system
  88294. */
  88295. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88296. /**
  88297. * Remove a specific emit rate gradient
  88298. * @param gradient defines the gradient to remove
  88299. * @returns the current particle system
  88300. */
  88301. removeEmitRateGradient(gradient: number): IParticleSystem;
  88302. /**
  88303. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88304. * @param gradient defines the gradient to use (between 0 and 1)
  88305. * @param factor defines the start size value to affect to the specified gradient
  88306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88307. * @returns the current particle system
  88308. */
  88309. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88310. /**
  88311. * Remove a specific start size gradient
  88312. * @param gradient defines the gradient to remove
  88313. * @returns the current particle system
  88314. */
  88315. removeStartSizeGradient(gradient: number): IParticleSystem;
  88316. private _createRampGradientTexture;
  88317. /**
  88318. * Gets the current list of ramp gradients.
  88319. * You must use addRampGradient and removeRampGradient to udpate this list
  88320. * @returns the list of ramp gradients
  88321. */
  88322. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88323. /**
  88324. * Adds a new ramp gradient used to remap particle colors
  88325. * @param gradient defines the gradient to use (between 0 and 1)
  88326. * @param color defines the color to affect to the specified gradient
  88327. * @returns the current particle system
  88328. */
  88329. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  88330. /**
  88331. * Remove a specific ramp gradient
  88332. * @param gradient defines the gradient to remove
  88333. * @returns the current particle system
  88334. */
  88335. removeRampGradient(gradient: number): ParticleSystem;
  88336. /**
  88337. * Adds a new color gradient
  88338. * @param gradient defines the gradient to use (between 0 and 1)
  88339. * @param color1 defines the color to affect to the specified gradient
  88340. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88341. * @returns this particle system
  88342. */
  88343. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88344. /**
  88345. * Remove a specific color gradient
  88346. * @param gradient defines the gradient to remove
  88347. * @returns this particle system
  88348. */
  88349. removeColorGradient(gradient: number): IParticleSystem;
  88350. private _fetchR;
  88351. protected _reset(): void;
  88352. private _resetEffect;
  88353. private _createVertexBuffers;
  88354. private _createIndexBuffer;
  88355. /**
  88356. * Gets the maximum number of particles active at the same time.
  88357. * @returns The max number of active particles.
  88358. */
  88359. getCapacity(): number;
  88360. /**
  88361. * Gets whether there are still active particles in the system.
  88362. * @returns True if it is alive, otherwise false.
  88363. */
  88364. isAlive(): boolean;
  88365. /**
  88366. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88367. * @returns True if it has been started, otherwise false.
  88368. */
  88369. isStarted(): boolean;
  88370. private _prepareSubEmitterInternalArray;
  88371. /**
  88372. * Starts the particle system and begins to emit
  88373. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  88374. */
  88375. start(delay?: number): void;
  88376. /**
  88377. * Stops the particle system.
  88378. * @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.
  88379. */
  88380. stop(stopSubEmitters?: boolean): void;
  88381. /**
  88382. * Remove all active particles
  88383. */
  88384. reset(): void;
  88385. /**
  88386. * @hidden (for internal use only)
  88387. */
  88388. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  88389. /**
  88390. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  88391. * Its lifetime will start back at 0.
  88392. */
  88393. recycleParticle: (particle: Particle) => void;
  88394. private _stopSubEmitters;
  88395. private _createParticle;
  88396. private _removeFromRoot;
  88397. private _emitFromParticle;
  88398. private _update;
  88399. /** @hidden */
  88400. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  88401. /** @hidden */
  88402. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  88403. /** @hidden */
  88404. private _getEffect;
  88405. /**
  88406. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  88407. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  88408. */
  88409. animate(preWarmOnly?: boolean): void;
  88410. private _appendParticleVertices;
  88411. /**
  88412. * Rebuilds the particle system.
  88413. */
  88414. rebuild(): void;
  88415. /**
  88416. * Is this system ready to be used/rendered
  88417. * @return true if the system is ready
  88418. */
  88419. isReady(): boolean;
  88420. private _render;
  88421. /**
  88422. * Renders the particle system in its current state.
  88423. * @returns the current number of particles
  88424. */
  88425. render(): number;
  88426. /**
  88427. * Disposes the particle system and free the associated resources
  88428. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88429. */
  88430. dispose(disposeTexture?: boolean): void;
  88431. /**
  88432. * Clones the particle system.
  88433. * @param name The name of the cloned object
  88434. * @param newEmitter The new emitter to use
  88435. * @returns the cloned particle system
  88436. */
  88437. clone(name: string, newEmitter: any): ParticleSystem;
  88438. /**
  88439. * Serializes the particle system to a JSON object.
  88440. * @returns the JSON object
  88441. */
  88442. serialize(): any;
  88443. /** @hidden */
  88444. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  88445. /** @hidden */
  88446. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  88447. /**
  88448. * Parses a JSON object to create a particle system.
  88449. * @param parsedParticleSystem The JSON object to parse
  88450. * @param scene The scene to create the particle system in
  88451. * @param rootUrl The root url to use to load external dependencies like texture
  88452. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  88453. * @returns the Parsed particle system
  88454. */
  88455. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  88456. }
  88457. }
  88458. declare module BABYLON {
  88459. /**
  88460. * A particle represents one of the element emitted by a particle system.
  88461. * This is mainly define by its coordinates, direction, velocity and age.
  88462. */
  88463. export class Particle {
  88464. /**
  88465. * The particle system the particle belongs to.
  88466. */
  88467. particleSystem: ParticleSystem;
  88468. private static _Count;
  88469. /**
  88470. * Unique ID of the particle
  88471. */
  88472. id: number;
  88473. /**
  88474. * The world position of the particle in the scene.
  88475. */
  88476. position: Vector3;
  88477. /**
  88478. * The world direction of the particle in the scene.
  88479. */
  88480. direction: Vector3;
  88481. /**
  88482. * The color of the particle.
  88483. */
  88484. color: Color4;
  88485. /**
  88486. * The color change of the particle per step.
  88487. */
  88488. colorStep: Color4;
  88489. /**
  88490. * Defines how long will the life of the particle be.
  88491. */
  88492. lifeTime: number;
  88493. /**
  88494. * The current age of the particle.
  88495. */
  88496. age: number;
  88497. /**
  88498. * The current size of the particle.
  88499. */
  88500. size: number;
  88501. /**
  88502. * The current scale of the particle.
  88503. */
  88504. scale: Vector2;
  88505. /**
  88506. * The current angle of the particle.
  88507. */
  88508. angle: number;
  88509. /**
  88510. * Defines how fast is the angle changing.
  88511. */
  88512. angularSpeed: number;
  88513. /**
  88514. * Defines the cell index used by the particle to be rendered from a sprite.
  88515. */
  88516. cellIndex: number;
  88517. /**
  88518. * The information required to support color remapping
  88519. */
  88520. remapData: Vector4;
  88521. /** @hidden */
  88522. _randomCellOffset?: number;
  88523. /** @hidden */
  88524. _initialDirection: Nullable<Vector3>;
  88525. /** @hidden */
  88526. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  88527. /** @hidden */
  88528. _initialStartSpriteCellID: number;
  88529. /** @hidden */
  88530. _initialEndSpriteCellID: number;
  88531. /** @hidden */
  88532. _currentColorGradient: Nullable<ColorGradient>;
  88533. /** @hidden */
  88534. _currentColor1: Color4;
  88535. /** @hidden */
  88536. _currentColor2: Color4;
  88537. /** @hidden */
  88538. _currentSizeGradient: Nullable<FactorGradient>;
  88539. /** @hidden */
  88540. _currentSize1: number;
  88541. /** @hidden */
  88542. _currentSize2: number;
  88543. /** @hidden */
  88544. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  88545. /** @hidden */
  88546. _currentAngularSpeed1: number;
  88547. /** @hidden */
  88548. _currentAngularSpeed2: number;
  88549. /** @hidden */
  88550. _currentVelocityGradient: Nullable<FactorGradient>;
  88551. /** @hidden */
  88552. _currentVelocity1: number;
  88553. /** @hidden */
  88554. _currentVelocity2: number;
  88555. /** @hidden */
  88556. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  88557. /** @hidden */
  88558. _currentLimitVelocity1: number;
  88559. /** @hidden */
  88560. _currentLimitVelocity2: number;
  88561. /** @hidden */
  88562. _currentDragGradient: Nullable<FactorGradient>;
  88563. /** @hidden */
  88564. _currentDrag1: number;
  88565. /** @hidden */
  88566. _currentDrag2: number;
  88567. /** @hidden */
  88568. _randomNoiseCoordinates1: Vector3;
  88569. /** @hidden */
  88570. _randomNoiseCoordinates2: Vector3;
  88571. /**
  88572. * Creates a new instance Particle
  88573. * @param particleSystem the particle system the particle belongs to
  88574. */
  88575. constructor(
  88576. /**
  88577. * The particle system the particle belongs to.
  88578. */
  88579. particleSystem: ParticleSystem);
  88580. private updateCellInfoFromSystem;
  88581. /**
  88582. * Defines how the sprite cell index is updated for the particle
  88583. */
  88584. updateCellIndex(): void;
  88585. /** @hidden */
  88586. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88587. /** @hidden */
  88588. _inheritParticleInfoToSubEmitters(): void;
  88589. /** @hidden */
  88590. _reset(): void;
  88591. /**
  88592. * Copy the properties of particle to another one.
  88593. * @param other the particle to copy the information to.
  88594. */
  88595. copyTo(other: Particle): void;
  88596. }
  88597. }
  88598. declare module BABYLON {
  88599. /**
  88600. * Particle emitter represents a volume emitting particles.
  88601. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88602. */
  88603. export interface IParticleEmitterType {
  88604. /**
  88605. * Called by the particle System when the direction is computed for the created particle.
  88606. * @param worldMatrix is the world matrix of the particle system
  88607. * @param directionToUpdate is the direction vector to update with the result
  88608. * @param particle is the particle we are computed the direction for
  88609. */
  88610. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88611. /**
  88612. * Called by the particle System when the position is computed for the created particle.
  88613. * @param worldMatrix is the world matrix of the particle system
  88614. * @param positionToUpdate is the position vector to update with the result
  88615. * @param particle is the particle we are computed the position for
  88616. */
  88617. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88618. /**
  88619. * Clones the current emitter and returns a copy of it
  88620. * @returns the new emitter
  88621. */
  88622. clone(): IParticleEmitterType;
  88623. /**
  88624. * Called by the GPUParticleSystem to setup the update shader
  88625. * @param effect defines the update shader
  88626. */
  88627. applyToShader(effect: Effect): void;
  88628. /**
  88629. * Returns a string to use to update the GPU particles update shader
  88630. * @returns the effect defines string
  88631. */
  88632. getEffectDefines(): string;
  88633. /**
  88634. * Returns a string representing the class name
  88635. * @returns a string containing the class name
  88636. */
  88637. getClassName(): string;
  88638. /**
  88639. * Serializes the particle system to a JSON object.
  88640. * @returns the JSON object
  88641. */
  88642. serialize(): any;
  88643. /**
  88644. * Parse properties from a JSON object
  88645. * @param serializationObject defines the JSON object
  88646. */
  88647. parse(serializationObject: any): void;
  88648. }
  88649. }
  88650. declare module BABYLON {
  88651. /**
  88652. * Particle emitter emitting particles from the inside of a box.
  88653. * It emits the particles randomly between 2 given directions.
  88654. */
  88655. export class BoxParticleEmitter implements IParticleEmitterType {
  88656. /**
  88657. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88658. */
  88659. direction1: Vector3;
  88660. /**
  88661. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88662. */
  88663. direction2: Vector3;
  88664. /**
  88665. * 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.
  88666. */
  88667. minEmitBox: Vector3;
  88668. /**
  88669. * 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.
  88670. */
  88671. maxEmitBox: Vector3;
  88672. /**
  88673. * Creates a new instance BoxParticleEmitter
  88674. */
  88675. constructor();
  88676. /**
  88677. * Called by the particle System when the direction is computed for the created particle.
  88678. * @param worldMatrix is the world matrix of the particle system
  88679. * @param directionToUpdate is the direction vector to update with the result
  88680. * @param particle is the particle we are computed the direction for
  88681. */
  88682. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88683. /**
  88684. * Called by the particle System when the position is computed for the created particle.
  88685. * @param worldMatrix is the world matrix of the particle system
  88686. * @param positionToUpdate is the position vector to update with the result
  88687. * @param particle is the particle we are computed the position for
  88688. */
  88689. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88690. /**
  88691. * Clones the current emitter and returns a copy of it
  88692. * @returns the new emitter
  88693. */
  88694. clone(): BoxParticleEmitter;
  88695. /**
  88696. * Called by the GPUParticleSystem to setup the update shader
  88697. * @param effect defines the update shader
  88698. */
  88699. applyToShader(effect: Effect): void;
  88700. /**
  88701. * Returns a string to use to update the GPU particles update shader
  88702. * @returns a string containng the defines string
  88703. */
  88704. getEffectDefines(): string;
  88705. /**
  88706. * Returns the string "BoxParticleEmitter"
  88707. * @returns a string containing the class name
  88708. */
  88709. getClassName(): string;
  88710. /**
  88711. * Serializes the particle system to a JSON object.
  88712. * @returns the JSON object
  88713. */
  88714. serialize(): any;
  88715. /**
  88716. * Parse properties from a JSON object
  88717. * @param serializationObject defines the JSON object
  88718. */
  88719. parse(serializationObject: any): void;
  88720. }
  88721. }
  88722. declare module BABYLON {
  88723. /**
  88724. * Particle emitter emitting particles from the inside of a cone.
  88725. * It emits the particles alongside the cone volume from the base to the particle.
  88726. * The emission direction might be randomized.
  88727. */
  88728. export class ConeParticleEmitter implements IParticleEmitterType {
  88729. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88730. directionRandomizer: number;
  88731. private _radius;
  88732. private _angle;
  88733. private _height;
  88734. /**
  88735. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88736. */
  88737. radiusRange: number;
  88738. /**
  88739. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88740. */
  88741. heightRange: number;
  88742. /**
  88743. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88744. */
  88745. emitFromSpawnPointOnly: boolean;
  88746. /**
  88747. * Gets or sets the radius of the emission cone
  88748. */
  88749. get radius(): number;
  88750. set radius(value: number);
  88751. /**
  88752. * Gets or sets the angle of the emission cone
  88753. */
  88754. get angle(): number;
  88755. set angle(value: number);
  88756. private _buildHeight;
  88757. /**
  88758. * Creates a new instance ConeParticleEmitter
  88759. * @param radius the radius of the emission cone (1 by default)
  88760. * @param angle the cone base angle (PI by default)
  88761. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88762. */
  88763. constructor(radius?: number, angle?: number,
  88764. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88765. directionRandomizer?: number);
  88766. /**
  88767. * Called by the particle System when the direction is computed for the created particle.
  88768. * @param worldMatrix is the world matrix of the particle system
  88769. * @param directionToUpdate is the direction vector to update with the result
  88770. * @param particle is the particle we are computed the direction for
  88771. */
  88772. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88773. /**
  88774. * Called by the particle System when the position is computed for the created particle.
  88775. * @param worldMatrix is the world matrix of the particle system
  88776. * @param positionToUpdate is the position vector to update with the result
  88777. * @param particle is the particle we are computed the position for
  88778. */
  88779. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88780. /**
  88781. * Clones the current emitter and returns a copy of it
  88782. * @returns the new emitter
  88783. */
  88784. clone(): ConeParticleEmitter;
  88785. /**
  88786. * Called by the GPUParticleSystem to setup the update shader
  88787. * @param effect defines the update shader
  88788. */
  88789. applyToShader(effect: Effect): void;
  88790. /**
  88791. * Returns a string to use to update the GPU particles update shader
  88792. * @returns a string containng the defines string
  88793. */
  88794. getEffectDefines(): string;
  88795. /**
  88796. * Returns the string "ConeParticleEmitter"
  88797. * @returns a string containing the class name
  88798. */
  88799. getClassName(): string;
  88800. /**
  88801. * Serializes the particle system to a JSON object.
  88802. * @returns the JSON object
  88803. */
  88804. serialize(): any;
  88805. /**
  88806. * Parse properties from a JSON object
  88807. * @param serializationObject defines the JSON object
  88808. */
  88809. parse(serializationObject: any): void;
  88810. }
  88811. }
  88812. declare module BABYLON {
  88813. /**
  88814. * Particle emitter emitting particles from the inside of a cylinder.
  88815. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88816. */
  88817. export class CylinderParticleEmitter implements IParticleEmitterType {
  88818. /**
  88819. * The radius of the emission cylinder.
  88820. */
  88821. radius: number;
  88822. /**
  88823. * The height of the emission cylinder.
  88824. */
  88825. height: number;
  88826. /**
  88827. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88828. */
  88829. radiusRange: number;
  88830. /**
  88831. * How much to randomize the particle direction [0-1].
  88832. */
  88833. directionRandomizer: number;
  88834. /**
  88835. * Creates a new instance CylinderParticleEmitter
  88836. * @param radius the radius of the emission cylinder (1 by default)
  88837. * @param height the height of the emission cylinder (1 by default)
  88838. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88839. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88840. */
  88841. constructor(
  88842. /**
  88843. * The radius of the emission cylinder.
  88844. */
  88845. radius?: number,
  88846. /**
  88847. * The height of the emission cylinder.
  88848. */
  88849. height?: number,
  88850. /**
  88851. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88852. */
  88853. radiusRange?: number,
  88854. /**
  88855. * How much to randomize the particle direction [0-1].
  88856. */
  88857. directionRandomizer?: number);
  88858. /**
  88859. * Called by the particle System when the direction is computed for the created particle.
  88860. * @param worldMatrix is the world matrix of the particle system
  88861. * @param directionToUpdate is the direction vector to update with the result
  88862. * @param particle is the particle we are computed the direction for
  88863. */
  88864. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88865. /**
  88866. * Called by the particle System when the position is computed for the created particle.
  88867. * @param worldMatrix is the world matrix of the particle system
  88868. * @param positionToUpdate is the position vector to update with the result
  88869. * @param particle is the particle we are computed the position for
  88870. */
  88871. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88872. /**
  88873. * Clones the current emitter and returns a copy of it
  88874. * @returns the new emitter
  88875. */
  88876. clone(): CylinderParticleEmitter;
  88877. /**
  88878. * Called by the GPUParticleSystem to setup the update shader
  88879. * @param effect defines the update shader
  88880. */
  88881. applyToShader(effect: Effect): void;
  88882. /**
  88883. * Returns a string to use to update the GPU particles update shader
  88884. * @returns a string containng the defines string
  88885. */
  88886. getEffectDefines(): string;
  88887. /**
  88888. * Returns the string "CylinderParticleEmitter"
  88889. * @returns a string containing the class name
  88890. */
  88891. getClassName(): string;
  88892. /**
  88893. * Serializes the particle system to a JSON object.
  88894. * @returns the JSON object
  88895. */
  88896. serialize(): any;
  88897. /**
  88898. * Parse properties from a JSON object
  88899. * @param serializationObject defines the JSON object
  88900. */
  88901. parse(serializationObject: any): void;
  88902. }
  88903. /**
  88904. * Particle emitter emitting particles from the inside of a cylinder.
  88905. * It emits the particles randomly between two vectors.
  88906. */
  88907. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88908. /**
  88909. * The min limit of the emission direction.
  88910. */
  88911. direction1: Vector3;
  88912. /**
  88913. * The max limit of the emission direction.
  88914. */
  88915. direction2: Vector3;
  88916. /**
  88917. * Creates a new instance CylinderDirectedParticleEmitter
  88918. * @param radius the radius of the emission cylinder (1 by default)
  88919. * @param height the height of the emission cylinder (1 by default)
  88920. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88921. * @param direction1 the min limit of the emission direction (up vector by default)
  88922. * @param direction2 the max limit of the emission direction (up vector by default)
  88923. */
  88924. constructor(radius?: number, height?: number, radiusRange?: number,
  88925. /**
  88926. * The min limit of the emission direction.
  88927. */
  88928. direction1?: Vector3,
  88929. /**
  88930. * The max limit of the emission direction.
  88931. */
  88932. direction2?: Vector3);
  88933. /**
  88934. * Called by the particle System when the direction is computed for the created particle.
  88935. * @param worldMatrix is the world matrix of the particle system
  88936. * @param directionToUpdate is the direction vector to update with the result
  88937. * @param particle is the particle we are computed the direction for
  88938. */
  88939. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88940. /**
  88941. * Clones the current emitter and returns a copy of it
  88942. * @returns the new emitter
  88943. */
  88944. clone(): CylinderDirectedParticleEmitter;
  88945. /**
  88946. * Called by the GPUParticleSystem to setup the update shader
  88947. * @param effect defines the update shader
  88948. */
  88949. applyToShader(effect: Effect): void;
  88950. /**
  88951. * Returns a string to use to update the GPU particles update shader
  88952. * @returns a string containng the defines string
  88953. */
  88954. getEffectDefines(): string;
  88955. /**
  88956. * Returns the string "CylinderDirectedParticleEmitter"
  88957. * @returns a string containing the class name
  88958. */
  88959. getClassName(): string;
  88960. /**
  88961. * Serializes the particle system to a JSON object.
  88962. * @returns the JSON object
  88963. */
  88964. serialize(): any;
  88965. /**
  88966. * Parse properties from a JSON object
  88967. * @param serializationObject defines the JSON object
  88968. */
  88969. parse(serializationObject: any): void;
  88970. }
  88971. }
  88972. declare module BABYLON {
  88973. /**
  88974. * Particle emitter emitting particles from the inside of a hemisphere.
  88975. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88976. */
  88977. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88978. /**
  88979. * The radius of the emission hemisphere.
  88980. */
  88981. radius: number;
  88982. /**
  88983. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88984. */
  88985. radiusRange: number;
  88986. /**
  88987. * How much to randomize the particle direction [0-1].
  88988. */
  88989. directionRandomizer: number;
  88990. /**
  88991. * Creates a new instance HemisphericParticleEmitter
  88992. * @param radius the radius of the emission hemisphere (1 by default)
  88993. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88994. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88995. */
  88996. constructor(
  88997. /**
  88998. * The radius of the emission hemisphere.
  88999. */
  89000. radius?: number,
  89001. /**
  89002. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89003. */
  89004. radiusRange?: number,
  89005. /**
  89006. * How much to randomize the particle direction [0-1].
  89007. */
  89008. directionRandomizer?: number);
  89009. /**
  89010. * Called by the particle System when the direction is computed for the created particle.
  89011. * @param worldMatrix is the world matrix of the particle system
  89012. * @param directionToUpdate is the direction vector to update with the result
  89013. * @param particle is the particle we are computed the direction for
  89014. */
  89015. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89016. /**
  89017. * Called by the particle System when the position is computed for the created particle.
  89018. * @param worldMatrix is the world matrix of the particle system
  89019. * @param positionToUpdate is the position vector to update with the result
  89020. * @param particle is the particle we are computed the position for
  89021. */
  89022. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89023. /**
  89024. * Clones the current emitter and returns a copy of it
  89025. * @returns the new emitter
  89026. */
  89027. clone(): HemisphericParticleEmitter;
  89028. /**
  89029. * Called by the GPUParticleSystem to setup the update shader
  89030. * @param effect defines the update shader
  89031. */
  89032. applyToShader(effect: Effect): void;
  89033. /**
  89034. * Returns a string to use to update the GPU particles update shader
  89035. * @returns a string containng the defines string
  89036. */
  89037. getEffectDefines(): string;
  89038. /**
  89039. * Returns the string "HemisphericParticleEmitter"
  89040. * @returns a string containing the class name
  89041. */
  89042. getClassName(): string;
  89043. /**
  89044. * Serializes the particle system to a JSON object.
  89045. * @returns the JSON object
  89046. */
  89047. serialize(): any;
  89048. /**
  89049. * Parse properties from a JSON object
  89050. * @param serializationObject defines the JSON object
  89051. */
  89052. parse(serializationObject: any): void;
  89053. }
  89054. }
  89055. declare module BABYLON {
  89056. /**
  89057. * Particle emitter emitting particles from a point.
  89058. * It emits the particles randomly between 2 given directions.
  89059. */
  89060. export class PointParticleEmitter implements IParticleEmitterType {
  89061. /**
  89062. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89063. */
  89064. direction1: Vector3;
  89065. /**
  89066. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89067. */
  89068. direction2: Vector3;
  89069. /**
  89070. * Creates a new instance PointParticleEmitter
  89071. */
  89072. constructor();
  89073. /**
  89074. * Called by the particle System when the direction is computed for the created particle.
  89075. * @param worldMatrix is the world matrix of the particle system
  89076. * @param directionToUpdate is the direction vector to update with the result
  89077. * @param particle is the particle we are computed the direction for
  89078. */
  89079. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89080. /**
  89081. * Called by the particle System when the position is computed for the created particle.
  89082. * @param worldMatrix is the world matrix of the particle system
  89083. * @param positionToUpdate is the position vector to update with the result
  89084. * @param particle is the particle we are computed the position for
  89085. */
  89086. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89087. /**
  89088. * Clones the current emitter and returns a copy of it
  89089. * @returns the new emitter
  89090. */
  89091. clone(): PointParticleEmitter;
  89092. /**
  89093. * Called by the GPUParticleSystem to setup the update shader
  89094. * @param effect defines the update shader
  89095. */
  89096. applyToShader(effect: Effect): void;
  89097. /**
  89098. * Returns a string to use to update the GPU particles update shader
  89099. * @returns a string containng the defines string
  89100. */
  89101. getEffectDefines(): string;
  89102. /**
  89103. * Returns the string "PointParticleEmitter"
  89104. * @returns a string containing the class name
  89105. */
  89106. getClassName(): string;
  89107. /**
  89108. * Serializes the particle system to a JSON object.
  89109. * @returns the JSON object
  89110. */
  89111. serialize(): any;
  89112. /**
  89113. * Parse properties from a JSON object
  89114. * @param serializationObject defines the JSON object
  89115. */
  89116. parse(serializationObject: any): void;
  89117. }
  89118. }
  89119. declare module BABYLON {
  89120. /**
  89121. * Particle emitter emitting particles from the inside of a sphere.
  89122. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  89123. */
  89124. export class SphereParticleEmitter implements IParticleEmitterType {
  89125. /**
  89126. * The radius of the emission sphere.
  89127. */
  89128. radius: number;
  89129. /**
  89130. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89131. */
  89132. radiusRange: number;
  89133. /**
  89134. * How much to randomize the particle direction [0-1].
  89135. */
  89136. directionRandomizer: number;
  89137. /**
  89138. * Creates a new instance SphereParticleEmitter
  89139. * @param radius the radius of the emission sphere (1 by default)
  89140. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89141. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89142. */
  89143. constructor(
  89144. /**
  89145. * The radius of the emission sphere.
  89146. */
  89147. radius?: number,
  89148. /**
  89149. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89150. */
  89151. radiusRange?: number,
  89152. /**
  89153. * How much to randomize the particle direction [0-1].
  89154. */
  89155. directionRandomizer?: number);
  89156. /**
  89157. * Called by the particle System when the direction is computed for the created particle.
  89158. * @param worldMatrix is the world matrix of the particle system
  89159. * @param directionToUpdate is the direction vector to update with the result
  89160. * @param particle is the particle we are computed the direction for
  89161. */
  89162. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89163. /**
  89164. * Called by the particle System when the position is computed for the created particle.
  89165. * @param worldMatrix is the world matrix of the particle system
  89166. * @param positionToUpdate is the position vector to update with the result
  89167. * @param particle is the particle we are computed the position for
  89168. */
  89169. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89170. /**
  89171. * Clones the current emitter and returns a copy of it
  89172. * @returns the new emitter
  89173. */
  89174. clone(): SphereParticleEmitter;
  89175. /**
  89176. * Called by the GPUParticleSystem to setup the update shader
  89177. * @param effect defines the update shader
  89178. */
  89179. applyToShader(effect: Effect): void;
  89180. /**
  89181. * Returns a string to use to update the GPU particles update shader
  89182. * @returns a string containng the defines string
  89183. */
  89184. getEffectDefines(): string;
  89185. /**
  89186. * Returns the string "SphereParticleEmitter"
  89187. * @returns a string containing the class name
  89188. */
  89189. getClassName(): string;
  89190. /**
  89191. * Serializes the particle system to a JSON object.
  89192. * @returns the JSON object
  89193. */
  89194. serialize(): any;
  89195. /**
  89196. * Parse properties from a JSON object
  89197. * @param serializationObject defines the JSON object
  89198. */
  89199. parse(serializationObject: any): void;
  89200. }
  89201. /**
  89202. * Particle emitter emitting particles from the inside of a sphere.
  89203. * It emits the particles randomly between two vectors.
  89204. */
  89205. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  89206. /**
  89207. * The min limit of the emission direction.
  89208. */
  89209. direction1: Vector3;
  89210. /**
  89211. * The max limit of the emission direction.
  89212. */
  89213. direction2: Vector3;
  89214. /**
  89215. * Creates a new instance SphereDirectedParticleEmitter
  89216. * @param radius the radius of the emission sphere (1 by default)
  89217. * @param direction1 the min limit of the emission direction (up vector by default)
  89218. * @param direction2 the max limit of the emission direction (up vector by default)
  89219. */
  89220. constructor(radius?: number,
  89221. /**
  89222. * The min limit of the emission direction.
  89223. */
  89224. direction1?: Vector3,
  89225. /**
  89226. * The max limit of the emission direction.
  89227. */
  89228. direction2?: Vector3);
  89229. /**
  89230. * Called by the particle System when the direction is computed for the created particle.
  89231. * @param worldMatrix is the world matrix of the particle system
  89232. * @param directionToUpdate is the direction vector to update with the result
  89233. * @param particle is the particle we are computed the direction for
  89234. */
  89235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89236. /**
  89237. * Clones the current emitter and returns a copy of it
  89238. * @returns the new emitter
  89239. */
  89240. clone(): SphereDirectedParticleEmitter;
  89241. /**
  89242. * Called by the GPUParticleSystem to setup the update shader
  89243. * @param effect defines the update shader
  89244. */
  89245. applyToShader(effect: Effect): void;
  89246. /**
  89247. * Returns a string to use to update the GPU particles update shader
  89248. * @returns a string containng the defines string
  89249. */
  89250. getEffectDefines(): string;
  89251. /**
  89252. * Returns the string "SphereDirectedParticleEmitter"
  89253. * @returns a string containing the class name
  89254. */
  89255. getClassName(): string;
  89256. /**
  89257. * Serializes the particle system to a JSON object.
  89258. * @returns the JSON object
  89259. */
  89260. serialize(): any;
  89261. /**
  89262. * Parse properties from a JSON object
  89263. * @param serializationObject defines the JSON object
  89264. */
  89265. parse(serializationObject: any): void;
  89266. }
  89267. }
  89268. declare module BABYLON {
  89269. /**
  89270. * Interface representing a particle system in Babylon.js.
  89271. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89272. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89273. */
  89274. export interface IParticleSystem {
  89275. /**
  89276. * List of animations used by the particle system.
  89277. */
  89278. animations: Animation[];
  89279. /**
  89280. * The id of the Particle system.
  89281. */
  89282. id: string;
  89283. /**
  89284. * The name of the Particle system.
  89285. */
  89286. name: string;
  89287. /**
  89288. * The emitter represents the Mesh or position we are attaching the particle system to.
  89289. */
  89290. emitter: Nullable<AbstractMesh | Vector3>;
  89291. /**
  89292. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89293. */
  89294. isBillboardBased: boolean;
  89295. /**
  89296. * The rendering group used by the Particle system to chose when to render.
  89297. */
  89298. renderingGroupId: number;
  89299. /**
  89300. * The layer mask we are rendering the particles through.
  89301. */
  89302. layerMask: number;
  89303. /**
  89304. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89305. */
  89306. updateSpeed: number;
  89307. /**
  89308. * The amount of time the particle system is running (depends of the overall update speed).
  89309. */
  89310. targetStopDuration: number;
  89311. /**
  89312. * The texture used to render each particle. (this can be a spritesheet)
  89313. */
  89314. particleTexture: Nullable<Texture>;
  89315. /**
  89316. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  89317. */
  89318. blendMode: number;
  89319. /**
  89320. * Minimum life time of emitting particles.
  89321. */
  89322. minLifeTime: number;
  89323. /**
  89324. * Maximum life time of emitting particles.
  89325. */
  89326. maxLifeTime: number;
  89327. /**
  89328. * Minimum Size of emitting particles.
  89329. */
  89330. minSize: number;
  89331. /**
  89332. * Maximum Size of emitting particles.
  89333. */
  89334. maxSize: number;
  89335. /**
  89336. * Minimum scale of emitting particles on X axis.
  89337. */
  89338. minScaleX: number;
  89339. /**
  89340. * Maximum scale of emitting particles on X axis.
  89341. */
  89342. maxScaleX: number;
  89343. /**
  89344. * Minimum scale of emitting particles on Y axis.
  89345. */
  89346. minScaleY: number;
  89347. /**
  89348. * Maximum scale of emitting particles on Y axis.
  89349. */
  89350. maxScaleY: number;
  89351. /**
  89352. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89353. */
  89354. color1: Color4;
  89355. /**
  89356. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89357. */
  89358. color2: Color4;
  89359. /**
  89360. * Color the particle will have at the end of its lifetime.
  89361. */
  89362. colorDead: Color4;
  89363. /**
  89364. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  89365. */
  89366. emitRate: number;
  89367. /**
  89368. * You can use gravity if you want to give an orientation to your particles.
  89369. */
  89370. gravity: Vector3;
  89371. /**
  89372. * Minimum power of emitting particles.
  89373. */
  89374. minEmitPower: number;
  89375. /**
  89376. * Maximum power of emitting particles.
  89377. */
  89378. maxEmitPower: number;
  89379. /**
  89380. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89381. */
  89382. minAngularSpeed: number;
  89383. /**
  89384. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89385. */
  89386. maxAngularSpeed: number;
  89387. /**
  89388. * Gets or sets the minimal initial rotation in radians.
  89389. */
  89390. minInitialRotation: number;
  89391. /**
  89392. * Gets or sets the maximal initial rotation in radians.
  89393. */
  89394. maxInitialRotation: number;
  89395. /**
  89396. * The particle emitter type defines the emitter used by the particle system.
  89397. * It can be for example box, sphere, or cone...
  89398. */
  89399. particleEmitterType: Nullable<IParticleEmitterType>;
  89400. /**
  89401. * Defines the delay in milliseconds before starting the system (0 by default)
  89402. */
  89403. startDelay: number;
  89404. /**
  89405. * 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
  89406. */
  89407. preWarmCycles: number;
  89408. /**
  89409. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89410. */
  89411. preWarmStepOffset: number;
  89412. /**
  89413. * 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)
  89414. */
  89415. spriteCellChangeSpeed: number;
  89416. /**
  89417. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89418. */
  89419. startSpriteCellID: number;
  89420. /**
  89421. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89422. */
  89423. endSpriteCellID: number;
  89424. /**
  89425. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89426. */
  89427. spriteCellWidth: number;
  89428. /**
  89429. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89430. */
  89431. spriteCellHeight: number;
  89432. /**
  89433. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89434. */
  89435. spriteRandomStartCell: boolean;
  89436. /**
  89437. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89438. */
  89439. isAnimationSheetEnabled: boolean;
  89440. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89441. translationPivot: Vector2;
  89442. /**
  89443. * Gets or sets a texture used to add random noise to particle positions
  89444. */
  89445. noiseTexture: Nullable<BaseTexture>;
  89446. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89447. noiseStrength: Vector3;
  89448. /**
  89449. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89450. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89451. */
  89452. billboardMode: number;
  89453. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89454. limitVelocityDamping: number;
  89455. /**
  89456. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89457. */
  89458. beginAnimationOnStart: boolean;
  89459. /**
  89460. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89461. */
  89462. beginAnimationFrom: number;
  89463. /**
  89464. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89465. */
  89466. beginAnimationTo: number;
  89467. /**
  89468. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89469. */
  89470. beginAnimationLoop: boolean;
  89471. /**
  89472. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89473. */
  89474. disposeOnStop: boolean;
  89475. /**
  89476. * Gets the maximum number of particles active at the same time.
  89477. * @returns The max number of active particles.
  89478. */
  89479. getCapacity(): number;
  89480. /**
  89481. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89482. * @returns True if it has been started, otherwise false.
  89483. */
  89484. isStarted(): boolean;
  89485. /**
  89486. * Animates the particle system for this frame.
  89487. */
  89488. animate(): void;
  89489. /**
  89490. * Renders the particle system in its current state.
  89491. * @returns the current number of particles
  89492. */
  89493. render(): number;
  89494. /**
  89495. * Dispose the particle system and frees its associated resources.
  89496. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89497. */
  89498. dispose(disposeTexture?: boolean): void;
  89499. /**
  89500. * Clones the particle system.
  89501. * @param name The name of the cloned object
  89502. * @param newEmitter The new emitter to use
  89503. * @returns the cloned particle system
  89504. */
  89505. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89506. /**
  89507. * Serializes the particle system to a JSON object.
  89508. * @returns the JSON object
  89509. */
  89510. serialize(): any;
  89511. /**
  89512. * Rebuild the particle system
  89513. */
  89514. rebuild(): void;
  89515. /**
  89516. * Starts the particle system and begins to emit
  89517. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89518. */
  89519. start(delay?: number): void;
  89520. /**
  89521. * Stops the particle system.
  89522. */
  89523. stop(): void;
  89524. /**
  89525. * Remove all active particles
  89526. */
  89527. reset(): void;
  89528. /**
  89529. * Is this system ready to be used/rendered
  89530. * @return true if the system is ready
  89531. */
  89532. isReady(): boolean;
  89533. /**
  89534. * Adds a new color gradient
  89535. * @param gradient defines the gradient to use (between 0 and 1)
  89536. * @param color1 defines the color to affect to the specified gradient
  89537. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89538. * @returns the current particle system
  89539. */
  89540. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89541. /**
  89542. * Remove a specific color gradient
  89543. * @param gradient defines the gradient to remove
  89544. * @returns the current particle system
  89545. */
  89546. removeColorGradient(gradient: number): IParticleSystem;
  89547. /**
  89548. * Adds a new size gradient
  89549. * @param gradient defines the gradient to use (between 0 and 1)
  89550. * @param factor defines the size factor to affect to the specified gradient
  89551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89552. * @returns the current particle system
  89553. */
  89554. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89555. /**
  89556. * Remove a specific size gradient
  89557. * @param gradient defines the gradient to remove
  89558. * @returns the current particle system
  89559. */
  89560. removeSizeGradient(gradient: number): IParticleSystem;
  89561. /**
  89562. * Gets the current list of color gradients.
  89563. * You must use addColorGradient and removeColorGradient to udpate this list
  89564. * @returns the list of color gradients
  89565. */
  89566. getColorGradients(): Nullable<Array<ColorGradient>>;
  89567. /**
  89568. * Gets the current list of size gradients.
  89569. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89570. * @returns the list of size gradients
  89571. */
  89572. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89573. /**
  89574. * Gets the current list of angular speed gradients.
  89575. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89576. * @returns the list of angular speed gradients
  89577. */
  89578. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89579. /**
  89580. * Adds a new angular speed gradient
  89581. * @param gradient defines the gradient to use (between 0 and 1)
  89582. * @param factor defines the angular speed to affect to the specified gradient
  89583. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89584. * @returns the current particle system
  89585. */
  89586. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89587. /**
  89588. * Remove a specific angular speed gradient
  89589. * @param gradient defines the gradient to remove
  89590. * @returns the current particle system
  89591. */
  89592. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89593. /**
  89594. * Gets the current list of velocity gradients.
  89595. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89596. * @returns the list of velocity gradients
  89597. */
  89598. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89599. /**
  89600. * Adds a new velocity gradient
  89601. * @param gradient defines the gradient to use (between 0 and 1)
  89602. * @param factor defines the velocity to affect to the specified gradient
  89603. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89604. * @returns the current particle system
  89605. */
  89606. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89607. /**
  89608. * Remove a specific velocity gradient
  89609. * @param gradient defines the gradient to remove
  89610. * @returns the current particle system
  89611. */
  89612. removeVelocityGradient(gradient: number): IParticleSystem;
  89613. /**
  89614. * Gets the current list of limit velocity gradients.
  89615. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89616. * @returns the list of limit velocity gradients
  89617. */
  89618. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89619. /**
  89620. * Adds a new limit velocity gradient
  89621. * @param gradient defines the gradient to use (between 0 and 1)
  89622. * @param factor defines the limit velocity to affect to the specified gradient
  89623. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89624. * @returns the current particle system
  89625. */
  89626. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89627. /**
  89628. * Remove a specific limit velocity gradient
  89629. * @param gradient defines the gradient to remove
  89630. * @returns the current particle system
  89631. */
  89632. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89633. /**
  89634. * Adds a new drag gradient
  89635. * @param gradient defines the gradient to use (between 0 and 1)
  89636. * @param factor defines the drag to affect to the specified gradient
  89637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89638. * @returns the current particle system
  89639. */
  89640. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89641. /**
  89642. * Remove a specific drag gradient
  89643. * @param gradient defines the gradient to remove
  89644. * @returns the current particle system
  89645. */
  89646. removeDragGradient(gradient: number): IParticleSystem;
  89647. /**
  89648. * Gets the current list of drag gradients.
  89649. * You must use addDragGradient and removeDragGradient to udpate this list
  89650. * @returns the list of drag gradients
  89651. */
  89652. getDragGradients(): Nullable<Array<FactorGradient>>;
  89653. /**
  89654. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89655. * @param gradient defines the gradient to use (between 0 and 1)
  89656. * @param factor defines the emit rate to affect to the specified gradient
  89657. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89658. * @returns the current particle system
  89659. */
  89660. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89661. /**
  89662. * Remove a specific emit rate gradient
  89663. * @param gradient defines the gradient to remove
  89664. * @returns the current particle system
  89665. */
  89666. removeEmitRateGradient(gradient: number): IParticleSystem;
  89667. /**
  89668. * Gets the current list of emit rate gradients.
  89669. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89670. * @returns the list of emit rate gradients
  89671. */
  89672. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89673. /**
  89674. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89675. * @param gradient defines the gradient to use (between 0 and 1)
  89676. * @param factor defines the start size to affect to the specified gradient
  89677. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89678. * @returns the current particle system
  89679. */
  89680. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89681. /**
  89682. * Remove a specific start size gradient
  89683. * @param gradient defines the gradient to remove
  89684. * @returns the current particle system
  89685. */
  89686. removeStartSizeGradient(gradient: number): IParticleSystem;
  89687. /**
  89688. * Gets the current list of start size gradients.
  89689. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89690. * @returns the list of start size gradients
  89691. */
  89692. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89693. /**
  89694. * Adds a new life time gradient
  89695. * @param gradient defines the gradient to use (between 0 and 1)
  89696. * @param factor defines the life time factor to affect to the specified gradient
  89697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89698. * @returns the current particle system
  89699. */
  89700. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89701. /**
  89702. * Remove a specific life time gradient
  89703. * @param gradient defines the gradient to remove
  89704. * @returns the current particle system
  89705. */
  89706. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89707. /**
  89708. * Gets the current list of life time gradients.
  89709. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89710. * @returns the list of life time gradients
  89711. */
  89712. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89713. /**
  89714. * Gets the current list of color gradients.
  89715. * You must use addColorGradient and removeColorGradient to udpate this list
  89716. * @returns the list of color gradients
  89717. */
  89718. getColorGradients(): Nullable<Array<ColorGradient>>;
  89719. /**
  89720. * Adds a new ramp gradient used to remap particle colors
  89721. * @param gradient defines the gradient to use (between 0 and 1)
  89722. * @param color defines the color to affect to the specified gradient
  89723. * @returns the current particle system
  89724. */
  89725. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89726. /**
  89727. * Gets the current list of ramp gradients.
  89728. * You must use addRampGradient and removeRampGradient to udpate this list
  89729. * @returns the list of ramp gradients
  89730. */
  89731. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89732. /** Gets or sets a boolean indicating that ramp gradients must be used
  89733. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89734. */
  89735. useRampGradients: boolean;
  89736. /**
  89737. * Adds a new color remap gradient
  89738. * @param gradient defines the gradient to use (between 0 and 1)
  89739. * @param min defines the color remap minimal range
  89740. * @param max defines the color remap maximal range
  89741. * @returns the current particle system
  89742. */
  89743. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89744. /**
  89745. * Gets the current list of color remap gradients.
  89746. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89747. * @returns the list of color remap gradients
  89748. */
  89749. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89750. /**
  89751. * Adds a new alpha remap gradient
  89752. * @param gradient defines the gradient to use (between 0 and 1)
  89753. * @param min defines the alpha remap minimal range
  89754. * @param max defines the alpha remap maximal range
  89755. * @returns the current particle system
  89756. */
  89757. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89758. /**
  89759. * Gets the current list of alpha remap gradients.
  89760. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89761. * @returns the list of alpha remap gradients
  89762. */
  89763. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89764. /**
  89765. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89766. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89767. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89768. * @returns the emitter
  89769. */
  89770. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89771. /**
  89772. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89773. * @param radius The radius of the hemisphere to emit from
  89774. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89775. * @returns the emitter
  89776. */
  89777. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89778. /**
  89779. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89780. * @param radius The radius of the sphere to emit from
  89781. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89782. * @returns the emitter
  89783. */
  89784. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89785. /**
  89786. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89787. * @param radius The radius of the sphere to emit from
  89788. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89789. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89790. * @returns the emitter
  89791. */
  89792. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89793. /**
  89794. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89795. * @param radius The radius of the emission cylinder
  89796. * @param height The height of the emission cylinder
  89797. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89798. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89799. * @returns the emitter
  89800. */
  89801. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89802. /**
  89803. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89804. * @param radius The radius of the cylinder to emit from
  89805. * @param height The height of the emission cylinder
  89806. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89807. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89808. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89809. * @returns the emitter
  89810. */
  89811. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89812. /**
  89813. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89814. * @param radius The radius of the cone to emit from
  89815. * @param angle The base angle of the cone
  89816. * @returns the emitter
  89817. */
  89818. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89819. /**
  89820. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89821. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89822. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89823. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89824. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89825. * @returns the emitter
  89826. */
  89827. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89828. /**
  89829. * Get hosting scene
  89830. * @returns the scene
  89831. */
  89832. getScene(): Scene;
  89833. }
  89834. }
  89835. declare module BABYLON {
  89836. /**
  89837. * Creates an instance based on a source mesh.
  89838. */
  89839. export class InstancedMesh extends AbstractMesh {
  89840. private _sourceMesh;
  89841. private _currentLOD;
  89842. /** @hidden */
  89843. _indexInSourceMeshInstanceArray: number;
  89844. constructor(name: string, source: Mesh);
  89845. /**
  89846. * Returns the string "InstancedMesh".
  89847. */
  89848. getClassName(): string;
  89849. /** Gets the list of lights affecting that mesh */
  89850. get lightSources(): Light[];
  89851. _resyncLightSources(): void;
  89852. _resyncLightSource(light: Light): void;
  89853. _removeLightSource(light: Light, dispose: boolean): void;
  89854. /**
  89855. * If the source mesh receives shadows
  89856. */
  89857. get receiveShadows(): boolean;
  89858. /**
  89859. * The material of the source mesh
  89860. */
  89861. get material(): Nullable<Material>;
  89862. /**
  89863. * Visibility of the source mesh
  89864. */
  89865. get visibility(): number;
  89866. /**
  89867. * Skeleton of the source mesh
  89868. */
  89869. get skeleton(): Nullable<Skeleton>;
  89870. /**
  89871. * Rendering ground id of the source mesh
  89872. */
  89873. get renderingGroupId(): number;
  89874. set renderingGroupId(value: number);
  89875. /**
  89876. * Returns the total number of vertices (integer).
  89877. */
  89878. getTotalVertices(): number;
  89879. /**
  89880. * Returns a positive integer : the total number of indices in this mesh geometry.
  89881. * @returns the numner of indices or zero if the mesh has no geometry.
  89882. */
  89883. getTotalIndices(): number;
  89884. /**
  89885. * The source mesh of the instance
  89886. */
  89887. get sourceMesh(): Mesh;
  89888. /**
  89889. * Is this node ready to be used/rendered
  89890. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89891. * @return {boolean} is it ready
  89892. */
  89893. isReady(completeCheck?: boolean): boolean;
  89894. /**
  89895. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89896. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89897. * @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.
  89898. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89899. */
  89900. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89901. /**
  89902. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89903. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89904. * The `data` are either a numeric array either a Float32Array.
  89905. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89906. * 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).
  89907. * Note that a new underlying VertexBuffer object is created each call.
  89908. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89909. *
  89910. * Possible `kind` values :
  89911. * - VertexBuffer.PositionKind
  89912. * - VertexBuffer.UVKind
  89913. * - VertexBuffer.UV2Kind
  89914. * - VertexBuffer.UV3Kind
  89915. * - VertexBuffer.UV4Kind
  89916. * - VertexBuffer.UV5Kind
  89917. * - VertexBuffer.UV6Kind
  89918. * - VertexBuffer.ColorKind
  89919. * - VertexBuffer.MatricesIndicesKind
  89920. * - VertexBuffer.MatricesIndicesExtraKind
  89921. * - VertexBuffer.MatricesWeightsKind
  89922. * - VertexBuffer.MatricesWeightsExtraKind
  89923. *
  89924. * Returns the Mesh.
  89925. */
  89926. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89927. /**
  89928. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89929. * If the mesh has no geometry, it is simply returned as it is.
  89930. * The `data` are either a numeric array either a Float32Array.
  89931. * No new underlying VertexBuffer object is created.
  89932. * 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.
  89933. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89934. *
  89935. * Possible `kind` values :
  89936. * - VertexBuffer.PositionKind
  89937. * - VertexBuffer.UVKind
  89938. * - VertexBuffer.UV2Kind
  89939. * - VertexBuffer.UV3Kind
  89940. * - VertexBuffer.UV4Kind
  89941. * - VertexBuffer.UV5Kind
  89942. * - VertexBuffer.UV6Kind
  89943. * - VertexBuffer.ColorKind
  89944. * - VertexBuffer.MatricesIndicesKind
  89945. * - VertexBuffer.MatricesIndicesExtraKind
  89946. * - VertexBuffer.MatricesWeightsKind
  89947. * - VertexBuffer.MatricesWeightsExtraKind
  89948. *
  89949. * Returns the Mesh.
  89950. */
  89951. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89952. /**
  89953. * Sets the mesh indices.
  89954. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89955. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89956. * This method creates a new index buffer each call.
  89957. * Returns the Mesh.
  89958. */
  89959. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89960. /**
  89961. * Boolean : True if the mesh owns the requested kind of data.
  89962. */
  89963. isVerticesDataPresent(kind: string): boolean;
  89964. /**
  89965. * Returns an array of indices (IndicesArray).
  89966. */
  89967. getIndices(): Nullable<IndicesArray>;
  89968. get _positions(): Nullable<Vector3[]>;
  89969. /**
  89970. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89971. * This means the mesh underlying bounding box and sphere are recomputed.
  89972. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89973. * @returns the current mesh
  89974. */
  89975. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89976. /** @hidden */
  89977. _preActivate(): InstancedMesh;
  89978. /** @hidden */
  89979. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89980. /** @hidden */
  89981. _postActivate(): void;
  89982. getWorldMatrix(): Matrix;
  89983. get isAnInstance(): boolean;
  89984. /**
  89985. * Returns the current associated LOD AbstractMesh.
  89986. */
  89987. getLOD(camera: Camera): AbstractMesh;
  89988. /** @hidden */
  89989. _syncSubMeshes(): InstancedMesh;
  89990. /** @hidden */
  89991. _generatePointsArray(): boolean;
  89992. /**
  89993. * Creates a new InstancedMesh from the current mesh.
  89994. * - name (string) : the cloned mesh name
  89995. * - newParent (optional Node) : the optional Node to parent the clone to.
  89996. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89997. *
  89998. * Returns the clone.
  89999. */
  90000. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90001. /**
  90002. * Disposes the InstancedMesh.
  90003. * Returns nothing.
  90004. */
  90005. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90006. }
  90007. interface Mesh {
  90008. /**
  90009. * Register a custom buffer that will be instanced
  90010. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  90011. * @param kind defines the buffer kind
  90012. * @param stride defines the stride in floats
  90013. */
  90014. registerInstancedBuffer(kind: string, stride: number): void;
  90015. /** @hidden */
  90016. _userInstancedBuffersStorage: {
  90017. data: {
  90018. [key: string]: Float32Array;
  90019. };
  90020. sizes: {
  90021. [key: string]: number;
  90022. };
  90023. vertexBuffers: {
  90024. [key: string]: Nullable<VertexBuffer>;
  90025. };
  90026. strides: {
  90027. [key: string]: number;
  90028. };
  90029. };
  90030. }
  90031. interface AbstractMesh {
  90032. /**
  90033. * Object used to store instanced buffers defined by user
  90034. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  90035. */
  90036. instancedBuffers: {
  90037. [key: string]: any;
  90038. };
  90039. }
  90040. }
  90041. declare module BABYLON {
  90042. /**
  90043. * Defines the options associated with the creation of a shader material.
  90044. */
  90045. export interface IShaderMaterialOptions {
  90046. /**
  90047. * Does the material work in alpha blend mode
  90048. */
  90049. needAlphaBlending: boolean;
  90050. /**
  90051. * Does the material work in alpha test mode
  90052. */
  90053. needAlphaTesting: boolean;
  90054. /**
  90055. * The list of attribute names used in the shader
  90056. */
  90057. attributes: string[];
  90058. /**
  90059. * The list of unifrom names used in the shader
  90060. */
  90061. uniforms: string[];
  90062. /**
  90063. * The list of UBO names used in the shader
  90064. */
  90065. uniformBuffers: string[];
  90066. /**
  90067. * The list of sampler names used in the shader
  90068. */
  90069. samplers: string[];
  90070. /**
  90071. * The list of defines used in the shader
  90072. */
  90073. defines: string[];
  90074. }
  90075. /**
  90076. * 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.
  90077. *
  90078. * This returned material effects how the mesh will look based on the code in the shaders.
  90079. *
  90080. * @see http://doc.babylonjs.com/how_to/shader_material
  90081. */
  90082. export class ShaderMaterial extends Material {
  90083. private _shaderPath;
  90084. private _options;
  90085. private _textures;
  90086. private _textureArrays;
  90087. private _floats;
  90088. private _ints;
  90089. private _floatsArrays;
  90090. private _colors3;
  90091. private _colors3Arrays;
  90092. private _colors4;
  90093. private _colors4Arrays;
  90094. private _vectors2;
  90095. private _vectors3;
  90096. private _vectors4;
  90097. private _matrices;
  90098. private _matrixArrays;
  90099. private _matrices3x3;
  90100. private _matrices2x2;
  90101. private _vectors2Arrays;
  90102. private _vectors3Arrays;
  90103. private _vectors4Arrays;
  90104. private _cachedWorldViewMatrix;
  90105. private _cachedWorldViewProjectionMatrix;
  90106. private _renderId;
  90107. private _multiview;
  90108. /**
  90109. * Instantiate a new shader material.
  90110. * 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.
  90111. * This returned material effects how the mesh will look based on the code in the shaders.
  90112. * @see http://doc.babylonjs.com/how_to/shader_material
  90113. * @param name Define the name of the material in the scene
  90114. * @param scene Define the scene the material belongs to
  90115. * @param shaderPath Defines the route to the shader code in one of three ways:
  90116. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  90117. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  90118. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  90119. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  90120. * @param options Define the options used to create the shader
  90121. */
  90122. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  90123. /**
  90124. * Gets the shader path used to define the shader code
  90125. * It can be modified to trigger a new compilation
  90126. */
  90127. get shaderPath(): any;
  90128. /**
  90129. * Sets the shader path used to define the shader code
  90130. * It can be modified to trigger a new compilation
  90131. */
  90132. set shaderPath(shaderPath: any);
  90133. /**
  90134. * Gets the options used to compile the shader.
  90135. * They can be modified to trigger a new compilation
  90136. */
  90137. get options(): IShaderMaterialOptions;
  90138. /**
  90139. * Gets the current class name of the material e.g. "ShaderMaterial"
  90140. * Mainly use in serialization.
  90141. * @returns the class name
  90142. */
  90143. getClassName(): string;
  90144. /**
  90145. * Specifies if the material will require alpha blending
  90146. * @returns a boolean specifying if alpha blending is needed
  90147. */
  90148. needAlphaBlending(): boolean;
  90149. /**
  90150. * Specifies if this material should be rendered in alpha test mode
  90151. * @returns a boolean specifying if an alpha test is needed.
  90152. */
  90153. needAlphaTesting(): boolean;
  90154. private _checkUniform;
  90155. /**
  90156. * Set a texture in the shader.
  90157. * @param name Define the name of the uniform samplers as defined in the shader
  90158. * @param texture Define the texture to bind to this sampler
  90159. * @return the material itself allowing "fluent" like uniform updates
  90160. */
  90161. setTexture(name: string, texture: Texture): ShaderMaterial;
  90162. /**
  90163. * Set a texture array in the shader.
  90164. * @param name Define the name of the uniform sampler array as defined in the shader
  90165. * @param textures Define the list of textures to bind to this sampler
  90166. * @return the material itself allowing "fluent" like uniform updates
  90167. */
  90168. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  90169. /**
  90170. * Set a float in the shader.
  90171. * @param name Define the name of the uniform as defined in the shader
  90172. * @param value Define the value to give to the uniform
  90173. * @return the material itself allowing "fluent" like uniform updates
  90174. */
  90175. setFloat(name: string, value: number): ShaderMaterial;
  90176. /**
  90177. * Set a int in the shader.
  90178. * @param name Define the name of the uniform as defined in the shader
  90179. * @param value Define the value to give to the uniform
  90180. * @return the material itself allowing "fluent" like uniform updates
  90181. */
  90182. setInt(name: string, value: number): ShaderMaterial;
  90183. /**
  90184. * Set an array of floats in the shader.
  90185. * @param name Define the name of the uniform as defined in the shader
  90186. * @param value Define the value to give to the uniform
  90187. * @return the material itself allowing "fluent" like uniform updates
  90188. */
  90189. setFloats(name: string, value: number[]): ShaderMaterial;
  90190. /**
  90191. * Set a vec3 in the shader from a Color3.
  90192. * @param name Define the name of the uniform as defined in the shader
  90193. * @param value Define the value to give to the uniform
  90194. * @return the material itself allowing "fluent" like uniform updates
  90195. */
  90196. setColor3(name: string, value: Color3): ShaderMaterial;
  90197. /**
  90198. * Set a vec3 array in the shader from a Color3 array.
  90199. * @param name Define the name of the uniform as defined in the shader
  90200. * @param value Define the value to give to the uniform
  90201. * @return the material itself allowing "fluent" like uniform updates
  90202. */
  90203. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  90204. /**
  90205. * Set a vec4 in the shader from a Color4.
  90206. * @param name Define the name of the uniform as defined in the shader
  90207. * @param value Define the value to give to the uniform
  90208. * @return the material itself allowing "fluent" like uniform updates
  90209. */
  90210. setColor4(name: string, value: Color4): ShaderMaterial;
  90211. /**
  90212. * Set a vec4 array in the shader from a Color4 array.
  90213. * @param name Define the name of the uniform as defined in the shader
  90214. * @param value Define the value to give to the uniform
  90215. * @return the material itself allowing "fluent" like uniform updates
  90216. */
  90217. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  90218. /**
  90219. * Set a vec2 in the shader from a Vector2.
  90220. * @param name Define the name of the uniform as defined in the shader
  90221. * @param value Define the value to give to the uniform
  90222. * @return the material itself allowing "fluent" like uniform updates
  90223. */
  90224. setVector2(name: string, value: Vector2): ShaderMaterial;
  90225. /**
  90226. * Set a vec3 in the shader from a Vector3.
  90227. * @param name Define the name of the uniform as defined in the shader
  90228. * @param value Define the value to give to the uniform
  90229. * @return the material itself allowing "fluent" like uniform updates
  90230. */
  90231. setVector3(name: string, value: Vector3): ShaderMaterial;
  90232. /**
  90233. * Set a vec4 in the shader from a Vector4.
  90234. * @param name Define the name of the uniform as defined in the shader
  90235. * @param value Define the value to give to the uniform
  90236. * @return the material itself allowing "fluent" like uniform updates
  90237. */
  90238. setVector4(name: string, value: Vector4): ShaderMaterial;
  90239. /**
  90240. * Set a mat4 in the shader from a Matrix.
  90241. * @param name Define the name of the uniform as defined in the shader
  90242. * @param value Define the value to give to the uniform
  90243. * @return the material itself allowing "fluent" like uniform updates
  90244. */
  90245. setMatrix(name: string, value: Matrix): ShaderMaterial;
  90246. /**
  90247. * Set a float32Array in the shader from a matrix array.
  90248. * @param name Define the name of the uniform as defined in the shader
  90249. * @param value Define the value to give to the uniform
  90250. * @return the material itself allowing "fluent" like uniform updates
  90251. */
  90252. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  90253. /**
  90254. * Set a mat3 in the shader from a Float32Array.
  90255. * @param name Define the name of the uniform as defined in the shader
  90256. * @param value Define the value to give to the uniform
  90257. * @return the material itself allowing "fluent" like uniform updates
  90258. */
  90259. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  90260. /**
  90261. * Set a mat2 in the shader from a Float32Array.
  90262. * @param name Define the name of the uniform as defined in the shader
  90263. * @param value Define the value to give to the uniform
  90264. * @return the material itself allowing "fluent" like uniform updates
  90265. */
  90266. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  90267. /**
  90268. * Set a vec2 array in the shader from a number array.
  90269. * @param name Define the name of the uniform as defined in the shader
  90270. * @param value Define the value to give to the uniform
  90271. * @return the material itself allowing "fluent" like uniform updates
  90272. */
  90273. setArray2(name: string, value: number[]): ShaderMaterial;
  90274. /**
  90275. * Set a vec3 array in the shader from a number array.
  90276. * @param name Define the name of the uniform as defined in the shader
  90277. * @param value Define the value to give to the uniform
  90278. * @return the material itself allowing "fluent" like uniform updates
  90279. */
  90280. setArray3(name: string, value: number[]): ShaderMaterial;
  90281. /**
  90282. * Set a vec4 array in the shader from a number array.
  90283. * @param name Define the name of the uniform as defined in the shader
  90284. * @param value Define the value to give to the uniform
  90285. * @return the material itself allowing "fluent" like uniform updates
  90286. */
  90287. setArray4(name: string, value: number[]): ShaderMaterial;
  90288. private _checkCache;
  90289. /**
  90290. * Specifies that the submesh is ready to be used
  90291. * @param mesh defines the mesh to check
  90292. * @param subMesh defines which submesh to check
  90293. * @param useInstances specifies that instances should be used
  90294. * @returns a boolean indicating that the submesh is ready or not
  90295. */
  90296. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90297. /**
  90298. * Checks if the material is ready to render the requested mesh
  90299. * @param mesh Define the mesh to render
  90300. * @param useInstances Define whether or not the material is used with instances
  90301. * @returns true if ready, otherwise false
  90302. */
  90303. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90304. /**
  90305. * Binds the world matrix to the material
  90306. * @param world defines the world transformation matrix
  90307. */
  90308. bindOnlyWorldMatrix(world: Matrix): void;
  90309. /**
  90310. * Binds the material to the mesh
  90311. * @param world defines the world transformation matrix
  90312. * @param mesh defines the mesh to bind the material to
  90313. */
  90314. bind(world: Matrix, mesh?: Mesh): void;
  90315. /**
  90316. * Gets the active textures from the material
  90317. * @returns an array of textures
  90318. */
  90319. getActiveTextures(): BaseTexture[];
  90320. /**
  90321. * Specifies if the material uses a texture
  90322. * @param texture defines the texture to check against the material
  90323. * @returns a boolean specifying if the material uses the texture
  90324. */
  90325. hasTexture(texture: BaseTexture): boolean;
  90326. /**
  90327. * Makes a duplicate of the material, and gives it a new name
  90328. * @param name defines the new name for the duplicated material
  90329. * @returns the cloned material
  90330. */
  90331. clone(name: string): ShaderMaterial;
  90332. /**
  90333. * Disposes the material
  90334. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90335. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90336. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90337. */
  90338. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90339. /**
  90340. * Serializes this material in a JSON representation
  90341. * @returns the serialized material object
  90342. */
  90343. serialize(): any;
  90344. /**
  90345. * Creates a shader material from parsed shader material data
  90346. * @param source defines the JSON represnetation of the material
  90347. * @param scene defines the hosting scene
  90348. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90349. * @returns a new material
  90350. */
  90351. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90352. }
  90353. }
  90354. declare module BABYLON {
  90355. /** @hidden */
  90356. export var colorPixelShader: {
  90357. name: string;
  90358. shader: string;
  90359. };
  90360. }
  90361. declare module BABYLON {
  90362. /** @hidden */
  90363. export var colorVertexShader: {
  90364. name: string;
  90365. shader: string;
  90366. };
  90367. }
  90368. declare module BABYLON {
  90369. /**
  90370. * Line mesh
  90371. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90372. */
  90373. export class LinesMesh extends Mesh {
  90374. /**
  90375. * If vertex color should be applied to the mesh
  90376. */
  90377. readonly useVertexColor?: boolean | undefined;
  90378. /**
  90379. * If vertex alpha should be applied to the mesh
  90380. */
  90381. readonly useVertexAlpha?: boolean | undefined;
  90382. /**
  90383. * Color of the line (Default: White)
  90384. */
  90385. color: Color3;
  90386. /**
  90387. * Alpha of the line (Default: 1)
  90388. */
  90389. alpha: number;
  90390. /**
  90391. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90392. * This margin is expressed in world space coordinates, so its value may vary.
  90393. * Default value is 0.1
  90394. */
  90395. intersectionThreshold: number;
  90396. private _colorShader;
  90397. private color4;
  90398. /**
  90399. * Creates a new LinesMesh
  90400. * @param name defines the name
  90401. * @param scene defines the hosting scene
  90402. * @param parent defines the parent mesh if any
  90403. * @param source defines the optional source LinesMesh used to clone data from
  90404. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90405. * When false, achieved by calling a clone(), also passing False.
  90406. * This will make creation of children, recursive.
  90407. * @param useVertexColor defines if this LinesMesh supports vertex color
  90408. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90409. */
  90410. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90411. /**
  90412. * If vertex color should be applied to the mesh
  90413. */
  90414. useVertexColor?: boolean | undefined,
  90415. /**
  90416. * If vertex alpha should be applied to the mesh
  90417. */
  90418. useVertexAlpha?: boolean | undefined);
  90419. private _addClipPlaneDefine;
  90420. private _removeClipPlaneDefine;
  90421. isReady(): boolean;
  90422. /**
  90423. * Returns the string "LineMesh"
  90424. */
  90425. getClassName(): string;
  90426. /**
  90427. * @hidden
  90428. */
  90429. get material(): Material;
  90430. /**
  90431. * @hidden
  90432. */
  90433. set material(value: Material);
  90434. /**
  90435. * @hidden
  90436. */
  90437. get checkCollisions(): boolean;
  90438. /** @hidden */
  90439. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90440. /** @hidden */
  90441. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90442. /**
  90443. * Disposes of the line mesh
  90444. * @param doNotRecurse If children should be disposed
  90445. */
  90446. dispose(doNotRecurse?: boolean): void;
  90447. /**
  90448. * Returns a new LineMesh object cloned from the current one.
  90449. */
  90450. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90451. /**
  90452. * Creates a new InstancedLinesMesh object from the mesh model.
  90453. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90454. * @param name defines the name of the new instance
  90455. * @returns a new InstancedLinesMesh
  90456. */
  90457. createInstance(name: string): InstancedLinesMesh;
  90458. }
  90459. /**
  90460. * Creates an instance based on a source LinesMesh
  90461. */
  90462. export class InstancedLinesMesh extends InstancedMesh {
  90463. /**
  90464. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90465. * This margin is expressed in world space coordinates, so its value may vary.
  90466. * Initilized with the intersectionThreshold value of the source LinesMesh
  90467. */
  90468. intersectionThreshold: number;
  90469. constructor(name: string, source: LinesMesh);
  90470. /**
  90471. * Returns the string "InstancedLinesMesh".
  90472. */
  90473. getClassName(): string;
  90474. }
  90475. }
  90476. declare module BABYLON {
  90477. /** @hidden */
  90478. export var linePixelShader: {
  90479. name: string;
  90480. shader: string;
  90481. };
  90482. }
  90483. declare module BABYLON {
  90484. /** @hidden */
  90485. export var lineVertexShader: {
  90486. name: string;
  90487. shader: string;
  90488. };
  90489. }
  90490. declare module BABYLON {
  90491. interface AbstractMesh {
  90492. /**
  90493. * Gets the edgesRenderer associated with the mesh
  90494. */
  90495. edgesRenderer: Nullable<EdgesRenderer>;
  90496. }
  90497. interface LinesMesh {
  90498. /**
  90499. * Enables the edge rendering mode on the mesh.
  90500. * This mode makes the mesh edges visible
  90501. * @param epsilon defines the maximal distance between two angles to detect a face
  90502. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90503. * @returns the currentAbstractMesh
  90504. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90505. */
  90506. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90507. }
  90508. interface InstancedLinesMesh {
  90509. /**
  90510. * Enables the edge rendering mode on the mesh.
  90511. * This mode makes the mesh edges visible
  90512. * @param epsilon defines the maximal distance between two angles to detect a face
  90513. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90514. * @returns the current InstancedLinesMesh
  90515. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90516. */
  90517. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90518. }
  90519. /**
  90520. * Defines the minimum contract an Edges renderer should follow.
  90521. */
  90522. export interface IEdgesRenderer extends IDisposable {
  90523. /**
  90524. * Gets or sets a boolean indicating if the edgesRenderer is active
  90525. */
  90526. isEnabled: boolean;
  90527. /**
  90528. * Renders the edges of the attached mesh,
  90529. */
  90530. render(): void;
  90531. /**
  90532. * Checks wether or not the edges renderer is ready to render.
  90533. * @return true if ready, otherwise false.
  90534. */
  90535. isReady(): boolean;
  90536. }
  90537. /**
  90538. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90539. */
  90540. export class EdgesRenderer implements IEdgesRenderer {
  90541. /**
  90542. * Define the size of the edges with an orthographic camera
  90543. */
  90544. edgesWidthScalerForOrthographic: number;
  90545. /**
  90546. * Define the size of the edges with a perspective camera
  90547. */
  90548. edgesWidthScalerForPerspective: number;
  90549. protected _source: AbstractMesh;
  90550. protected _linesPositions: number[];
  90551. protected _linesNormals: number[];
  90552. protected _linesIndices: number[];
  90553. protected _epsilon: number;
  90554. protected _indicesCount: number;
  90555. protected _lineShader: ShaderMaterial;
  90556. protected _ib: DataBuffer;
  90557. protected _buffers: {
  90558. [key: string]: Nullable<VertexBuffer>;
  90559. };
  90560. protected _checkVerticesInsteadOfIndices: boolean;
  90561. private _meshRebuildObserver;
  90562. private _meshDisposeObserver;
  90563. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90564. isEnabled: boolean;
  90565. /**
  90566. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90567. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90568. * @param source Mesh used to create edges
  90569. * @param epsilon sum of angles in adjacency to check for edge
  90570. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90571. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90572. */
  90573. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90574. protected _prepareRessources(): void;
  90575. /** @hidden */
  90576. _rebuild(): void;
  90577. /**
  90578. * Releases the required resources for the edges renderer
  90579. */
  90580. dispose(): void;
  90581. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90582. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90583. /**
  90584. * Checks if the pair of p0 and p1 is en edge
  90585. * @param faceIndex
  90586. * @param edge
  90587. * @param faceNormals
  90588. * @param p0
  90589. * @param p1
  90590. * @private
  90591. */
  90592. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90593. /**
  90594. * push line into the position, normal and index buffer
  90595. * @protected
  90596. */
  90597. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90598. /**
  90599. * Generates lines edges from adjacencjes
  90600. * @private
  90601. */
  90602. _generateEdgesLines(): void;
  90603. /**
  90604. * Checks wether or not the edges renderer is ready to render.
  90605. * @return true if ready, otherwise false.
  90606. */
  90607. isReady(): boolean;
  90608. /**
  90609. * Renders the edges of the attached mesh,
  90610. */
  90611. render(): void;
  90612. }
  90613. /**
  90614. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90615. */
  90616. export class LineEdgesRenderer extends EdgesRenderer {
  90617. /**
  90618. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90619. * @param source LineMesh used to generate edges
  90620. * @param epsilon not important (specified angle for edge detection)
  90621. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90622. */
  90623. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90624. /**
  90625. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90626. */
  90627. _generateEdgesLines(): void;
  90628. }
  90629. }
  90630. declare module BABYLON {
  90631. /**
  90632. * This represents the object necessary to create a rendering group.
  90633. * This is exclusively used and created by the rendering manager.
  90634. * To modify the behavior, you use the available helpers in your scene or meshes.
  90635. * @hidden
  90636. */
  90637. export class RenderingGroup {
  90638. index: number;
  90639. private static _zeroVector;
  90640. private _scene;
  90641. private _opaqueSubMeshes;
  90642. private _transparentSubMeshes;
  90643. private _alphaTestSubMeshes;
  90644. private _depthOnlySubMeshes;
  90645. private _particleSystems;
  90646. private _spriteManagers;
  90647. private _opaqueSortCompareFn;
  90648. private _alphaTestSortCompareFn;
  90649. private _transparentSortCompareFn;
  90650. private _renderOpaque;
  90651. private _renderAlphaTest;
  90652. private _renderTransparent;
  90653. /** @hidden */
  90654. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90655. onBeforeTransparentRendering: () => void;
  90656. /**
  90657. * Set the opaque sort comparison function.
  90658. * If null the sub meshes will be render in the order they were created
  90659. */
  90660. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90661. /**
  90662. * Set the alpha test sort comparison function.
  90663. * If null the sub meshes will be render in the order they were created
  90664. */
  90665. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90666. /**
  90667. * Set the transparent sort comparison function.
  90668. * If null the sub meshes will be render in the order they were created
  90669. */
  90670. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90671. /**
  90672. * Creates a new rendering group.
  90673. * @param index The rendering group index
  90674. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90675. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90676. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90677. */
  90678. 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>);
  90679. /**
  90680. * Render all the sub meshes contained in the group.
  90681. * @param customRenderFunction Used to override the default render behaviour of the group.
  90682. * @returns true if rendered some submeshes.
  90683. */
  90684. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90685. /**
  90686. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90687. * @param subMeshes The submeshes to render
  90688. */
  90689. private renderOpaqueSorted;
  90690. /**
  90691. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90692. * @param subMeshes The submeshes to render
  90693. */
  90694. private renderAlphaTestSorted;
  90695. /**
  90696. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90697. * @param subMeshes The submeshes to render
  90698. */
  90699. private renderTransparentSorted;
  90700. /**
  90701. * Renders the submeshes in a specified order.
  90702. * @param subMeshes The submeshes to sort before render
  90703. * @param sortCompareFn The comparison function use to sort
  90704. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90705. * @param transparent Specifies to activate blending if true
  90706. */
  90707. private static renderSorted;
  90708. /**
  90709. * Renders the submeshes in the order they were dispatched (no sort applied).
  90710. * @param subMeshes The submeshes to render
  90711. */
  90712. private static renderUnsorted;
  90713. /**
  90714. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90715. * are rendered back to front if in the same alpha index.
  90716. *
  90717. * @param a The first submesh
  90718. * @param b The second submesh
  90719. * @returns The result of the comparison
  90720. */
  90721. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90722. /**
  90723. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90724. * are rendered back to front.
  90725. *
  90726. * @param a The first submesh
  90727. * @param b The second submesh
  90728. * @returns The result of the comparison
  90729. */
  90730. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90731. /**
  90732. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90733. * are rendered front to back (prevent overdraw).
  90734. *
  90735. * @param a The first submesh
  90736. * @param b The second submesh
  90737. * @returns The result of the comparison
  90738. */
  90739. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90740. /**
  90741. * Resets the different lists of submeshes to prepare a new frame.
  90742. */
  90743. prepare(): void;
  90744. dispose(): void;
  90745. /**
  90746. * Inserts the submesh in its correct queue depending on its material.
  90747. * @param subMesh The submesh to dispatch
  90748. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90749. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90750. */
  90751. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90752. dispatchSprites(spriteManager: ISpriteManager): void;
  90753. dispatchParticles(particleSystem: IParticleSystem): void;
  90754. private _renderParticles;
  90755. private _renderSprites;
  90756. }
  90757. }
  90758. declare module BABYLON {
  90759. /**
  90760. * Interface describing the different options available in the rendering manager
  90761. * regarding Auto Clear between groups.
  90762. */
  90763. export interface IRenderingManagerAutoClearSetup {
  90764. /**
  90765. * Defines whether or not autoclear is enable.
  90766. */
  90767. autoClear: boolean;
  90768. /**
  90769. * Defines whether or not to autoclear the depth buffer.
  90770. */
  90771. depth: boolean;
  90772. /**
  90773. * Defines whether or not to autoclear the stencil buffer.
  90774. */
  90775. stencil: boolean;
  90776. }
  90777. /**
  90778. * This class is used by the onRenderingGroupObservable
  90779. */
  90780. export class RenderingGroupInfo {
  90781. /**
  90782. * The Scene that being rendered
  90783. */
  90784. scene: Scene;
  90785. /**
  90786. * The camera currently used for the rendering pass
  90787. */
  90788. camera: Nullable<Camera>;
  90789. /**
  90790. * The ID of the renderingGroup being processed
  90791. */
  90792. renderingGroupId: number;
  90793. }
  90794. /**
  90795. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90796. * It is enable to manage the different groups as well as the different necessary sort functions.
  90797. * This should not be used directly aside of the few static configurations
  90798. */
  90799. export class RenderingManager {
  90800. /**
  90801. * The max id used for rendering groups (not included)
  90802. */
  90803. static MAX_RENDERINGGROUPS: number;
  90804. /**
  90805. * The min id used for rendering groups (included)
  90806. */
  90807. static MIN_RENDERINGGROUPS: number;
  90808. /**
  90809. * Used to globally prevent autoclearing scenes.
  90810. */
  90811. static AUTOCLEAR: boolean;
  90812. /**
  90813. * @hidden
  90814. */
  90815. _useSceneAutoClearSetup: boolean;
  90816. private _scene;
  90817. private _renderingGroups;
  90818. private _depthStencilBufferAlreadyCleaned;
  90819. private _autoClearDepthStencil;
  90820. private _customOpaqueSortCompareFn;
  90821. private _customAlphaTestSortCompareFn;
  90822. private _customTransparentSortCompareFn;
  90823. private _renderingGroupInfo;
  90824. /**
  90825. * Instantiates a new rendering group for a particular scene
  90826. * @param scene Defines the scene the groups belongs to
  90827. */
  90828. constructor(scene: Scene);
  90829. private _clearDepthStencilBuffer;
  90830. /**
  90831. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90832. * @hidden
  90833. */
  90834. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90835. /**
  90836. * Resets the different information of the group to prepare a new frame
  90837. * @hidden
  90838. */
  90839. reset(): void;
  90840. /**
  90841. * Dispose and release the group and its associated resources.
  90842. * @hidden
  90843. */
  90844. dispose(): void;
  90845. /**
  90846. * Clear the info related to rendering groups preventing retention points during dispose.
  90847. */
  90848. freeRenderingGroups(): void;
  90849. private _prepareRenderingGroup;
  90850. /**
  90851. * Add a sprite manager to the rendering manager in order to render it this frame.
  90852. * @param spriteManager Define the sprite manager to render
  90853. */
  90854. dispatchSprites(spriteManager: ISpriteManager): void;
  90855. /**
  90856. * Add a particle system to the rendering manager in order to render it this frame.
  90857. * @param particleSystem Define the particle system to render
  90858. */
  90859. dispatchParticles(particleSystem: IParticleSystem): void;
  90860. /**
  90861. * Add a submesh to the manager in order to render it this frame
  90862. * @param subMesh The submesh to dispatch
  90863. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90864. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90865. */
  90866. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90867. /**
  90868. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90869. * This allowed control for front to back rendering or reversly depending of the special needs.
  90870. *
  90871. * @param renderingGroupId The rendering group id corresponding to its index
  90872. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90873. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90874. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90875. */
  90876. 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;
  90877. /**
  90878. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90879. *
  90880. * @param renderingGroupId The rendering group id corresponding to its index
  90881. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90882. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90883. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90884. */
  90885. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90886. /**
  90887. * Gets the current auto clear configuration for one rendering group of the rendering
  90888. * manager.
  90889. * @param index the rendering group index to get the information for
  90890. * @returns The auto clear setup for the requested rendering group
  90891. */
  90892. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90893. }
  90894. }
  90895. declare module BABYLON {
  90896. /**
  90897. * This Helps creating a texture that will be created from a camera in your scene.
  90898. * It is basically a dynamic texture that could be used to create special effects for instance.
  90899. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  90900. */
  90901. export class RenderTargetTexture extends Texture {
  90902. isCube: boolean;
  90903. /**
  90904. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  90905. */
  90906. static readonly REFRESHRATE_RENDER_ONCE: number;
  90907. /**
  90908. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  90909. */
  90910. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  90911. /**
  90912. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  90913. * the central point of your effect and can save a lot of performances.
  90914. */
  90915. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  90916. /**
  90917. * Use this predicate to dynamically define the list of mesh you want to render.
  90918. * If set, the renderList property will be overwritten.
  90919. */
  90920. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  90921. private _renderList;
  90922. /**
  90923. * Use this list to define the list of mesh you want to render.
  90924. */
  90925. get renderList(): Nullable<Array<AbstractMesh>>;
  90926. set renderList(value: Nullable<Array<AbstractMesh>>);
  90927. private _hookArray;
  90928. /**
  90929. * Define if particles should be rendered in your texture.
  90930. */
  90931. renderParticles: boolean;
  90932. /**
  90933. * Define if sprites should be rendered in your texture.
  90934. */
  90935. renderSprites: boolean;
  90936. /**
  90937. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  90938. */
  90939. coordinatesMode: number;
  90940. /**
  90941. * Define the camera used to render the texture.
  90942. */
  90943. activeCamera: Nullable<Camera>;
  90944. /**
  90945. * Override the render function of the texture with your own one.
  90946. */
  90947. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  90948. /**
  90949. * Define if camera post processes should be use while rendering the texture.
  90950. */
  90951. useCameraPostProcesses: boolean;
  90952. /**
  90953. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  90954. */
  90955. ignoreCameraViewport: boolean;
  90956. private _postProcessManager;
  90957. private _postProcesses;
  90958. private _resizeObserver;
  90959. /**
  90960. * An event triggered when the texture is unbind.
  90961. */
  90962. onBeforeBindObservable: Observable<RenderTargetTexture>;
  90963. /**
  90964. * An event triggered when the texture is unbind.
  90965. */
  90966. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  90967. private _onAfterUnbindObserver;
  90968. /**
  90969. * Set a after unbind callback in the texture.
  90970. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  90971. */
  90972. set onAfterUnbind(callback: () => void);
  90973. /**
  90974. * An event triggered before rendering the texture
  90975. */
  90976. onBeforeRenderObservable: Observable<number>;
  90977. private _onBeforeRenderObserver;
  90978. /**
  90979. * Set a before render callback in the texture.
  90980. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  90981. */
  90982. set onBeforeRender(callback: (faceIndex: number) => void);
  90983. /**
  90984. * An event triggered after rendering the texture
  90985. */
  90986. onAfterRenderObservable: Observable<number>;
  90987. private _onAfterRenderObserver;
  90988. /**
  90989. * Set a after render callback in the texture.
  90990. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  90991. */
  90992. set onAfterRender(callback: (faceIndex: number) => void);
  90993. /**
  90994. * An event triggered after the texture clear
  90995. */
  90996. onClearObservable: Observable<Engine>;
  90997. private _onClearObserver;
  90998. /**
  90999. * Set a clear callback in the texture.
  91000. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  91001. */
  91002. set onClear(callback: (Engine: Engine) => void);
  91003. /**
  91004. * An event triggered when the texture is resized.
  91005. */
  91006. onResizeObservable: Observable<RenderTargetTexture>;
  91007. /**
  91008. * Define the clear color of the Render Target if it should be different from the scene.
  91009. */
  91010. clearColor: Color4;
  91011. protected _size: number | {
  91012. width: number;
  91013. height: number;
  91014. };
  91015. protected _initialSizeParameter: number | {
  91016. width: number;
  91017. height: number;
  91018. } | {
  91019. ratio: number;
  91020. };
  91021. protected _sizeRatio: Nullable<number>;
  91022. /** @hidden */
  91023. _generateMipMaps: boolean;
  91024. protected _renderingManager: RenderingManager;
  91025. /** @hidden */
  91026. _waitingRenderList: string[];
  91027. protected _doNotChangeAspectRatio: boolean;
  91028. protected _currentRefreshId: number;
  91029. protected _refreshRate: number;
  91030. protected _textureMatrix: Matrix;
  91031. protected _samples: number;
  91032. protected _renderTargetOptions: RenderTargetCreationOptions;
  91033. /**
  91034. * Gets render target creation options that were used.
  91035. */
  91036. get renderTargetOptions(): RenderTargetCreationOptions;
  91037. protected _engine: Engine;
  91038. protected _onRatioRescale(): void;
  91039. /**
  91040. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  91041. * It must define where the camera used to render the texture is set
  91042. */
  91043. boundingBoxPosition: Vector3;
  91044. private _boundingBoxSize;
  91045. /**
  91046. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  91047. * When defined, the cubemap will switch to local mode
  91048. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  91049. * @example https://www.babylonjs-playground.com/#RNASML
  91050. */
  91051. set boundingBoxSize(value: Vector3);
  91052. get boundingBoxSize(): Vector3;
  91053. /**
  91054. * In case the RTT has been created with a depth texture, get the associated
  91055. * depth texture.
  91056. * Otherwise, return null.
  91057. */
  91058. depthStencilTexture: Nullable<InternalTexture>;
  91059. /**
  91060. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  91061. * or used a shadow, depth texture...
  91062. * @param name The friendly name of the texture
  91063. * @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)
  91064. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  91065. * @param generateMipMaps True if mip maps need to be generated after render.
  91066. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  91067. * @param type The type of the buffer in the RTT (int, half float, float...)
  91068. * @param isCube True if a cube texture needs to be created
  91069. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  91070. * @param generateDepthBuffer True to generate a depth buffer
  91071. * @param generateStencilBuffer True to generate a stencil buffer
  91072. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  91073. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  91074. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91075. */
  91076. constructor(name: string, size: number | {
  91077. width: number;
  91078. height: number;
  91079. } | {
  91080. ratio: number;
  91081. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  91082. /**
  91083. * Creates a depth stencil texture.
  91084. * This is only available in WebGL 2 or with the depth texture extension available.
  91085. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  91086. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  91087. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  91088. */
  91089. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  91090. private _processSizeParameter;
  91091. /**
  91092. * Define the number of samples to use in case of MSAA.
  91093. * It defaults to one meaning no MSAA has been enabled.
  91094. */
  91095. get samples(): number;
  91096. set samples(value: number);
  91097. /**
  91098. * Resets the refresh counter of the texture and start bak from scratch.
  91099. * Could be useful to regenerate the texture if it is setup to render only once.
  91100. */
  91101. resetRefreshCounter(): void;
  91102. /**
  91103. * Define the refresh rate of the texture or the rendering frequency.
  91104. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91105. */
  91106. get refreshRate(): number;
  91107. set refreshRate(value: number);
  91108. /**
  91109. * Adds a post process to the render target rendering passes.
  91110. * @param postProcess define the post process to add
  91111. */
  91112. addPostProcess(postProcess: PostProcess): void;
  91113. /**
  91114. * Clear all the post processes attached to the render target
  91115. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  91116. */
  91117. clearPostProcesses(dispose?: boolean): void;
  91118. /**
  91119. * Remove one of the post process from the list of attached post processes to the texture
  91120. * @param postProcess define the post process to remove from the list
  91121. */
  91122. removePostProcess(postProcess: PostProcess): void;
  91123. /** @hidden */
  91124. _shouldRender(): boolean;
  91125. /**
  91126. * Gets the actual render size of the texture.
  91127. * @returns the width of the render size
  91128. */
  91129. getRenderSize(): number;
  91130. /**
  91131. * Gets the actual render width of the texture.
  91132. * @returns the width of the render size
  91133. */
  91134. getRenderWidth(): number;
  91135. /**
  91136. * Gets the actual render height of the texture.
  91137. * @returns the height of the render size
  91138. */
  91139. getRenderHeight(): number;
  91140. /**
  91141. * Get if the texture can be rescaled or not.
  91142. */
  91143. get canRescale(): boolean;
  91144. /**
  91145. * Resize the texture using a ratio.
  91146. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  91147. */
  91148. scale(ratio: number): void;
  91149. /**
  91150. * Get the texture reflection matrix used to rotate/transform the reflection.
  91151. * @returns the reflection matrix
  91152. */
  91153. getReflectionTextureMatrix(): Matrix;
  91154. /**
  91155. * Resize the texture to a new desired size.
  91156. * Be carrefull as it will recreate all the data in the new texture.
  91157. * @param size Define the new size. It can be:
  91158. * - a number for squared texture,
  91159. * - an object containing { width: number, height: number }
  91160. * - or an object containing a ratio { ratio: number }
  91161. */
  91162. resize(size: number | {
  91163. width: number;
  91164. height: number;
  91165. } | {
  91166. ratio: number;
  91167. }): void;
  91168. /**
  91169. * Renders all the objects from the render list into the texture.
  91170. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  91171. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  91172. */
  91173. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  91174. private _bestReflectionRenderTargetDimension;
  91175. /**
  91176. * @hidden
  91177. * @param faceIndex face index to bind to if this is a cubetexture
  91178. */
  91179. _bindFrameBuffer(faceIndex?: number): void;
  91180. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  91181. private renderToTarget;
  91182. /**
  91183. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91184. * This allowed control for front to back rendering or reversly depending of the special needs.
  91185. *
  91186. * @param renderingGroupId The rendering group id corresponding to its index
  91187. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91188. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91189. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91190. */
  91191. 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;
  91192. /**
  91193. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91194. *
  91195. * @param renderingGroupId The rendering group id corresponding to its index
  91196. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91197. */
  91198. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  91199. /**
  91200. * Clones the texture.
  91201. * @returns the cloned texture
  91202. */
  91203. clone(): RenderTargetTexture;
  91204. /**
  91205. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  91206. * @returns The JSON representation of the texture
  91207. */
  91208. serialize(): any;
  91209. /**
  91210. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  91211. */
  91212. disposeFramebufferObjects(): void;
  91213. /**
  91214. * Dispose the texture and release its associated resources.
  91215. */
  91216. dispose(): void;
  91217. /** @hidden */
  91218. _rebuild(): void;
  91219. /**
  91220. * Clear the info related to rendering groups preventing retention point in material dispose.
  91221. */
  91222. freeRenderingGroups(): void;
  91223. /**
  91224. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  91225. * @returns the view count
  91226. */
  91227. getViewCount(): number;
  91228. }
  91229. }
  91230. declare module BABYLON {
  91231. /**
  91232. * Options for compiling materials.
  91233. */
  91234. export interface IMaterialCompilationOptions {
  91235. /**
  91236. * Defines whether clip planes are enabled.
  91237. */
  91238. clipPlane: boolean;
  91239. /**
  91240. * Defines whether instances are enabled.
  91241. */
  91242. useInstances: boolean;
  91243. }
  91244. /**
  91245. * Base class for the main features of a material in Babylon.js
  91246. */
  91247. export class Material implements IAnimatable {
  91248. /**
  91249. * Returns the triangle fill mode
  91250. */
  91251. static readonly TriangleFillMode: number;
  91252. /**
  91253. * Returns the wireframe mode
  91254. */
  91255. static readonly WireFrameFillMode: number;
  91256. /**
  91257. * Returns the point fill mode
  91258. */
  91259. static readonly PointFillMode: number;
  91260. /**
  91261. * Returns the point list draw mode
  91262. */
  91263. static readonly PointListDrawMode: number;
  91264. /**
  91265. * Returns the line list draw mode
  91266. */
  91267. static readonly LineListDrawMode: number;
  91268. /**
  91269. * Returns the line loop draw mode
  91270. */
  91271. static readonly LineLoopDrawMode: number;
  91272. /**
  91273. * Returns the line strip draw mode
  91274. */
  91275. static readonly LineStripDrawMode: number;
  91276. /**
  91277. * Returns the triangle strip draw mode
  91278. */
  91279. static readonly TriangleStripDrawMode: number;
  91280. /**
  91281. * Returns the triangle fan draw mode
  91282. */
  91283. static readonly TriangleFanDrawMode: number;
  91284. /**
  91285. * Stores the clock-wise side orientation
  91286. */
  91287. static readonly ClockWiseSideOrientation: number;
  91288. /**
  91289. * Stores the counter clock-wise side orientation
  91290. */
  91291. static readonly CounterClockWiseSideOrientation: number;
  91292. /**
  91293. * The dirty texture flag value
  91294. */
  91295. static readonly TextureDirtyFlag: number;
  91296. /**
  91297. * The dirty light flag value
  91298. */
  91299. static readonly LightDirtyFlag: number;
  91300. /**
  91301. * The dirty fresnel flag value
  91302. */
  91303. static readonly FresnelDirtyFlag: number;
  91304. /**
  91305. * The dirty attribute flag value
  91306. */
  91307. static readonly AttributesDirtyFlag: number;
  91308. /**
  91309. * The dirty misc flag value
  91310. */
  91311. static readonly MiscDirtyFlag: number;
  91312. /**
  91313. * The all dirty flag value
  91314. */
  91315. static readonly AllDirtyFlag: number;
  91316. /**
  91317. * The ID of the material
  91318. */
  91319. id: string;
  91320. /**
  91321. * Gets or sets the unique id of the material
  91322. */
  91323. uniqueId: number;
  91324. /**
  91325. * The name of the material
  91326. */
  91327. name: string;
  91328. /**
  91329. * Gets or sets user defined metadata
  91330. */
  91331. metadata: any;
  91332. /**
  91333. * For internal use only. Please do not use.
  91334. */
  91335. reservedDataStore: any;
  91336. /**
  91337. * Specifies if the ready state should be checked on each call
  91338. */
  91339. checkReadyOnEveryCall: boolean;
  91340. /**
  91341. * Specifies if the ready state should be checked once
  91342. */
  91343. checkReadyOnlyOnce: boolean;
  91344. /**
  91345. * The state of the material
  91346. */
  91347. state: string;
  91348. /**
  91349. * The alpha value of the material
  91350. */
  91351. protected _alpha: number;
  91352. /**
  91353. * List of inspectable custom properties (used by the Inspector)
  91354. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91355. */
  91356. inspectableCustomProperties: IInspectable[];
  91357. /**
  91358. * Sets the alpha value of the material
  91359. */
  91360. set alpha(value: number);
  91361. /**
  91362. * Gets the alpha value of the material
  91363. */
  91364. get alpha(): number;
  91365. /**
  91366. * Specifies if back face culling is enabled
  91367. */
  91368. protected _backFaceCulling: boolean;
  91369. /**
  91370. * Sets the back-face culling state
  91371. */
  91372. set backFaceCulling(value: boolean);
  91373. /**
  91374. * Gets the back-face culling state
  91375. */
  91376. get backFaceCulling(): boolean;
  91377. /**
  91378. * Stores the value for side orientation
  91379. */
  91380. sideOrientation: number;
  91381. /**
  91382. * Callback triggered when the material is compiled
  91383. */
  91384. onCompiled: Nullable<(effect: Effect) => void>;
  91385. /**
  91386. * Callback triggered when an error occurs
  91387. */
  91388. onError: Nullable<(effect: Effect, errors: string) => void>;
  91389. /**
  91390. * Callback triggered to get the render target textures
  91391. */
  91392. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  91393. /**
  91394. * Gets a boolean indicating that current material needs to register RTT
  91395. */
  91396. get hasRenderTargetTextures(): boolean;
  91397. /**
  91398. * Specifies if the material should be serialized
  91399. */
  91400. doNotSerialize: boolean;
  91401. /**
  91402. * @hidden
  91403. */
  91404. _storeEffectOnSubMeshes: boolean;
  91405. /**
  91406. * Stores the animations for the material
  91407. */
  91408. animations: Nullable<Array<Animation>>;
  91409. /**
  91410. * An event triggered when the material is disposed
  91411. */
  91412. onDisposeObservable: Observable<Material>;
  91413. /**
  91414. * An observer which watches for dispose events
  91415. */
  91416. private _onDisposeObserver;
  91417. private _onUnBindObservable;
  91418. /**
  91419. * Called during a dispose event
  91420. */
  91421. set onDispose(callback: () => void);
  91422. private _onBindObservable;
  91423. /**
  91424. * An event triggered when the material is bound
  91425. */
  91426. get onBindObservable(): Observable<AbstractMesh>;
  91427. /**
  91428. * An observer which watches for bind events
  91429. */
  91430. private _onBindObserver;
  91431. /**
  91432. * Called during a bind event
  91433. */
  91434. set onBind(callback: (Mesh: AbstractMesh) => void);
  91435. /**
  91436. * An event triggered when the material is unbound
  91437. */
  91438. get onUnBindObservable(): Observable<Material>;
  91439. /**
  91440. * Stores the value of the alpha mode
  91441. */
  91442. private _alphaMode;
  91443. /**
  91444. * Sets the value of the alpha mode.
  91445. *
  91446. * | Value | Type | Description |
  91447. * | --- | --- | --- |
  91448. * | 0 | ALPHA_DISABLE | |
  91449. * | 1 | ALPHA_ADD | |
  91450. * | 2 | ALPHA_COMBINE | |
  91451. * | 3 | ALPHA_SUBTRACT | |
  91452. * | 4 | ALPHA_MULTIPLY | |
  91453. * | 5 | ALPHA_MAXIMIZED | |
  91454. * | 6 | ALPHA_ONEONE | |
  91455. * | 7 | ALPHA_PREMULTIPLIED | |
  91456. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  91457. * | 9 | ALPHA_INTERPOLATE | |
  91458. * | 10 | ALPHA_SCREENMODE | |
  91459. *
  91460. */
  91461. set alphaMode(value: number);
  91462. /**
  91463. * Gets the value of the alpha mode
  91464. */
  91465. get alphaMode(): number;
  91466. /**
  91467. * Stores the state of the need depth pre-pass value
  91468. */
  91469. private _needDepthPrePass;
  91470. /**
  91471. * Sets the need depth pre-pass value
  91472. */
  91473. set needDepthPrePass(value: boolean);
  91474. /**
  91475. * Gets the depth pre-pass value
  91476. */
  91477. get needDepthPrePass(): boolean;
  91478. /**
  91479. * Specifies if depth writing should be disabled
  91480. */
  91481. disableDepthWrite: boolean;
  91482. /**
  91483. * Specifies if depth writing should be forced
  91484. */
  91485. forceDepthWrite: boolean;
  91486. /**
  91487. * Specifies the depth function that should be used. 0 means the default engine function
  91488. */
  91489. depthFunction: number;
  91490. /**
  91491. * Specifies if there should be a separate pass for culling
  91492. */
  91493. separateCullingPass: boolean;
  91494. /**
  91495. * Stores the state specifing if fog should be enabled
  91496. */
  91497. private _fogEnabled;
  91498. /**
  91499. * Sets the state for enabling fog
  91500. */
  91501. set fogEnabled(value: boolean);
  91502. /**
  91503. * Gets the value of the fog enabled state
  91504. */
  91505. get fogEnabled(): boolean;
  91506. /**
  91507. * Stores the size of points
  91508. */
  91509. pointSize: number;
  91510. /**
  91511. * Stores the z offset value
  91512. */
  91513. zOffset: number;
  91514. /**
  91515. * Gets a value specifying if wireframe mode is enabled
  91516. */
  91517. get wireframe(): boolean;
  91518. /**
  91519. * Sets the state of wireframe mode
  91520. */
  91521. set wireframe(value: boolean);
  91522. /**
  91523. * Gets the value specifying if point clouds are enabled
  91524. */
  91525. get pointsCloud(): boolean;
  91526. /**
  91527. * Sets the state of point cloud mode
  91528. */
  91529. set pointsCloud(value: boolean);
  91530. /**
  91531. * Gets the material fill mode
  91532. */
  91533. get fillMode(): number;
  91534. /**
  91535. * Sets the material fill mode
  91536. */
  91537. set fillMode(value: number);
  91538. /**
  91539. * @hidden
  91540. * Stores the effects for the material
  91541. */
  91542. _effect: Nullable<Effect>;
  91543. /**
  91544. * Specifies if uniform buffers should be used
  91545. */
  91546. private _useUBO;
  91547. /**
  91548. * Stores a reference to the scene
  91549. */
  91550. private _scene;
  91551. /**
  91552. * Stores the fill mode state
  91553. */
  91554. private _fillMode;
  91555. /**
  91556. * Specifies if the depth write state should be cached
  91557. */
  91558. private _cachedDepthWriteState;
  91559. /**
  91560. * Specifies if the depth function state should be cached
  91561. */
  91562. private _cachedDepthFunctionState;
  91563. /**
  91564. * Stores the uniform buffer
  91565. */
  91566. protected _uniformBuffer: UniformBuffer;
  91567. /** @hidden */
  91568. _indexInSceneMaterialArray: number;
  91569. /** @hidden */
  91570. meshMap: Nullable<{
  91571. [id: string]: AbstractMesh | undefined;
  91572. }>;
  91573. /**
  91574. * Creates a material instance
  91575. * @param name defines the name of the material
  91576. * @param scene defines the scene to reference
  91577. * @param doNotAdd specifies if the material should be added to the scene
  91578. */
  91579. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  91580. /**
  91581. * Returns a string representation of the current material
  91582. * @param fullDetails defines a boolean indicating which levels of logging is desired
  91583. * @returns a string with material information
  91584. */
  91585. toString(fullDetails?: boolean): string;
  91586. /**
  91587. * Gets the class name of the material
  91588. * @returns a string with the class name of the material
  91589. */
  91590. getClassName(): string;
  91591. /**
  91592. * Specifies if updates for the material been locked
  91593. */
  91594. get isFrozen(): boolean;
  91595. /**
  91596. * Locks updates for the material
  91597. */
  91598. freeze(): void;
  91599. /**
  91600. * Unlocks updates for the material
  91601. */
  91602. unfreeze(): void;
  91603. /**
  91604. * Specifies if the material is ready to be used
  91605. * @param mesh defines the mesh to check
  91606. * @param useInstances specifies if instances should be used
  91607. * @returns a boolean indicating if the material is ready to be used
  91608. */
  91609. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91610. /**
  91611. * Specifies that the submesh is ready to be used
  91612. * @param mesh defines the mesh to check
  91613. * @param subMesh defines which submesh to check
  91614. * @param useInstances specifies that instances should be used
  91615. * @returns a boolean indicating that the submesh is ready or not
  91616. */
  91617. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91618. /**
  91619. * Returns the material effect
  91620. * @returns the effect associated with the material
  91621. */
  91622. getEffect(): Nullable<Effect>;
  91623. /**
  91624. * Returns the current scene
  91625. * @returns a Scene
  91626. */
  91627. getScene(): Scene;
  91628. /**
  91629. * Specifies if the material will require alpha blending
  91630. * @returns a boolean specifying if alpha blending is needed
  91631. */
  91632. needAlphaBlending(): boolean;
  91633. /**
  91634. * Specifies if the mesh will require alpha blending
  91635. * @param mesh defines the mesh to check
  91636. * @returns a boolean specifying if alpha blending is needed for the mesh
  91637. */
  91638. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  91639. /**
  91640. * Specifies if this material should be rendered in alpha test mode
  91641. * @returns a boolean specifying if an alpha test is needed.
  91642. */
  91643. needAlphaTesting(): boolean;
  91644. /**
  91645. * Gets the texture used for the alpha test
  91646. * @returns the texture to use for alpha testing
  91647. */
  91648. getAlphaTestTexture(): Nullable<BaseTexture>;
  91649. /**
  91650. * Marks the material to indicate that it needs to be re-calculated
  91651. */
  91652. markDirty(): void;
  91653. /** @hidden */
  91654. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  91655. /**
  91656. * Binds the material to the mesh
  91657. * @param world defines the world transformation matrix
  91658. * @param mesh defines the mesh to bind the material to
  91659. */
  91660. bind(world: Matrix, mesh?: Mesh): void;
  91661. /**
  91662. * Binds the submesh to the material
  91663. * @param world defines the world transformation matrix
  91664. * @param mesh defines the mesh containing the submesh
  91665. * @param subMesh defines the submesh to bind the material to
  91666. */
  91667. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91668. /**
  91669. * Binds the world matrix to the material
  91670. * @param world defines the world transformation matrix
  91671. */
  91672. bindOnlyWorldMatrix(world: Matrix): void;
  91673. /**
  91674. * Binds the scene's uniform buffer to the effect.
  91675. * @param effect defines the effect to bind to the scene uniform buffer
  91676. * @param sceneUbo defines the uniform buffer storing scene data
  91677. */
  91678. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  91679. /**
  91680. * Binds the view matrix to the effect
  91681. * @param effect defines the effect to bind the view matrix to
  91682. */
  91683. bindView(effect: Effect): void;
  91684. /**
  91685. * Binds the view projection matrix to the effect
  91686. * @param effect defines the effect to bind the view projection matrix to
  91687. */
  91688. bindViewProjection(effect: Effect): void;
  91689. /**
  91690. * Specifies if material alpha testing should be turned on for the mesh
  91691. * @param mesh defines the mesh to check
  91692. */
  91693. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  91694. /**
  91695. * Processes to execute after binding the material to a mesh
  91696. * @param mesh defines the rendered mesh
  91697. */
  91698. protected _afterBind(mesh?: Mesh): void;
  91699. /**
  91700. * Unbinds the material from the mesh
  91701. */
  91702. unbind(): void;
  91703. /**
  91704. * Gets the active textures from the material
  91705. * @returns an array of textures
  91706. */
  91707. getActiveTextures(): BaseTexture[];
  91708. /**
  91709. * Specifies if the material uses a texture
  91710. * @param texture defines the texture to check against the material
  91711. * @returns a boolean specifying if the material uses the texture
  91712. */
  91713. hasTexture(texture: BaseTexture): boolean;
  91714. /**
  91715. * Makes a duplicate of the material, and gives it a new name
  91716. * @param name defines the new name for the duplicated material
  91717. * @returns the cloned material
  91718. */
  91719. clone(name: string): Nullable<Material>;
  91720. /**
  91721. * Gets the meshes bound to the material
  91722. * @returns an array of meshes bound to the material
  91723. */
  91724. getBindedMeshes(): AbstractMesh[];
  91725. /**
  91726. * Force shader compilation
  91727. * @param mesh defines the mesh associated with this material
  91728. * @param onCompiled defines a function to execute once the material is compiled
  91729. * @param options defines the options to configure the compilation
  91730. * @param onError defines a function to execute if the material fails compiling
  91731. */
  91732. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  91733. /**
  91734. * Force shader compilation
  91735. * @param mesh defines the mesh that will use this material
  91736. * @param options defines additional options for compiling the shaders
  91737. * @returns a promise that resolves when the compilation completes
  91738. */
  91739. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  91740. private static readonly _AllDirtyCallBack;
  91741. private static readonly _ImageProcessingDirtyCallBack;
  91742. private static readonly _TextureDirtyCallBack;
  91743. private static readonly _FresnelDirtyCallBack;
  91744. private static readonly _MiscDirtyCallBack;
  91745. private static readonly _LightsDirtyCallBack;
  91746. private static readonly _AttributeDirtyCallBack;
  91747. private static _FresnelAndMiscDirtyCallBack;
  91748. private static _TextureAndMiscDirtyCallBack;
  91749. private static readonly _DirtyCallbackArray;
  91750. private static readonly _RunDirtyCallBacks;
  91751. /**
  91752. * Marks a define in the material to indicate that it needs to be re-computed
  91753. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  91754. */
  91755. markAsDirty(flag: number): void;
  91756. /**
  91757. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  91758. * @param func defines a function which checks material defines against the submeshes
  91759. */
  91760. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  91761. /**
  91762. * Indicates that we need to re-calculated for all submeshes
  91763. */
  91764. protected _markAllSubMeshesAsAllDirty(): void;
  91765. /**
  91766. * Indicates that image processing needs to be re-calculated for all submeshes
  91767. */
  91768. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  91769. /**
  91770. * Indicates that textures need to be re-calculated for all submeshes
  91771. */
  91772. protected _markAllSubMeshesAsTexturesDirty(): void;
  91773. /**
  91774. * Indicates that fresnel needs to be re-calculated for all submeshes
  91775. */
  91776. protected _markAllSubMeshesAsFresnelDirty(): void;
  91777. /**
  91778. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  91779. */
  91780. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  91781. /**
  91782. * Indicates that lights need to be re-calculated for all submeshes
  91783. */
  91784. protected _markAllSubMeshesAsLightsDirty(): void;
  91785. /**
  91786. * Indicates that attributes need to be re-calculated for all submeshes
  91787. */
  91788. protected _markAllSubMeshesAsAttributesDirty(): void;
  91789. /**
  91790. * Indicates that misc needs to be re-calculated for all submeshes
  91791. */
  91792. protected _markAllSubMeshesAsMiscDirty(): void;
  91793. /**
  91794. * Indicates that textures and misc need to be re-calculated for all submeshes
  91795. */
  91796. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  91797. /**
  91798. * Disposes the material
  91799. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91800. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91801. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91802. */
  91803. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91804. /** @hidden */
  91805. private releaseVertexArrayObject;
  91806. /**
  91807. * Serializes this material
  91808. * @returns the serialized material object
  91809. */
  91810. serialize(): any;
  91811. /**
  91812. * Creates a material from parsed material data
  91813. * @param parsedMaterial defines parsed material data
  91814. * @param scene defines the hosting scene
  91815. * @param rootUrl defines the root URL to use to load textures
  91816. * @returns a new material
  91817. */
  91818. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  91819. }
  91820. }
  91821. declare module BABYLON {
  91822. /**
  91823. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91824. * separate meshes. This can be use to improve performances.
  91825. * @see http://doc.babylonjs.com/how_to/multi_materials
  91826. */
  91827. export class MultiMaterial extends Material {
  91828. private _subMaterials;
  91829. /**
  91830. * Gets or Sets the list of Materials used within the multi material.
  91831. * They need to be ordered according to the submeshes order in the associated mesh
  91832. */
  91833. get subMaterials(): Nullable<Material>[];
  91834. set subMaterials(value: Nullable<Material>[]);
  91835. /**
  91836. * Function used to align with Node.getChildren()
  91837. * @returns the list of Materials used within the multi material
  91838. */
  91839. getChildren(): Nullable<Material>[];
  91840. /**
  91841. * Instantiates a new Multi Material
  91842. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91843. * separate meshes. This can be use to improve performances.
  91844. * @see http://doc.babylonjs.com/how_to/multi_materials
  91845. * @param name Define the name in the scene
  91846. * @param scene Define the scene the material belongs to
  91847. */
  91848. constructor(name: string, scene: Scene);
  91849. private _hookArray;
  91850. /**
  91851. * Get one of the submaterial by its index in the submaterials array
  91852. * @param index The index to look the sub material at
  91853. * @returns The Material if the index has been defined
  91854. */
  91855. getSubMaterial(index: number): Nullable<Material>;
  91856. /**
  91857. * Get the list of active textures for the whole sub materials list.
  91858. * @returns All the textures that will be used during the rendering
  91859. */
  91860. getActiveTextures(): BaseTexture[];
  91861. /**
  91862. * Gets the current class name of the material e.g. "MultiMaterial"
  91863. * Mainly use in serialization.
  91864. * @returns the class name
  91865. */
  91866. getClassName(): string;
  91867. /**
  91868. * Checks if the material is ready to render the requested sub mesh
  91869. * @param mesh Define the mesh the submesh belongs to
  91870. * @param subMesh Define the sub mesh to look readyness for
  91871. * @param useInstances Define whether or not the material is used with instances
  91872. * @returns true if ready, otherwise false
  91873. */
  91874. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91875. /**
  91876. * Clones the current material and its related sub materials
  91877. * @param name Define the name of the newly cloned material
  91878. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  91879. * @returns the cloned material
  91880. */
  91881. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  91882. /**
  91883. * Serializes the materials into a JSON representation.
  91884. * @returns the JSON representation
  91885. */
  91886. serialize(): any;
  91887. /**
  91888. * Dispose the material and release its associated resources
  91889. * @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)
  91890. * @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)
  91891. * @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)
  91892. */
  91893. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  91894. /**
  91895. * Creates a MultiMaterial from parsed MultiMaterial data.
  91896. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  91897. * @param scene defines the hosting scene
  91898. * @returns a new MultiMaterial
  91899. */
  91900. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  91901. }
  91902. }
  91903. declare module BABYLON {
  91904. /**
  91905. * Base class for submeshes
  91906. */
  91907. export class BaseSubMesh {
  91908. /** @hidden */
  91909. _materialDefines: Nullable<MaterialDefines>;
  91910. /** @hidden */
  91911. _materialEffect: Nullable<Effect>;
  91912. /**
  91913. * Gets material defines used by the effect associated to the sub mesh
  91914. */
  91915. get materialDefines(): Nullable<MaterialDefines>;
  91916. /**
  91917. * Sets material defines used by the effect associated to the sub mesh
  91918. */
  91919. set materialDefines(defines: Nullable<MaterialDefines>);
  91920. /**
  91921. * Gets associated effect
  91922. */
  91923. get effect(): Nullable<Effect>;
  91924. /**
  91925. * Sets associated effect (effect used to render this submesh)
  91926. * @param effect defines the effect to associate with
  91927. * @param defines defines the set of defines used to compile this effect
  91928. */
  91929. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  91930. }
  91931. /**
  91932. * Defines a subdivision inside a mesh
  91933. */
  91934. export class SubMesh extends BaseSubMesh implements ICullable {
  91935. /** the material index to use */
  91936. materialIndex: number;
  91937. /** vertex index start */
  91938. verticesStart: number;
  91939. /** vertices count */
  91940. verticesCount: number;
  91941. /** index start */
  91942. indexStart: number;
  91943. /** indices count */
  91944. indexCount: number;
  91945. /** @hidden */
  91946. _linesIndexCount: number;
  91947. private _mesh;
  91948. private _renderingMesh;
  91949. private _boundingInfo;
  91950. private _linesIndexBuffer;
  91951. /** @hidden */
  91952. _lastColliderWorldVertices: Nullable<Vector3[]>;
  91953. /** @hidden */
  91954. _trianglePlanes: Plane[];
  91955. /** @hidden */
  91956. _lastColliderTransformMatrix: Nullable<Matrix>;
  91957. /** @hidden */
  91958. _renderId: number;
  91959. /** @hidden */
  91960. _alphaIndex: number;
  91961. /** @hidden */
  91962. _distanceToCamera: number;
  91963. /** @hidden */
  91964. _id: number;
  91965. private _currentMaterial;
  91966. /**
  91967. * Add a new submesh to a mesh
  91968. * @param materialIndex defines the material index to use
  91969. * @param verticesStart defines vertex index start
  91970. * @param verticesCount defines vertices count
  91971. * @param indexStart defines index start
  91972. * @param indexCount defines indices count
  91973. * @param mesh defines the parent mesh
  91974. * @param renderingMesh defines an optional rendering mesh
  91975. * @param createBoundingBox defines if bounding box should be created for this submesh
  91976. * @returns the new submesh
  91977. */
  91978. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  91979. /**
  91980. * Creates a new submesh
  91981. * @param materialIndex defines the material index to use
  91982. * @param verticesStart defines vertex index start
  91983. * @param verticesCount defines vertices count
  91984. * @param indexStart defines index start
  91985. * @param indexCount defines indices count
  91986. * @param mesh defines the parent mesh
  91987. * @param renderingMesh defines an optional rendering mesh
  91988. * @param createBoundingBox defines if bounding box should be created for this submesh
  91989. */
  91990. constructor(
  91991. /** the material index to use */
  91992. materialIndex: number,
  91993. /** vertex index start */
  91994. verticesStart: number,
  91995. /** vertices count */
  91996. verticesCount: number,
  91997. /** index start */
  91998. indexStart: number,
  91999. /** indices count */
  92000. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  92001. /**
  92002. * Returns true if this submesh covers the entire parent mesh
  92003. * @ignorenaming
  92004. */
  92005. get IsGlobal(): boolean;
  92006. /**
  92007. * Returns the submesh BoudingInfo object
  92008. * @returns current bounding info (or mesh's one if the submesh is global)
  92009. */
  92010. getBoundingInfo(): BoundingInfo;
  92011. /**
  92012. * Sets the submesh BoundingInfo
  92013. * @param boundingInfo defines the new bounding info to use
  92014. * @returns the SubMesh
  92015. */
  92016. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  92017. /**
  92018. * Returns the mesh of the current submesh
  92019. * @return the parent mesh
  92020. */
  92021. getMesh(): AbstractMesh;
  92022. /**
  92023. * Returns the rendering mesh of the submesh
  92024. * @returns the rendering mesh (could be different from parent mesh)
  92025. */
  92026. getRenderingMesh(): Mesh;
  92027. /**
  92028. * Returns the submesh material
  92029. * @returns null or the current material
  92030. */
  92031. getMaterial(): Nullable<Material>;
  92032. /**
  92033. * Sets a new updated BoundingInfo object to the submesh
  92034. * @param data defines an optional position array to use to determine the bounding info
  92035. * @returns the SubMesh
  92036. */
  92037. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  92038. /** @hidden */
  92039. _checkCollision(collider: Collider): boolean;
  92040. /**
  92041. * Updates the submesh BoundingInfo
  92042. * @param world defines the world matrix to use to update the bounding info
  92043. * @returns the submesh
  92044. */
  92045. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  92046. /**
  92047. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  92048. * @param frustumPlanes defines the frustum planes
  92049. * @returns true if the submesh is intersecting with the frustum
  92050. */
  92051. isInFrustum(frustumPlanes: Plane[]): boolean;
  92052. /**
  92053. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  92054. * @param frustumPlanes defines the frustum planes
  92055. * @returns true if the submesh is inside the frustum
  92056. */
  92057. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92058. /**
  92059. * Renders the submesh
  92060. * @param enableAlphaMode defines if alpha needs to be used
  92061. * @returns the submesh
  92062. */
  92063. render(enableAlphaMode: boolean): SubMesh;
  92064. /**
  92065. * @hidden
  92066. */
  92067. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  92068. /**
  92069. * Checks if the submesh intersects with a ray
  92070. * @param ray defines the ray to test
  92071. * @returns true is the passed ray intersects the submesh bounding box
  92072. */
  92073. canIntersects(ray: Ray): boolean;
  92074. /**
  92075. * Intersects current submesh with a ray
  92076. * @param ray defines the ray to test
  92077. * @param positions defines mesh's positions array
  92078. * @param indices defines mesh's indices array
  92079. * @param fastCheck defines if only bounding info should be used
  92080. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92081. * @returns intersection info or null if no intersection
  92082. */
  92083. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  92084. /** @hidden */
  92085. private _intersectLines;
  92086. /** @hidden */
  92087. private _intersectUnIndexedLines;
  92088. /** @hidden */
  92089. private _intersectTriangles;
  92090. /** @hidden */
  92091. private _intersectUnIndexedTriangles;
  92092. /** @hidden */
  92093. _rebuild(): void;
  92094. /**
  92095. * Creates a new submesh from the passed mesh
  92096. * @param newMesh defines the new hosting mesh
  92097. * @param newRenderingMesh defines an optional rendering mesh
  92098. * @returns the new submesh
  92099. */
  92100. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  92101. /**
  92102. * Release associated resources
  92103. */
  92104. dispose(): void;
  92105. /**
  92106. * Gets the class name
  92107. * @returns the string "SubMesh".
  92108. */
  92109. getClassName(): string;
  92110. /**
  92111. * Creates a new submesh from indices data
  92112. * @param materialIndex the index of the main mesh material
  92113. * @param startIndex the index where to start the copy in the mesh indices array
  92114. * @param indexCount the number of indices to copy then from the startIndex
  92115. * @param mesh the main mesh to create the submesh from
  92116. * @param renderingMesh the optional rendering mesh
  92117. * @returns a new submesh
  92118. */
  92119. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  92120. }
  92121. }
  92122. declare module BABYLON {
  92123. /**
  92124. * Class used to represent data loading progression
  92125. */
  92126. export class SceneLoaderFlags {
  92127. private static _ForceFullSceneLoadingForIncremental;
  92128. private static _ShowLoadingScreen;
  92129. private static _CleanBoneMatrixWeights;
  92130. private static _loggingLevel;
  92131. /**
  92132. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  92133. */
  92134. static get ForceFullSceneLoadingForIncremental(): boolean;
  92135. static set ForceFullSceneLoadingForIncremental(value: boolean);
  92136. /**
  92137. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  92138. */
  92139. static get ShowLoadingScreen(): boolean;
  92140. static set ShowLoadingScreen(value: boolean);
  92141. /**
  92142. * Defines the current logging level (while loading the scene)
  92143. * @ignorenaming
  92144. */
  92145. static get loggingLevel(): number;
  92146. static set loggingLevel(value: number);
  92147. /**
  92148. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  92149. */
  92150. static get CleanBoneMatrixWeights(): boolean;
  92151. static set CleanBoneMatrixWeights(value: boolean);
  92152. }
  92153. }
  92154. declare module BABYLON {
  92155. /**
  92156. * Class used to store geometry data (vertex buffers + index buffer)
  92157. */
  92158. export class Geometry implements IGetSetVerticesData {
  92159. /**
  92160. * Gets or sets the ID of the geometry
  92161. */
  92162. id: string;
  92163. /**
  92164. * Gets or sets the unique ID of the geometry
  92165. */
  92166. uniqueId: number;
  92167. /**
  92168. * Gets the delay loading state of the geometry (none by default which means not delayed)
  92169. */
  92170. delayLoadState: number;
  92171. /**
  92172. * Gets the file containing the data to load when running in delay load state
  92173. */
  92174. delayLoadingFile: Nullable<string>;
  92175. /**
  92176. * Callback called when the geometry is updated
  92177. */
  92178. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  92179. private _scene;
  92180. private _engine;
  92181. private _meshes;
  92182. private _totalVertices;
  92183. /** @hidden */
  92184. _indices: IndicesArray;
  92185. /** @hidden */
  92186. _vertexBuffers: {
  92187. [key: string]: VertexBuffer;
  92188. };
  92189. private _isDisposed;
  92190. private _extend;
  92191. private _boundingBias;
  92192. /** @hidden */
  92193. _delayInfo: Array<string>;
  92194. private _indexBuffer;
  92195. private _indexBufferIsUpdatable;
  92196. /** @hidden */
  92197. _boundingInfo: Nullable<BoundingInfo>;
  92198. /** @hidden */
  92199. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  92200. /** @hidden */
  92201. _softwareSkinningFrameId: number;
  92202. private _vertexArrayObjects;
  92203. private _updatable;
  92204. /** @hidden */
  92205. _positions: Nullable<Vector3[]>;
  92206. /**
  92207. * 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
  92208. */
  92209. get boundingBias(): Vector2;
  92210. /**
  92211. * 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
  92212. */
  92213. set boundingBias(value: Vector2);
  92214. /**
  92215. * Static function used to attach a new empty geometry to a mesh
  92216. * @param mesh defines the mesh to attach the geometry to
  92217. * @returns the new Geometry
  92218. */
  92219. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  92220. /**
  92221. * Creates a new geometry
  92222. * @param id defines the unique ID
  92223. * @param scene defines the hosting scene
  92224. * @param vertexData defines the VertexData used to get geometry data
  92225. * @param updatable defines if geometry must be updatable (false by default)
  92226. * @param mesh defines the mesh that will be associated with the geometry
  92227. */
  92228. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  92229. /**
  92230. * Gets the current extend of the geometry
  92231. */
  92232. get extend(): {
  92233. minimum: Vector3;
  92234. maximum: Vector3;
  92235. };
  92236. /**
  92237. * Gets the hosting scene
  92238. * @returns the hosting Scene
  92239. */
  92240. getScene(): Scene;
  92241. /**
  92242. * Gets the hosting engine
  92243. * @returns the hosting Engine
  92244. */
  92245. getEngine(): Engine;
  92246. /**
  92247. * Defines if the geometry is ready to use
  92248. * @returns true if the geometry is ready to be used
  92249. */
  92250. isReady(): boolean;
  92251. /**
  92252. * Gets a value indicating that the geometry should not be serialized
  92253. */
  92254. get doNotSerialize(): boolean;
  92255. /** @hidden */
  92256. _rebuild(): void;
  92257. /**
  92258. * Affects all geometry data in one call
  92259. * @param vertexData defines the geometry data
  92260. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  92261. */
  92262. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  92263. /**
  92264. * Set specific vertex data
  92265. * @param kind defines the data kind (Position, normal, etc...)
  92266. * @param data defines the vertex data to use
  92267. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92268. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92269. */
  92270. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  92271. /**
  92272. * Removes a specific vertex data
  92273. * @param kind defines the data kind (Position, normal, etc...)
  92274. */
  92275. removeVerticesData(kind: string): void;
  92276. /**
  92277. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  92278. * @param buffer defines the vertex buffer to use
  92279. * @param totalVertices defines the total number of vertices for position kind (could be null)
  92280. */
  92281. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  92282. /**
  92283. * Update a specific vertex buffer
  92284. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  92285. * It will do nothing if the buffer is not updatable
  92286. * @param kind defines the data kind (Position, normal, etc...)
  92287. * @param data defines the data to use
  92288. * @param offset defines the offset in the target buffer where to store the data
  92289. * @param useBytes set to true if the offset is in bytes
  92290. */
  92291. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  92292. /**
  92293. * Update a specific vertex buffer
  92294. * This function will create a new buffer if the current one is not updatable
  92295. * @param kind defines the data kind (Position, normal, etc...)
  92296. * @param data defines the data to use
  92297. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  92298. */
  92299. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  92300. private _updateBoundingInfo;
  92301. /** @hidden */
  92302. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  92303. /**
  92304. * Gets total number of vertices
  92305. * @returns the total number of vertices
  92306. */
  92307. getTotalVertices(): number;
  92308. /**
  92309. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92310. * @param kind defines the data kind (Position, normal, etc...)
  92311. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92312. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92313. * @returns a float array containing vertex data
  92314. */
  92315. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92316. /**
  92317. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  92318. * @param kind defines the data kind (Position, normal, etc...)
  92319. * @returns true if the vertex buffer with the specified kind is updatable
  92320. */
  92321. isVertexBufferUpdatable(kind: string): boolean;
  92322. /**
  92323. * Gets a specific vertex buffer
  92324. * @param kind defines the data kind (Position, normal, etc...)
  92325. * @returns a VertexBuffer
  92326. */
  92327. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92328. /**
  92329. * Returns all vertex buffers
  92330. * @return an object holding all vertex buffers indexed by kind
  92331. */
  92332. getVertexBuffers(): Nullable<{
  92333. [key: string]: VertexBuffer;
  92334. }>;
  92335. /**
  92336. * Gets a boolean indicating if specific vertex buffer is present
  92337. * @param kind defines the data kind (Position, normal, etc...)
  92338. * @returns true if data is present
  92339. */
  92340. isVerticesDataPresent(kind: string): boolean;
  92341. /**
  92342. * Gets a list of all attached data kinds (Position, normal, etc...)
  92343. * @returns a list of string containing all kinds
  92344. */
  92345. getVerticesDataKinds(): string[];
  92346. /**
  92347. * Update index buffer
  92348. * @param indices defines the indices to store in the index buffer
  92349. * @param offset defines the offset in the target buffer where to store the data
  92350. * @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)
  92351. */
  92352. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  92353. /**
  92354. * Creates a new index buffer
  92355. * @param indices defines the indices to store in the index buffer
  92356. * @param totalVertices defines the total number of vertices (could be null)
  92357. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92358. */
  92359. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  92360. /**
  92361. * Return the total number of indices
  92362. * @returns the total number of indices
  92363. */
  92364. getTotalIndices(): number;
  92365. /**
  92366. * Gets the index buffer array
  92367. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92368. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92369. * @returns the index buffer array
  92370. */
  92371. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92372. /**
  92373. * Gets the index buffer
  92374. * @return the index buffer
  92375. */
  92376. getIndexBuffer(): Nullable<DataBuffer>;
  92377. /** @hidden */
  92378. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  92379. /**
  92380. * Release the associated resources for a specific mesh
  92381. * @param mesh defines the source mesh
  92382. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  92383. */
  92384. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  92385. /**
  92386. * Apply current geometry to a given mesh
  92387. * @param mesh defines the mesh to apply geometry to
  92388. */
  92389. applyToMesh(mesh: Mesh): void;
  92390. private _updateExtend;
  92391. private _applyToMesh;
  92392. private notifyUpdate;
  92393. /**
  92394. * Load the geometry if it was flagged as delay loaded
  92395. * @param scene defines the hosting scene
  92396. * @param onLoaded defines a callback called when the geometry is loaded
  92397. */
  92398. load(scene: Scene, onLoaded?: () => void): void;
  92399. private _queueLoad;
  92400. /**
  92401. * Invert the geometry to move from a right handed system to a left handed one.
  92402. */
  92403. toLeftHanded(): void;
  92404. /** @hidden */
  92405. _resetPointsArrayCache(): void;
  92406. /** @hidden */
  92407. _generatePointsArray(): boolean;
  92408. /**
  92409. * Gets a value indicating if the geometry is disposed
  92410. * @returns true if the geometry was disposed
  92411. */
  92412. isDisposed(): boolean;
  92413. private _disposeVertexArrayObjects;
  92414. /**
  92415. * Free all associated resources
  92416. */
  92417. dispose(): void;
  92418. /**
  92419. * Clone the current geometry into a new geometry
  92420. * @param id defines the unique ID of the new geometry
  92421. * @returns a new geometry object
  92422. */
  92423. copy(id: string): Geometry;
  92424. /**
  92425. * Serialize the current geometry info (and not the vertices data) into a JSON object
  92426. * @return a JSON representation of the current geometry data (without the vertices data)
  92427. */
  92428. serialize(): any;
  92429. private toNumberArray;
  92430. /**
  92431. * Serialize all vertices data into a JSON oject
  92432. * @returns a JSON representation of the current geometry data
  92433. */
  92434. serializeVerticeData(): any;
  92435. /**
  92436. * Extracts a clone of a mesh geometry
  92437. * @param mesh defines the source mesh
  92438. * @param id defines the unique ID of the new geometry object
  92439. * @returns the new geometry object
  92440. */
  92441. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  92442. /**
  92443. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  92444. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92445. * Be aware Math.random() could cause collisions, but:
  92446. * "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"
  92447. * @returns a string containing a new GUID
  92448. */
  92449. static RandomId(): string;
  92450. /** @hidden */
  92451. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  92452. private static _CleanMatricesWeights;
  92453. /**
  92454. * Create a new geometry from persisted data (Using .babylon file format)
  92455. * @param parsedVertexData defines the persisted data
  92456. * @param scene defines the hosting scene
  92457. * @param rootUrl defines the root url to use to load assets (like delayed data)
  92458. * @returns the new geometry object
  92459. */
  92460. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  92461. }
  92462. }
  92463. declare module BABYLON {
  92464. /**
  92465. * Define an interface for all classes that will get and set the data on vertices
  92466. */
  92467. export interface IGetSetVerticesData {
  92468. /**
  92469. * Gets a boolean indicating if specific vertex data is present
  92470. * @param kind defines the vertex data kind to use
  92471. * @returns true is data kind is present
  92472. */
  92473. isVerticesDataPresent(kind: string): boolean;
  92474. /**
  92475. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92476. * @param kind defines the data kind (Position, normal, etc...)
  92477. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92478. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92479. * @returns a float array containing vertex data
  92480. */
  92481. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92482. /**
  92483. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92484. * @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.
  92485. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92486. * @returns the indices array or an empty array if the mesh has no geometry
  92487. */
  92488. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92489. /**
  92490. * Set specific vertex data
  92491. * @param kind defines the data kind (Position, normal, etc...)
  92492. * @param data defines the vertex data to use
  92493. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92494. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92495. */
  92496. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  92497. /**
  92498. * Update a specific associated vertex buffer
  92499. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92500. * - VertexBuffer.PositionKind
  92501. * - VertexBuffer.UVKind
  92502. * - VertexBuffer.UV2Kind
  92503. * - VertexBuffer.UV3Kind
  92504. * - VertexBuffer.UV4Kind
  92505. * - VertexBuffer.UV5Kind
  92506. * - VertexBuffer.UV6Kind
  92507. * - VertexBuffer.ColorKind
  92508. * - VertexBuffer.MatricesIndicesKind
  92509. * - VertexBuffer.MatricesIndicesExtraKind
  92510. * - VertexBuffer.MatricesWeightsKind
  92511. * - VertexBuffer.MatricesWeightsExtraKind
  92512. * @param data defines the data source
  92513. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92514. * @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)
  92515. */
  92516. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  92517. /**
  92518. * Creates a new index buffer
  92519. * @param indices defines the indices to store in the index buffer
  92520. * @param totalVertices defines the total number of vertices (could be null)
  92521. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92522. */
  92523. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  92524. }
  92525. /**
  92526. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  92527. */
  92528. export class VertexData {
  92529. /**
  92530. * Mesh side orientation : usually the external or front surface
  92531. */
  92532. static readonly FRONTSIDE: number;
  92533. /**
  92534. * Mesh side orientation : usually the internal or back surface
  92535. */
  92536. static readonly BACKSIDE: number;
  92537. /**
  92538. * Mesh side orientation : both internal and external or front and back surfaces
  92539. */
  92540. static readonly DOUBLESIDE: number;
  92541. /**
  92542. * Mesh side orientation : by default, `FRONTSIDE`
  92543. */
  92544. static readonly DEFAULTSIDE: number;
  92545. /**
  92546. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  92547. */
  92548. positions: Nullable<FloatArray>;
  92549. /**
  92550. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  92551. */
  92552. normals: Nullable<FloatArray>;
  92553. /**
  92554. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  92555. */
  92556. tangents: Nullable<FloatArray>;
  92557. /**
  92558. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92559. */
  92560. uvs: Nullable<FloatArray>;
  92561. /**
  92562. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92563. */
  92564. uvs2: Nullable<FloatArray>;
  92565. /**
  92566. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92567. */
  92568. uvs3: Nullable<FloatArray>;
  92569. /**
  92570. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92571. */
  92572. uvs4: Nullable<FloatArray>;
  92573. /**
  92574. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92575. */
  92576. uvs5: Nullable<FloatArray>;
  92577. /**
  92578. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92579. */
  92580. uvs6: Nullable<FloatArray>;
  92581. /**
  92582. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  92583. */
  92584. colors: Nullable<FloatArray>;
  92585. /**
  92586. * 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).
  92587. */
  92588. matricesIndices: Nullable<FloatArray>;
  92589. /**
  92590. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  92591. */
  92592. matricesWeights: Nullable<FloatArray>;
  92593. /**
  92594. * An array extending the number of possible indices
  92595. */
  92596. matricesIndicesExtra: Nullable<FloatArray>;
  92597. /**
  92598. * An array extending the number of possible weights when the number of indices is extended
  92599. */
  92600. matricesWeightsExtra: Nullable<FloatArray>;
  92601. /**
  92602. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  92603. */
  92604. indices: Nullable<IndicesArray>;
  92605. /**
  92606. * Uses the passed data array to set the set the values for the specified kind of data
  92607. * @param data a linear array of floating numbers
  92608. * @param kind the type of data that is being set, eg positions, colors etc
  92609. */
  92610. set(data: FloatArray, kind: string): void;
  92611. /**
  92612. * Associates the vertexData to the passed Mesh.
  92613. * Sets it as updatable or not (default `false`)
  92614. * @param mesh the mesh the vertexData is applied to
  92615. * @param updatable when used and having the value true allows new data to update the vertexData
  92616. * @returns the VertexData
  92617. */
  92618. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  92619. /**
  92620. * Associates the vertexData to the passed Geometry.
  92621. * Sets it as updatable or not (default `false`)
  92622. * @param geometry the geometry the vertexData is applied to
  92623. * @param updatable when used and having the value true allows new data to update the vertexData
  92624. * @returns VertexData
  92625. */
  92626. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  92627. /**
  92628. * Updates the associated mesh
  92629. * @param mesh the mesh to be updated
  92630. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92631. * @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
  92632. * @returns VertexData
  92633. */
  92634. updateMesh(mesh: Mesh): VertexData;
  92635. /**
  92636. * Updates the associated geometry
  92637. * @param geometry the geometry to be updated
  92638. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92639. * @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
  92640. * @returns VertexData.
  92641. */
  92642. updateGeometry(geometry: Geometry): VertexData;
  92643. private _applyTo;
  92644. private _update;
  92645. /**
  92646. * Transforms each position and each normal of the vertexData according to the passed Matrix
  92647. * @param matrix the transforming matrix
  92648. * @returns the VertexData
  92649. */
  92650. transform(matrix: Matrix): VertexData;
  92651. /**
  92652. * Merges the passed VertexData into the current one
  92653. * @param other the VertexData to be merged into the current one
  92654. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  92655. * @returns the modified VertexData
  92656. */
  92657. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  92658. private _mergeElement;
  92659. private _validate;
  92660. /**
  92661. * Serializes the VertexData
  92662. * @returns a serialized object
  92663. */
  92664. serialize(): any;
  92665. /**
  92666. * Extracts the vertexData from a mesh
  92667. * @param mesh the mesh from which to extract the VertexData
  92668. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  92669. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92670. * @returns the object VertexData associated to the passed mesh
  92671. */
  92672. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92673. /**
  92674. * Extracts the vertexData from the geometry
  92675. * @param geometry the geometry from which to extract the VertexData
  92676. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  92677. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92678. * @returns the object VertexData associated to the passed mesh
  92679. */
  92680. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92681. private static _ExtractFrom;
  92682. /**
  92683. * Creates the VertexData for a Ribbon
  92684. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  92685. * * pathArray array of paths, each of which an array of successive Vector3
  92686. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  92687. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  92688. * * 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
  92689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92690. * * 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)
  92691. * * 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)
  92692. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  92693. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  92694. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  92695. * @returns the VertexData of the ribbon
  92696. */
  92697. static CreateRibbon(options: {
  92698. pathArray: Vector3[][];
  92699. closeArray?: boolean;
  92700. closePath?: boolean;
  92701. offset?: number;
  92702. sideOrientation?: number;
  92703. frontUVs?: Vector4;
  92704. backUVs?: Vector4;
  92705. invertUV?: boolean;
  92706. uvs?: Vector2[];
  92707. colors?: Color4[];
  92708. }): VertexData;
  92709. /**
  92710. * Creates the VertexData for a box
  92711. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92712. * * size sets the width, height and depth of the box to the value of size, optional default 1
  92713. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  92714. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  92715. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  92716. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92717. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92718. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92719. * * 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)
  92720. * * 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)
  92721. * @returns the VertexData of the box
  92722. */
  92723. static CreateBox(options: {
  92724. size?: number;
  92725. width?: number;
  92726. height?: number;
  92727. depth?: number;
  92728. faceUV?: Vector4[];
  92729. faceColors?: Color4[];
  92730. sideOrientation?: number;
  92731. frontUVs?: Vector4;
  92732. backUVs?: Vector4;
  92733. }): VertexData;
  92734. /**
  92735. * Creates the VertexData for a tiled box
  92736. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92737. * * faceTiles sets the pattern, tile size and number of tiles for a face
  92738. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92739. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92741. * @returns the VertexData of the box
  92742. */
  92743. static CreateTiledBox(options: {
  92744. pattern?: number;
  92745. width?: number;
  92746. height?: number;
  92747. depth?: number;
  92748. tileSize?: number;
  92749. tileWidth?: number;
  92750. tileHeight?: number;
  92751. alignHorizontal?: number;
  92752. alignVertical?: number;
  92753. faceUV?: Vector4[];
  92754. faceColors?: Color4[];
  92755. sideOrientation?: number;
  92756. }): VertexData;
  92757. /**
  92758. * Creates the VertexData for a tiled plane
  92759. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92760. * * pattern a limited pattern arrangement depending on the number
  92761. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  92762. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  92763. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  92764. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92765. * * 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)
  92766. * * 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)
  92767. * @returns the VertexData of the tiled plane
  92768. */
  92769. static CreateTiledPlane(options: {
  92770. pattern?: number;
  92771. tileSize?: number;
  92772. tileWidth?: number;
  92773. tileHeight?: number;
  92774. size?: number;
  92775. width?: number;
  92776. height?: number;
  92777. alignHorizontal?: number;
  92778. alignVertical?: number;
  92779. sideOrientation?: number;
  92780. frontUVs?: Vector4;
  92781. backUVs?: Vector4;
  92782. }): VertexData;
  92783. /**
  92784. * Creates the VertexData for an ellipsoid, defaults to a sphere
  92785. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92786. * * segments sets the number of horizontal strips optional, default 32
  92787. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  92788. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  92789. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  92790. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  92791. * * 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
  92792. * * 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
  92793. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92794. * * 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)
  92795. * * 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)
  92796. * @returns the VertexData of the ellipsoid
  92797. */
  92798. static CreateSphere(options: {
  92799. segments?: number;
  92800. diameter?: number;
  92801. diameterX?: number;
  92802. diameterY?: number;
  92803. diameterZ?: number;
  92804. arc?: number;
  92805. slice?: number;
  92806. sideOrientation?: number;
  92807. frontUVs?: Vector4;
  92808. backUVs?: Vector4;
  92809. }): VertexData;
  92810. /**
  92811. * Creates the VertexData for a cylinder, cone or prism
  92812. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92813. * * height sets the height (y direction) of the cylinder, optional, default 2
  92814. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  92815. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  92816. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  92817. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92818. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  92819. * * 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
  92820. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92821. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92822. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  92823. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  92824. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92825. * * 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)
  92826. * * 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)
  92827. * @returns the VertexData of the cylinder, cone or prism
  92828. */
  92829. static CreateCylinder(options: {
  92830. height?: number;
  92831. diameterTop?: number;
  92832. diameterBottom?: number;
  92833. diameter?: number;
  92834. tessellation?: number;
  92835. subdivisions?: number;
  92836. arc?: number;
  92837. faceColors?: Color4[];
  92838. faceUV?: Vector4[];
  92839. hasRings?: boolean;
  92840. enclose?: boolean;
  92841. sideOrientation?: number;
  92842. frontUVs?: Vector4;
  92843. backUVs?: Vector4;
  92844. }): VertexData;
  92845. /**
  92846. * Creates the VertexData for a torus
  92847. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92848. * * diameter the diameter of the torus, optional default 1
  92849. * * thickness the diameter of the tube forming the torus, optional default 0.5
  92850. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92851. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92852. * * 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)
  92853. * * 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)
  92854. * @returns the VertexData of the torus
  92855. */
  92856. static CreateTorus(options: {
  92857. diameter?: number;
  92858. thickness?: number;
  92859. tessellation?: number;
  92860. sideOrientation?: number;
  92861. frontUVs?: Vector4;
  92862. backUVs?: Vector4;
  92863. }): VertexData;
  92864. /**
  92865. * Creates the VertexData of the LineSystem
  92866. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  92867. * - lines an array of lines, each line being an array of successive Vector3
  92868. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  92869. * @returns the VertexData of the LineSystem
  92870. */
  92871. static CreateLineSystem(options: {
  92872. lines: Vector3[][];
  92873. colors?: Nullable<Color4[][]>;
  92874. }): VertexData;
  92875. /**
  92876. * Create the VertexData for a DashedLines
  92877. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  92878. * - points an array successive Vector3
  92879. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  92880. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  92881. * - dashNb the intended total number of dashes, optional, default 200
  92882. * @returns the VertexData for the DashedLines
  92883. */
  92884. static CreateDashedLines(options: {
  92885. points: Vector3[];
  92886. dashSize?: number;
  92887. gapSize?: number;
  92888. dashNb?: number;
  92889. }): VertexData;
  92890. /**
  92891. * Creates the VertexData for a Ground
  92892. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92893. * - width the width (x direction) of the ground, optional, default 1
  92894. * - height the height (z direction) of the ground, optional, default 1
  92895. * - subdivisions the number of subdivisions per side, optional, default 1
  92896. * @returns the VertexData of the Ground
  92897. */
  92898. static CreateGround(options: {
  92899. width?: number;
  92900. height?: number;
  92901. subdivisions?: number;
  92902. subdivisionsX?: number;
  92903. subdivisionsY?: number;
  92904. }): VertexData;
  92905. /**
  92906. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  92907. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92908. * * xmin the ground minimum X coordinate, optional, default -1
  92909. * * zmin the ground minimum Z coordinate, optional, default -1
  92910. * * xmax the ground maximum X coordinate, optional, default 1
  92911. * * zmax the ground maximum Z coordinate, optional, default 1
  92912. * * 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}
  92913. * * 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}
  92914. * @returns the VertexData of the TiledGround
  92915. */
  92916. static CreateTiledGround(options: {
  92917. xmin: number;
  92918. zmin: number;
  92919. xmax: number;
  92920. zmax: number;
  92921. subdivisions?: {
  92922. w: number;
  92923. h: number;
  92924. };
  92925. precision?: {
  92926. w: number;
  92927. h: number;
  92928. };
  92929. }): VertexData;
  92930. /**
  92931. * Creates the VertexData of the Ground designed from a heightmap
  92932. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  92933. * * width the width (x direction) of the ground
  92934. * * height the height (z direction) of the ground
  92935. * * subdivisions the number of subdivisions per side
  92936. * * minHeight the minimum altitude on the ground, optional, default 0
  92937. * * maxHeight the maximum altitude on the ground, optional default 1
  92938. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  92939. * * buffer the array holding the image color data
  92940. * * bufferWidth the width of image
  92941. * * bufferHeight the height of image
  92942. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  92943. * @returns the VertexData of the Ground designed from a heightmap
  92944. */
  92945. static CreateGroundFromHeightMap(options: {
  92946. width: number;
  92947. height: number;
  92948. subdivisions: number;
  92949. minHeight: number;
  92950. maxHeight: number;
  92951. colorFilter: Color3;
  92952. buffer: Uint8Array;
  92953. bufferWidth: number;
  92954. bufferHeight: number;
  92955. alphaFilter: number;
  92956. }): VertexData;
  92957. /**
  92958. * Creates the VertexData for a Plane
  92959. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  92960. * * size sets the width and height of the plane to the value of size, optional default 1
  92961. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  92962. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  92963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92964. * * 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)
  92965. * * 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)
  92966. * @returns the VertexData of the box
  92967. */
  92968. static CreatePlane(options: {
  92969. size?: number;
  92970. width?: number;
  92971. height?: number;
  92972. sideOrientation?: number;
  92973. frontUVs?: Vector4;
  92974. backUVs?: Vector4;
  92975. }): VertexData;
  92976. /**
  92977. * Creates the VertexData of the Disc or regular Polygon
  92978. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  92979. * * radius the radius of the disc, optional default 0.5
  92980. * * tessellation the number of polygon sides, optional, default 64
  92981. * * 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
  92982. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92983. * * 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)
  92984. * * 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)
  92985. * @returns the VertexData of the box
  92986. */
  92987. static CreateDisc(options: {
  92988. radius?: number;
  92989. tessellation?: number;
  92990. arc?: number;
  92991. sideOrientation?: number;
  92992. frontUVs?: Vector4;
  92993. backUVs?: Vector4;
  92994. }): VertexData;
  92995. /**
  92996. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  92997. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  92998. * @param polygon a mesh built from polygonTriangulation.build()
  92999. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93000. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93001. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93002. * @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)
  93003. * @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)
  93004. * @returns the VertexData of the Polygon
  93005. */
  93006. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  93007. /**
  93008. * Creates the VertexData of the IcoSphere
  93009. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  93010. * * radius the radius of the IcoSphere, optional default 1
  93011. * * radiusX allows stretching in the x direction, optional, default radius
  93012. * * radiusY allows stretching in the y direction, optional, default radius
  93013. * * radiusZ allows stretching in the z direction, optional, default radius
  93014. * * flat when true creates a flat shaded mesh, optional, default true
  93015. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93017. * * 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)
  93018. * * 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)
  93019. * @returns the VertexData of the IcoSphere
  93020. */
  93021. static CreateIcoSphere(options: {
  93022. radius?: number;
  93023. radiusX?: number;
  93024. radiusY?: number;
  93025. radiusZ?: number;
  93026. flat?: boolean;
  93027. subdivisions?: number;
  93028. sideOrientation?: number;
  93029. frontUVs?: Vector4;
  93030. backUVs?: Vector4;
  93031. }): VertexData;
  93032. /**
  93033. * Creates the VertexData for a Polyhedron
  93034. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  93035. * * type provided types are:
  93036. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  93037. * * 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)
  93038. * * size the size of the IcoSphere, optional default 1
  93039. * * sizeX allows stretching in the x direction, optional, default size
  93040. * * sizeY allows stretching in the y direction, optional, default size
  93041. * * sizeZ allows stretching in the z direction, optional, default size
  93042. * * 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
  93043. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93044. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93045. * * flat when true creates a flat shaded mesh, optional, default true
  93046. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93047. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93048. * * 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)
  93049. * * 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)
  93050. * @returns the VertexData of the Polyhedron
  93051. */
  93052. static CreatePolyhedron(options: {
  93053. type?: number;
  93054. size?: number;
  93055. sizeX?: number;
  93056. sizeY?: number;
  93057. sizeZ?: number;
  93058. custom?: any;
  93059. faceUV?: Vector4[];
  93060. faceColors?: Color4[];
  93061. flat?: boolean;
  93062. sideOrientation?: number;
  93063. frontUVs?: Vector4;
  93064. backUVs?: Vector4;
  93065. }): VertexData;
  93066. /**
  93067. * Creates the VertexData for a TorusKnot
  93068. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  93069. * * radius the radius of the torus knot, optional, default 2
  93070. * * tube the thickness of the tube, optional, default 0.5
  93071. * * radialSegments the number of sides on each tube segments, optional, default 32
  93072. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  93073. * * p the number of windings around the z axis, optional, default 2
  93074. * * q the number of windings around the x axis, optional, default 3
  93075. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93076. * * 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)
  93077. * * 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)
  93078. * @returns the VertexData of the Torus Knot
  93079. */
  93080. static CreateTorusKnot(options: {
  93081. radius?: number;
  93082. tube?: number;
  93083. radialSegments?: number;
  93084. tubularSegments?: number;
  93085. p?: number;
  93086. q?: number;
  93087. sideOrientation?: number;
  93088. frontUVs?: Vector4;
  93089. backUVs?: Vector4;
  93090. }): VertexData;
  93091. /**
  93092. * Compute normals for given positions and indices
  93093. * @param positions an array of vertex positions, [...., x, y, z, ......]
  93094. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  93095. * @param normals an array of vertex normals, [...., x, y, z, ......]
  93096. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  93097. * * facetNormals : optional array of facet normals (vector3)
  93098. * * facetPositions : optional array of facet positions (vector3)
  93099. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  93100. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  93101. * * bInfo : optional bounding info, required for facetPartitioning computation
  93102. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  93103. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  93104. * * useRightHandedSystem: optional boolean to for right handed system computation
  93105. * * depthSort : optional boolean to enable the facet depth sort computation
  93106. * * distanceTo : optional Vector3 to compute the facet depth from this location
  93107. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  93108. */
  93109. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  93110. facetNormals?: any;
  93111. facetPositions?: any;
  93112. facetPartitioning?: any;
  93113. ratio?: number;
  93114. bInfo?: any;
  93115. bbSize?: Vector3;
  93116. subDiv?: any;
  93117. useRightHandedSystem?: boolean;
  93118. depthSort?: boolean;
  93119. distanceTo?: Vector3;
  93120. depthSortedFacets?: any;
  93121. }): void;
  93122. /** @hidden */
  93123. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  93124. /**
  93125. * Applies VertexData created from the imported parameters to the geometry
  93126. * @param parsedVertexData the parsed data from an imported file
  93127. * @param geometry the geometry to apply the VertexData to
  93128. */
  93129. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  93130. }
  93131. }
  93132. declare module BABYLON {
  93133. /**
  93134. * Defines a target to use with MorphTargetManager
  93135. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93136. */
  93137. export class MorphTarget implements IAnimatable {
  93138. /** defines the name of the target */
  93139. name: string;
  93140. /**
  93141. * Gets or sets the list of animations
  93142. */
  93143. animations: Animation[];
  93144. private _scene;
  93145. private _positions;
  93146. private _normals;
  93147. private _tangents;
  93148. private _uvs;
  93149. private _influence;
  93150. private _uniqueId;
  93151. /**
  93152. * Observable raised when the influence changes
  93153. */
  93154. onInfluenceChanged: Observable<boolean>;
  93155. /** @hidden */
  93156. _onDataLayoutChanged: Observable<void>;
  93157. /**
  93158. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  93159. */
  93160. get influence(): number;
  93161. set influence(influence: number);
  93162. /**
  93163. * Gets or sets the id of the morph Target
  93164. */
  93165. id: string;
  93166. private _animationPropertiesOverride;
  93167. /**
  93168. * Gets or sets the animation properties override
  93169. */
  93170. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93171. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93172. /**
  93173. * Creates a new MorphTarget
  93174. * @param name defines the name of the target
  93175. * @param influence defines the influence to use
  93176. * @param scene defines the scene the morphtarget belongs to
  93177. */
  93178. constructor(
  93179. /** defines the name of the target */
  93180. name: string, influence?: number, scene?: Nullable<Scene>);
  93181. /**
  93182. * Gets the unique ID of this manager
  93183. */
  93184. get uniqueId(): number;
  93185. /**
  93186. * Gets a boolean defining if the target contains position data
  93187. */
  93188. get hasPositions(): boolean;
  93189. /**
  93190. * Gets a boolean defining if the target contains normal data
  93191. */
  93192. get hasNormals(): boolean;
  93193. /**
  93194. * Gets a boolean defining if the target contains tangent data
  93195. */
  93196. get hasTangents(): boolean;
  93197. /**
  93198. * Gets a boolean defining if the target contains texture coordinates data
  93199. */
  93200. get hasUVs(): boolean;
  93201. /**
  93202. * Affects position data to this target
  93203. * @param data defines the position data to use
  93204. */
  93205. setPositions(data: Nullable<FloatArray>): void;
  93206. /**
  93207. * Gets the position data stored in this target
  93208. * @returns a FloatArray containing the position data (or null if not present)
  93209. */
  93210. getPositions(): Nullable<FloatArray>;
  93211. /**
  93212. * Affects normal data to this target
  93213. * @param data defines the normal data to use
  93214. */
  93215. setNormals(data: Nullable<FloatArray>): void;
  93216. /**
  93217. * Gets the normal data stored in this target
  93218. * @returns a FloatArray containing the normal data (or null if not present)
  93219. */
  93220. getNormals(): Nullable<FloatArray>;
  93221. /**
  93222. * Affects tangent data to this target
  93223. * @param data defines the tangent data to use
  93224. */
  93225. setTangents(data: Nullable<FloatArray>): void;
  93226. /**
  93227. * Gets the tangent data stored in this target
  93228. * @returns a FloatArray containing the tangent data (or null if not present)
  93229. */
  93230. getTangents(): Nullable<FloatArray>;
  93231. /**
  93232. * Affects texture coordinates data to this target
  93233. * @param data defines the texture coordinates data to use
  93234. */
  93235. setUVs(data: Nullable<FloatArray>): void;
  93236. /**
  93237. * Gets the texture coordinates data stored in this target
  93238. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  93239. */
  93240. getUVs(): Nullable<FloatArray>;
  93241. /**
  93242. * Clone the current target
  93243. * @returns a new MorphTarget
  93244. */
  93245. clone(): MorphTarget;
  93246. /**
  93247. * Serializes the current target into a Serialization object
  93248. * @returns the serialized object
  93249. */
  93250. serialize(): any;
  93251. /**
  93252. * Returns the string "MorphTarget"
  93253. * @returns "MorphTarget"
  93254. */
  93255. getClassName(): string;
  93256. /**
  93257. * Creates a new target from serialized data
  93258. * @param serializationObject defines the serialized data to use
  93259. * @returns a new MorphTarget
  93260. */
  93261. static Parse(serializationObject: any): MorphTarget;
  93262. /**
  93263. * Creates a MorphTarget from mesh data
  93264. * @param mesh defines the source mesh
  93265. * @param name defines the name to use for the new target
  93266. * @param influence defines the influence to attach to the target
  93267. * @returns a new MorphTarget
  93268. */
  93269. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  93270. }
  93271. }
  93272. declare module BABYLON {
  93273. /**
  93274. * This class is used to deform meshes using morphing between different targets
  93275. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93276. */
  93277. export class MorphTargetManager {
  93278. private _targets;
  93279. private _targetInfluenceChangedObservers;
  93280. private _targetDataLayoutChangedObservers;
  93281. private _activeTargets;
  93282. private _scene;
  93283. private _influences;
  93284. private _supportsNormals;
  93285. private _supportsTangents;
  93286. private _supportsUVs;
  93287. private _vertexCount;
  93288. private _uniqueId;
  93289. private _tempInfluences;
  93290. /**
  93291. * Gets or sets a boolean indicating if normals must be morphed
  93292. */
  93293. enableNormalMorphing: boolean;
  93294. /**
  93295. * Gets or sets a boolean indicating if tangents must be morphed
  93296. */
  93297. enableTangentMorphing: boolean;
  93298. /**
  93299. * Gets or sets a boolean indicating if UV must be morphed
  93300. */
  93301. enableUVMorphing: boolean;
  93302. /**
  93303. * Creates a new MorphTargetManager
  93304. * @param scene defines the current scene
  93305. */
  93306. constructor(scene?: Nullable<Scene>);
  93307. /**
  93308. * Gets the unique ID of this manager
  93309. */
  93310. get uniqueId(): number;
  93311. /**
  93312. * Gets the number of vertices handled by this manager
  93313. */
  93314. get vertexCount(): number;
  93315. /**
  93316. * Gets a boolean indicating if this manager supports morphing of normals
  93317. */
  93318. get supportsNormals(): boolean;
  93319. /**
  93320. * Gets a boolean indicating if this manager supports morphing of tangents
  93321. */
  93322. get supportsTangents(): boolean;
  93323. /**
  93324. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  93325. */
  93326. get supportsUVs(): boolean;
  93327. /**
  93328. * Gets the number of targets stored in this manager
  93329. */
  93330. get numTargets(): number;
  93331. /**
  93332. * Gets the number of influencers (ie. the number of targets with influences > 0)
  93333. */
  93334. get numInfluencers(): number;
  93335. /**
  93336. * Gets the list of influences (one per target)
  93337. */
  93338. get influences(): Float32Array;
  93339. /**
  93340. * Gets the active target at specified index. An active target is a target with an influence > 0
  93341. * @param index defines the index to check
  93342. * @returns the requested target
  93343. */
  93344. getActiveTarget(index: number): MorphTarget;
  93345. /**
  93346. * Gets the target at specified index
  93347. * @param index defines the index to check
  93348. * @returns the requested target
  93349. */
  93350. getTarget(index: number): MorphTarget;
  93351. /**
  93352. * Add a new target to this manager
  93353. * @param target defines the target to add
  93354. */
  93355. addTarget(target: MorphTarget): void;
  93356. /**
  93357. * Removes a target from the manager
  93358. * @param target defines the target to remove
  93359. */
  93360. removeTarget(target: MorphTarget): void;
  93361. /**
  93362. * Clone the current manager
  93363. * @returns a new MorphTargetManager
  93364. */
  93365. clone(): MorphTargetManager;
  93366. /**
  93367. * Serializes the current manager into a Serialization object
  93368. * @returns the serialized object
  93369. */
  93370. serialize(): any;
  93371. private _syncActiveTargets;
  93372. /**
  93373. * Syncrhonize the targets with all the meshes using this morph target manager
  93374. */
  93375. synchronize(): void;
  93376. /**
  93377. * Creates a new MorphTargetManager from serialized data
  93378. * @param serializationObject defines the serialized data
  93379. * @param scene defines the hosting scene
  93380. * @returns the new MorphTargetManager
  93381. */
  93382. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  93383. }
  93384. }
  93385. declare module BABYLON {
  93386. /**
  93387. * Class used to represent a specific level of detail of a mesh
  93388. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  93389. */
  93390. export class MeshLODLevel {
  93391. /** Defines the distance where this level should start being displayed */
  93392. distance: number;
  93393. /** Defines the mesh to use to render this level */
  93394. mesh: Nullable<Mesh>;
  93395. /**
  93396. * Creates a new LOD level
  93397. * @param distance defines the distance where this level should star being displayed
  93398. * @param mesh defines the mesh to use to render this level
  93399. */
  93400. constructor(
  93401. /** Defines the distance where this level should start being displayed */
  93402. distance: number,
  93403. /** Defines the mesh to use to render this level */
  93404. mesh: Nullable<Mesh>);
  93405. }
  93406. }
  93407. declare module BABYLON {
  93408. /**
  93409. * Mesh representing the gorund
  93410. */
  93411. export class GroundMesh extends Mesh {
  93412. /** If octree should be generated */
  93413. generateOctree: boolean;
  93414. private _heightQuads;
  93415. /** @hidden */
  93416. _subdivisionsX: number;
  93417. /** @hidden */
  93418. _subdivisionsY: number;
  93419. /** @hidden */
  93420. _width: number;
  93421. /** @hidden */
  93422. _height: number;
  93423. /** @hidden */
  93424. _minX: number;
  93425. /** @hidden */
  93426. _maxX: number;
  93427. /** @hidden */
  93428. _minZ: number;
  93429. /** @hidden */
  93430. _maxZ: number;
  93431. constructor(name: string, scene: Scene);
  93432. /**
  93433. * "GroundMesh"
  93434. * @returns "GroundMesh"
  93435. */
  93436. getClassName(): string;
  93437. /**
  93438. * The minimum of x and y subdivisions
  93439. */
  93440. get subdivisions(): number;
  93441. /**
  93442. * X subdivisions
  93443. */
  93444. get subdivisionsX(): number;
  93445. /**
  93446. * Y subdivisions
  93447. */
  93448. get subdivisionsY(): number;
  93449. /**
  93450. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  93451. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  93452. * @param chunksCount the number of subdivisions for x and y
  93453. * @param octreeBlocksSize (Default: 32)
  93454. */
  93455. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  93456. /**
  93457. * Returns a height (y) value in the Worl system :
  93458. * the ground altitude at the coordinates (x, z) expressed in the World system.
  93459. * @param x x coordinate
  93460. * @param z z coordinate
  93461. * @returns the ground y position if (x, z) are outside the ground surface.
  93462. */
  93463. getHeightAtCoordinates(x: number, z: number): number;
  93464. /**
  93465. * Returns a normalized vector (Vector3) orthogonal to the ground
  93466. * at the ground coordinates (x, z) expressed in the World system.
  93467. * @param x x coordinate
  93468. * @param z z coordinate
  93469. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  93470. */
  93471. getNormalAtCoordinates(x: number, z: number): Vector3;
  93472. /**
  93473. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  93474. * at the ground coordinates (x, z) expressed in the World system.
  93475. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  93476. * @param x x coordinate
  93477. * @param z z coordinate
  93478. * @param ref vector to store the result
  93479. * @returns the GroundMesh.
  93480. */
  93481. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  93482. /**
  93483. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  93484. * if the ground has been updated.
  93485. * This can be used in the render loop.
  93486. * @returns the GroundMesh.
  93487. */
  93488. updateCoordinateHeights(): GroundMesh;
  93489. private _getFacetAt;
  93490. private _initHeightQuads;
  93491. private _computeHeightQuads;
  93492. /**
  93493. * Serializes this ground mesh
  93494. * @param serializationObject object to write serialization to
  93495. */
  93496. serialize(serializationObject: any): void;
  93497. /**
  93498. * Parses a serialized ground mesh
  93499. * @param parsedMesh the serialized mesh
  93500. * @param scene the scene to create the ground mesh in
  93501. * @returns the created ground mesh
  93502. */
  93503. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  93504. }
  93505. }
  93506. declare module BABYLON {
  93507. /**
  93508. * Interface for Physics-Joint data
  93509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93510. */
  93511. export interface PhysicsJointData {
  93512. /**
  93513. * The main pivot of the joint
  93514. */
  93515. mainPivot?: Vector3;
  93516. /**
  93517. * The connected pivot of the joint
  93518. */
  93519. connectedPivot?: Vector3;
  93520. /**
  93521. * The main axis of the joint
  93522. */
  93523. mainAxis?: Vector3;
  93524. /**
  93525. * The connected axis of the joint
  93526. */
  93527. connectedAxis?: Vector3;
  93528. /**
  93529. * The collision of the joint
  93530. */
  93531. collision?: boolean;
  93532. /**
  93533. * Native Oimo/Cannon/Energy data
  93534. */
  93535. nativeParams?: any;
  93536. }
  93537. /**
  93538. * This is a holder class for the physics joint created by the physics plugin
  93539. * It holds a set of functions to control the underlying joint
  93540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93541. */
  93542. export class PhysicsJoint {
  93543. /**
  93544. * The type of the physics joint
  93545. */
  93546. type: number;
  93547. /**
  93548. * The data for the physics joint
  93549. */
  93550. jointData: PhysicsJointData;
  93551. private _physicsJoint;
  93552. protected _physicsPlugin: IPhysicsEnginePlugin;
  93553. /**
  93554. * Initializes the physics joint
  93555. * @param type The type of the physics joint
  93556. * @param jointData The data for the physics joint
  93557. */
  93558. constructor(
  93559. /**
  93560. * The type of the physics joint
  93561. */
  93562. type: number,
  93563. /**
  93564. * The data for the physics joint
  93565. */
  93566. jointData: PhysicsJointData);
  93567. /**
  93568. * Gets the physics joint
  93569. */
  93570. get physicsJoint(): any;
  93571. /**
  93572. * Sets the physics joint
  93573. */
  93574. set physicsJoint(newJoint: any);
  93575. /**
  93576. * Sets the physics plugin
  93577. */
  93578. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  93579. /**
  93580. * Execute a function that is physics-plugin specific.
  93581. * @param {Function} func the function that will be executed.
  93582. * It accepts two parameters: the physics world and the physics joint
  93583. */
  93584. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  93585. /**
  93586. * Distance-Joint type
  93587. */
  93588. static DistanceJoint: number;
  93589. /**
  93590. * Hinge-Joint type
  93591. */
  93592. static HingeJoint: number;
  93593. /**
  93594. * Ball-and-Socket joint type
  93595. */
  93596. static BallAndSocketJoint: number;
  93597. /**
  93598. * Wheel-Joint type
  93599. */
  93600. static WheelJoint: number;
  93601. /**
  93602. * Slider-Joint type
  93603. */
  93604. static SliderJoint: number;
  93605. /**
  93606. * Prismatic-Joint type
  93607. */
  93608. static PrismaticJoint: number;
  93609. /**
  93610. * Universal-Joint type
  93611. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  93612. */
  93613. static UniversalJoint: number;
  93614. /**
  93615. * Hinge-Joint 2 type
  93616. */
  93617. static Hinge2Joint: number;
  93618. /**
  93619. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  93620. */
  93621. static PointToPointJoint: number;
  93622. /**
  93623. * Spring-Joint type
  93624. */
  93625. static SpringJoint: number;
  93626. /**
  93627. * Lock-Joint type
  93628. */
  93629. static LockJoint: number;
  93630. }
  93631. /**
  93632. * A class representing a physics distance joint
  93633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93634. */
  93635. export class DistanceJoint extends PhysicsJoint {
  93636. /**
  93637. *
  93638. * @param jointData The data for the Distance-Joint
  93639. */
  93640. constructor(jointData: DistanceJointData);
  93641. /**
  93642. * Update the predefined distance.
  93643. * @param maxDistance The maximum preferred distance
  93644. * @param minDistance The minimum preferred distance
  93645. */
  93646. updateDistance(maxDistance: number, minDistance?: number): void;
  93647. }
  93648. /**
  93649. * Represents a Motor-Enabled Joint
  93650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93651. */
  93652. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  93653. /**
  93654. * Initializes the Motor-Enabled Joint
  93655. * @param type The type of the joint
  93656. * @param jointData The physica joint data for the joint
  93657. */
  93658. constructor(type: number, jointData: PhysicsJointData);
  93659. /**
  93660. * Set the motor values.
  93661. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93662. * @param force the force to apply
  93663. * @param maxForce max force for this motor.
  93664. */
  93665. setMotor(force?: number, maxForce?: number): void;
  93666. /**
  93667. * Set the motor's limits.
  93668. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93669. * @param upperLimit The upper limit of the motor
  93670. * @param lowerLimit The lower limit of the motor
  93671. */
  93672. setLimit(upperLimit: number, lowerLimit?: number): void;
  93673. }
  93674. /**
  93675. * This class represents a single physics Hinge-Joint
  93676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93677. */
  93678. export class HingeJoint extends MotorEnabledJoint {
  93679. /**
  93680. * Initializes the Hinge-Joint
  93681. * @param jointData The joint data for the Hinge-Joint
  93682. */
  93683. constructor(jointData: PhysicsJointData);
  93684. /**
  93685. * Set the motor values.
  93686. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93687. * @param {number} force the force to apply
  93688. * @param {number} maxForce max force for this motor.
  93689. */
  93690. setMotor(force?: number, maxForce?: number): void;
  93691. /**
  93692. * Set the motor's limits.
  93693. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93694. * @param upperLimit The upper limit of the motor
  93695. * @param lowerLimit The lower limit of the motor
  93696. */
  93697. setLimit(upperLimit: number, lowerLimit?: number): void;
  93698. }
  93699. /**
  93700. * This class represents a dual hinge physics joint (same as wheel joint)
  93701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93702. */
  93703. export class Hinge2Joint extends MotorEnabledJoint {
  93704. /**
  93705. * Initializes the Hinge2-Joint
  93706. * @param jointData The joint data for the Hinge2-Joint
  93707. */
  93708. constructor(jointData: PhysicsJointData);
  93709. /**
  93710. * Set the motor values.
  93711. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93712. * @param {number} targetSpeed the speed the motor is to reach
  93713. * @param {number} maxForce max force for this motor.
  93714. * @param {motorIndex} the motor's index, 0 or 1.
  93715. */
  93716. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  93717. /**
  93718. * Set the motor limits.
  93719. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93720. * @param {number} upperLimit the upper limit
  93721. * @param {number} lowerLimit lower limit
  93722. * @param {motorIndex} the motor's index, 0 or 1.
  93723. */
  93724. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93725. }
  93726. /**
  93727. * Interface for a motor enabled joint
  93728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93729. */
  93730. export interface IMotorEnabledJoint {
  93731. /**
  93732. * Physics joint
  93733. */
  93734. physicsJoint: any;
  93735. /**
  93736. * Sets the motor of the motor-enabled joint
  93737. * @param force The force of the motor
  93738. * @param maxForce The maximum force of the motor
  93739. * @param motorIndex The index of the motor
  93740. */
  93741. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  93742. /**
  93743. * Sets the limit of the motor
  93744. * @param upperLimit The upper limit of the motor
  93745. * @param lowerLimit The lower limit of the motor
  93746. * @param motorIndex The index of the motor
  93747. */
  93748. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93749. }
  93750. /**
  93751. * Joint data for a Distance-Joint
  93752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93753. */
  93754. export interface DistanceJointData extends PhysicsJointData {
  93755. /**
  93756. * Max distance the 2 joint objects can be apart
  93757. */
  93758. maxDistance: number;
  93759. }
  93760. /**
  93761. * Joint data from a spring joint
  93762. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93763. */
  93764. export interface SpringJointData extends PhysicsJointData {
  93765. /**
  93766. * Length of the spring
  93767. */
  93768. length: number;
  93769. /**
  93770. * Stiffness of the spring
  93771. */
  93772. stiffness: number;
  93773. /**
  93774. * Damping of the spring
  93775. */
  93776. damping: number;
  93777. /** this callback will be called when applying the force to the impostors. */
  93778. forceApplicationCallback: () => void;
  93779. }
  93780. }
  93781. declare module BABYLON {
  93782. /**
  93783. * Holds the data for the raycast result
  93784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93785. */
  93786. export class PhysicsRaycastResult {
  93787. private _hasHit;
  93788. private _hitDistance;
  93789. private _hitNormalWorld;
  93790. private _hitPointWorld;
  93791. private _rayFromWorld;
  93792. private _rayToWorld;
  93793. /**
  93794. * Gets if there was a hit
  93795. */
  93796. get hasHit(): boolean;
  93797. /**
  93798. * Gets the distance from the hit
  93799. */
  93800. get hitDistance(): number;
  93801. /**
  93802. * Gets the hit normal/direction in the world
  93803. */
  93804. get hitNormalWorld(): Vector3;
  93805. /**
  93806. * Gets the hit point in the world
  93807. */
  93808. get hitPointWorld(): Vector3;
  93809. /**
  93810. * Gets the ray "start point" of the ray in the world
  93811. */
  93812. get rayFromWorld(): Vector3;
  93813. /**
  93814. * Gets the ray "end point" of the ray in the world
  93815. */
  93816. get rayToWorld(): Vector3;
  93817. /**
  93818. * Sets the hit data (normal & point in world space)
  93819. * @param hitNormalWorld defines the normal in world space
  93820. * @param hitPointWorld defines the point in world space
  93821. */
  93822. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  93823. /**
  93824. * Sets the distance from the start point to the hit point
  93825. * @param distance
  93826. */
  93827. setHitDistance(distance: number): void;
  93828. /**
  93829. * Calculates the distance manually
  93830. */
  93831. calculateHitDistance(): void;
  93832. /**
  93833. * Resets all the values to default
  93834. * @param from The from point on world space
  93835. * @param to The to point on world space
  93836. */
  93837. reset(from?: Vector3, to?: Vector3): void;
  93838. }
  93839. /**
  93840. * Interface for the size containing width and height
  93841. */
  93842. interface IXYZ {
  93843. /**
  93844. * X
  93845. */
  93846. x: number;
  93847. /**
  93848. * Y
  93849. */
  93850. y: number;
  93851. /**
  93852. * Z
  93853. */
  93854. z: number;
  93855. }
  93856. }
  93857. declare module BABYLON {
  93858. /**
  93859. * Interface used to describe a physics joint
  93860. */
  93861. export interface PhysicsImpostorJoint {
  93862. /** Defines the main impostor to which the joint is linked */
  93863. mainImpostor: PhysicsImpostor;
  93864. /** Defines the impostor that is connected to the main impostor using this joint */
  93865. connectedImpostor: PhysicsImpostor;
  93866. /** Defines the joint itself */
  93867. joint: PhysicsJoint;
  93868. }
  93869. /** @hidden */
  93870. export interface IPhysicsEnginePlugin {
  93871. world: any;
  93872. name: string;
  93873. setGravity(gravity: Vector3): void;
  93874. setTimeStep(timeStep: number): void;
  93875. getTimeStep(): number;
  93876. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  93877. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93878. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93879. generatePhysicsBody(impostor: PhysicsImpostor): void;
  93880. removePhysicsBody(impostor: PhysicsImpostor): void;
  93881. generateJoint(joint: PhysicsImpostorJoint): void;
  93882. removeJoint(joint: PhysicsImpostorJoint): void;
  93883. isSupported(): boolean;
  93884. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  93885. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  93886. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93887. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93888. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93889. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93890. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  93891. getBodyMass(impostor: PhysicsImpostor): number;
  93892. getBodyFriction(impostor: PhysicsImpostor): number;
  93893. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  93894. getBodyRestitution(impostor: PhysicsImpostor): number;
  93895. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  93896. getBodyPressure?(impostor: PhysicsImpostor): number;
  93897. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  93898. getBodyStiffness?(impostor: PhysicsImpostor): number;
  93899. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  93900. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  93901. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  93902. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  93903. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  93904. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93905. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93906. sleepBody(impostor: PhysicsImpostor): void;
  93907. wakeUpBody(impostor: PhysicsImpostor): void;
  93908. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93909. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  93910. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  93911. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93912. getRadius(impostor: PhysicsImpostor): number;
  93913. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  93914. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  93915. dispose(): void;
  93916. }
  93917. /**
  93918. * Interface used to define a physics engine
  93919. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  93920. */
  93921. export interface IPhysicsEngine {
  93922. /**
  93923. * Gets the gravity vector used by the simulation
  93924. */
  93925. gravity: Vector3;
  93926. /**
  93927. * Sets the gravity vector used by the simulation
  93928. * @param gravity defines the gravity vector to use
  93929. */
  93930. setGravity(gravity: Vector3): void;
  93931. /**
  93932. * Set the time step of the physics engine.
  93933. * Default is 1/60.
  93934. * To slow it down, enter 1/600 for example.
  93935. * To speed it up, 1/30
  93936. * @param newTimeStep the new timestep to apply to this world.
  93937. */
  93938. setTimeStep(newTimeStep: number): void;
  93939. /**
  93940. * Get the time step of the physics engine.
  93941. * @returns the current time step
  93942. */
  93943. getTimeStep(): number;
  93944. /**
  93945. * Set the sub time step of the physics engine.
  93946. * Default is 0 meaning there is no sub steps
  93947. * To increase physics resolution precision, set a small value (like 1 ms)
  93948. * @param subTimeStep defines the new sub timestep used for physics resolution.
  93949. */
  93950. setSubTimeStep(subTimeStep: number): void;
  93951. /**
  93952. * Get the sub time step of the physics engine.
  93953. * @returns the current sub time step
  93954. */
  93955. getSubTimeStep(): number;
  93956. /**
  93957. * Release all resources
  93958. */
  93959. dispose(): void;
  93960. /**
  93961. * Gets the name of the current physics plugin
  93962. * @returns the name of the plugin
  93963. */
  93964. getPhysicsPluginName(): string;
  93965. /**
  93966. * Adding a new impostor for the impostor tracking.
  93967. * This will be done by the impostor itself.
  93968. * @param impostor the impostor to add
  93969. */
  93970. addImpostor(impostor: PhysicsImpostor): void;
  93971. /**
  93972. * Remove an impostor from the engine.
  93973. * This impostor and its mesh will not longer be updated by the physics engine.
  93974. * @param impostor the impostor to remove
  93975. */
  93976. removeImpostor(impostor: PhysicsImpostor): void;
  93977. /**
  93978. * Add a joint to the physics engine
  93979. * @param mainImpostor defines the main impostor to which the joint is added.
  93980. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  93981. * @param joint defines the joint that will connect both impostors.
  93982. */
  93983. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93984. /**
  93985. * Removes a joint from the simulation
  93986. * @param mainImpostor defines the impostor used with the joint
  93987. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  93988. * @param joint defines the joint to remove
  93989. */
  93990. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93991. /**
  93992. * Gets the current plugin used to run the simulation
  93993. * @returns current plugin
  93994. */
  93995. getPhysicsPlugin(): IPhysicsEnginePlugin;
  93996. /**
  93997. * Gets the list of physic impostors
  93998. * @returns an array of PhysicsImpostor
  93999. */
  94000. getImpostors(): Array<PhysicsImpostor>;
  94001. /**
  94002. * Gets the impostor for a physics enabled object
  94003. * @param object defines the object impersonated by the impostor
  94004. * @returns the PhysicsImpostor or null if not found
  94005. */
  94006. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94007. /**
  94008. * Gets the impostor for a physics body object
  94009. * @param body defines physics body used by the impostor
  94010. * @returns the PhysicsImpostor or null if not found
  94011. */
  94012. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  94013. /**
  94014. * Does a raycast in the physics world
  94015. * @param from when should the ray start?
  94016. * @param to when should the ray end?
  94017. * @returns PhysicsRaycastResult
  94018. */
  94019. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  94020. /**
  94021. * Called by the scene. No need to call it.
  94022. * @param delta defines the timespam between frames
  94023. */
  94024. _step(delta: number): void;
  94025. }
  94026. }
  94027. declare module BABYLON {
  94028. /**
  94029. * The interface for the physics imposter parameters
  94030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94031. */
  94032. export interface PhysicsImpostorParameters {
  94033. /**
  94034. * The mass of the physics imposter
  94035. */
  94036. mass: number;
  94037. /**
  94038. * The friction of the physics imposter
  94039. */
  94040. friction?: number;
  94041. /**
  94042. * The coefficient of restitution of the physics imposter
  94043. */
  94044. restitution?: number;
  94045. /**
  94046. * The native options of the physics imposter
  94047. */
  94048. nativeOptions?: any;
  94049. /**
  94050. * Specifies if the parent should be ignored
  94051. */
  94052. ignoreParent?: boolean;
  94053. /**
  94054. * Specifies if bi-directional transformations should be disabled
  94055. */
  94056. disableBidirectionalTransformation?: boolean;
  94057. /**
  94058. * The pressure inside the physics imposter, soft object only
  94059. */
  94060. pressure?: number;
  94061. /**
  94062. * The stiffness the physics imposter, soft object only
  94063. */
  94064. stiffness?: number;
  94065. /**
  94066. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  94067. */
  94068. velocityIterations?: number;
  94069. /**
  94070. * The number of iterations used in maintaining consistent vertex positions, soft object only
  94071. */
  94072. positionIterations?: number;
  94073. /**
  94074. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  94075. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  94076. * Add to fix multiple points
  94077. */
  94078. fixedPoints?: number;
  94079. /**
  94080. * The collision margin around a soft object
  94081. */
  94082. margin?: number;
  94083. /**
  94084. * The collision margin around a soft object
  94085. */
  94086. damping?: number;
  94087. /**
  94088. * The path for a rope based on an extrusion
  94089. */
  94090. path?: any;
  94091. /**
  94092. * The shape of an extrusion used for a rope based on an extrusion
  94093. */
  94094. shape?: any;
  94095. }
  94096. /**
  94097. * Interface for a physics-enabled object
  94098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94099. */
  94100. export interface IPhysicsEnabledObject {
  94101. /**
  94102. * The position of the physics-enabled object
  94103. */
  94104. position: Vector3;
  94105. /**
  94106. * The rotation of the physics-enabled object
  94107. */
  94108. rotationQuaternion: Nullable<Quaternion>;
  94109. /**
  94110. * The scale of the physics-enabled object
  94111. */
  94112. scaling: Vector3;
  94113. /**
  94114. * The rotation of the physics-enabled object
  94115. */
  94116. rotation?: Vector3;
  94117. /**
  94118. * The parent of the physics-enabled object
  94119. */
  94120. parent?: any;
  94121. /**
  94122. * The bounding info of the physics-enabled object
  94123. * @returns The bounding info of the physics-enabled object
  94124. */
  94125. getBoundingInfo(): BoundingInfo;
  94126. /**
  94127. * Computes the world matrix
  94128. * @param force Specifies if the world matrix should be computed by force
  94129. * @returns A world matrix
  94130. */
  94131. computeWorldMatrix(force: boolean): Matrix;
  94132. /**
  94133. * Gets the world matrix
  94134. * @returns A world matrix
  94135. */
  94136. getWorldMatrix?(): Matrix;
  94137. /**
  94138. * Gets the child meshes
  94139. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  94140. * @returns An array of abstract meshes
  94141. */
  94142. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  94143. /**
  94144. * Gets the vertex data
  94145. * @param kind The type of vertex data
  94146. * @returns A nullable array of numbers, or a float32 array
  94147. */
  94148. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  94149. /**
  94150. * Gets the indices from the mesh
  94151. * @returns A nullable array of index arrays
  94152. */
  94153. getIndices?(): Nullable<IndicesArray>;
  94154. /**
  94155. * Gets the scene from the mesh
  94156. * @returns the indices array or null
  94157. */
  94158. getScene?(): Scene;
  94159. /**
  94160. * Gets the absolute position from the mesh
  94161. * @returns the absolute position
  94162. */
  94163. getAbsolutePosition(): Vector3;
  94164. /**
  94165. * Gets the absolute pivot point from the mesh
  94166. * @returns the absolute pivot point
  94167. */
  94168. getAbsolutePivotPoint(): Vector3;
  94169. /**
  94170. * Rotates the mesh
  94171. * @param axis The axis of rotation
  94172. * @param amount The amount of rotation
  94173. * @param space The space of the rotation
  94174. * @returns The rotation transform node
  94175. */
  94176. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94177. /**
  94178. * Translates the mesh
  94179. * @param axis The axis of translation
  94180. * @param distance The distance of translation
  94181. * @param space The space of the translation
  94182. * @returns The transform node
  94183. */
  94184. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94185. /**
  94186. * Sets the absolute position of the mesh
  94187. * @param absolutePosition The absolute position of the mesh
  94188. * @returns The transform node
  94189. */
  94190. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94191. /**
  94192. * Gets the class name of the mesh
  94193. * @returns The class name
  94194. */
  94195. getClassName(): string;
  94196. }
  94197. /**
  94198. * Represents a physics imposter
  94199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94200. */
  94201. export class PhysicsImpostor {
  94202. /**
  94203. * The physics-enabled object used as the physics imposter
  94204. */
  94205. object: IPhysicsEnabledObject;
  94206. /**
  94207. * The type of the physics imposter
  94208. */
  94209. type: number;
  94210. private _options;
  94211. private _scene?;
  94212. /**
  94213. * The default object size of the imposter
  94214. */
  94215. static DEFAULT_OBJECT_SIZE: Vector3;
  94216. /**
  94217. * The identity quaternion of the imposter
  94218. */
  94219. static IDENTITY_QUATERNION: Quaternion;
  94220. /** @hidden */
  94221. _pluginData: any;
  94222. private _physicsEngine;
  94223. private _physicsBody;
  94224. private _bodyUpdateRequired;
  94225. private _onBeforePhysicsStepCallbacks;
  94226. private _onAfterPhysicsStepCallbacks;
  94227. /** @hidden */
  94228. _onPhysicsCollideCallbacks: Array<{
  94229. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  94230. otherImpostors: Array<PhysicsImpostor>;
  94231. }>;
  94232. private _deltaPosition;
  94233. private _deltaRotation;
  94234. private _deltaRotationConjugated;
  94235. /** @hidden */
  94236. _isFromLine: boolean;
  94237. private _parent;
  94238. private _isDisposed;
  94239. private static _tmpVecs;
  94240. private static _tmpQuat;
  94241. /**
  94242. * Specifies if the physics imposter is disposed
  94243. */
  94244. get isDisposed(): boolean;
  94245. /**
  94246. * Gets the mass of the physics imposter
  94247. */
  94248. get mass(): number;
  94249. set mass(value: number);
  94250. /**
  94251. * Gets the coefficient of friction
  94252. */
  94253. get friction(): number;
  94254. /**
  94255. * Sets the coefficient of friction
  94256. */
  94257. set friction(value: number);
  94258. /**
  94259. * Gets the coefficient of restitution
  94260. */
  94261. get restitution(): number;
  94262. /**
  94263. * Sets the coefficient of restitution
  94264. */
  94265. set restitution(value: number);
  94266. /**
  94267. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  94268. */
  94269. get pressure(): number;
  94270. /**
  94271. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  94272. */
  94273. set pressure(value: number);
  94274. /**
  94275. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94276. */
  94277. get stiffness(): number;
  94278. /**
  94279. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94280. */
  94281. set stiffness(value: number);
  94282. /**
  94283. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94284. */
  94285. get velocityIterations(): number;
  94286. /**
  94287. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94288. */
  94289. set velocityIterations(value: number);
  94290. /**
  94291. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94292. */
  94293. get positionIterations(): number;
  94294. /**
  94295. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94296. */
  94297. set positionIterations(value: number);
  94298. /**
  94299. * The unique id of the physics imposter
  94300. * set by the physics engine when adding this impostor to the array
  94301. */
  94302. uniqueId: number;
  94303. /**
  94304. * @hidden
  94305. */
  94306. soft: boolean;
  94307. /**
  94308. * @hidden
  94309. */
  94310. segments: number;
  94311. private _joints;
  94312. /**
  94313. * Initializes the physics imposter
  94314. * @param object The physics-enabled object used as the physics imposter
  94315. * @param type The type of the physics imposter
  94316. * @param _options The options for the physics imposter
  94317. * @param _scene The Babylon scene
  94318. */
  94319. constructor(
  94320. /**
  94321. * The physics-enabled object used as the physics imposter
  94322. */
  94323. object: IPhysicsEnabledObject,
  94324. /**
  94325. * The type of the physics imposter
  94326. */
  94327. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  94328. /**
  94329. * This function will completly initialize this impostor.
  94330. * It will create a new body - but only if this mesh has no parent.
  94331. * If it has, this impostor will not be used other than to define the impostor
  94332. * of the child mesh.
  94333. * @hidden
  94334. */
  94335. _init(): void;
  94336. private _getPhysicsParent;
  94337. /**
  94338. * Should a new body be generated.
  94339. * @returns boolean specifying if body initialization is required
  94340. */
  94341. isBodyInitRequired(): boolean;
  94342. /**
  94343. * Sets the updated scaling
  94344. * @param updated Specifies if the scaling is updated
  94345. */
  94346. setScalingUpdated(): void;
  94347. /**
  94348. * Force a regeneration of this or the parent's impostor's body.
  94349. * Use under cautious - This will remove all joints already implemented.
  94350. */
  94351. forceUpdate(): void;
  94352. /**
  94353. * Gets the body that holds this impostor. Either its own, or its parent.
  94354. */
  94355. get physicsBody(): any;
  94356. /**
  94357. * Get the parent of the physics imposter
  94358. * @returns Physics imposter or null
  94359. */
  94360. get parent(): Nullable<PhysicsImpostor>;
  94361. /**
  94362. * Sets the parent of the physics imposter
  94363. */
  94364. set parent(value: Nullable<PhysicsImpostor>);
  94365. /**
  94366. * Set the physics body. Used mainly by the physics engine/plugin
  94367. */
  94368. set physicsBody(physicsBody: any);
  94369. /**
  94370. * Resets the update flags
  94371. */
  94372. resetUpdateFlags(): void;
  94373. /**
  94374. * Gets the object extend size
  94375. * @returns the object extend size
  94376. */
  94377. getObjectExtendSize(): Vector3;
  94378. /**
  94379. * Gets the object center
  94380. * @returns The object center
  94381. */
  94382. getObjectCenter(): Vector3;
  94383. /**
  94384. * Get a specific parametes from the options parameter
  94385. * @param paramName The object parameter name
  94386. * @returns The object parameter
  94387. */
  94388. getParam(paramName: string): any;
  94389. /**
  94390. * Sets a specific parameter in the options given to the physics plugin
  94391. * @param paramName The parameter name
  94392. * @param value The value of the parameter
  94393. */
  94394. setParam(paramName: string, value: number): void;
  94395. /**
  94396. * Specifically change the body's mass option. Won't recreate the physics body object
  94397. * @param mass The mass of the physics imposter
  94398. */
  94399. setMass(mass: number): void;
  94400. /**
  94401. * Gets the linear velocity
  94402. * @returns linear velocity or null
  94403. */
  94404. getLinearVelocity(): Nullable<Vector3>;
  94405. /**
  94406. * Sets the linear velocity
  94407. * @param velocity linear velocity or null
  94408. */
  94409. setLinearVelocity(velocity: Nullable<Vector3>): void;
  94410. /**
  94411. * Gets the angular velocity
  94412. * @returns angular velocity or null
  94413. */
  94414. getAngularVelocity(): Nullable<Vector3>;
  94415. /**
  94416. * Sets the angular velocity
  94417. * @param velocity The velocity or null
  94418. */
  94419. setAngularVelocity(velocity: Nullable<Vector3>): void;
  94420. /**
  94421. * Execute a function with the physics plugin native code
  94422. * Provide a function the will have two variables - the world object and the physics body object
  94423. * @param func The function to execute with the physics plugin native code
  94424. */
  94425. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  94426. /**
  94427. * Register a function that will be executed before the physics world is stepping forward
  94428. * @param func The function to execute before the physics world is stepped forward
  94429. */
  94430. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94431. /**
  94432. * Unregister a function that will be executed before the physics world is stepping forward
  94433. * @param func The function to execute before the physics world is stepped forward
  94434. */
  94435. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94436. /**
  94437. * Register a function that will be executed after the physics step
  94438. * @param func The function to execute after physics step
  94439. */
  94440. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94441. /**
  94442. * Unregisters a function that will be executed after the physics step
  94443. * @param func The function to execute after physics step
  94444. */
  94445. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94446. /**
  94447. * register a function that will be executed when this impostor collides against a different body
  94448. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  94449. * @param func Callback that is executed on collision
  94450. */
  94451. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  94452. /**
  94453. * Unregisters the physics imposter on contact
  94454. * @param collideAgainst The physics object to collide against
  94455. * @param func Callback to execute on collision
  94456. */
  94457. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  94458. private _tmpQuat;
  94459. private _tmpQuat2;
  94460. /**
  94461. * Get the parent rotation
  94462. * @returns The parent rotation
  94463. */
  94464. getParentsRotation(): Quaternion;
  94465. /**
  94466. * this function is executed by the physics engine.
  94467. */
  94468. beforeStep: () => void;
  94469. /**
  94470. * this function is executed by the physics engine
  94471. */
  94472. afterStep: () => void;
  94473. /**
  94474. * Legacy collision detection event support
  94475. */
  94476. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  94477. /**
  94478. * event and body object due to cannon's event-based architecture.
  94479. */
  94480. onCollide: (e: {
  94481. body: any;
  94482. }) => void;
  94483. /**
  94484. * Apply a force
  94485. * @param force The force to apply
  94486. * @param contactPoint The contact point for the force
  94487. * @returns The physics imposter
  94488. */
  94489. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94490. /**
  94491. * Apply an impulse
  94492. * @param force The impulse force
  94493. * @param contactPoint The contact point for the impulse force
  94494. * @returns The physics imposter
  94495. */
  94496. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94497. /**
  94498. * A help function to create a joint
  94499. * @param otherImpostor A physics imposter used to create a joint
  94500. * @param jointType The type of joint
  94501. * @param jointData The data for the joint
  94502. * @returns The physics imposter
  94503. */
  94504. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  94505. /**
  94506. * Add a joint to this impostor with a different impostor
  94507. * @param otherImpostor A physics imposter used to add a joint
  94508. * @param joint The joint to add
  94509. * @returns The physics imposter
  94510. */
  94511. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  94512. /**
  94513. * Add an anchor to a cloth impostor
  94514. * @param otherImpostor rigid impostor to anchor to
  94515. * @param width ratio across width from 0 to 1
  94516. * @param height ratio up height from 0 to 1
  94517. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  94518. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  94519. * @returns impostor the soft imposter
  94520. */
  94521. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94522. /**
  94523. * Add a hook to a rope impostor
  94524. * @param otherImpostor rigid impostor to anchor to
  94525. * @param length ratio across rope from 0 to 1
  94526. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  94527. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  94528. * @returns impostor the rope imposter
  94529. */
  94530. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94531. /**
  94532. * Will keep this body still, in a sleep mode.
  94533. * @returns the physics imposter
  94534. */
  94535. sleep(): PhysicsImpostor;
  94536. /**
  94537. * Wake the body up.
  94538. * @returns The physics imposter
  94539. */
  94540. wakeUp(): PhysicsImpostor;
  94541. /**
  94542. * Clones the physics imposter
  94543. * @param newObject The physics imposter clones to this physics-enabled object
  94544. * @returns A nullable physics imposter
  94545. */
  94546. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94547. /**
  94548. * Disposes the physics imposter
  94549. */
  94550. dispose(): void;
  94551. /**
  94552. * Sets the delta position
  94553. * @param position The delta position amount
  94554. */
  94555. setDeltaPosition(position: Vector3): void;
  94556. /**
  94557. * Sets the delta rotation
  94558. * @param rotation The delta rotation amount
  94559. */
  94560. setDeltaRotation(rotation: Quaternion): void;
  94561. /**
  94562. * Gets the box size of the physics imposter and stores the result in the input parameter
  94563. * @param result Stores the box size
  94564. * @returns The physics imposter
  94565. */
  94566. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  94567. /**
  94568. * Gets the radius of the physics imposter
  94569. * @returns Radius of the physics imposter
  94570. */
  94571. getRadius(): number;
  94572. /**
  94573. * Sync a bone with this impostor
  94574. * @param bone The bone to sync to the impostor.
  94575. * @param boneMesh The mesh that the bone is influencing.
  94576. * @param jointPivot The pivot of the joint / bone in local space.
  94577. * @param distToJoint Optional distance from the impostor to the joint.
  94578. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94579. */
  94580. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  94581. /**
  94582. * Sync impostor to a bone
  94583. * @param bone The bone that the impostor will be synced to.
  94584. * @param boneMesh The mesh that the bone is influencing.
  94585. * @param jointPivot The pivot of the joint / bone in local space.
  94586. * @param distToJoint Optional distance from the impostor to the joint.
  94587. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94588. * @param boneAxis Optional vector3 axis the bone is aligned with
  94589. */
  94590. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  94591. /**
  94592. * No-Imposter type
  94593. */
  94594. static NoImpostor: number;
  94595. /**
  94596. * Sphere-Imposter type
  94597. */
  94598. static SphereImpostor: number;
  94599. /**
  94600. * Box-Imposter type
  94601. */
  94602. static BoxImpostor: number;
  94603. /**
  94604. * Plane-Imposter type
  94605. */
  94606. static PlaneImpostor: number;
  94607. /**
  94608. * Mesh-imposter type
  94609. */
  94610. static MeshImpostor: number;
  94611. /**
  94612. * Capsule-Impostor type (Ammo.js plugin only)
  94613. */
  94614. static CapsuleImpostor: number;
  94615. /**
  94616. * Cylinder-Imposter type
  94617. */
  94618. static CylinderImpostor: number;
  94619. /**
  94620. * Particle-Imposter type
  94621. */
  94622. static ParticleImpostor: number;
  94623. /**
  94624. * Heightmap-Imposter type
  94625. */
  94626. static HeightmapImpostor: number;
  94627. /**
  94628. * ConvexHull-Impostor type (Ammo.js plugin only)
  94629. */
  94630. static ConvexHullImpostor: number;
  94631. /**
  94632. * Custom-Imposter type (Ammo.js plugin only)
  94633. */
  94634. static CustomImpostor: number;
  94635. /**
  94636. * Rope-Imposter type
  94637. */
  94638. static RopeImpostor: number;
  94639. /**
  94640. * Cloth-Imposter type
  94641. */
  94642. static ClothImpostor: number;
  94643. /**
  94644. * Softbody-Imposter type
  94645. */
  94646. static SoftbodyImpostor: number;
  94647. }
  94648. }
  94649. declare module BABYLON {
  94650. /**
  94651. * @hidden
  94652. **/
  94653. export class _CreationDataStorage {
  94654. closePath?: boolean;
  94655. closeArray?: boolean;
  94656. idx: number[];
  94657. dashSize: number;
  94658. gapSize: number;
  94659. path3D: Path3D;
  94660. pathArray: Vector3[][];
  94661. arc: number;
  94662. radius: number;
  94663. cap: number;
  94664. tessellation: number;
  94665. }
  94666. /**
  94667. * @hidden
  94668. **/
  94669. class _InstanceDataStorage {
  94670. visibleInstances: any;
  94671. batchCache: _InstancesBatch;
  94672. instancesBufferSize: number;
  94673. instancesBuffer: Nullable<Buffer>;
  94674. instancesData: Float32Array;
  94675. overridenInstanceCount: number;
  94676. isFrozen: boolean;
  94677. previousBatch: Nullable<_InstancesBatch>;
  94678. hardwareInstancedRendering: boolean;
  94679. sideOrientation: number;
  94680. manualUpdate: boolean;
  94681. }
  94682. /**
  94683. * @hidden
  94684. **/
  94685. export class _InstancesBatch {
  94686. mustReturn: boolean;
  94687. visibleInstances: Nullable<InstancedMesh[]>[];
  94688. renderSelf: boolean[];
  94689. hardwareInstancedRendering: boolean[];
  94690. }
  94691. /**
  94692. * Class used to represent renderable models
  94693. */
  94694. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  94695. /**
  94696. * Mesh side orientation : usually the external or front surface
  94697. */
  94698. static readonly FRONTSIDE: number;
  94699. /**
  94700. * Mesh side orientation : usually the internal or back surface
  94701. */
  94702. static readonly BACKSIDE: number;
  94703. /**
  94704. * Mesh side orientation : both internal and external or front and back surfaces
  94705. */
  94706. static readonly DOUBLESIDE: number;
  94707. /**
  94708. * Mesh side orientation : by default, `FRONTSIDE`
  94709. */
  94710. static readonly DEFAULTSIDE: number;
  94711. /**
  94712. * Mesh cap setting : no cap
  94713. */
  94714. static readonly NO_CAP: number;
  94715. /**
  94716. * Mesh cap setting : one cap at the beginning of the mesh
  94717. */
  94718. static readonly CAP_START: number;
  94719. /**
  94720. * Mesh cap setting : one cap at the end of the mesh
  94721. */
  94722. static readonly CAP_END: number;
  94723. /**
  94724. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  94725. */
  94726. static readonly CAP_ALL: number;
  94727. /**
  94728. * Mesh pattern setting : no flip or rotate
  94729. */
  94730. static readonly NO_FLIP: number;
  94731. /**
  94732. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  94733. */
  94734. static readonly FLIP_TILE: number;
  94735. /**
  94736. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  94737. */
  94738. static readonly ROTATE_TILE: number;
  94739. /**
  94740. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  94741. */
  94742. static readonly FLIP_ROW: number;
  94743. /**
  94744. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  94745. */
  94746. static readonly ROTATE_ROW: number;
  94747. /**
  94748. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  94749. */
  94750. static readonly FLIP_N_ROTATE_TILE: number;
  94751. /**
  94752. * Mesh pattern setting : rotate pattern and rotate
  94753. */
  94754. static readonly FLIP_N_ROTATE_ROW: number;
  94755. /**
  94756. * Mesh tile positioning : part tiles same on left/right or top/bottom
  94757. */
  94758. static readonly CENTER: number;
  94759. /**
  94760. * Mesh tile positioning : part tiles on left
  94761. */
  94762. static readonly LEFT: number;
  94763. /**
  94764. * Mesh tile positioning : part tiles on right
  94765. */
  94766. static readonly RIGHT: number;
  94767. /**
  94768. * Mesh tile positioning : part tiles on top
  94769. */
  94770. static readonly TOP: number;
  94771. /**
  94772. * Mesh tile positioning : part tiles on bottom
  94773. */
  94774. static readonly BOTTOM: number;
  94775. /**
  94776. * Gets the default side orientation.
  94777. * @param orientation the orientation to value to attempt to get
  94778. * @returns the default orientation
  94779. * @hidden
  94780. */
  94781. static _GetDefaultSideOrientation(orientation?: number): number;
  94782. private _internalMeshDataInfo;
  94783. /**
  94784. * An event triggered before rendering the mesh
  94785. */
  94786. get onBeforeRenderObservable(): Observable<Mesh>;
  94787. /**
  94788. * An event triggered before binding the mesh
  94789. */
  94790. get onBeforeBindObservable(): Observable<Mesh>;
  94791. /**
  94792. * An event triggered after rendering the mesh
  94793. */
  94794. get onAfterRenderObservable(): Observable<Mesh>;
  94795. /**
  94796. * An event triggered before drawing the mesh
  94797. */
  94798. get onBeforeDrawObservable(): Observable<Mesh>;
  94799. private _onBeforeDrawObserver;
  94800. /**
  94801. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  94802. */
  94803. set onBeforeDraw(callback: () => void);
  94804. get hasInstances(): boolean;
  94805. /**
  94806. * Gets the delay loading state of the mesh (when delay loading is turned on)
  94807. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  94808. */
  94809. delayLoadState: number;
  94810. /**
  94811. * Gets the list of instances created from this mesh
  94812. * it is not supposed to be modified manually.
  94813. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  94814. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94815. */
  94816. instances: InstancedMesh[];
  94817. /**
  94818. * Gets the file containing delay loading data for this mesh
  94819. */
  94820. delayLoadingFile: string;
  94821. /** @hidden */
  94822. _binaryInfo: any;
  94823. /**
  94824. * User defined function used to change how LOD level selection is done
  94825. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  94826. */
  94827. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  94828. /**
  94829. * Gets or sets the morph target manager
  94830. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  94831. */
  94832. get morphTargetManager(): Nullable<MorphTargetManager>;
  94833. set morphTargetManager(value: Nullable<MorphTargetManager>);
  94834. /** @hidden */
  94835. _creationDataStorage: Nullable<_CreationDataStorage>;
  94836. /** @hidden */
  94837. _geometry: Nullable<Geometry>;
  94838. /** @hidden */
  94839. _delayInfo: Array<string>;
  94840. /** @hidden */
  94841. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  94842. /** @hidden */
  94843. _instanceDataStorage: _InstanceDataStorage;
  94844. private _effectiveMaterial;
  94845. /** @hidden */
  94846. _shouldGenerateFlatShading: boolean;
  94847. /** @hidden */
  94848. _originalBuilderSideOrientation: number;
  94849. /**
  94850. * Use this property to change the original side orientation defined at construction time
  94851. */
  94852. overrideMaterialSideOrientation: Nullable<number>;
  94853. /**
  94854. * Gets the source mesh (the one used to clone this one from)
  94855. */
  94856. get source(): Nullable<Mesh>;
  94857. /**
  94858. * Gets or sets a boolean indicating that this mesh does not use index buffer
  94859. */
  94860. get isUnIndexed(): boolean;
  94861. set isUnIndexed(value: boolean);
  94862. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  94863. get worldMatrixInstancedBuffer(): Float32Array;
  94864. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  94865. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  94866. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  94867. /**
  94868. * @constructor
  94869. * @param name The value used by scene.getMeshByName() to do a lookup.
  94870. * @param scene The scene to add this mesh to.
  94871. * @param parent The parent of this mesh, if it has one
  94872. * @param source An optional Mesh from which geometry is shared, cloned.
  94873. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94874. * When false, achieved by calling a clone(), also passing False.
  94875. * This will make creation of children, recursive.
  94876. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  94877. */
  94878. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  94879. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94880. doNotInstantiate: boolean;
  94881. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94882. /**
  94883. * Gets the class name
  94884. * @returns the string "Mesh".
  94885. */
  94886. getClassName(): string;
  94887. /** @hidden */
  94888. get _isMesh(): boolean;
  94889. /**
  94890. * Returns a description of this mesh
  94891. * @param fullDetails define if full details about this mesh must be used
  94892. * @returns a descriptive string representing this mesh
  94893. */
  94894. toString(fullDetails?: boolean): string;
  94895. /** @hidden */
  94896. _unBindEffect(): void;
  94897. /**
  94898. * Gets a boolean indicating if this mesh has LOD
  94899. */
  94900. get hasLODLevels(): boolean;
  94901. /**
  94902. * Gets the list of MeshLODLevel associated with the current mesh
  94903. * @returns an array of MeshLODLevel
  94904. */
  94905. getLODLevels(): MeshLODLevel[];
  94906. private _sortLODLevels;
  94907. /**
  94908. * Add a mesh as LOD level triggered at the given distance.
  94909. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94910. * @param distance The distance from the center of the object to show this level
  94911. * @param mesh The mesh to be added as LOD level (can be null)
  94912. * @return This mesh (for chaining)
  94913. */
  94914. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  94915. /**
  94916. * Returns the LOD level mesh at the passed distance or null if not found.
  94917. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94918. * @param distance The distance from the center of the object to show this level
  94919. * @returns a Mesh or `null`
  94920. */
  94921. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  94922. /**
  94923. * Remove a mesh from the LOD array
  94924. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94925. * @param mesh defines the mesh to be removed
  94926. * @return This mesh (for chaining)
  94927. */
  94928. removeLODLevel(mesh: Mesh): Mesh;
  94929. /**
  94930. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  94931. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94932. * @param camera defines the camera to use to compute distance
  94933. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  94934. * @return This mesh (for chaining)
  94935. */
  94936. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  94937. /**
  94938. * Gets the mesh internal Geometry object
  94939. */
  94940. get geometry(): Nullable<Geometry>;
  94941. /**
  94942. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  94943. * @returns the total number of vertices
  94944. */
  94945. getTotalVertices(): number;
  94946. /**
  94947. * Returns the content of an associated vertex buffer
  94948. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94949. * - VertexBuffer.PositionKind
  94950. * - VertexBuffer.UVKind
  94951. * - VertexBuffer.UV2Kind
  94952. * - VertexBuffer.UV3Kind
  94953. * - VertexBuffer.UV4Kind
  94954. * - VertexBuffer.UV5Kind
  94955. * - VertexBuffer.UV6Kind
  94956. * - VertexBuffer.ColorKind
  94957. * - VertexBuffer.MatricesIndicesKind
  94958. * - VertexBuffer.MatricesIndicesExtraKind
  94959. * - VertexBuffer.MatricesWeightsKind
  94960. * - VertexBuffer.MatricesWeightsExtraKind
  94961. * @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
  94962. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  94963. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  94964. */
  94965. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94966. /**
  94967. * Returns the mesh VertexBuffer object from the requested `kind`
  94968. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94969. * - VertexBuffer.PositionKind
  94970. * - VertexBuffer.NormalKind
  94971. * - VertexBuffer.UVKind
  94972. * - VertexBuffer.UV2Kind
  94973. * - VertexBuffer.UV3Kind
  94974. * - VertexBuffer.UV4Kind
  94975. * - VertexBuffer.UV5Kind
  94976. * - VertexBuffer.UV6Kind
  94977. * - VertexBuffer.ColorKind
  94978. * - VertexBuffer.MatricesIndicesKind
  94979. * - VertexBuffer.MatricesIndicesExtraKind
  94980. * - VertexBuffer.MatricesWeightsKind
  94981. * - VertexBuffer.MatricesWeightsExtraKind
  94982. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  94983. */
  94984. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94985. /**
  94986. * Tests if a specific vertex buffer is associated with this mesh
  94987. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94988. * - VertexBuffer.PositionKind
  94989. * - VertexBuffer.NormalKind
  94990. * - VertexBuffer.UVKind
  94991. * - VertexBuffer.UV2Kind
  94992. * - VertexBuffer.UV3Kind
  94993. * - VertexBuffer.UV4Kind
  94994. * - VertexBuffer.UV5Kind
  94995. * - VertexBuffer.UV6Kind
  94996. * - VertexBuffer.ColorKind
  94997. * - VertexBuffer.MatricesIndicesKind
  94998. * - VertexBuffer.MatricesIndicesExtraKind
  94999. * - VertexBuffer.MatricesWeightsKind
  95000. * - VertexBuffer.MatricesWeightsExtraKind
  95001. * @returns a boolean
  95002. */
  95003. isVerticesDataPresent(kind: string): boolean;
  95004. /**
  95005. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  95006. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  95007. * - VertexBuffer.PositionKind
  95008. * - VertexBuffer.UVKind
  95009. * - VertexBuffer.UV2Kind
  95010. * - VertexBuffer.UV3Kind
  95011. * - VertexBuffer.UV4Kind
  95012. * - VertexBuffer.UV5Kind
  95013. * - VertexBuffer.UV6Kind
  95014. * - VertexBuffer.ColorKind
  95015. * - VertexBuffer.MatricesIndicesKind
  95016. * - VertexBuffer.MatricesIndicesExtraKind
  95017. * - VertexBuffer.MatricesWeightsKind
  95018. * - VertexBuffer.MatricesWeightsExtraKind
  95019. * @returns a boolean
  95020. */
  95021. isVertexBufferUpdatable(kind: string): boolean;
  95022. /**
  95023. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  95024. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  95025. * - VertexBuffer.PositionKind
  95026. * - VertexBuffer.NormalKind
  95027. * - VertexBuffer.UVKind
  95028. * - VertexBuffer.UV2Kind
  95029. * - VertexBuffer.UV3Kind
  95030. * - VertexBuffer.UV4Kind
  95031. * - VertexBuffer.UV5Kind
  95032. * - VertexBuffer.UV6Kind
  95033. * - VertexBuffer.ColorKind
  95034. * - VertexBuffer.MatricesIndicesKind
  95035. * - VertexBuffer.MatricesIndicesExtraKind
  95036. * - VertexBuffer.MatricesWeightsKind
  95037. * - VertexBuffer.MatricesWeightsExtraKind
  95038. * @returns an array of strings
  95039. */
  95040. getVerticesDataKinds(): string[];
  95041. /**
  95042. * Returns a positive integer : the total number of indices in this mesh geometry.
  95043. * @returns the numner of indices or zero if the mesh has no geometry.
  95044. */
  95045. getTotalIndices(): number;
  95046. /**
  95047. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95048. * @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.
  95049. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95050. * @returns the indices array or an empty array if the mesh has no geometry
  95051. */
  95052. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95053. get isBlocked(): boolean;
  95054. /**
  95055. * Determine if the current mesh is ready to be rendered
  95056. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95057. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  95058. * @returns true if all associated assets are ready (material, textures, shaders)
  95059. */
  95060. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  95061. /**
  95062. * 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.
  95063. */
  95064. get areNormalsFrozen(): boolean;
  95065. /**
  95066. * 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.
  95067. * @returns the current mesh
  95068. */
  95069. freezeNormals(): Mesh;
  95070. /**
  95071. * 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
  95072. * @returns the current mesh
  95073. */
  95074. unfreezeNormals(): Mesh;
  95075. /**
  95076. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  95077. */
  95078. set overridenInstanceCount(count: number);
  95079. /** @hidden */
  95080. _preActivate(): Mesh;
  95081. /** @hidden */
  95082. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95083. /** @hidden */
  95084. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  95085. /**
  95086. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95087. * This means the mesh underlying bounding box and sphere are recomputed.
  95088. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95089. * @returns the current mesh
  95090. */
  95091. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  95092. /** @hidden */
  95093. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  95094. /**
  95095. * This function will subdivide the mesh into multiple submeshes
  95096. * @param count defines the expected number of submeshes
  95097. */
  95098. subdivide(count: number): void;
  95099. /**
  95100. * Copy a FloatArray into a specific associated vertex buffer
  95101. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95102. * - VertexBuffer.PositionKind
  95103. * - VertexBuffer.UVKind
  95104. * - VertexBuffer.UV2Kind
  95105. * - VertexBuffer.UV3Kind
  95106. * - VertexBuffer.UV4Kind
  95107. * - VertexBuffer.UV5Kind
  95108. * - VertexBuffer.UV6Kind
  95109. * - VertexBuffer.ColorKind
  95110. * - VertexBuffer.MatricesIndicesKind
  95111. * - VertexBuffer.MatricesIndicesExtraKind
  95112. * - VertexBuffer.MatricesWeightsKind
  95113. * - VertexBuffer.MatricesWeightsExtraKind
  95114. * @param data defines the data source
  95115. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95116. * @param stride defines the data stride size (can be null)
  95117. * @returns the current mesh
  95118. */
  95119. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95120. /**
  95121. * Delete a vertex buffer associated with this mesh
  95122. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  95123. * - VertexBuffer.PositionKind
  95124. * - VertexBuffer.UVKind
  95125. * - VertexBuffer.UV2Kind
  95126. * - VertexBuffer.UV3Kind
  95127. * - VertexBuffer.UV4Kind
  95128. * - VertexBuffer.UV5Kind
  95129. * - VertexBuffer.UV6Kind
  95130. * - VertexBuffer.ColorKind
  95131. * - VertexBuffer.MatricesIndicesKind
  95132. * - VertexBuffer.MatricesIndicesExtraKind
  95133. * - VertexBuffer.MatricesWeightsKind
  95134. * - VertexBuffer.MatricesWeightsExtraKind
  95135. */
  95136. removeVerticesData(kind: string): void;
  95137. /**
  95138. * Flags an associated vertex buffer as updatable
  95139. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  95140. * - VertexBuffer.PositionKind
  95141. * - VertexBuffer.UVKind
  95142. * - VertexBuffer.UV2Kind
  95143. * - VertexBuffer.UV3Kind
  95144. * - VertexBuffer.UV4Kind
  95145. * - VertexBuffer.UV5Kind
  95146. * - VertexBuffer.UV6Kind
  95147. * - VertexBuffer.ColorKind
  95148. * - VertexBuffer.MatricesIndicesKind
  95149. * - VertexBuffer.MatricesIndicesExtraKind
  95150. * - VertexBuffer.MatricesWeightsKind
  95151. * - VertexBuffer.MatricesWeightsExtraKind
  95152. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95153. */
  95154. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  95155. /**
  95156. * Sets the mesh global Vertex Buffer
  95157. * @param buffer defines the buffer to use
  95158. * @returns the current mesh
  95159. */
  95160. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  95161. /**
  95162. * Update a specific associated vertex buffer
  95163. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95164. * - VertexBuffer.PositionKind
  95165. * - VertexBuffer.UVKind
  95166. * - VertexBuffer.UV2Kind
  95167. * - VertexBuffer.UV3Kind
  95168. * - VertexBuffer.UV4Kind
  95169. * - VertexBuffer.UV5Kind
  95170. * - VertexBuffer.UV6Kind
  95171. * - VertexBuffer.ColorKind
  95172. * - VertexBuffer.MatricesIndicesKind
  95173. * - VertexBuffer.MatricesIndicesExtraKind
  95174. * - VertexBuffer.MatricesWeightsKind
  95175. * - VertexBuffer.MatricesWeightsExtraKind
  95176. * @param data defines the data source
  95177. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95178. * @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)
  95179. * @returns the current mesh
  95180. */
  95181. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95182. /**
  95183. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  95184. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  95185. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  95186. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  95187. * @returns the current mesh
  95188. */
  95189. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  95190. /**
  95191. * Creates a un-shared specific occurence of the geometry for the mesh.
  95192. * @returns the current mesh
  95193. */
  95194. makeGeometryUnique(): Mesh;
  95195. /**
  95196. * Set the index buffer of this mesh
  95197. * @param indices defines the source data
  95198. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  95199. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  95200. * @returns the current mesh
  95201. */
  95202. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  95203. /**
  95204. * Update the current index buffer
  95205. * @param indices defines the source data
  95206. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95207. * @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)
  95208. * @returns the current mesh
  95209. */
  95210. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95211. /**
  95212. * Invert the geometry to move from a right handed system to a left handed one.
  95213. * @returns the current mesh
  95214. */
  95215. toLeftHanded(): Mesh;
  95216. /** @hidden */
  95217. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95218. /** @hidden */
  95219. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95220. /**
  95221. * Registers for this mesh a javascript function called just before the rendering process
  95222. * @param func defines the function to call before rendering this mesh
  95223. * @returns the current mesh
  95224. */
  95225. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95226. /**
  95227. * Disposes a previously registered javascript function called before the rendering
  95228. * @param func defines the function to remove
  95229. * @returns the current mesh
  95230. */
  95231. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95232. /**
  95233. * Registers for this mesh a javascript function called just after the rendering is complete
  95234. * @param func defines the function to call after rendering this mesh
  95235. * @returns the current mesh
  95236. */
  95237. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95238. /**
  95239. * Disposes a previously registered javascript function called after the rendering.
  95240. * @param func defines the function to remove
  95241. * @returns the current mesh
  95242. */
  95243. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95244. /** @hidden */
  95245. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  95246. /** @hidden */
  95247. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  95248. /** @hidden */
  95249. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  95250. /** @hidden */
  95251. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  95252. /** @hidden */
  95253. _rebuild(): void;
  95254. /** @hidden */
  95255. _freeze(): void;
  95256. /** @hidden */
  95257. _unFreeze(): void;
  95258. /**
  95259. * 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
  95260. * @param subMesh defines the subMesh to render
  95261. * @param enableAlphaMode defines if alpha mode can be changed
  95262. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  95263. * @returns the current mesh
  95264. */
  95265. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  95266. private _onBeforeDraw;
  95267. /**
  95268. * Renormalize the mesh and patch it up if there are no weights
  95269. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  95270. * However in the case of zero weights then we set just a single influence to 1.
  95271. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  95272. */
  95273. cleanMatrixWeights(): void;
  95274. private normalizeSkinFourWeights;
  95275. private normalizeSkinWeightsAndExtra;
  95276. /**
  95277. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  95278. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  95279. * the user know there was an issue with importing the mesh
  95280. * @returns a validation object with skinned, valid and report string
  95281. */
  95282. validateSkinning(): {
  95283. skinned: boolean;
  95284. valid: boolean;
  95285. report: string;
  95286. };
  95287. /** @hidden */
  95288. _checkDelayState(): Mesh;
  95289. private _queueLoad;
  95290. /**
  95291. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95292. * A mesh is in the frustum if its bounding box intersects the frustum
  95293. * @param frustumPlanes defines the frustum to test
  95294. * @returns true if the mesh is in the frustum planes
  95295. */
  95296. isInFrustum(frustumPlanes: Plane[]): boolean;
  95297. /**
  95298. * Sets the mesh material by the material or multiMaterial `id` property
  95299. * @param id is a string identifying the material or the multiMaterial
  95300. * @returns the current mesh
  95301. */
  95302. setMaterialByID(id: string): Mesh;
  95303. /**
  95304. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  95305. * @returns an array of IAnimatable
  95306. */
  95307. getAnimatables(): IAnimatable[];
  95308. /**
  95309. * Modifies the mesh geometry according to the passed transformation matrix.
  95310. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  95311. * The mesh normals are modified using the same transformation.
  95312. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95313. * @param transform defines the transform matrix to use
  95314. * @see http://doc.babylonjs.com/resources/baking_transformations
  95315. * @returns the current mesh
  95316. */
  95317. bakeTransformIntoVertices(transform: Matrix): Mesh;
  95318. /**
  95319. * Modifies the mesh geometry according to its own current World Matrix.
  95320. * The mesh World Matrix is then reset.
  95321. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  95322. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95323. * @see http://doc.babylonjs.com/resources/baking_transformations
  95324. * @returns the current mesh
  95325. */
  95326. bakeCurrentTransformIntoVertices(): Mesh;
  95327. /** @hidden */
  95328. get _positions(): Nullable<Vector3[]>;
  95329. /** @hidden */
  95330. _resetPointsArrayCache(): Mesh;
  95331. /** @hidden */
  95332. _generatePointsArray(): boolean;
  95333. /**
  95334. * Returns a new Mesh object generated from the current mesh properties.
  95335. * This method must not get confused with createInstance()
  95336. * @param name is a string, the name given to the new mesh
  95337. * @param newParent can be any Node object (default `null`)
  95338. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  95339. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  95340. * @returns a new mesh
  95341. */
  95342. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  95343. /**
  95344. * Releases resources associated with this mesh.
  95345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95347. */
  95348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95349. /** @hidden */
  95350. _disposeInstanceSpecificData(): void;
  95351. /**
  95352. * Modifies the mesh geometry according to a displacement map.
  95353. * 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.
  95354. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95355. * @param url is a string, the URL from the image file is to be downloaded.
  95356. * @param minHeight is the lower limit of the displacement.
  95357. * @param maxHeight is the upper limit of the displacement.
  95358. * @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.
  95359. * @param uvOffset is an optional vector2 used to offset UV.
  95360. * @param uvScale is an optional vector2 used to scale UV.
  95361. * @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.
  95362. * @returns the Mesh.
  95363. */
  95364. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95365. /**
  95366. * Modifies the mesh geometry according to a displacementMap buffer.
  95367. * 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.
  95368. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95369. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  95370. * @param heightMapWidth is the width of the buffer image.
  95371. * @param heightMapHeight is the height of the buffer image.
  95372. * @param minHeight is the lower limit of the displacement.
  95373. * @param maxHeight is the upper limit of the displacement.
  95374. * @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.
  95375. * @param uvOffset is an optional vector2 used to offset UV.
  95376. * @param uvScale is an optional vector2 used to scale UV.
  95377. * @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.
  95378. * @returns the Mesh.
  95379. */
  95380. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95381. /**
  95382. * Modify the mesh to get a flat shading rendering.
  95383. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  95384. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  95385. * @returns current mesh
  95386. */
  95387. convertToFlatShadedMesh(): Mesh;
  95388. /**
  95389. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  95390. * In other words, more vertices, no more indices and a single bigger VBO.
  95391. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  95392. * @returns current mesh
  95393. */
  95394. convertToUnIndexedMesh(): Mesh;
  95395. /**
  95396. * Inverses facet orientations.
  95397. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95398. * @param flipNormals will also inverts the normals
  95399. * @returns current mesh
  95400. */
  95401. flipFaces(flipNormals?: boolean): Mesh;
  95402. /**
  95403. * Increase the number of facets and hence vertices in a mesh
  95404. * Vertex normals are interpolated from existing vertex normals
  95405. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95406. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  95407. */
  95408. increaseVertices(numberPerEdge: number): void;
  95409. /**
  95410. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  95411. * This will undo any application of covertToFlatShadedMesh
  95412. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95413. */
  95414. forceSharedVertices(): void;
  95415. /** @hidden */
  95416. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  95417. /** @hidden */
  95418. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  95419. /**
  95420. * Creates a new InstancedMesh object from the mesh model.
  95421. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  95422. * @param name defines the name of the new instance
  95423. * @returns a new InstancedMesh
  95424. */
  95425. createInstance(name: string): InstancedMesh;
  95426. /**
  95427. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  95428. * After this call, all the mesh instances have the same submeshes than the current mesh.
  95429. * @returns the current mesh
  95430. */
  95431. synchronizeInstances(): Mesh;
  95432. /**
  95433. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  95434. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  95435. * This should be used together with the simplification to avoid disappearing triangles.
  95436. * @param successCallback an optional success callback to be called after the optimization finished.
  95437. * @returns the current mesh
  95438. */
  95439. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  95440. /**
  95441. * Serialize current mesh
  95442. * @param serializationObject defines the object which will receive the serialization data
  95443. */
  95444. serialize(serializationObject: any): void;
  95445. /** @hidden */
  95446. _syncGeometryWithMorphTargetManager(): void;
  95447. /** @hidden */
  95448. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  95449. /**
  95450. * Returns a new Mesh object parsed from the source provided.
  95451. * @param parsedMesh is the source
  95452. * @param scene defines the hosting scene
  95453. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  95454. * @returns a new Mesh
  95455. */
  95456. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  95457. /**
  95458. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  95459. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95460. * @param name defines the name of the mesh to create
  95461. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  95462. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  95463. * @param closePath creates a seam between the first and the last points of each path of the path array
  95464. * @param offset is taken in account only if the `pathArray` is containing a single path
  95465. * @param scene defines the hosting scene
  95466. * @param updatable defines if the mesh must be flagged as updatable
  95467. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95468. * @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)
  95469. * @returns a new Mesh
  95470. */
  95471. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95472. /**
  95473. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  95474. * @param name defines the name of the mesh to create
  95475. * @param radius sets the radius size (float) of the polygon (default 0.5)
  95476. * @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
  95477. * @param scene defines the hosting scene
  95478. * @param updatable defines if the mesh must be flagged as updatable
  95479. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95480. * @returns a new Mesh
  95481. */
  95482. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95483. /**
  95484. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  95485. * @param name defines the name of the mesh to create
  95486. * @param size sets the size (float) of each box side (default 1)
  95487. * @param scene defines the hosting scene
  95488. * @param updatable defines if the mesh must be flagged as updatable
  95489. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95490. * @returns a new Mesh
  95491. */
  95492. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95493. /**
  95494. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  95495. * @param name defines the name of the mesh to create
  95496. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95497. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95498. * @param scene defines the hosting scene
  95499. * @param updatable defines if the mesh must be flagged as updatable
  95500. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95501. * @returns a new Mesh
  95502. */
  95503. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95504. /**
  95505. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  95506. * @param name defines the name of the mesh to create
  95507. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95508. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95509. * @param scene defines the hosting scene
  95510. * @returns a new Mesh
  95511. */
  95512. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  95513. /**
  95514. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  95515. * @param name defines the name of the mesh to create
  95516. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  95517. * @param diameterTop set the top cap diameter (floats, default 1)
  95518. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  95519. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  95520. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  95521. * @param scene defines the hosting scene
  95522. * @param updatable defines if the mesh must be flagged as updatable
  95523. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95524. * @returns a new Mesh
  95525. */
  95526. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  95527. /**
  95528. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  95529. * @param name defines the name of the mesh to create
  95530. * @param diameter sets the diameter size (float) of the torus (default 1)
  95531. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  95532. * @param tessellation sets the number of torus sides (postive integer, default 16)
  95533. * @param scene defines the hosting scene
  95534. * @param updatable defines if the mesh must be flagged as updatable
  95535. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95536. * @returns a new Mesh
  95537. */
  95538. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95539. /**
  95540. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  95541. * @param name defines the name of the mesh to create
  95542. * @param radius sets the global radius size (float) of the torus knot (default 2)
  95543. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  95544. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  95545. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  95546. * @param p the number of windings on X axis (positive integers, default 2)
  95547. * @param q the number of windings on Y axis (positive integers, default 3)
  95548. * @param scene defines the hosting scene
  95549. * @param updatable defines if the mesh must be flagged as updatable
  95550. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95551. * @returns a new Mesh
  95552. */
  95553. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95554. /**
  95555. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  95556. * @param name defines the name of the mesh to create
  95557. * @param points is an array successive Vector3
  95558. * @param scene defines the hosting scene
  95559. * @param updatable defines if the mesh must be flagged as updatable
  95560. * @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).
  95561. * @returns a new Mesh
  95562. */
  95563. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  95564. /**
  95565. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  95566. * @param name defines the name of the mesh to create
  95567. * @param points is an array successive Vector3
  95568. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  95569. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95570. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  95571. * @param scene defines the hosting scene
  95572. * @param updatable defines if the mesh must be flagged as updatable
  95573. * @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)
  95574. * @returns a new Mesh
  95575. */
  95576. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  95577. /**
  95578. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  95579. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  95580. * 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.
  95581. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95582. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95583. * Remember you can only change the shape positions, not their number when updating a polygon.
  95584. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  95585. * @param name defines the name of the mesh to create
  95586. * @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
  95587. * @param scene defines the hosting scene
  95588. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95589. * @param updatable defines if the mesh must be flagged as updatable
  95590. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95591. * @param earcutInjection can be used to inject your own earcut reference
  95592. * @returns a new Mesh
  95593. */
  95594. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95595. /**
  95596. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  95597. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  95598. * @param name defines the name of the mesh to create
  95599. * @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
  95600. * @param depth defines the height of extrusion
  95601. * @param scene defines the hosting scene
  95602. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95603. * @param updatable defines if the mesh must be flagged as updatable
  95604. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95605. * @param earcutInjection can be used to inject your own earcut reference
  95606. * @returns a new Mesh
  95607. */
  95608. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95609. /**
  95610. * Creates an extruded shape mesh.
  95611. * 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
  95612. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95613. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95614. * @param name defines the name of the mesh to create
  95615. * @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
  95616. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95617. * @param scale is the value to scale the shape
  95618. * @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
  95619. * @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
  95620. * @param scene defines the hosting scene
  95621. * @param updatable defines if the mesh must be flagged as updatable
  95622. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95623. * @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)
  95624. * @returns a new Mesh
  95625. */
  95626. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95627. /**
  95628. * Creates an custom extruded shape mesh.
  95629. * The custom extrusion is a parametric shape.
  95630. * It has no predefined shape. Its final shape will depend on the input parameters.
  95631. * Please consider using the same method from the MeshBuilder class instead
  95632. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95633. * @param name defines the name of the mesh to create
  95634. * @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
  95635. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95636. * @param scaleFunction is a custom Javascript function called on each path point
  95637. * @param rotationFunction is a custom Javascript function called on each path point
  95638. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  95639. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  95640. * @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
  95641. * @param scene defines the hosting scene
  95642. * @param updatable defines if the mesh must be flagged as updatable
  95643. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95644. * @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)
  95645. * @returns a new Mesh
  95646. */
  95647. 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;
  95648. /**
  95649. * Creates lathe mesh.
  95650. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  95651. * Please consider using the same method from the MeshBuilder class instead
  95652. * @param name defines the name of the mesh to create
  95653. * @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
  95654. * @param radius is the radius value of the lathe
  95655. * @param tessellation is the side number of the lathe.
  95656. * @param scene defines the hosting scene
  95657. * @param updatable defines if the mesh must be flagged as updatable
  95658. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95659. * @returns a new Mesh
  95660. */
  95661. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95662. /**
  95663. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  95664. * @param name defines the name of the mesh to create
  95665. * @param size sets the size (float) of both sides of the plane at once (default 1)
  95666. * @param scene defines the hosting scene
  95667. * @param updatable defines if the mesh must be flagged as updatable
  95668. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95669. * @returns a new Mesh
  95670. */
  95671. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95672. /**
  95673. * Creates a ground mesh.
  95674. * Please consider using the same method from the MeshBuilder class instead
  95675. * @param name defines the name of the mesh to create
  95676. * @param width set the width of the ground
  95677. * @param height set the height of the ground
  95678. * @param subdivisions sets the number of subdivisions per side
  95679. * @param scene defines the hosting scene
  95680. * @param updatable defines if the mesh must be flagged as updatable
  95681. * @returns a new Mesh
  95682. */
  95683. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  95684. /**
  95685. * Creates a tiled ground mesh.
  95686. * Please consider using the same method from the MeshBuilder class instead
  95687. * @param name defines the name of the mesh to create
  95688. * @param xmin set the ground minimum X coordinate
  95689. * @param zmin set the ground minimum Y coordinate
  95690. * @param xmax set the ground maximum X coordinate
  95691. * @param zmax set the ground maximum Z coordinate
  95692. * @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
  95693. * @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
  95694. * @param scene defines the hosting scene
  95695. * @param updatable defines if the mesh must be flagged as updatable
  95696. * @returns a new Mesh
  95697. */
  95698. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  95699. w: number;
  95700. h: number;
  95701. }, precision: {
  95702. w: number;
  95703. h: number;
  95704. }, scene: Scene, updatable?: boolean): Mesh;
  95705. /**
  95706. * Creates a ground mesh from a height map.
  95707. * Please consider using the same method from the MeshBuilder class instead
  95708. * @see http://doc.babylonjs.com/babylon101/height_map
  95709. * @param name defines the name of the mesh to create
  95710. * @param url sets the URL of the height map image resource
  95711. * @param width set the ground width size
  95712. * @param height set the ground height size
  95713. * @param subdivisions sets the number of subdivision per side
  95714. * @param minHeight is the minimum altitude on the ground
  95715. * @param maxHeight is the maximum altitude on the ground
  95716. * @param scene defines the hosting scene
  95717. * @param updatable defines if the mesh must be flagged as updatable
  95718. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  95719. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95720. * @returns a new Mesh
  95721. */
  95722. 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;
  95723. /**
  95724. * Creates a tube mesh.
  95725. * The tube is a parametric shape.
  95726. * It has no predefined shape. Its final shape will depend on the input parameters.
  95727. * Please consider using the same method from the MeshBuilder class instead
  95728. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95729. * @param name defines the name of the mesh to create
  95730. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  95731. * @param radius sets the tube radius size
  95732. * @param tessellation is the number of sides on the tubular surface
  95733. * @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
  95734. * @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
  95735. * @param scene defines the hosting scene
  95736. * @param updatable defines if the mesh must be flagged as updatable
  95737. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95738. * @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)
  95739. * @returns a new Mesh
  95740. */
  95741. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  95742. (i: number, distance: number): number;
  95743. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95744. /**
  95745. * Creates a polyhedron mesh.
  95746. * Please consider using the same method from the MeshBuilder class instead.
  95747. * * 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
  95748. * * The parameter `size` (positive float, default 1) sets the polygon size
  95749. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  95750. * * 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`
  95751. * * 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
  95752. * * 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)`)
  95753. * * 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
  95754. * * 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
  95755. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95756. * * If you create a double-sided mesh, you can choose what parts of 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
  95757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95758. * @param name defines the name of the mesh to create
  95759. * @param options defines the options used to create the mesh
  95760. * @param scene defines the hosting scene
  95761. * @returns a new Mesh
  95762. */
  95763. static CreatePolyhedron(name: string, options: {
  95764. type?: number;
  95765. size?: number;
  95766. sizeX?: number;
  95767. sizeY?: number;
  95768. sizeZ?: number;
  95769. custom?: any;
  95770. faceUV?: Vector4[];
  95771. faceColors?: Color4[];
  95772. updatable?: boolean;
  95773. sideOrientation?: number;
  95774. }, scene: Scene): Mesh;
  95775. /**
  95776. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  95777. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  95778. * * 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`)
  95779. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  95780. * * 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
  95781. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95782. * * If you create a double-sided mesh, you can choose what parts of 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
  95783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95784. * @param name defines the name of the mesh
  95785. * @param options defines the options used to create the mesh
  95786. * @param scene defines the hosting scene
  95787. * @returns a new Mesh
  95788. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  95789. */
  95790. static CreateIcoSphere(name: string, options: {
  95791. radius?: number;
  95792. flat?: boolean;
  95793. subdivisions?: number;
  95794. sideOrientation?: number;
  95795. updatable?: boolean;
  95796. }, scene: Scene): Mesh;
  95797. /**
  95798. * Creates a decal mesh.
  95799. * Please consider using the same method from the MeshBuilder class instead.
  95800. * A decal is a mesh usually applied as a model onto the surface of another mesh
  95801. * @param name defines the name of the mesh
  95802. * @param sourceMesh defines the mesh receiving the decal
  95803. * @param position sets the position of the decal in world coordinates
  95804. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  95805. * @param size sets the decal scaling
  95806. * @param angle sets the angle to rotate the decal
  95807. * @returns a new Mesh
  95808. */
  95809. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  95810. /**
  95811. * Prepare internal position array for software CPU skinning
  95812. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  95813. */
  95814. setPositionsForCPUSkinning(): Float32Array;
  95815. /**
  95816. * Prepare internal normal array for software CPU skinning
  95817. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  95818. */
  95819. setNormalsForCPUSkinning(): Float32Array;
  95820. /**
  95821. * Updates the vertex buffer by applying transformation from the bones
  95822. * @param skeleton defines the skeleton to apply to current mesh
  95823. * @returns the current mesh
  95824. */
  95825. applySkeleton(skeleton: Skeleton): Mesh;
  95826. /**
  95827. * 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
  95828. * @param meshes defines the list of meshes to scan
  95829. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  95830. */
  95831. static MinMax(meshes: AbstractMesh[]): {
  95832. min: Vector3;
  95833. max: Vector3;
  95834. };
  95835. /**
  95836. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  95837. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  95838. * @returns a vector3
  95839. */
  95840. static Center(meshesOrMinMaxVector: {
  95841. min: Vector3;
  95842. max: Vector3;
  95843. } | AbstractMesh[]): Vector3;
  95844. /**
  95845. * Merge the array of meshes into a single mesh for performance reasons.
  95846. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  95847. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  95848. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  95849. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  95850. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  95851. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  95852. * @returns a new mesh
  95853. */
  95854. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  95855. /** @hidden */
  95856. addInstance(instance: InstancedMesh): void;
  95857. /** @hidden */
  95858. removeInstance(instance: InstancedMesh): void;
  95859. }
  95860. }
  95861. declare module BABYLON {
  95862. /**
  95863. * This is the base class of all the camera used in the application.
  95864. * @see http://doc.babylonjs.com/features/cameras
  95865. */
  95866. export class Camera extends Node {
  95867. /** @hidden */
  95868. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  95869. /**
  95870. * This is the default projection mode used by the cameras.
  95871. * It helps recreating a feeling of perspective and better appreciate depth.
  95872. * This is the best way to simulate real life cameras.
  95873. */
  95874. static readonly PERSPECTIVE_CAMERA: number;
  95875. /**
  95876. * This helps creating camera with an orthographic mode.
  95877. * 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.
  95878. */
  95879. static readonly ORTHOGRAPHIC_CAMERA: number;
  95880. /**
  95881. * This is the default FOV mode for perspective cameras.
  95882. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  95883. */
  95884. static readonly FOVMODE_VERTICAL_FIXED: number;
  95885. /**
  95886. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  95887. */
  95888. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  95889. /**
  95890. * This specifies ther is no need for a camera rig.
  95891. * Basically only one eye is rendered corresponding to the camera.
  95892. */
  95893. static readonly RIG_MODE_NONE: number;
  95894. /**
  95895. * Simulates a camera Rig with one blue eye and one red eye.
  95896. * This can be use with 3d blue and red glasses.
  95897. */
  95898. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  95899. /**
  95900. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  95901. */
  95902. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  95903. /**
  95904. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  95905. */
  95906. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  95907. /**
  95908. * Defines that both eyes of the camera will be rendered over under each other.
  95909. */
  95910. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  95911. /**
  95912. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  95913. */
  95914. static readonly RIG_MODE_VR: number;
  95915. /**
  95916. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  95917. */
  95918. static readonly RIG_MODE_WEBVR: number;
  95919. /**
  95920. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  95921. */
  95922. static readonly RIG_MODE_CUSTOM: number;
  95923. /**
  95924. * Defines if by default attaching controls should prevent the default javascript event to continue.
  95925. */
  95926. static ForceAttachControlToAlwaysPreventDefault: boolean;
  95927. /**
  95928. * Define the input manager associated with the camera.
  95929. */
  95930. inputs: CameraInputsManager<Camera>;
  95931. /** @hidden */
  95932. _position: Vector3;
  95933. /**
  95934. * Define the current local position of the camera in the scene
  95935. */
  95936. get position(): Vector3;
  95937. set position(newPosition: Vector3);
  95938. /**
  95939. * The vector the camera should consider as up.
  95940. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  95941. */
  95942. upVector: Vector3;
  95943. /**
  95944. * Define the current limit on the left side for an orthographic camera
  95945. * In scene unit
  95946. */
  95947. orthoLeft: Nullable<number>;
  95948. /**
  95949. * Define the current limit on the right side for an orthographic camera
  95950. * In scene unit
  95951. */
  95952. orthoRight: Nullable<number>;
  95953. /**
  95954. * Define the current limit on the bottom side for an orthographic camera
  95955. * In scene unit
  95956. */
  95957. orthoBottom: Nullable<number>;
  95958. /**
  95959. * Define the current limit on the top side for an orthographic camera
  95960. * In scene unit
  95961. */
  95962. orthoTop: Nullable<number>;
  95963. /**
  95964. * Field Of View is set in Radians. (default is 0.8)
  95965. */
  95966. fov: number;
  95967. /**
  95968. * Define the minimum distance the camera can see from.
  95969. * This is important to note that the depth buffer are not infinite and the closer it starts
  95970. * the more your scene might encounter depth fighting issue.
  95971. */
  95972. minZ: number;
  95973. /**
  95974. * Define the maximum distance the camera can see to.
  95975. * This is important to note that the depth buffer are not infinite and the further it end
  95976. * the more your scene might encounter depth fighting issue.
  95977. */
  95978. maxZ: number;
  95979. /**
  95980. * Define the default inertia of the camera.
  95981. * This helps giving a smooth feeling to the camera movement.
  95982. */
  95983. inertia: number;
  95984. /**
  95985. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  95986. */
  95987. mode: number;
  95988. /**
  95989. * Define wether the camera is intermediate.
  95990. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  95991. */
  95992. isIntermediate: boolean;
  95993. /**
  95994. * Define the viewport of the camera.
  95995. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  95996. */
  95997. viewport: Viewport;
  95998. /**
  95999. * Restricts the camera to viewing objects with the same layerMask.
  96000. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  96001. */
  96002. layerMask: number;
  96003. /**
  96004. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  96005. */
  96006. fovMode: number;
  96007. /**
  96008. * Rig mode of the camera.
  96009. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  96010. * This is normally controlled byt the camera themselves as internal use.
  96011. */
  96012. cameraRigMode: number;
  96013. /**
  96014. * Defines the distance between both "eyes" in case of a RIG
  96015. */
  96016. interaxialDistance: number;
  96017. /**
  96018. * Defines if stereoscopic rendering is done side by side or over under.
  96019. */
  96020. isStereoscopicSideBySide: boolean;
  96021. /**
  96022. * 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
  96023. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  96024. * else in the scene. (Eg. security camera)
  96025. *
  96026. * 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)
  96027. */
  96028. customRenderTargets: RenderTargetTexture[];
  96029. /**
  96030. * When set, the camera will render to this render target instead of the default canvas
  96031. *
  96032. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  96033. */
  96034. outputRenderTarget: Nullable<RenderTargetTexture>;
  96035. /**
  96036. * Observable triggered when the camera view matrix has changed.
  96037. */
  96038. onViewMatrixChangedObservable: Observable<Camera>;
  96039. /**
  96040. * Observable triggered when the camera Projection matrix has changed.
  96041. */
  96042. onProjectionMatrixChangedObservable: Observable<Camera>;
  96043. /**
  96044. * Observable triggered when the inputs have been processed.
  96045. */
  96046. onAfterCheckInputsObservable: Observable<Camera>;
  96047. /**
  96048. * Observable triggered when reset has been called and applied to the camera.
  96049. */
  96050. onRestoreStateObservable: Observable<Camera>;
  96051. /** @hidden */
  96052. _cameraRigParams: any;
  96053. /** @hidden */
  96054. _rigCameras: Camera[];
  96055. /** @hidden */
  96056. _rigPostProcess: Nullable<PostProcess>;
  96057. protected _webvrViewMatrix: Matrix;
  96058. /** @hidden */
  96059. _skipRendering: boolean;
  96060. /** @hidden */
  96061. _projectionMatrix: Matrix;
  96062. /** @hidden */
  96063. _postProcesses: Nullable<PostProcess>[];
  96064. /** @hidden */
  96065. _activeMeshes: SmartArray<AbstractMesh>;
  96066. protected _globalPosition: Vector3;
  96067. /** @hidden */
  96068. _computedViewMatrix: Matrix;
  96069. private _doNotComputeProjectionMatrix;
  96070. private _transformMatrix;
  96071. private _frustumPlanes;
  96072. private _refreshFrustumPlanes;
  96073. private _storedFov;
  96074. private _stateStored;
  96075. /**
  96076. * Instantiates a new camera object.
  96077. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  96078. * @see http://doc.babylonjs.com/features/cameras
  96079. * @param name Defines the name of the camera in the scene
  96080. * @param position Defines the position of the camera
  96081. * @param scene Defines the scene the camera belongs too
  96082. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  96083. */
  96084. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96085. /**
  96086. * Store current camera state (fov, position, etc..)
  96087. * @returns the camera
  96088. */
  96089. storeState(): Camera;
  96090. /**
  96091. * Restores the camera state values if it has been stored. You must call storeState() first
  96092. */
  96093. protected _restoreStateValues(): boolean;
  96094. /**
  96095. * Restored camera state. You must call storeState() first.
  96096. * @returns true if restored and false otherwise
  96097. */
  96098. restoreState(): boolean;
  96099. /**
  96100. * Gets the class name of the camera.
  96101. * @returns the class name
  96102. */
  96103. getClassName(): string;
  96104. /** @hidden */
  96105. readonly _isCamera: boolean;
  96106. /**
  96107. * Gets a string representation of the camera useful for debug purpose.
  96108. * @param fullDetails Defines that a more verboe level of logging is required
  96109. * @returns the string representation
  96110. */
  96111. toString(fullDetails?: boolean): string;
  96112. /**
  96113. * Gets the current world space position of the camera.
  96114. */
  96115. get globalPosition(): Vector3;
  96116. /**
  96117. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  96118. * @returns the active meshe list
  96119. */
  96120. getActiveMeshes(): SmartArray<AbstractMesh>;
  96121. /**
  96122. * Check wether a mesh is part of the current active mesh list of the camera
  96123. * @param mesh Defines the mesh to check
  96124. * @returns true if active, false otherwise
  96125. */
  96126. isActiveMesh(mesh: Mesh): boolean;
  96127. /**
  96128. * Is this camera ready to be used/rendered
  96129. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  96130. * @return true if the camera is ready
  96131. */
  96132. isReady(completeCheck?: boolean): boolean;
  96133. /** @hidden */
  96134. _initCache(): void;
  96135. /** @hidden */
  96136. _updateCache(ignoreParentClass?: boolean): void;
  96137. /** @hidden */
  96138. _isSynchronized(): boolean;
  96139. /** @hidden */
  96140. _isSynchronizedViewMatrix(): boolean;
  96141. /** @hidden */
  96142. _isSynchronizedProjectionMatrix(): boolean;
  96143. /**
  96144. * Attach the input controls to a specific dom element to get the input from.
  96145. * @param element Defines the element the controls should be listened from
  96146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96147. */
  96148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96149. /**
  96150. * Detach the current controls from the specified dom element.
  96151. * @param element Defines the element to stop listening the inputs from
  96152. */
  96153. detachControl(element: HTMLElement): void;
  96154. /**
  96155. * Update the camera state according to the different inputs gathered during the frame.
  96156. */
  96157. update(): void;
  96158. /** @hidden */
  96159. _checkInputs(): void;
  96160. /** @hidden */
  96161. get rigCameras(): Camera[];
  96162. /**
  96163. * Gets the post process used by the rig cameras
  96164. */
  96165. get rigPostProcess(): Nullable<PostProcess>;
  96166. /**
  96167. * Internal, gets the first post proces.
  96168. * @returns the first post process to be run on this camera.
  96169. */
  96170. _getFirstPostProcess(): Nullable<PostProcess>;
  96171. private _cascadePostProcessesToRigCams;
  96172. /**
  96173. * Attach a post process to the camera.
  96174. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96175. * @param postProcess The post process to attach to the camera
  96176. * @param insertAt The position of the post process in case several of them are in use in the scene
  96177. * @returns the position the post process has been inserted at
  96178. */
  96179. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  96180. /**
  96181. * Detach a post process to the camera.
  96182. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96183. * @param postProcess The post process to detach from the camera
  96184. */
  96185. detachPostProcess(postProcess: PostProcess): void;
  96186. /**
  96187. * Gets the current world matrix of the camera
  96188. */
  96189. getWorldMatrix(): Matrix;
  96190. /** @hidden */
  96191. _getViewMatrix(): Matrix;
  96192. /**
  96193. * Gets the current view matrix of the camera.
  96194. * @param force forces the camera to recompute the matrix without looking at the cached state
  96195. * @returns the view matrix
  96196. */
  96197. getViewMatrix(force?: boolean): Matrix;
  96198. /**
  96199. * Freeze the projection matrix.
  96200. * It will prevent the cache check of the camera projection compute and can speed up perf
  96201. * if no parameter of the camera are meant to change
  96202. * @param projection Defines manually a projection if necessary
  96203. */
  96204. freezeProjectionMatrix(projection?: Matrix): void;
  96205. /**
  96206. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  96207. */
  96208. unfreezeProjectionMatrix(): void;
  96209. /**
  96210. * Gets the current projection matrix of the camera.
  96211. * @param force forces the camera to recompute the matrix without looking at the cached state
  96212. * @returns the projection matrix
  96213. */
  96214. getProjectionMatrix(force?: boolean): Matrix;
  96215. /**
  96216. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  96217. * @returns a Matrix
  96218. */
  96219. getTransformationMatrix(): Matrix;
  96220. private _updateFrustumPlanes;
  96221. /**
  96222. * Checks if a cullable object (mesh...) is in the camera frustum
  96223. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  96224. * @param target The object to check
  96225. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  96226. * @returns true if the object is in frustum otherwise false
  96227. */
  96228. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  96229. /**
  96230. * Checks if a cullable object (mesh...) is in the camera frustum
  96231. * Unlike isInFrustum this cheks the full bounding box
  96232. * @param target The object to check
  96233. * @returns true if the object is in frustum otherwise false
  96234. */
  96235. isCompletelyInFrustum(target: ICullable): boolean;
  96236. /**
  96237. * Gets a ray in the forward direction from the camera.
  96238. * @param length Defines the length of the ray to create
  96239. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  96240. * @param origin Defines the start point of the ray which defaults to the camera position
  96241. * @returns the forward ray
  96242. */
  96243. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  96244. /**
  96245. * Releases resources associated with this node.
  96246. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96247. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96248. */
  96249. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96250. /** @hidden */
  96251. _isLeftCamera: boolean;
  96252. /**
  96253. * Gets the left camera of a rig setup in case of Rigged Camera
  96254. */
  96255. get isLeftCamera(): boolean;
  96256. /** @hidden */
  96257. _isRightCamera: boolean;
  96258. /**
  96259. * Gets the right camera of a rig setup in case of Rigged Camera
  96260. */
  96261. get isRightCamera(): boolean;
  96262. /**
  96263. * Gets the left camera of a rig setup in case of Rigged Camera
  96264. */
  96265. get leftCamera(): Nullable<FreeCamera>;
  96266. /**
  96267. * Gets the right camera of a rig setup in case of Rigged Camera
  96268. */
  96269. get rightCamera(): Nullable<FreeCamera>;
  96270. /**
  96271. * Gets the left camera target of a rig setup in case of Rigged Camera
  96272. * @returns the target position
  96273. */
  96274. getLeftTarget(): Nullable<Vector3>;
  96275. /**
  96276. * Gets the right camera target of a rig setup in case of Rigged Camera
  96277. * @returns the target position
  96278. */
  96279. getRightTarget(): Nullable<Vector3>;
  96280. /**
  96281. * @hidden
  96282. */
  96283. setCameraRigMode(mode: number, rigParams: any): void;
  96284. /** @hidden */
  96285. static _setStereoscopicRigMode(camera: Camera): void;
  96286. /** @hidden */
  96287. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  96288. /** @hidden */
  96289. static _setVRRigMode(camera: Camera, rigParams: any): void;
  96290. /** @hidden */
  96291. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  96292. /** @hidden */
  96293. _getVRProjectionMatrix(): Matrix;
  96294. protected _updateCameraRotationMatrix(): void;
  96295. protected _updateWebVRCameraRotationMatrix(): void;
  96296. /**
  96297. * This function MUST be overwritten by the different WebVR cameras available.
  96298. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96299. * @hidden
  96300. */
  96301. _getWebVRProjectionMatrix(): Matrix;
  96302. /**
  96303. * This function MUST be overwritten by the different WebVR cameras available.
  96304. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96305. * @hidden
  96306. */
  96307. _getWebVRViewMatrix(): Matrix;
  96308. /** @hidden */
  96309. setCameraRigParameter(name: string, value: any): void;
  96310. /**
  96311. * needs to be overridden by children so sub has required properties to be copied
  96312. * @hidden
  96313. */
  96314. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96315. /**
  96316. * May need to be overridden by children
  96317. * @hidden
  96318. */
  96319. _updateRigCameras(): void;
  96320. /** @hidden */
  96321. _setupInputs(): void;
  96322. /**
  96323. * Serialiaze the camera setup to a json represention
  96324. * @returns the JSON representation
  96325. */
  96326. serialize(): any;
  96327. /**
  96328. * Clones the current camera.
  96329. * @param name The cloned camera name
  96330. * @returns the cloned camera
  96331. */
  96332. clone(name: string): Camera;
  96333. /**
  96334. * Gets the direction of the camera relative to a given local axis.
  96335. * @param localAxis Defines the reference axis to provide a relative direction.
  96336. * @return the direction
  96337. */
  96338. getDirection(localAxis: Vector3): Vector3;
  96339. /**
  96340. * Returns the current camera absolute rotation
  96341. */
  96342. get absoluteRotation(): Quaternion;
  96343. /**
  96344. * Gets the direction of the camera relative to a given local axis into a passed vector.
  96345. * @param localAxis Defines the reference axis to provide a relative direction.
  96346. * @param result Defines the vector to store the result in
  96347. */
  96348. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  96349. /**
  96350. * Gets a camera constructor for a given camera type
  96351. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  96352. * @param name The name of the camera the result will be able to instantiate
  96353. * @param scene The scene the result will construct the camera in
  96354. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  96355. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  96356. * @returns a factory method to construc the camera
  96357. */
  96358. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  96359. /**
  96360. * Compute the world matrix of the camera.
  96361. * @returns the camera world matrix
  96362. */
  96363. computeWorldMatrix(): Matrix;
  96364. /**
  96365. * Parse a JSON and creates the camera from the parsed information
  96366. * @param parsedCamera The JSON to parse
  96367. * @param scene The scene to instantiate the camera in
  96368. * @returns the newly constructed camera
  96369. */
  96370. static Parse(parsedCamera: any, scene: Scene): Camera;
  96371. }
  96372. }
  96373. declare module BABYLON {
  96374. /**
  96375. * Class containing static functions to help procedurally build meshes
  96376. */
  96377. export class DiscBuilder {
  96378. /**
  96379. * Creates a plane polygonal mesh. By default, this is a disc
  96380. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  96381. * * 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
  96382. * * 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
  96383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96386. * @param name defines the name of the mesh
  96387. * @param options defines the options used to create the mesh
  96388. * @param scene defines the hosting scene
  96389. * @returns the plane polygonal mesh
  96390. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  96391. */
  96392. static CreateDisc(name: string, options: {
  96393. radius?: number;
  96394. tessellation?: number;
  96395. arc?: number;
  96396. updatable?: boolean;
  96397. sideOrientation?: number;
  96398. frontUVs?: Vector4;
  96399. backUVs?: Vector4;
  96400. }, scene?: Nullable<Scene>): Mesh;
  96401. }
  96402. }
  96403. declare module BABYLON {
  96404. /**
  96405. * This represents all the required information to add a fresnel effect on a material:
  96406. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96407. */
  96408. export class FresnelParameters {
  96409. private _isEnabled;
  96410. /**
  96411. * Define if the fresnel effect is enable or not.
  96412. */
  96413. get isEnabled(): boolean;
  96414. set isEnabled(value: boolean);
  96415. /**
  96416. * Define the color used on edges (grazing angle)
  96417. */
  96418. leftColor: Color3;
  96419. /**
  96420. * Define the color used on center
  96421. */
  96422. rightColor: Color3;
  96423. /**
  96424. * Define bias applied to computed fresnel term
  96425. */
  96426. bias: number;
  96427. /**
  96428. * Defined the power exponent applied to fresnel term
  96429. */
  96430. power: number;
  96431. /**
  96432. * Clones the current fresnel and its valuues
  96433. * @returns a clone fresnel configuration
  96434. */
  96435. clone(): FresnelParameters;
  96436. /**
  96437. * Serializes the current fresnel parameters to a JSON representation.
  96438. * @return the JSON serialization
  96439. */
  96440. serialize(): any;
  96441. /**
  96442. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96443. * @param parsedFresnelParameters Define the JSON representation
  96444. * @returns the parsed parameters
  96445. */
  96446. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96447. }
  96448. }
  96449. declare module BABYLON {
  96450. /**
  96451. * Base class of materials working in push mode in babylon JS
  96452. * @hidden
  96453. */
  96454. export class PushMaterial extends Material {
  96455. protected _activeEffect: Effect;
  96456. protected _normalMatrix: Matrix;
  96457. /**
  96458. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96459. * This means that the material can keep using a previous shader while a new one is being compiled.
  96460. * This is mostly used when shader parallel compilation is supported (true by default)
  96461. */
  96462. allowShaderHotSwapping: boolean;
  96463. constructor(name: string, scene: Scene);
  96464. getEffect(): Effect;
  96465. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96466. /**
  96467. * Binds the given world matrix to the active effect
  96468. *
  96469. * @param world the matrix to bind
  96470. */
  96471. bindOnlyWorldMatrix(world: Matrix): void;
  96472. /**
  96473. * Binds the given normal matrix to the active effect
  96474. *
  96475. * @param normalMatrix the matrix to bind
  96476. */
  96477. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96478. bind(world: Matrix, mesh?: Mesh): void;
  96479. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96480. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96481. }
  96482. }
  96483. declare module BABYLON {
  96484. /**
  96485. * This groups all the flags used to control the materials channel.
  96486. */
  96487. export class MaterialFlags {
  96488. private static _DiffuseTextureEnabled;
  96489. /**
  96490. * Are diffuse textures enabled in the application.
  96491. */
  96492. static get DiffuseTextureEnabled(): boolean;
  96493. static set DiffuseTextureEnabled(value: boolean);
  96494. private static _AmbientTextureEnabled;
  96495. /**
  96496. * Are ambient textures enabled in the application.
  96497. */
  96498. static get AmbientTextureEnabled(): boolean;
  96499. static set AmbientTextureEnabled(value: boolean);
  96500. private static _OpacityTextureEnabled;
  96501. /**
  96502. * Are opacity textures enabled in the application.
  96503. */
  96504. static get OpacityTextureEnabled(): boolean;
  96505. static set OpacityTextureEnabled(value: boolean);
  96506. private static _ReflectionTextureEnabled;
  96507. /**
  96508. * Are reflection textures enabled in the application.
  96509. */
  96510. static get ReflectionTextureEnabled(): boolean;
  96511. static set ReflectionTextureEnabled(value: boolean);
  96512. private static _EmissiveTextureEnabled;
  96513. /**
  96514. * Are emissive textures enabled in the application.
  96515. */
  96516. static get EmissiveTextureEnabled(): boolean;
  96517. static set EmissiveTextureEnabled(value: boolean);
  96518. private static _SpecularTextureEnabled;
  96519. /**
  96520. * Are specular textures enabled in the application.
  96521. */
  96522. static get SpecularTextureEnabled(): boolean;
  96523. static set SpecularTextureEnabled(value: boolean);
  96524. private static _BumpTextureEnabled;
  96525. /**
  96526. * Are bump textures enabled in the application.
  96527. */
  96528. static get BumpTextureEnabled(): boolean;
  96529. static set BumpTextureEnabled(value: boolean);
  96530. private static _LightmapTextureEnabled;
  96531. /**
  96532. * Are lightmap textures enabled in the application.
  96533. */
  96534. static get LightmapTextureEnabled(): boolean;
  96535. static set LightmapTextureEnabled(value: boolean);
  96536. private static _RefractionTextureEnabled;
  96537. /**
  96538. * Are refraction textures enabled in the application.
  96539. */
  96540. static get RefractionTextureEnabled(): boolean;
  96541. static set RefractionTextureEnabled(value: boolean);
  96542. private static _ColorGradingTextureEnabled;
  96543. /**
  96544. * Are color grading textures enabled in the application.
  96545. */
  96546. static get ColorGradingTextureEnabled(): boolean;
  96547. static set ColorGradingTextureEnabled(value: boolean);
  96548. private static _FresnelEnabled;
  96549. /**
  96550. * Are fresnels enabled in the application.
  96551. */
  96552. static get FresnelEnabled(): boolean;
  96553. static set FresnelEnabled(value: boolean);
  96554. private static _ClearCoatTextureEnabled;
  96555. /**
  96556. * Are clear coat textures enabled in the application.
  96557. */
  96558. static get ClearCoatTextureEnabled(): boolean;
  96559. static set ClearCoatTextureEnabled(value: boolean);
  96560. private static _ClearCoatBumpTextureEnabled;
  96561. /**
  96562. * Are clear coat bump textures enabled in the application.
  96563. */
  96564. static get ClearCoatBumpTextureEnabled(): boolean;
  96565. static set ClearCoatBumpTextureEnabled(value: boolean);
  96566. private static _ClearCoatTintTextureEnabled;
  96567. /**
  96568. * Are clear coat tint textures enabled in the application.
  96569. */
  96570. static get ClearCoatTintTextureEnabled(): boolean;
  96571. static set ClearCoatTintTextureEnabled(value: boolean);
  96572. private static _SheenTextureEnabled;
  96573. /**
  96574. * Are sheen textures enabled in the application.
  96575. */
  96576. static get SheenTextureEnabled(): boolean;
  96577. static set SheenTextureEnabled(value: boolean);
  96578. private static _AnisotropicTextureEnabled;
  96579. /**
  96580. * Are anisotropic textures enabled in the application.
  96581. */
  96582. static get AnisotropicTextureEnabled(): boolean;
  96583. static set AnisotropicTextureEnabled(value: boolean);
  96584. private static _ThicknessTextureEnabled;
  96585. /**
  96586. * Are thickness textures enabled in the application.
  96587. */
  96588. static get ThicknessTextureEnabled(): boolean;
  96589. static set ThicknessTextureEnabled(value: boolean);
  96590. }
  96591. }
  96592. declare module BABYLON {
  96593. /** @hidden */
  96594. export var defaultFragmentDeclaration: {
  96595. name: string;
  96596. shader: string;
  96597. };
  96598. }
  96599. declare module BABYLON {
  96600. /** @hidden */
  96601. export var defaultUboDeclaration: {
  96602. name: string;
  96603. shader: string;
  96604. };
  96605. }
  96606. declare module BABYLON {
  96607. /** @hidden */
  96608. export var lightFragmentDeclaration: {
  96609. name: string;
  96610. shader: string;
  96611. };
  96612. }
  96613. declare module BABYLON {
  96614. /** @hidden */
  96615. export var lightUboDeclaration: {
  96616. name: string;
  96617. shader: string;
  96618. };
  96619. }
  96620. declare module BABYLON {
  96621. /** @hidden */
  96622. export var lightsFragmentFunctions: {
  96623. name: string;
  96624. shader: string;
  96625. };
  96626. }
  96627. declare module BABYLON {
  96628. /** @hidden */
  96629. export var shadowsFragmentFunctions: {
  96630. name: string;
  96631. shader: string;
  96632. };
  96633. }
  96634. declare module BABYLON {
  96635. /** @hidden */
  96636. export var fresnelFunction: {
  96637. name: string;
  96638. shader: string;
  96639. };
  96640. }
  96641. declare module BABYLON {
  96642. /** @hidden */
  96643. export var reflectionFunction: {
  96644. name: string;
  96645. shader: string;
  96646. };
  96647. }
  96648. declare module BABYLON {
  96649. /** @hidden */
  96650. export var bumpFragmentFunctions: {
  96651. name: string;
  96652. shader: string;
  96653. };
  96654. }
  96655. declare module BABYLON {
  96656. /** @hidden */
  96657. export var logDepthDeclaration: {
  96658. name: string;
  96659. shader: string;
  96660. };
  96661. }
  96662. declare module BABYLON {
  96663. /** @hidden */
  96664. export var bumpFragment: {
  96665. name: string;
  96666. shader: string;
  96667. };
  96668. }
  96669. declare module BABYLON {
  96670. /** @hidden */
  96671. export var depthPrePass: {
  96672. name: string;
  96673. shader: string;
  96674. };
  96675. }
  96676. declare module BABYLON {
  96677. /** @hidden */
  96678. export var lightFragment: {
  96679. name: string;
  96680. shader: string;
  96681. };
  96682. }
  96683. declare module BABYLON {
  96684. /** @hidden */
  96685. export var logDepthFragment: {
  96686. name: string;
  96687. shader: string;
  96688. };
  96689. }
  96690. declare module BABYLON {
  96691. /** @hidden */
  96692. export var defaultPixelShader: {
  96693. name: string;
  96694. shader: string;
  96695. };
  96696. }
  96697. declare module BABYLON {
  96698. /** @hidden */
  96699. export var defaultVertexDeclaration: {
  96700. name: string;
  96701. shader: string;
  96702. };
  96703. }
  96704. declare module BABYLON {
  96705. /** @hidden */
  96706. export var bumpVertexDeclaration: {
  96707. name: string;
  96708. shader: string;
  96709. };
  96710. }
  96711. declare module BABYLON {
  96712. /** @hidden */
  96713. export var bumpVertex: {
  96714. name: string;
  96715. shader: string;
  96716. };
  96717. }
  96718. declare module BABYLON {
  96719. /** @hidden */
  96720. export var fogVertex: {
  96721. name: string;
  96722. shader: string;
  96723. };
  96724. }
  96725. declare module BABYLON {
  96726. /** @hidden */
  96727. export var shadowsVertex: {
  96728. name: string;
  96729. shader: string;
  96730. };
  96731. }
  96732. declare module BABYLON {
  96733. /** @hidden */
  96734. export var pointCloudVertex: {
  96735. name: string;
  96736. shader: string;
  96737. };
  96738. }
  96739. declare module BABYLON {
  96740. /** @hidden */
  96741. export var logDepthVertex: {
  96742. name: string;
  96743. shader: string;
  96744. };
  96745. }
  96746. declare module BABYLON {
  96747. /** @hidden */
  96748. export var defaultVertexShader: {
  96749. name: string;
  96750. shader: string;
  96751. };
  96752. }
  96753. declare module BABYLON {
  96754. /** @hidden */
  96755. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96756. MAINUV1: boolean;
  96757. MAINUV2: boolean;
  96758. DIFFUSE: boolean;
  96759. DIFFUSEDIRECTUV: number;
  96760. AMBIENT: boolean;
  96761. AMBIENTDIRECTUV: number;
  96762. OPACITY: boolean;
  96763. OPACITYDIRECTUV: number;
  96764. OPACITYRGB: boolean;
  96765. REFLECTION: boolean;
  96766. EMISSIVE: boolean;
  96767. EMISSIVEDIRECTUV: number;
  96768. SPECULAR: boolean;
  96769. SPECULARDIRECTUV: number;
  96770. BUMP: boolean;
  96771. BUMPDIRECTUV: number;
  96772. PARALLAX: boolean;
  96773. PARALLAXOCCLUSION: boolean;
  96774. SPECULAROVERALPHA: boolean;
  96775. CLIPPLANE: boolean;
  96776. CLIPPLANE2: boolean;
  96777. CLIPPLANE3: boolean;
  96778. CLIPPLANE4: boolean;
  96779. CLIPPLANE5: boolean;
  96780. CLIPPLANE6: boolean;
  96781. ALPHATEST: boolean;
  96782. DEPTHPREPASS: boolean;
  96783. ALPHAFROMDIFFUSE: boolean;
  96784. POINTSIZE: boolean;
  96785. FOG: boolean;
  96786. SPECULARTERM: boolean;
  96787. DIFFUSEFRESNEL: boolean;
  96788. OPACITYFRESNEL: boolean;
  96789. REFLECTIONFRESNEL: boolean;
  96790. REFRACTIONFRESNEL: boolean;
  96791. EMISSIVEFRESNEL: boolean;
  96792. FRESNEL: boolean;
  96793. NORMAL: boolean;
  96794. UV1: boolean;
  96795. UV2: boolean;
  96796. VERTEXCOLOR: boolean;
  96797. VERTEXALPHA: boolean;
  96798. NUM_BONE_INFLUENCERS: number;
  96799. BonesPerMesh: number;
  96800. BONETEXTURE: boolean;
  96801. INSTANCES: boolean;
  96802. GLOSSINESS: boolean;
  96803. ROUGHNESS: boolean;
  96804. EMISSIVEASILLUMINATION: boolean;
  96805. LINKEMISSIVEWITHDIFFUSE: boolean;
  96806. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96807. LIGHTMAP: boolean;
  96808. LIGHTMAPDIRECTUV: number;
  96809. OBJECTSPACE_NORMALMAP: boolean;
  96810. USELIGHTMAPASSHADOWMAP: boolean;
  96811. REFLECTIONMAP_3D: boolean;
  96812. REFLECTIONMAP_SPHERICAL: boolean;
  96813. REFLECTIONMAP_PLANAR: boolean;
  96814. REFLECTIONMAP_CUBIC: boolean;
  96815. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96816. REFLECTIONMAP_PROJECTION: boolean;
  96817. REFLECTIONMAP_SKYBOX: boolean;
  96818. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96819. REFLECTIONMAP_EXPLICIT: boolean;
  96820. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96821. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96822. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96823. INVERTCUBICMAP: boolean;
  96824. LOGARITHMICDEPTH: boolean;
  96825. REFRACTION: boolean;
  96826. REFRACTIONMAP_3D: boolean;
  96827. REFLECTIONOVERALPHA: boolean;
  96828. TWOSIDEDLIGHTING: boolean;
  96829. SHADOWFLOAT: boolean;
  96830. MORPHTARGETS: boolean;
  96831. MORPHTARGETS_NORMAL: boolean;
  96832. MORPHTARGETS_TANGENT: boolean;
  96833. MORPHTARGETS_UV: boolean;
  96834. NUM_MORPH_INFLUENCERS: number;
  96835. NONUNIFORMSCALING: boolean;
  96836. PREMULTIPLYALPHA: boolean;
  96837. IMAGEPROCESSING: boolean;
  96838. VIGNETTE: boolean;
  96839. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96840. VIGNETTEBLENDMODEOPAQUE: boolean;
  96841. TONEMAPPING: boolean;
  96842. TONEMAPPING_ACES: boolean;
  96843. CONTRAST: boolean;
  96844. COLORCURVES: boolean;
  96845. COLORGRADING: boolean;
  96846. COLORGRADING3D: boolean;
  96847. SAMPLER3DGREENDEPTH: boolean;
  96848. SAMPLER3DBGRMAP: boolean;
  96849. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96850. MULTIVIEW: boolean;
  96851. /**
  96852. * If the reflection texture on this material is in linear color space
  96853. * @hidden
  96854. */
  96855. IS_REFLECTION_LINEAR: boolean;
  96856. /**
  96857. * If the refraction texture on this material is in linear color space
  96858. * @hidden
  96859. */
  96860. IS_REFRACTION_LINEAR: boolean;
  96861. EXPOSURE: boolean;
  96862. constructor();
  96863. setReflectionMode(modeToEnable: string): void;
  96864. }
  96865. /**
  96866. * This is the default material used in Babylon. It is the best trade off between quality
  96867. * and performances.
  96868. * @see http://doc.babylonjs.com/babylon101/materials
  96869. */
  96870. export class StandardMaterial extends PushMaterial {
  96871. private _diffuseTexture;
  96872. /**
  96873. * The basic texture of the material as viewed under a light.
  96874. */
  96875. diffuseTexture: Nullable<BaseTexture>;
  96876. private _ambientTexture;
  96877. /**
  96878. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96879. */
  96880. ambientTexture: Nullable<BaseTexture>;
  96881. private _opacityTexture;
  96882. /**
  96883. * Define the transparency of the material from a texture.
  96884. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96885. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96886. */
  96887. opacityTexture: Nullable<BaseTexture>;
  96888. private _reflectionTexture;
  96889. /**
  96890. * Define the texture used to display the reflection.
  96891. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96892. */
  96893. reflectionTexture: Nullable<BaseTexture>;
  96894. private _emissiveTexture;
  96895. /**
  96896. * Define texture of the material as if self lit.
  96897. * This will be mixed in the final result even in the absence of light.
  96898. */
  96899. emissiveTexture: Nullable<BaseTexture>;
  96900. private _specularTexture;
  96901. /**
  96902. * Define how the color and intensity of the highlight given by the light in the material.
  96903. */
  96904. specularTexture: Nullable<BaseTexture>;
  96905. private _bumpTexture;
  96906. /**
  96907. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96908. * 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.
  96909. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96910. */
  96911. bumpTexture: Nullable<BaseTexture>;
  96912. private _lightmapTexture;
  96913. /**
  96914. * Complex lighting can be computationally expensive to compute at runtime.
  96915. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96916. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96917. */
  96918. lightmapTexture: Nullable<BaseTexture>;
  96919. private _refractionTexture;
  96920. /**
  96921. * Define the texture used to display the refraction.
  96922. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96923. */
  96924. refractionTexture: Nullable<BaseTexture>;
  96925. /**
  96926. * The color of the material lit by the environmental background lighting.
  96927. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96928. */
  96929. ambientColor: Color3;
  96930. /**
  96931. * The basic color of the material as viewed under a light.
  96932. */
  96933. diffuseColor: Color3;
  96934. /**
  96935. * Define how the color and intensity of the highlight given by the light in the material.
  96936. */
  96937. specularColor: Color3;
  96938. /**
  96939. * Define the color of the material as if self lit.
  96940. * This will be mixed in the final result even in the absence of light.
  96941. */
  96942. emissiveColor: Color3;
  96943. /**
  96944. * Defines how sharp are the highlights in the material.
  96945. * The bigger the value the sharper giving a more glossy feeling to the result.
  96946. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96947. */
  96948. specularPower: number;
  96949. private _useAlphaFromDiffuseTexture;
  96950. /**
  96951. * Does the transparency come from the diffuse texture alpha channel.
  96952. */
  96953. useAlphaFromDiffuseTexture: boolean;
  96954. private _useEmissiveAsIllumination;
  96955. /**
  96956. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96957. */
  96958. useEmissiveAsIllumination: boolean;
  96959. private _linkEmissiveWithDiffuse;
  96960. /**
  96961. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96962. * the emissive level when the final color is close to one.
  96963. */
  96964. linkEmissiveWithDiffuse: boolean;
  96965. private _useSpecularOverAlpha;
  96966. /**
  96967. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96968. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96969. */
  96970. useSpecularOverAlpha: boolean;
  96971. private _useReflectionOverAlpha;
  96972. /**
  96973. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96974. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96975. */
  96976. useReflectionOverAlpha: boolean;
  96977. private _disableLighting;
  96978. /**
  96979. * Does lights from the scene impacts this material.
  96980. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96981. */
  96982. disableLighting: boolean;
  96983. private _useObjectSpaceNormalMap;
  96984. /**
  96985. * Allows using an object space normal map (instead of tangent space).
  96986. */
  96987. useObjectSpaceNormalMap: boolean;
  96988. private _useParallax;
  96989. /**
  96990. * Is parallax enabled or not.
  96991. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96992. */
  96993. useParallax: boolean;
  96994. private _useParallaxOcclusion;
  96995. /**
  96996. * Is parallax occlusion enabled or not.
  96997. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96998. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96999. */
  97000. useParallaxOcclusion: boolean;
  97001. /**
  97002. * 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.
  97003. */
  97004. parallaxScaleBias: number;
  97005. private _roughness;
  97006. /**
  97007. * Helps to define how blurry the reflections should appears in the material.
  97008. */
  97009. roughness: number;
  97010. /**
  97011. * In case of refraction, define the value of the index of refraction.
  97012. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97013. */
  97014. indexOfRefraction: number;
  97015. /**
  97016. * Invert the refraction texture alongside the y axis.
  97017. * It can be useful with procedural textures or probe for instance.
  97018. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97019. */
  97020. invertRefractionY: boolean;
  97021. /**
  97022. * Defines the alpha limits in alpha test mode.
  97023. */
  97024. alphaCutOff: number;
  97025. private _useLightmapAsShadowmap;
  97026. /**
  97027. * In case of light mapping, define whether the map contains light or shadow informations.
  97028. */
  97029. useLightmapAsShadowmap: boolean;
  97030. private _diffuseFresnelParameters;
  97031. /**
  97032. * Define the diffuse fresnel parameters of the material.
  97033. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97034. */
  97035. diffuseFresnelParameters: FresnelParameters;
  97036. private _opacityFresnelParameters;
  97037. /**
  97038. * Define the opacity fresnel parameters of the material.
  97039. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97040. */
  97041. opacityFresnelParameters: FresnelParameters;
  97042. private _reflectionFresnelParameters;
  97043. /**
  97044. * Define the reflection fresnel parameters of the material.
  97045. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97046. */
  97047. reflectionFresnelParameters: FresnelParameters;
  97048. private _refractionFresnelParameters;
  97049. /**
  97050. * Define the refraction fresnel parameters of the material.
  97051. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97052. */
  97053. refractionFresnelParameters: FresnelParameters;
  97054. private _emissiveFresnelParameters;
  97055. /**
  97056. * Define the emissive fresnel parameters of the material.
  97057. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97058. */
  97059. emissiveFresnelParameters: FresnelParameters;
  97060. private _useReflectionFresnelFromSpecular;
  97061. /**
  97062. * If true automatically deducts the fresnels values from the material specularity.
  97063. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97064. */
  97065. useReflectionFresnelFromSpecular: boolean;
  97066. private _useGlossinessFromSpecularMapAlpha;
  97067. /**
  97068. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97069. */
  97070. useGlossinessFromSpecularMapAlpha: boolean;
  97071. private _maxSimultaneousLights;
  97072. /**
  97073. * Defines the maximum number of lights that can be used in the material
  97074. */
  97075. maxSimultaneousLights: number;
  97076. private _invertNormalMapX;
  97077. /**
  97078. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97079. */
  97080. invertNormalMapX: boolean;
  97081. private _invertNormalMapY;
  97082. /**
  97083. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97084. */
  97085. invertNormalMapY: boolean;
  97086. private _twoSidedLighting;
  97087. /**
  97088. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97089. */
  97090. twoSidedLighting: boolean;
  97091. /**
  97092. * Default configuration related to image processing available in the standard Material.
  97093. */
  97094. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97095. /**
  97096. * Gets the image processing configuration used either in this material.
  97097. */
  97098. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  97099. /**
  97100. * Sets the Default image processing configuration used either in the this material.
  97101. *
  97102. * If sets to null, the scene one is in use.
  97103. */
  97104. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  97105. /**
  97106. * Keep track of the image processing observer to allow dispose and replace.
  97107. */
  97108. private _imageProcessingObserver;
  97109. /**
  97110. * Attaches a new image processing configuration to the Standard Material.
  97111. * @param configuration
  97112. */
  97113. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97114. /**
  97115. * Gets wether the color curves effect is enabled.
  97116. */
  97117. get cameraColorCurvesEnabled(): boolean;
  97118. /**
  97119. * Sets wether the color curves effect is enabled.
  97120. */
  97121. set cameraColorCurvesEnabled(value: boolean);
  97122. /**
  97123. * Gets wether the color grading effect is enabled.
  97124. */
  97125. get cameraColorGradingEnabled(): boolean;
  97126. /**
  97127. * Gets wether the color grading effect is enabled.
  97128. */
  97129. set cameraColorGradingEnabled(value: boolean);
  97130. /**
  97131. * Gets wether tonemapping is enabled or not.
  97132. */
  97133. get cameraToneMappingEnabled(): boolean;
  97134. /**
  97135. * Sets wether tonemapping is enabled or not
  97136. */
  97137. set cameraToneMappingEnabled(value: boolean);
  97138. /**
  97139. * The camera exposure used on this material.
  97140. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97141. * This corresponds to a photographic exposure.
  97142. */
  97143. get cameraExposure(): number;
  97144. /**
  97145. * The camera exposure used on this material.
  97146. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97147. * This corresponds to a photographic exposure.
  97148. */
  97149. set cameraExposure(value: number);
  97150. /**
  97151. * Gets The camera contrast used on this material.
  97152. */
  97153. get cameraContrast(): number;
  97154. /**
  97155. * Sets The camera contrast used on this material.
  97156. */
  97157. set cameraContrast(value: number);
  97158. /**
  97159. * Gets the Color Grading 2D Lookup Texture.
  97160. */
  97161. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  97162. /**
  97163. * Sets the Color Grading 2D Lookup Texture.
  97164. */
  97165. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  97166. /**
  97167. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97168. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97169. * 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;
  97170. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97171. */
  97172. get cameraColorCurves(): Nullable<ColorCurves>;
  97173. /**
  97174. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97175. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97176. * 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;
  97177. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97178. */
  97179. set cameraColorCurves(value: Nullable<ColorCurves>);
  97180. /**
  97181. * Custom callback helping to override the default shader used in the material.
  97182. */
  97183. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97184. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97185. protected _worldViewProjectionMatrix: Matrix;
  97186. protected _globalAmbientColor: Color3;
  97187. protected _useLogarithmicDepth: boolean;
  97188. protected _rebuildInParallel: boolean;
  97189. /**
  97190. * Instantiates a new standard material.
  97191. * This is the default material used in Babylon. It is the best trade off between quality
  97192. * and performances.
  97193. * @see http://doc.babylonjs.com/babylon101/materials
  97194. * @param name Define the name of the material in the scene
  97195. * @param scene Define the scene the material belong to
  97196. */
  97197. constructor(name: string, scene: Scene);
  97198. /**
  97199. * Gets a boolean indicating that current material needs to register RTT
  97200. */
  97201. get hasRenderTargetTextures(): boolean;
  97202. /**
  97203. * Gets the current class name of the material e.g. "StandardMaterial"
  97204. * Mainly use in serialization.
  97205. * @returns the class name
  97206. */
  97207. getClassName(): string;
  97208. /**
  97209. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97210. * You can try switching to logarithmic depth.
  97211. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97212. */
  97213. get useLogarithmicDepth(): boolean;
  97214. set useLogarithmicDepth(value: boolean);
  97215. /**
  97216. * Specifies if the material will require alpha blending
  97217. * @returns a boolean specifying if alpha blending is needed
  97218. */
  97219. needAlphaBlending(): boolean;
  97220. /**
  97221. * Specifies if this material should be rendered in alpha test mode
  97222. * @returns a boolean specifying if an alpha test is needed.
  97223. */
  97224. needAlphaTesting(): boolean;
  97225. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97226. /**
  97227. * Get the texture used for alpha test purpose.
  97228. * @returns the diffuse texture in case of the standard material.
  97229. */
  97230. getAlphaTestTexture(): Nullable<BaseTexture>;
  97231. /**
  97232. * Get if the submesh is ready to be used and all its information available.
  97233. * Child classes can use it to update shaders
  97234. * @param mesh defines the mesh to check
  97235. * @param subMesh defines which submesh to check
  97236. * @param useInstances specifies that instances should be used
  97237. * @returns a boolean indicating that the submesh is ready or not
  97238. */
  97239. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97240. /**
  97241. * Builds the material UBO layouts.
  97242. * Used internally during the effect preparation.
  97243. */
  97244. buildUniformLayout(): void;
  97245. /**
  97246. * Unbinds the material from the mesh
  97247. */
  97248. unbind(): void;
  97249. /**
  97250. * Binds the submesh to this material by preparing the effect and shader to draw
  97251. * @param world defines the world transformation matrix
  97252. * @param mesh defines the mesh containing the submesh
  97253. * @param subMesh defines the submesh to bind the material to
  97254. */
  97255. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97256. /**
  97257. * Get the list of animatables in the material.
  97258. * @returns the list of animatables object used in the material
  97259. */
  97260. getAnimatables(): IAnimatable[];
  97261. /**
  97262. * Gets the active textures from the material
  97263. * @returns an array of textures
  97264. */
  97265. getActiveTextures(): BaseTexture[];
  97266. /**
  97267. * Specifies if the material uses a texture
  97268. * @param texture defines the texture to check against the material
  97269. * @returns a boolean specifying if the material uses the texture
  97270. */
  97271. hasTexture(texture: BaseTexture): boolean;
  97272. /**
  97273. * Disposes the material
  97274. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97275. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97276. */
  97277. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97278. /**
  97279. * Makes a duplicate of the material, and gives it a new name
  97280. * @param name defines the new name for the duplicated material
  97281. * @returns the cloned material
  97282. */
  97283. clone(name: string): StandardMaterial;
  97284. /**
  97285. * Serializes this material in a JSON representation
  97286. * @returns the serialized material object
  97287. */
  97288. serialize(): any;
  97289. /**
  97290. * Creates a standard material from parsed material data
  97291. * @param source defines the JSON representation of the material
  97292. * @param scene defines the hosting scene
  97293. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97294. * @returns a new standard material
  97295. */
  97296. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97297. /**
  97298. * Are diffuse textures enabled in the application.
  97299. */
  97300. static get DiffuseTextureEnabled(): boolean;
  97301. static set DiffuseTextureEnabled(value: boolean);
  97302. /**
  97303. * Are ambient textures enabled in the application.
  97304. */
  97305. static get AmbientTextureEnabled(): boolean;
  97306. static set AmbientTextureEnabled(value: boolean);
  97307. /**
  97308. * Are opacity textures enabled in the application.
  97309. */
  97310. static get OpacityTextureEnabled(): boolean;
  97311. static set OpacityTextureEnabled(value: boolean);
  97312. /**
  97313. * Are reflection textures enabled in the application.
  97314. */
  97315. static get ReflectionTextureEnabled(): boolean;
  97316. static set ReflectionTextureEnabled(value: boolean);
  97317. /**
  97318. * Are emissive textures enabled in the application.
  97319. */
  97320. static get EmissiveTextureEnabled(): boolean;
  97321. static set EmissiveTextureEnabled(value: boolean);
  97322. /**
  97323. * Are specular textures enabled in the application.
  97324. */
  97325. static get SpecularTextureEnabled(): boolean;
  97326. static set SpecularTextureEnabled(value: boolean);
  97327. /**
  97328. * Are bump textures enabled in the application.
  97329. */
  97330. static get BumpTextureEnabled(): boolean;
  97331. static set BumpTextureEnabled(value: boolean);
  97332. /**
  97333. * Are lightmap textures enabled in the application.
  97334. */
  97335. static get LightmapTextureEnabled(): boolean;
  97336. static set LightmapTextureEnabled(value: boolean);
  97337. /**
  97338. * Are refraction textures enabled in the application.
  97339. */
  97340. static get RefractionTextureEnabled(): boolean;
  97341. static set RefractionTextureEnabled(value: boolean);
  97342. /**
  97343. * Are color grading textures enabled in the application.
  97344. */
  97345. static get ColorGradingTextureEnabled(): boolean;
  97346. static set ColorGradingTextureEnabled(value: boolean);
  97347. /**
  97348. * Are fresnels enabled in the application.
  97349. */
  97350. static get FresnelEnabled(): boolean;
  97351. static set FresnelEnabled(value: boolean);
  97352. }
  97353. }
  97354. declare module BABYLON {
  97355. /**
  97356. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  97357. *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.
  97358. * The SPS is also a particle system. It provides some methods to manage the particles.
  97359. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  97360. *
  97361. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  97362. */
  97363. export class SolidParticleSystem implements IDisposable {
  97364. /**
  97365. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  97366. * Example : var p = SPS.particles[i];
  97367. */
  97368. particles: SolidParticle[];
  97369. /**
  97370. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  97371. */
  97372. nbParticles: number;
  97373. /**
  97374. * If the particles must ever face the camera (default false). Useful for planar particles.
  97375. */
  97376. billboard: boolean;
  97377. /**
  97378. * Recompute normals when adding a shape
  97379. */
  97380. recomputeNormals: boolean;
  97381. /**
  97382. * This a counter ofr your own usage. It's not set by any SPS functions.
  97383. */
  97384. counter: number;
  97385. /**
  97386. * The SPS name. This name is also given to the underlying mesh.
  97387. */
  97388. name: string;
  97389. /**
  97390. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  97391. */
  97392. mesh: Mesh;
  97393. /**
  97394. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  97395. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  97396. */
  97397. vars: any;
  97398. /**
  97399. * This array is populated when the SPS is set as 'pickable'.
  97400. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  97401. * Each element of this array is an object `{idx: int, faceId: int}`.
  97402. * `idx` is the picked particle index in the `SPS.particles` array
  97403. * `faceId` is the picked face index counted within this particle.
  97404. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  97405. */
  97406. pickedParticles: {
  97407. idx: number;
  97408. faceId: number;
  97409. }[];
  97410. /**
  97411. * This array is populated when `enableDepthSort` is set to true.
  97412. * Each element of this array is an instance of the class DepthSortedParticle.
  97413. */
  97414. depthSortedParticles: DepthSortedParticle[];
  97415. /**
  97416. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  97417. * @hidden
  97418. */
  97419. _bSphereOnly: boolean;
  97420. /**
  97421. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  97422. * @hidden
  97423. */
  97424. _bSphereRadiusFactor: number;
  97425. private _scene;
  97426. private _positions;
  97427. private _indices;
  97428. private _normals;
  97429. private _colors;
  97430. private _uvs;
  97431. private _indices32;
  97432. private _positions32;
  97433. private _normals32;
  97434. private _fixedNormal32;
  97435. private _colors32;
  97436. private _uvs32;
  97437. private _index;
  97438. private _updatable;
  97439. private _pickable;
  97440. private _isVisibilityBoxLocked;
  97441. private _alwaysVisible;
  97442. private _depthSort;
  97443. private _expandable;
  97444. private _shapeCounter;
  97445. private _copy;
  97446. private _color;
  97447. private _computeParticleColor;
  97448. private _computeParticleTexture;
  97449. private _computeParticleRotation;
  97450. private _computeParticleVertex;
  97451. private _computeBoundingBox;
  97452. private _depthSortParticles;
  97453. private _camera;
  97454. private _mustUnrotateFixedNormals;
  97455. private _particlesIntersect;
  97456. private _needs32Bits;
  97457. private _isNotBuilt;
  97458. private _lastParticleId;
  97459. private _idxOfId;
  97460. private _multimaterialEnabled;
  97461. private _useModelMaterial;
  97462. private _indicesByMaterial;
  97463. private _materialIndexes;
  97464. private _depthSortFunction;
  97465. private _materialSortFunction;
  97466. private _materials;
  97467. private _multimaterial;
  97468. private _materialIndexesById;
  97469. private _defaultMaterial;
  97470. private _autoUpdateSubMeshes;
  97471. /**
  97472. * Creates a SPS (Solid Particle System) object.
  97473. * @param name (String) is the SPS name, this will be the underlying mesh name.
  97474. * @param scene (Scene) is the scene in which the SPS is added.
  97475. * @param options defines the options of the sps e.g.
  97476. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  97477. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  97478. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  97479. * * 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.
  97480. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  97481. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  97482. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  97483. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  97484. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  97485. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  97486. */
  97487. constructor(name: string, scene: Scene, options?: {
  97488. updatable?: boolean;
  97489. isPickable?: boolean;
  97490. enableDepthSort?: boolean;
  97491. particleIntersection?: boolean;
  97492. boundingSphereOnly?: boolean;
  97493. bSphereRadiusFactor?: number;
  97494. expandable?: boolean;
  97495. useModelMaterial?: boolean;
  97496. enableMultiMaterial?: boolean;
  97497. });
  97498. /**
  97499. * Builds the SPS underlying mesh. Returns a standard Mesh.
  97500. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  97501. * @returns the created mesh
  97502. */
  97503. buildMesh(): Mesh;
  97504. /**
  97505. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  97506. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  97507. * Thus the particles generated from `digest()` have their property `position` set yet.
  97508. * @param mesh ( Mesh ) is the mesh to be digested
  97509. * @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
  97510. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  97511. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  97512. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97513. * @returns the current SPS
  97514. */
  97515. digest(mesh: Mesh, options?: {
  97516. facetNb?: number;
  97517. number?: number;
  97518. delta?: number;
  97519. storage?: [];
  97520. }): SolidParticleSystem;
  97521. /**
  97522. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  97523. * @hidden
  97524. */
  97525. private _unrotateFixedNormals;
  97526. /**
  97527. * Resets the temporary working copy particle
  97528. * @hidden
  97529. */
  97530. private _resetCopy;
  97531. /**
  97532. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  97533. * @param p the current index in the positions array to be updated
  97534. * @param ind the current index in the indices array
  97535. * @param shape a Vector3 array, the shape geometry
  97536. * @param positions the positions array to be updated
  97537. * @param meshInd the shape indices array
  97538. * @param indices the indices array to be updated
  97539. * @param meshUV the shape uv array
  97540. * @param uvs the uv array to be updated
  97541. * @param meshCol the shape color array
  97542. * @param colors the color array to be updated
  97543. * @param meshNor the shape normals array
  97544. * @param normals the normals array to be updated
  97545. * @param idx the particle index
  97546. * @param idxInShape the particle index in its shape
  97547. * @param options the addShape() method passed options
  97548. * @model the particle model
  97549. * @hidden
  97550. */
  97551. private _meshBuilder;
  97552. /**
  97553. * Returns a shape Vector3 array from positions float array
  97554. * @param positions float array
  97555. * @returns a vector3 array
  97556. * @hidden
  97557. */
  97558. private _posToShape;
  97559. /**
  97560. * Returns a shapeUV array from a float uvs (array deep copy)
  97561. * @param uvs as a float array
  97562. * @returns a shapeUV array
  97563. * @hidden
  97564. */
  97565. private _uvsToShapeUV;
  97566. /**
  97567. * Adds a new particle object in the particles array
  97568. * @param idx particle index in particles array
  97569. * @param id particle id
  97570. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  97571. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  97572. * @param model particle ModelShape object
  97573. * @param shapeId model shape identifier
  97574. * @param idxInShape index of the particle in the current model
  97575. * @param bInfo model bounding info object
  97576. * @param storage target storage array, if any
  97577. * @hidden
  97578. */
  97579. private _addParticle;
  97580. /**
  97581. * Adds some particles to the SPS from the model shape. Returns the shape id.
  97582. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  97583. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  97584. * @param nb (positive integer) the number of particles to be created from this model
  97585. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  97586. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  97587. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97588. * @returns the number of shapes in the system
  97589. */
  97590. addShape(mesh: Mesh, nb: number, options?: {
  97591. positionFunction?: any;
  97592. vertexFunction?: any;
  97593. storage?: [];
  97594. }): number;
  97595. /**
  97596. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  97597. * @hidden
  97598. */
  97599. private _rebuildParticle;
  97600. /**
  97601. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  97602. * @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.
  97603. * @returns the SPS.
  97604. */
  97605. rebuildMesh(reset?: boolean): SolidParticleSystem;
  97606. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  97607. * Returns an array with the removed particles.
  97608. * 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.
  97609. * The SPS can't be empty so at least one particle needs to remain in place.
  97610. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  97611. * @param start index of the first particle to remove
  97612. * @param end index of the last particle to remove (included)
  97613. * @returns an array populated with the removed particles
  97614. */
  97615. removeParticles(start: number, end: number): SolidParticle[];
  97616. /**
  97617. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  97618. * @param solidParticleArray an array populated with Solid Particles objects
  97619. * @returns the SPS
  97620. */
  97621. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  97622. /**
  97623. * Creates a new particle and modifies the SPS mesh geometry :
  97624. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  97625. * - calls _addParticle() to populate the particle array
  97626. * factorized code from addShape() and insertParticlesFromArray()
  97627. * @param idx particle index in the particles array
  97628. * @param i particle index in its shape
  97629. * @param modelShape particle ModelShape object
  97630. * @param shape shape vertex array
  97631. * @param meshInd shape indices array
  97632. * @param meshUV shape uv array
  97633. * @param meshCol shape color array
  97634. * @param meshNor shape normals array
  97635. * @param bbInfo shape bounding info
  97636. * @param storage target particle storage
  97637. * @options addShape() passed options
  97638. * @hidden
  97639. */
  97640. private _insertNewParticle;
  97641. /**
  97642. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  97643. * This method calls `updateParticle()` for each particle of the SPS.
  97644. * For an animated SPS, it is usually called within the render loop.
  97645. * 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.
  97646. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  97647. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  97648. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  97649. * @returns the SPS.
  97650. */
  97651. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  97652. /**
  97653. * Disposes the SPS.
  97654. */
  97655. dispose(): void;
  97656. /**
  97657. * Returns a SolidParticle object from its identifier : particle.id
  97658. * @param id (integer) the particle Id
  97659. * @returns the searched particle or null if not found in the SPS.
  97660. */
  97661. getParticleById(id: number): Nullable<SolidParticle>;
  97662. /**
  97663. * Returns a new array populated with the particles having the passed shapeId.
  97664. * @param shapeId (integer) the shape identifier
  97665. * @returns a new solid particle array
  97666. */
  97667. getParticlesByShapeId(shapeId: number): SolidParticle[];
  97668. /**
  97669. * Populates the passed array "ref" with the particles having the passed shapeId.
  97670. * @param shapeId the shape identifier
  97671. * @returns the SPS
  97672. * @param ref
  97673. */
  97674. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  97675. /**
  97676. * Computes the required SubMeshes according the materials assigned to the particles.
  97677. * @returns the solid particle system.
  97678. * Does nothing if called before the SPS mesh is built.
  97679. */
  97680. computeSubMeshes(): SolidParticleSystem;
  97681. /**
  97682. * Sorts the solid particles by material when MultiMaterial is enabled.
  97683. * Updates the indices32 array.
  97684. * Updates the indicesByMaterial array.
  97685. * Updates the mesh indices array.
  97686. * @returns the SPS
  97687. * @hidden
  97688. */
  97689. private _sortParticlesByMaterial;
  97690. /**
  97691. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  97692. * @hidden
  97693. */
  97694. private _setMaterialIndexesById;
  97695. /**
  97696. * Returns an array with unique values of Materials from the passed array
  97697. * @param array the material array to be checked and filtered
  97698. * @hidden
  97699. */
  97700. private _filterUniqueMaterialId;
  97701. /**
  97702. * Sets a new Standard Material as _defaultMaterial if not already set.
  97703. * @hidden
  97704. */
  97705. private _setDefaultMaterial;
  97706. /**
  97707. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  97708. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97709. * @returns the SPS.
  97710. */
  97711. refreshVisibleSize(): SolidParticleSystem;
  97712. /**
  97713. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  97714. * @param size the size (float) of the visibility box
  97715. * note : this doesn't lock the SPS mesh bounding box.
  97716. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97717. */
  97718. setVisibilityBox(size: number): void;
  97719. /**
  97720. * Gets whether the SPS as always visible or not
  97721. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97722. */
  97723. get isAlwaysVisible(): boolean;
  97724. /**
  97725. * Sets the SPS as always visible or not
  97726. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97727. */
  97728. set isAlwaysVisible(val: boolean);
  97729. /**
  97730. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97731. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97732. */
  97733. set isVisibilityBoxLocked(val: boolean);
  97734. /**
  97735. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97736. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97737. */
  97738. get isVisibilityBoxLocked(): boolean;
  97739. /**
  97740. * Tells to `setParticles()` to compute the particle rotations or not.
  97741. * Default value : true. The SPS is faster when it's set to false.
  97742. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97743. */
  97744. set computeParticleRotation(val: boolean);
  97745. /**
  97746. * Tells to `setParticles()` to compute the particle colors or not.
  97747. * Default value : true. The SPS is faster when it's set to false.
  97748. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97749. */
  97750. set computeParticleColor(val: boolean);
  97751. set computeParticleTexture(val: boolean);
  97752. /**
  97753. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  97754. * Default value : false. The SPS is faster when it's set to false.
  97755. * Note : the particle custom vertex positions aren't stored values.
  97756. */
  97757. set computeParticleVertex(val: boolean);
  97758. /**
  97759. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  97760. */
  97761. set computeBoundingBox(val: boolean);
  97762. /**
  97763. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  97764. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97765. * Default : `true`
  97766. */
  97767. set depthSortParticles(val: boolean);
  97768. /**
  97769. * Gets if `setParticles()` computes the particle rotations or not.
  97770. * Default value : true. The SPS is faster when it's set to false.
  97771. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97772. */
  97773. get computeParticleRotation(): boolean;
  97774. /**
  97775. * Gets if `setParticles()` computes the particle colors or not.
  97776. * Default value : true. The SPS is faster when it's set to false.
  97777. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97778. */
  97779. get computeParticleColor(): boolean;
  97780. /**
  97781. * Gets if `setParticles()` computes the particle textures or not.
  97782. * Default value : true. The SPS is faster when it's set to false.
  97783. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  97784. */
  97785. get computeParticleTexture(): boolean;
  97786. /**
  97787. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  97788. * Default value : false. The SPS is faster when it's set to false.
  97789. * Note : the particle custom vertex positions aren't stored values.
  97790. */
  97791. get computeParticleVertex(): boolean;
  97792. /**
  97793. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  97794. */
  97795. get computeBoundingBox(): boolean;
  97796. /**
  97797. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  97798. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97799. * Default : `true`
  97800. */
  97801. get depthSortParticles(): boolean;
  97802. /**
  97803. * Gets if the SPS is created as expandable at construction time.
  97804. * Default : `false`
  97805. */
  97806. get expandable(): boolean;
  97807. /**
  97808. * Gets if the SPS supports the Multi Materials
  97809. */
  97810. get multimaterialEnabled(): boolean;
  97811. /**
  97812. * Gets if the SPS uses the model materials for its own multimaterial.
  97813. */
  97814. get useModelMaterial(): boolean;
  97815. /**
  97816. * The SPS used material array.
  97817. */
  97818. get materials(): Material[];
  97819. /**
  97820. * Sets the SPS MultiMaterial from the passed materials.
  97821. * Note : the passed array is internally copied and not used then by reference.
  97822. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  97823. */
  97824. setMultiMaterial(materials: Material[]): void;
  97825. /**
  97826. * The SPS computed multimaterial object
  97827. */
  97828. get multimaterial(): MultiMaterial;
  97829. set multimaterial(mm: MultiMaterial);
  97830. /**
  97831. * If the subMeshes must be updated on the next call to setParticles()
  97832. */
  97833. get autoUpdateSubMeshes(): boolean;
  97834. set autoUpdateSubMeshes(val: boolean);
  97835. /**
  97836. * This function does nothing. It may be overwritten to set all the particle first values.
  97837. * The SPS doesn't call this function, you may have to call it by your own.
  97838. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97839. */
  97840. initParticles(): void;
  97841. /**
  97842. * This function does nothing. It may be overwritten to recycle a particle.
  97843. * The SPS doesn't call this function, you may have to call it by your own.
  97844. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97845. * @param particle The particle to recycle
  97846. * @returns the recycled particle
  97847. */
  97848. recycleParticle(particle: SolidParticle): SolidParticle;
  97849. /**
  97850. * Updates a particle : this function should be overwritten by the user.
  97851. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  97852. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97853. * @example : just set a particle position or velocity and recycle conditions
  97854. * @param particle The particle to update
  97855. * @returns the updated particle
  97856. */
  97857. updateParticle(particle: SolidParticle): SolidParticle;
  97858. /**
  97859. * Updates a vertex of a particle : it can be overwritten by the user.
  97860. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  97861. * @param particle the current particle
  97862. * @param vertex the current index of the current particle
  97863. * @param pt the index of the current vertex in the particle shape
  97864. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  97865. * @example : just set a vertex particle position
  97866. * @returns the updated vertex
  97867. */
  97868. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  97869. /**
  97870. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  97871. * This does nothing and may be overwritten by the user.
  97872. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97873. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97874. * @param update the boolean update value actually passed to setParticles()
  97875. */
  97876. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97877. /**
  97878. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  97879. * This will be passed three parameters.
  97880. * This does nothing and may be overwritten by the user.
  97881. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97882. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97883. * @param update the boolean update value actually passed to setParticles()
  97884. */
  97885. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97886. }
  97887. }
  97888. declare module BABYLON {
  97889. /**
  97890. * Represents one particle of a solid particle system.
  97891. */
  97892. export class SolidParticle {
  97893. /**
  97894. * particle global index
  97895. */
  97896. idx: number;
  97897. /**
  97898. * particle identifier
  97899. */
  97900. id: number;
  97901. /**
  97902. * The color of the particle
  97903. */
  97904. color: Nullable<Color4>;
  97905. /**
  97906. * The world space position of the particle.
  97907. */
  97908. position: Vector3;
  97909. /**
  97910. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  97911. */
  97912. rotation: Vector3;
  97913. /**
  97914. * The world space rotation quaternion of the particle.
  97915. */
  97916. rotationQuaternion: Nullable<Quaternion>;
  97917. /**
  97918. * The scaling of the particle.
  97919. */
  97920. scaling: Vector3;
  97921. /**
  97922. * The uvs of the particle.
  97923. */
  97924. uvs: Vector4;
  97925. /**
  97926. * The current speed of the particle.
  97927. */
  97928. velocity: Vector3;
  97929. /**
  97930. * The pivot point in the particle local space.
  97931. */
  97932. pivot: Vector3;
  97933. /**
  97934. * Must the particle be translated from its pivot point in its local space ?
  97935. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  97936. * Default : false
  97937. */
  97938. translateFromPivot: boolean;
  97939. /**
  97940. * Is the particle active or not ?
  97941. */
  97942. alive: boolean;
  97943. /**
  97944. * Is the particle visible or not ?
  97945. */
  97946. isVisible: boolean;
  97947. /**
  97948. * Index of this particle in the global "positions" array (Internal use)
  97949. * @hidden
  97950. */
  97951. _pos: number;
  97952. /**
  97953. * @hidden Index of this particle in the global "indices" array (Internal use)
  97954. */
  97955. _ind: number;
  97956. /**
  97957. * @hidden ModelShape of this particle (Internal use)
  97958. */
  97959. _model: ModelShape;
  97960. /**
  97961. * ModelShape id of this particle
  97962. */
  97963. shapeId: number;
  97964. /**
  97965. * Index of the particle in its shape id
  97966. */
  97967. idxInShape: number;
  97968. /**
  97969. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  97970. */
  97971. _modelBoundingInfo: BoundingInfo;
  97972. /**
  97973. * @hidden Particle BoundingInfo object (Internal use)
  97974. */
  97975. _boundingInfo: BoundingInfo;
  97976. /**
  97977. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  97978. */
  97979. _sps: SolidParticleSystem;
  97980. /**
  97981. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  97982. */
  97983. _stillInvisible: boolean;
  97984. /**
  97985. * @hidden Last computed particle rotation matrix
  97986. */
  97987. _rotationMatrix: number[];
  97988. /**
  97989. * Parent particle Id, if any.
  97990. * Default null.
  97991. */
  97992. parentId: Nullable<number>;
  97993. /**
  97994. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  97995. */
  97996. materialIndex: Nullable<number>;
  97997. /**
  97998. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  97999. * The possible values are :
  98000. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98001. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98002. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98003. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98004. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98005. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  98006. * */
  98007. cullingStrategy: number;
  98008. /**
  98009. * @hidden Internal global position in the SPS.
  98010. */
  98011. _globalPosition: Vector3;
  98012. /**
  98013. * Creates a Solid Particle object.
  98014. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  98015. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  98016. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  98017. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  98018. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  98019. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  98020. * @param shapeId (integer) is the model shape identifier in the SPS.
  98021. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  98022. * @param sps defines the sps it is associated to
  98023. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  98024. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  98025. */
  98026. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  98027. /**
  98028. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  98029. * @param target the particle target
  98030. * @returns the current particle
  98031. */
  98032. copyToRef(target: SolidParticle): SolidParticle;
  98033. /**
  98034. * Legacy support, changed scale to scaling
  98035. */
  98036. get scale(): Vector3;
  98037. /**
  98038. * Legacy support, changed scale to scaling
  98039. */
  98040. set scale(scale: Vector3);
  98041. /**
  98042. * Legacy support, changed quaternion to rotationQuaternion
  98043. */
  98044. get quaternion(): Nullable<Quaternion>;
  98045. /**
  98046. * Legacy support, changed quaternion to rotationQuaternion
  98047. */
  98048. set quaternion(q: Nullable<Quaternion>);
  98049. /**
  98050. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  98051. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  98052. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  98053. * @returns true if it intersects
  98054. */
  98055. intersectsMesh(target: Mesh | SolidParticle): boolean;
  98056. /**
  98057. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  98058. * A particle is in the frustum if its bounding box intersects the frustum
  98059. * @param frustumPlanes defines the frustum to test
  98060. * @returns true if the particle is in the frustum planes
  98061. */
  98062. isInFrustum(frustumPlanes: Plane[]): boolean;
  98063. /**
  98064. * get the rotation matrix of the particle
  98065. * @hidden
  98066. */
  98067. getRotationMatrix(m: Matrix): void;
  98068. }
  98069. /**
  98070. * Represents the shape of the model used by one particle of a solid particle system.
  98071. * SPS internal tool, don't use it manually.
  98072. */
  98073. export class ModelShape {
  98074. /**
  98075. * The shape id
  98076. * @hidden
  98077. */
  98078. shapeID: number;
  98079. /**
  98080. * flat array of model positions (internal use)
  98081. * @hidden
  98082. */
  98083. _shape: Vector3[];
  98084. /**
  98085. * flat array of model UVs (internal use)
  98086. * @hidden
  98087. */
  98088. _shapeUV: number[];
  98089. /**
  98090. * color array of the model
  98091. * @hidden
  98092. */
  98093. _shapeColors: number[];
  98094. /**
  98095. * indices array of the model
  98096. * @hidden
  98097. */
  98098. _indices: number[];
  98099. /**
  98100. * normals array of the model
  98101. * @hidden
  98102. */
  98103. _normals: number[];
  98104. /**
  98105. * length of the shape in the model indices array (internal use)
  98106. * @hidden
  98107. */
  98108. _indicesLength: number;
  98109. /**
  98110. * Custom position function (internal use)
  98111. * @hidden
  98112. */
  98113. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  98114. /**
  98115. * Custom vertex function (internal use)
  98116. * @hidden
  98117. */
  98118. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  98119. /**
  98120. * Model material (internal use)
  98121. * @hidden
  98122. */
  98123. _material: Nullable<Material>;
  98124. /**
  98125. * 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.
  98126. * SPS internal tool, don't use it manually.
  98127. * @hidden
  98128. */
  98129. 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>);
  98130. }
  98131. /**
  98132. * Represents a Depth Sorted Particle in the solid particle system.
  98133. * @hidden
  98134. */
  98135. export class DepthSortedParticle {
  98136. /**
  98137. * Index of the particle in the "indices" array
  98138. */
  98139. ind: number;
  98140. /**
  98141. * Length of the particle shape in the "indices" array
  98142. */
  98143. indicesLength: number;
  98144. /**
  98145. * Squared distance from the particle to the camera
  98146. */
  98147. sqDistance: number;
  98148. /**
  98149. * Material index when used with MultiMaterials
  98150. */
  98151. materialIndex: number;
  98152. /**
  98153. * Creates a new sorted particle
  98154. * @param materialIndex
  98155. */
  98156. constructor(ind: number, indLength: number, materialIndex: number);
  98157. }
  98158. }
  98159. declare module BABYLON {
  98160. /**
  98161. * @hidden
  98162. */
  98163. export class _MeshCollisionData {
  98164. _checkCollisions: boolean;
  98165. _collisionMask: number;
  98166. _collisionGroup: number;
  98167. _collider: Nullable<Collider>;
  98168. _oldPositionForCollisions: Vector3;
  98169. _diffPositionForCollisions: Vector3;
  98170. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  98171. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  98172. }
  98173. }
  98174. declare module BABYLON {
  98175. /** @hidden */
  98176. class _FacetDataStorage {
  98177. facetPositions: Vector3[];
  98178. facetNormals: Vector3[];
  98179. facetPartitioning: number[][];
  98180. facetNb: number;
  98181. partitioningSubdivisions: number;
  98182. partitioningBBoxRatio: number;
  98183. facetDataEnabled: boolean;
  98184. facetParameters: any;
  98185. bbSize: Vector3;
  98186. subDiv: {
  98187. max: number;
  98188. X: number;
  98189. Y: number;
  98190. Z: number;
  98191. };
  98192. facetDepthSort: boolean;
  98193. facetDepthSortEnabled: boolean;
  98194. depthSortedIndices: IndicesArray;
  98195. depthSortedFacets: {
  98196. ind: number;
  98197. sqDistance: number;
  98198. }[];
  98199. facetDepthSortFunction: (f1: {
  98200. ind: number;
  98201. sqDistance: number;
  98202. }, f2: {
  98203. ind: number;
  98204. sqDistance: number;
  98205. }) => number;
  98206. facetDepthSortFrom: Vector3;
  98207. facetDepthSortOrigin: Vector3;
  98208. invertedMatrix: Matrix;
  98209. }
  98210. /**
  98211. * @hidden
  98212. **/
  98213. class _InternalAbstractMeshDataInfo {
  98214. _hasVertexAlpha: boolean;
  98215. _useVertexColors: boolean;
  98216. _numBoneInfluencers: number;
  98217. _applyFog: boolean;
  98218. _receiveShadows: boolean;
  98219. _facetData: _FacetDataStorage;
  98220. _visibility: number;
  98221. _skeleton: Nullable<Skeleton>;
  98222. _layerMask: number;
  98223. _computeBonesUsingShaders: boolean;
  98224. _isActive: boolean;
  98225. _onlyForInstances: boolean;
  98226. _isActiveIntermediate: boolean;
  98227. _onlyForInstancesIntermediate: boolean;
  98228. _actAsRegularMesh: boolean;
  98229. }
  98230. /**
  98231. * Class used to store all common mesh properties
  98232. */
  98233. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  98234. /** No occlusion */
  98235. static OCCLUSION_TYPE_NONE: number;
  98236. /** Occlusion set to optimisitic */
  98237. static OCCLUSION_TYPE_OPTIMISTIC: number;
  98238. /** Occlusion set to strict */
  98239. static OCCLUSION_TYPE_STRICT: number;
  98240. /** Use an accurante occlusion algorithm */
  98241. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  98242. /** Use a conservative occlusion algorithm */
  98243. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  98244. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  98245. * Test order :
  98246. * Is the bounding sphere outside the frustum ?
  98247. * If not, are the bounding box vertices outside the frustum ?
  98248. * It not, then the cullable object is in the frustum.
  98249. */
  98250. static readonly CULLINGSTRATEGY_STANDARD: number;
  98251. /** Culling strategy : Bounding Sphere Only.
  98252. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  98253. * It's also less accurate than the standard because some not visible objects can still be selected.
  98254. * Test : is the bounding sphere outside the frustum ?
  98255. * If not, then the cullable object is in the frustum.
  98256. */
  98257. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  98258. /** Culling strategy : Optimistic Inclusion.
  98259. * This in an inclusion test first, then the standard exclusion test.
  98260. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  98261. * 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.
  98262. * Anyway, it's as accurate as the standard strategy.
  98263. * Test :
  98264. * Is the cullable object bounding sphere center in the frustum ?
  98265. * If not, apply the default culling strategy.
  98266. */
  98267. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  98268. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  98269. * This in an inclusion test first, then the bounding sphere only exclusion test.
  98270. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  98271. * 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.
  98272. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  98273. * Test :
  98274. * Is the cullable object bounding sphere center in the frustum ?
  98275. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  98276. */
  98277. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  98278. /**
  98279. * No billboard
  98280. */
  98281. static get BILLBOARDMODE_NONE(): number;
  98282. /** Billboard on X axis */
  98283. static get BILLBOARDMODE_X(): number;
  98284. /** Billboard on Y axis */
  98285. static get BILLBOARDMODE_Y(): number;
  98286. /** Billboard on Z axis */
  98287. static get BILLBOARDMODE_Z(): number;
  98288. /** Billboard on all axes */
  98289. static get BILLBOARDMODE_ALL(): number;
  98290. /** Billboard on using position instead of orientation */
  98291. static get BILLBOARDMODE_USE_POSITION(): number;
  98292. /** @hidden */
  98293. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  98294. /**
  98295. * The culling strategy to use to check whether the mesh must be rendered or not.
  98296. * This value can be changed at any time and will be used on the next render mesh selection.
  98297. * The possible values are :
  98298. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98299. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98300. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98301. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98302. * Please read each static variable documentation to get details about the culling process.
  98303. * */
  98304. cullingStrategy: number;
  98305. /**
  98306. * Gets the number of facets in the mesh
  98307. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98308. */
  98309. get facetNb(): number;
  98310. /**
  98311. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  98312. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98313. */
  98314. get partitioningSubdivisions(): number;
  98315. set partitioningSubdivisions(nb: number);
  98316. /**
  98317. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  98318. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  98319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98320. */
  98321. get partitioningBBoxRatio(): number;
  98322. set partitioningBBoxRatio(ratio: number);
  98323. /**
  98324. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  98325. * Works only for updatable meshes.
  98326. * Doesn't work with multi-materials
  98327. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98328. */
  98329. get mustDepthSortFacets(): boolean;
  98330. set mustDepthSortFacets(sort: boolean);
  98331. /**
  98332. * The location (Vector3) where the facet depth sort must be computed from.
  98333. * By default, the active camera position.
  98334. * Used only when facet depth sort is enabled
  98335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98336. */
  98337. get facetDepthSortFrom(): Vector3;
  98338. set facetDepthSortFrom(location: Vector3);
  98339. /**
  98340. * gets a boolean indicating if facetData is enabled
  98341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98342. */
  98343. get isFacetDataEnabled(): boolean;
  98344. /** @hidden */
  98345. _updateNonUniformScalingState(value: boolean): boolean;
  98346. /**
  98347. * An event triggered when this mesh collides with another one
  98348. */
  98349. onCollideObservable: Observable<AbstractMesh>;
  98350. /** Set a function to call when this mesh collides with another one */
  98351. set onCollide(callback: () => void);
  98352. /**
  98353. * An event triggered when the collision's position changes
  98354. */
  98355. onCollisionPositionChangeObservable: Observable<Vector3>;
  98356. /** Set a function to call when the collision's position changes */
  98357. set onCollisionPositionChange(callback: () => void);
  98358. /**
  98359. * An event triggered when material is changed
  98360. */
  98361. onMaterialChangedObservable: Observable<AbstractMesh>;
  98362. /**
  98363. * Gets or sets the orientation for POV movement & rotation
  98364. */
  98365. definedFacingForward: boolean;
  98366. /** @hidden */
  98367. _occlusionQuery: Nullable<WebGLQuery>;
  98368. /** @hidden */
  98369. _renderingGroup: Nullable<RenderingGroup>;
  98370. /**
  98371. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98372. */
  98373. get visibility(): number;
  98374. /**
  98375. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98376. */
  98377. set visibility(value: number);
  98378. /** Gets or sets the alpha index used to sort transparent meshes
  98379. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  98380. */
  98381. alphaIndex: number;
  98382. /**
  98383. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  98384. */
  98385. isVisible: boolean;
  98386. /**
  98387. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  98388. */
  98389. isPickable: boolean;
  98390. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  98391. showSubMeshesBoundingBox: boolean;
  98392. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  98393. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  98394. */
  98395. isBlocker: boolean;
  98396. /**
  98397. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  98398. */
  98399. enablePointerMoveEvents: boolean;
  98400. /**
  98401. * Specifies the rendering group id for this mesh (0 by default)
  98402. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  98403. */
  98404. renderingGroupId: number;
  98405. private _material;
  98406. /** Gets or sets current material */
  98407. get material(): Nullable<Material>;
  98408. set material(value: Nullable<Material>);
  98409. /**
  98410. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  98411. * @see http://doc.babylonjs.com/babylon101/shadows
  98412. */
  98413. get receiveShadows(): boolean;
  98414. set receiveShadows(value: boolean);
  98415. /** Defines color to use when rendering outline */
  98416. outlineColor: Color3;
  98417. /** Define width to use when rendering outline */
  98418. outlineWidth: number;
  98419. /** Defines color to use when rendering overlay */
  98420. overlayColor: Color3;
  98421. /** Defines alpha to use when rendering overlay */
  98422. overlayAlpha: number;
  98423. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  98424. get hasVertexAlpha(): boolean;
  98425. set hasVertexAlpha(value: boolean);
  98426. /** 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) */
  98427. get useVertexColors(): boolean;
  98428. set useVertexColors(value: boolean);
  98429. /**
  98430. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  98431. */
  98432. get computeBonesUsingShaders(): boolean;
  98433. set computeBonesUsingShaders(value: boolean);
  98434. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  98435. get numBoneInfluencers(): number;
  98436. set numBoneInfluencers(value: number);
  98437. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  98438. get applyFog(): boolean;
  98439. set applyFog(value: boolean);
  98440. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  98441. useOctreeForRenderingSelection: boolean;
  98442. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  98443. useOctreeForPicking: boolean;
  98444. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  98445. useOctreeForCollisions: boolean;
  98446. /**
  98447. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  98448. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  98449. */
  98450. get layerMask(): number;
  98451. set layerMask(value: number);
  98452. /**
  98453. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  98454. */
  98455. alwaysSelectAsActiveMesh: boolean;
  98456. /**
  98457. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  98458. */
  98459. doNotSyncBoundingInfo: boolean;
  98460. /**
  98461. * Gets or sets the current action manager
  98462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98463. */
  98464. actionManager: Nullable<AbstractActionManager>;
  98465. private _meshCollisionData;
  98466. /**
  98467. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  98468. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98469. */
  98470. ellipsoid: Vector3;
  98471. /**
  98472. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  98473. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98474. */
  98475. ellipsoidOffset: Vector3;
  98476. /**
  98477. * Gets or sets a collision mask used to mask collisions (default is -1).
  98478. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98479. */
  98480. get collisionMask(): number;
  98481. set collisionMask(mask: number);
  98482. /**
  98483. * Gets or sets the current collision group mask (-1 by default).
  98484. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98485. */
  98486. get collisionGroup(): number;
  98487. set collisionGroup(mask: number);
  98488. /**
  98489. * Defines edge width used when edgesRenderer is enabled
  98490. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98491. */
  98492. edgesWidth: number;
  98493. /**
  98494. * Defines edge color used when edgesRenderer is enabled
  98495. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98496. */
  98497. edgesColor: Color4;
  98498. /** @hidden */
  98499. _edgesRenderer: Nullable<IEdgesRenderer>;
  98500. /** @hidden */
  98501. _masterMesh: Nullable<AbstractMesh>;
  98502. /** @hidden */
  98503. _boundingInfo: Nullable<BoundingInfo>;
  98504. /** @hidden */
  98505. _renderId: number;
  98506. /**
  98507. * Gets or sets the list of subMeshes
  98508. * @see http://doc.babylonjs.com/how_to/multi_materials
  98509. */
  98510. subMeshes: SubMesh[];
  98511. /** @hidden */
  98512. _intersectionsInProgress: AbstractMesh[];
  98513. /** @hidden */
  98514. _unIndexed: boolean;
  98515. /** @hidden */
  98516. _lightSources: Light[];
  98517. /** Gets the list of lights affecting that mesh */
  98518. get lightSources(): Light[];
  98519. /** @hidden */
  98520. get _positions(): Nullable<Vector3[]>;
  98521. /** @hidden */
  98522. _waitingData: {
  98523. lods: Nullable<any>;
  98524. actions: Nullable<any>;
  98525. freezeWorldMatrix: Nullable<boolean>;
  98526. };
  98527. /** @hidden */
  98528. _bonesTransformMatrices: Nullable<Float32Array>;
  98529. /** @hidden */
  98530. _transformMatrixTexture: Nullable<RawTexture>;
  98531. /**
  98532. * Gets or sets a skeleton to apply skining transformations
  98533. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98534. */
  98535. set skeleton(value: Nullable<Skeleton>);
  98536. get skeleton(): Nullable<Skeleton>;
  98537. /**
  98538. * An event triggered when the mesh is rebuilt.
  98539. */
  98540. onRebuildObservable: Observable<AbstractMesh>;
  98541. /**
  98542. * Creates a new AbstractMesh
  98543. * @param name defines the name of the mesh
  98544. * @param scene defines the hosting scene
  98545. */
  98546. constructor(name: string, scene?: Nullable<Scene>);
  98547. /**
  98548. * Returns the string "AbstractMesh"
  98549. * @returns "AbstractMesh"
  98550. */
  98551. getClassName(): string;
  98552. /**
  98553. * Gets a string representation of the current mesh
  98554. * @param fullDetails defines a boolean indicating if full details must be included
  98555. * @returns a string representation of the current mesh
  98556. */
  98557. toString(fullDetails?: boolean): string;
  98558. /**
  98559. * @hidden
  98560. */
  98561. protected _getEffectiveParent(): Nullable<Node>;
  98562. /** @hidden */
  98563. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  98564. /** @hidden */
  98565. _rebuild(): void;
  98566. /** @hidden */
  98567. _resyncLightSources(): void;
  98568. /** @hidden */
  98569. _resyncLightSource(light: Light): void;
  98570. /** @hidden */
  98571. _unBindEffect(): void;
  98572. /** @hidden */
  98573. _removeLightSource(light: Light, dispose: boolean): void;
  98574. private _markSubMeshesAsDirty;
  98575. /** @hidden */
  98576. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  98577. /** @hidden */
  98578. _markSubMeshesAsAttributesDirty(): void;
  98579. /** @hidden */
  98580. _markSubMeshesAsMiscDirty(): void;
  98581. /**
  98582. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  98583. */
  98584. get scaling(): Vector3;
  98585. set scaling(newScaling: Vector3);
  98586. /**
  98587. * Returns true if the mesh is blocked. Implemented by child classes
  98588. */
  98589. get isBlocked(): boolean;
  98590. /**
  98591. * Returns the mesh itself by default. Implemented by child classes
  98592. * @param camera defines the camera to use to pick the right LOD level
  98593. * @returns the currentAbstractMesh
  98594. */
  98595. getLOD(camera: Camera): Nullable<AbstractMesh>;
  98596. /**
  98597. * Returns 0 by default. Implemented by child classes
  98598. * @returns an integer
  98599. */
  98600. getTotalVertices(): number;
  98601. /**
  98602. * Returns a positive integer : the total number of indices in this mesh geometry.
  98603. * @returns the numner of indices or zero if the mesh has no geometry.
  98604. */
  98605. getTotalIndices(): number;
  98606. /**
  98607. * Returns null by default. Implemented by child classes
  98608. * @returns null
  98609. */
  98610. getIndices(): Nullable<IndicesArray>;
  98611. /**
  98612. * Returns the array of the requested vertex data kind. Implemented by child classes
  98613. * @param kind defines the vertex data kind to use
  98614. * @returns null
  98615. */
  98616. getVerticesData(kind: string): Nullable<FloatArray>;
  98617. /**
  98618. * Sets the vertex data of the mesh geometry for the requested `kind`.
  98619. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  98620. * Note that a new underlying VertexBuffer object is created each call.
  98621. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  98622. * @param kind defines vertex data kind:
  98623. * * VertexBuffer.PositionKind
  98624. * * VertexBuffer.UVKind
  98625. * * VertexBuffer.UV2Kind
  98626. * * VertexBuffer.UV3Kind
  98627. * * VertexBuffer.UV4Kind
  98628. * * VertexBuffer.UV5Kind
  98629. * * VertexBuffer.UV6Kind
  98630. * * VertexBuffer.ColorKind
  98631. * * VertexBuffer.MatricesIndicesKind
  98632. * * VertexBuffer.MatricesIndicesExtraKind
  98633. * * VertexBuffer.MatricesWeightsKind
  98634. * * VertexBuffer.MatricesWeightsExtraKind
  98635. * @param data defines the data source
  98636. * @param updatable defines if the data must be flagged as updatable (or static)
  98637. * @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
  98638. * @returns the current mesh
  98639. */
  98640. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98641. /**
  98642. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  98643. * If the mesh has no geometry, it is simply returned as it is.
  98644. * @param kind defines vertex data kind:
  98645. * * VertexBuffer.PositionKind
  98646. * * VertexBuffer.UVKind
  98647. * * VertexBuffer.UV2Kind
  98648. * * VertexBuffer.UV3Kind
  98649. * * VertexBuffer.UV4Kind
  98650. * * VertexBuffer.UV5Kind
  98651. * * VertexBuffer.UV6Kind
  98652. * * VertexBuffer.ColorKind
  98653. * * VertexBuffer.MatricesIndicesKind
  98654. * * VertexBuffer.MatricesIndicesExtraKind
  98655. * * VertexBuffer.MatricesWeightsKind
  98656. * * VertexBuffer.MatricesWeightsExtraKind
  98657. * @param data defines the data source
  98658. * @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
  98659. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  98660. * @returns the current mesh
  98661. */
  98662. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98663. /**
  98664. * Sets the mesh indices,
  98665. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  98666. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  98667. * @param totalVertices Defines the total number of vertices
  98668. * @returns the current mesh
  98669. */
  98670. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  98671. /**
  98672. * Gets a boolean indicating if specific vertex data is present
  98673. * @param kind defines the vertex data kind to use
  98674. * @returns true is data kind is present
  98675. */
  98676. isVerticesDataPresent(kind: string): boolean;
  98677. /**
  98678. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  98679. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  98680. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  98681. * @returns a BoundingInfo
  98682. */
  98683. getBoundingInfo(): BoundingInfo;
  98684. /**
  98685. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  98686. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  98687. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  98688. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  98689. * @returns the current mesh
  98690. */
  98691. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  98692. /**
  98693. * Overwrite the current bounding info
  98694. * @param boundingInfo defines the new bounding info
  98695. * @returns the current mesh
  98696. */
  98697. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  98698. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  98699. get useBones(): boolean;
  98700. /** @hidden */
  98701. _preActivate(): void;
  98702. /** @hidden */
  98703. _preActivateForIntermediateRendering(renderId: number): void;
  98704. /** @hidden */
  98705. _activate(renderId: number, intermediateRendering: boolean): boolean;
  98706. /** @hidden */
  98707. _postActivate(): void;
  98708. /** @hidden */
  98709. _freeze(): void;
  98710. /** @hidden */
  98711. _unFreeze(): void;
  98712. /**
  98713. * Gets the current world matrix
  98714. * @returns a Matrix
  98715. */
  98716. getWorldMatrix(): Matrix;
  98717. /** @hidden */
  98718. _getWorldMatrixDeterminant(): number;
  98719. /**
  98720. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  98721. */
  98722. get isAnInstance(): boolean;
  98723. /**
  98724. * Gets a boolean indicating if this mesh has instances
  98725. */
  98726. get hasInstances(): boolean;
  98727. /**
  98728. * Perform relative position change from the point of view of behind the front of the mesh.
  98729. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98730. * Supports definition of mesh facing forward or backward
  98731. * @param amountRight defines the distance on the right axis
  98732. * @param amountUp defines the distance on the up axis
  98733. * @param amountForward defines the distance on the forward axis
  98734. * @returns the current mesh
  98735. */
  98736. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  98737. /**
  98738. * Calculate relative position change from the point of view of behind the front of the mesh.
  98739. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98740. * Supports definition of mesh facing forward or backward
  98741. * @param amountRight defines the distance on the right axis
  98742. * @param amountUp defines the distance on the up axis
  98743. * @param amountForward defines the distance on the forward axis
  98744. * @returns the new displacement vector
  98745. */
  98746. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  98747. /**
  98748. * Perform relative rotation change from the point of view of behind the front of the mesh.
  98749. * Supports definition of mesh facing forward or backward
  98750. * @param flipBack defines the flip
  98751. * @param twirlClockwise defines the twirl
  98752. * @param tiltRight defines the tilt
  98753. * @returns the current mesh
  98754. */
  98755. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  98756. /**
  98757. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  98758. * Supports definition of mesh facing forward or backward.
  98759. * @param flipBack defines the flip
  98760. * @param twirlClockwise defines the twirl
  98761. * @param tiltRight defines the tilt
  98762. * @returns the new rotation vector
  98763. */
  98764. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  98765. /**
  98766. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98767. * This means the mesh underlying bounding box and sphere are recomputed.
  98768. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98769. * @returns the current mesh
  98770. */
  98771. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  98772. /** @hidden */
  98773. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  98774. /** @hidden */
  98775. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  98776. /** @hidden */
  98777. _updateBoundingInfo(): AbstractMesh;
  98778. /** @hidden */
  98779. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  98780. /** @hidden */
  98781. protected _afterComputeWorldMatrix(): void;
  98782. /** @hidden */
  98783. get _effectiveMesh(): AbstractMesh;
  98784. /**
  98785. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98786. * A mesh is in the frustum if its bounding box intersects the frustum
  98787. * @param frustumPlanes defines the frustum to test
  98788. * @returns true if the mesh is in the frustum planes
  98789. */
  98790. isInFrustum(frustumPlanes: Plane[]): boolean;
  98791. /**
  98792. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  98793. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  98794. * @param frustumPlanes defines the frustum to test
  98795. * @returns true if the mesh is completely in the frustum planes
  98796. */
  98797. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  98798. /**
  98799. * True if the mesh intersects another mesh or a SolidParticle object
  98800. * @param mesh defines a target mesh or SolidParticle to test
  98801. * @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)
  98802. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  98803. * @returns true if there is an intersection
  98804. */
  98805. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  98806. /**
  98807. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  98808. * @param point defines the point to test
  98809. * @returns true if there is an intersection
  98810. */
  98811. intersectsPoint(point: Vector3): boolean;
  98812. /**
  98813. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  98814. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98815. */
  98816. get checkCollisions(): boolean;
  98817. set checkCollisions(collisionEnabled: boolean);
  98818. /**
  98819. * Gets Collider object used to compute collisions (not physics)
  98820. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98821. */
  98822. get collider(): Nullable<Collider>;
  98823. /**
  98824. * Move the mesh using collision engine
  98825. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98826. * @param displacement defines the requested displacement vector
  98827. * @returns the current mesh
  98828. */
  98829. moveWithCollisions(displacement: Vector3): AbstractMesh;
  98830. private _onCollisionPositionChange;
  98831. /** @hidden */
  98832. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  98833. /** @hidden */
  98834. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  98835. /** @hidden */
  98836. _checkCollision(collider: Collider): AbstractMesh;
  98837. /** @hidden */
  98838. _generatePointsArray(): boolean;
  98839. /**
  98840. * Checks if the passed Ray intersects with the mesh
  98841. * @param ray defines the ray to use
  98842. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  98843. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98844. * @returns the picking info
  98845. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  98846. */
  98847. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  98848. /**
  98849. * Clones the current mesh
  98850. * @param name defines the mesh name
  98851. * @param newParent defines the new mesh parent
  98852. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  98853. * @returns the new mesh
  98854. */
  98855. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  98856. /**
  98857. * Disposes all the submeshes of the current meshnp
  98858. * @returns the current mesh
  98859. */
  98860. releaseSubMeshes(): AbstractMesh;
  98861. /**
  98862. * Releases resources associated with this abstract mesh.
  98863. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98864. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98865. */
  98866. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98867. /**
  98868. * Adds the passed mesh as a child to the current mesh
  98869. * @param mesh defines the child mesh
  98870. * @returns the current mesh
  98871. */
  98872. addChild(mesh: AbstractMesh): AbstractMesh;
  98873. /**
  98874. * Removes the passed mesh from the current mesh children list
  98875. * @param mesh defines the child mesh
  98876. * @returns the current mesh
  98877. */
  98878. removeChild(mesh: AbstractMesh): AbstractMesh;
  98879. /** @hidden */
  98880. private _initFacetData;
  98881. /**
  98882. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  98883. * This method can be called within the render loop.
  98884. * 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
  98885. * @returns the current mesh
  98886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98887. */
  98888. updateFacetData(): AbstractMesh;
  98889. /**
  98890. * Returns the facetLocalNormals array.
  98891. * The normals are expressed in the mesh local spac
  98892. * @returns an array of Vector3
  98893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98894. */
  98895. getFacetLocalNormals(): Vector3[];
  98896. /**
  98897. * Returns the facetLocalPositions array.
  98898. * The facet positions are expressed in the mesh local space
  98899. * @returns an array of Vector3
  98900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98901. */
  98902. getFacetLocalPositions(): Vector3[];
  98903. /**
  98904. * Returns the facetLocalPartioning array
  98905. * @returns an array of array of numbers
  98906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98907. */
  98908. getFacetLocalPartitioning(): number[][];
  98909. /**
  98910. * Returns the i-th facet position in the world system.
  98911. * This method allocates a new Vector3 per call
  98912. * @param i defines the facet index
  98913. * @returns a new Vector3
  98914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98915. */
  98916. getFacetPosition(i: number): Vector3;
  98917. /**
  98918. * Sets the reference Vector3 with the i-th facet position in the world system
  98919. * @param i defines the facet index
  98920. * @param ref defines the target vector
  98921. * @returns the current mesh
  98922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98923. */
  98924. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  98925. /**
  98926. * Returns the i-th facet normal in the world system.
  98927. * This method allocates a new Vector3 per call
  98928. * @param i defines the facet index
  98929. * @returns a new Vector3
  98930. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98931. */
  98932. getFacetNormal(i: number): Vector3;
  98933. /**
  98934. * Sets the reference Vector3 with the i-th facet normal in the world system
  98935. * @param i defines the facet index
  98936. * @param ref defines the target vector
  98937. * @returns the current mesh
  98938. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98939. */
  98940. getFacetNormalToRef(i: number, ref: Vector3): this;
  98941. /**
  98942. * 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)
  98943. * @param x defines x coordinate
  98944. * @param y defines y coordinate
  98945. * @param z defines z coordinate
  98946. * @returns the array of facet indexes
  98947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98948. */
  98949. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  98950. /**
  98951. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  98952. * @param projected sets as the (x,y,z) world projection on the facet
  98953. * @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
  98954. * @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
  98955. * @param x defines x coordinate
  98956. * @param y defines y coordinate
  98957. * @param z defines z coordinate
  98958. * @returns the face index if found (or null instead)
  98959. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98960. */
  98961. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98962. /**
  98963. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  98964. * @param projected sets as the (x,y,z) local projection on the facet
  98965. * @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
  98966. * @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
  98967. * @param x defines x coordinate
  98968. * @param y defines y coordinate
  98969. * @param z defines z coordinate
  98970. * @returns the face index if found (or null instead)
  98971. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98972. */
  98973. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98974. /**
  98975. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  98976. * @returns the parameters
  98977. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98978. */
  98979. getFacetDataParameters(): any;
  98980. /**
  98981. * Disables the feature FacetData and frees the related memory
  98982. * @returns the current mesh
  98983. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98984. */
  98985. disableFacetData(): AbstractMesh;
  98986. /**
  98987. * Updates the AbstractMesh indices array
  98988. * @param indices defines the data source
  98989. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98990. * @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)
  98991. * @returns the current mesh
  98992. */
  98993. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98994. /**
  98995. * Creates new normals data for the mesh
  98996. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  98997. * @returns the current mesh
  98998. */
  98999. createNormals(updatable: boolean): AbstractMesh;
  99000. /**
  99001. * Align the mesh with a normal
  99002. * @param normal defines the normal to use
  99003. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  99004. * @returns the current mesh
  99005. */
  99006. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  99007. /** @hidden */
  99008. _checkOcclusionQuery(): boolean;
  99009. /**
  99010. * Disables the mesh edge rendering mode
  99011. * @returns the currentAbstractMesh
  99012. */
  99013. disableEdgesRendering(): AbstractMesh;
  99014. /**
  99015. * Enables the edge rendering mode on the mesh.
  99016. * This mode makes the mesh edges visible
  99017. * @param epsilon defines the maximal distance between two angles to detect a face
  99018. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  99019. * @returns the currentAbstractMesh
  99020. * @see https://www.babylonjs-playground.com/#19O9TU#0
  99021. */
  99022. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  99023. }
  99024. }
  99025. declare module BABYLON {
  99026. /**
  99027. * Interface used to define ActionEvent
  99028. */
  99029. export interface IActionEvent {
  99030. /** The mesh or sprite that triggered the action */
  99031. source: any;
  99032. /** The X mouse cursor position at the time of the event */
  99033. pointerX: number;
  99034. /** The Y mouse cursor position at the time of the event */
  99035. pointerY: number;
  99036. /** The mesh that is currently pointed at (can be null) */
  99037. meshUnderPointer: Nullable<AbstractMesh>;
  99038. /** the original (browser) event that triggered the ActionEvent */
  99039. sourceEvent?: any;
  99040. /** additional data for the event */
  99041. additionalData?: any;
  99042. }
  99043. /**
  99044. * ActionEvent is the event being sent when an action is triggered.
  99045. */
  99046. export class ActionEvent implements IActionEvent {
  99047. /** The mesh or sprite that triggered the action */
  99048. source: any;
  99049. /** The X mouse cursor position at the time of the event */
  99050. pointerX: number;
  99051. /** The Y mouse cursor position at the time of the event */
  99052. pointerY: number;
  99053. /** The mesh that is currently pointed at (can be null) */
  99054. meshUnderPointer: Nullable<AbstractMesh>;
  99055. /** the original (browser) event that triggered the ActionEvent */
  99056. sourceEvent?: any;
  99057. /** additional data for the event */
  99058. additionalData?: any;
  99059. /**
  99060. * Creates a new ActionEvent
  99061. * @param source The mesh or sprite that triggered the action
  99062. * @param pointerX The X mouse cursor position at the time of the event
  99063. * @param pointerY The Y mouse cursor position at the time of the event
  99064. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  99065. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  99066. * @param additionalData additional data for the event
  99067. */
  99068. constructor(
  99069. /** The mesh or sprite that triggered the action */
  99070. source: any,
  99071. /** The X mouse cursor position at the time of the event */
  99072. pointerX: number,
  99073. /** The Y mouse cursor position at the time of the event */
  99074. pointerY: number,
  99075. /** The mesh that is currently pointed at (can be null) */
  99076. meshUnderPointer: Nullable<AbstractMesh>,
  99077. /** the original (browser) event that triggered the ActionEvent */
  99078. sourceEvent?: any,
  99079. /** additional data for the event */
  99080. additionalData?: any);
  99081. /**
  99082. * Helper function to auto-create an ActionEvent from a source mesh.
  99083. * @param source The source mesh that triggered the event
  99084. * @param evt The original (browser) event
  99085. * @param additionalData additional data for the event
  99086. * @returns the new ActionEvent
  99087. */
  99088. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  99089. /**
  99090. * Helper function to auto-create an ActionEvent from a source sprite
  99091. * @param source The source sprite that triggered the event
  99092. * @param scene Scene associated with the sprite
  99093. * @param evt The original (browser) event
  99094. * @param additionalData additional data for the event
  99095. * @returns the new ActionEvent
  99096. */
  99097. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  99098. /**
  99099. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  99100. * @param scene the scene where the event occurred
  99101. * @param evt The original (browser) event
  99102. * @returns the new ActionEvent
  99103. */
  99104. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  99105. /**
  99106. * Helper function to auto-create an ActionEvent from a primitive
  99107. * @param prim defines the target primitive
  99108. * @param pointerPos defines the pointer position
  99109. * @param evt The original (browser) event
  99110. * @param additionalData additional data for the event
  99111. * @returns the new ActionEvent
  99112. */
  99113. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  99114. }
  99115. }
  99116. declare module BABYLON {
  99117. /**
  99118. * Abstract class used to decouple action Manager from scene and meshes.
  99119. * Do not instantiate.
  99120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99121. */
  99122. export abstract class AbstractActionManager implements IDisposable {
  99123. /** Gets the list of active triggers */
  99124. static Triggers: {
  99125. [key: string]: number;
  99126. };
  99127. /** Gets the cursor to use when hovering items */
  99128. hoverCursor: string;
  99129. /** Gets the list of actions */
  99130. actions: IAction[];
  99131. /**
  99132. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  99133. */
  99134. isRecursive: boolean;
  99135. /**
  99136. * Releases all associated resources
  99137. */
  99138. abstract dispose(): void;
  99139. /**
  99140. * Does this action manager has pointer triggers
  99141. */
  99142. abstract get hasPointerTriggers(): boolean;
  99143. /**
  99144. * Does this action manager has pick triggers
  99145. */
  99146. abstract get hasPickTriggers(): boolean;
  99147. /**
  99148. * Process a specific trigger
  99149. * @param trigger defines the trigger to process
  99150. * @param evt defines the event details to be processed
  99151. */
  99152. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  99153. /**
  99154. * Does this action manager handles actions of any of the given triggers
  99155. * @param triggers defines the triggers to be tested
  99156. * @return a boolean indicating whether one (or more) of the triggers is handled
  99157. */
  99158. abstract hasSpecificTriggers(triggers: number[]): boolean;
  99159. /**
  99160. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  99161. * speed.
  99162. * @param triggerA defines the trigger to be tested
  99163. * @param triggerB defines the trigger to be tested
  99164. * @return a boolean indicating whether one (or more) of the triggers is handled
  99165. */
  99166. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  99167. /**
  99168. * Does this action manager handles actions of a given trigger
  99169. * @param trigger defines the trigger to be tested
  99170. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  99171. * @return whether the trigger is handled
  99172. */
  99173. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  99174. /**
  99175. * Serialize this manager to a JSON object
  99176. * @param name defines the property name to store this manager
  99177. * @returns a JSON representation of this manager
  99178. */
  99179. abstract serialize(name: string): any;
  99180. /**
  99181. * Registers an action to this action manager
  99182. * @param action defines the action to be registered
  99183. * @return the action amended (prepared) after registration
  99184. */
  99185. abstract registerAction(action: IAction): Nullable<IAction>;
  99186. /**
  99187. * Unregisters an action to this action manager
  99188. * @param action defines the action to be unregistered
  99189. * @return a boolean indicating whether the action has been unregistered
  99190. */
  99191. abstract unregisterAction(action: IAction): Boolean;
  99192. /**
  99193. * Does exist one action manager with at least one trigger
  99194. **/
  99195. static get HasTriggers(): boolean;
  99196. /**
  99197. * Does exist one action manager with at least one pick trigger
  99198. **/
  99199. static get HasPickTriggers(): boolean;
  99200. /**
  99201. * Does exist one action manager that handles actions of a given trigger
  99202. * @param trigger defines the trigger to be tested
  99203. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  99204. **/
  99205. static HasSpecificTrigger(trigger: number): boolean;
  99206. }
  99207. }
  99208. declare module BABYLON {
  99209. /**
  99210. * Defines how a node can be built from a string name.
  99211. */
  99212. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  99213. /**
  99214. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  99215. */
  99216. export class Node implements IBehaviorAware<Node> {
  99217. /** @hidden */
  99218. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  99219. private static _NodeConstructors;
  99220. /**
  99221. * Add a new node constructor
  99222. * @param type defines the type name of the node to construct
  99223. * @param constructorFunc defines the constructor function
  99224. */
  99225. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  99226. /**
  99227. * Returns a node constructor based on type name
  99228. * @param type defines the type name
  99229. * @param name defines the new node name
  99230. * @param scene defines the hosting scene
  99231. * @param options defines optional options to transmit to constructors
  99232. * @returns the new constructor or null
  99233. */
  99234. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  99235. /**
  99236. * Gets or sets the name of the node
  99237. */
  99238. name: string;
  99239. /**
  99240. * Gets or sets the id of the node
  99241. */
  99242. id: string;
  99243. /**
  99244. * Gets or sets the unique id of the node
  99245. */
  99246. uniqueId: number;
  99247. /**
  99248. * Gets or sets a string used to store user defined state for the node
  99249. */
  99250. state: string;
  99251. /**
  99252. * Gets or sets an object used to store user defined information for the node
  99253. */
  99254. metadata: any;
  99255. /**
  99256. * For internal use only. Please do not use.
  99257. */
  99258. reservedDataStore: any;
  99259. /**
  99260. * List of inspectable custom properties (used by the Inspector)
  99261. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99262. */
  99263. inspectableCustomProperties: IInspectable[];
  99264. private _doNotSerialize;
  99265. /**
  99266. * Gets or sets a boolean used to define if the node must be serialized
  99267. */
  99268. get doNotSerialize(): boolean;
  99269. set doNotSerialize(value: boolean);
  99270. /** @hidden */
  99271. _isDisposed: boolean;
  99272. /**
  99273. * Gets a list of Animations associated with the node
  99274. */
  99275. animations: Animation[];
  99276. protected _ranges: {
  99277. [name: string]: Nullable<AnimationRange>;
  99278. };
  99279. /**
  99280. * Callback raised when the node is ready to be used
  99281. */
  99282. onReady: Nullable<(node: Node) => void>;
  99283. private _isEnabled;
  99284. private _isParentEnabled;
  99285. private _isReady;
  99286. /** @hidden */
  99287. _currentRenderId: number;
  99288. private _parentUpdateId;
  99289. /** @hidden */
  99290. _childUpdateId: number;
  99291. /** @hidden */
  99292. _waitingParentId: Nullable<string>;
  99293. /** @hidden */
  99294. _scene: Scene;
  99295. /** @hidden */
  99296. _cache: any;
  99297. private _parentNode;
  99298. private _children;
  99299. /** @hidden */
  99300. _worldMatrix: Matrix;
  99301. /** @hidden */
  99302. _worldMatrixDeterminant: number;
  99303. /** @hidden */
  99304. _worldMatrixDeterminantIsDirty: boolean;
  99305. /** @hidden */
  99306. private _sceneRootNodesIndex;
  99307. /**
  99308. * Gets a boolean indicating if the node has been disposed
  99309. * @returns true if the node was disposed
  99310. */
  99311. isDisposed(): boolean;
  99312. /**
  99313. * Gets or sets the parent of the node (without keeping the current position in the scene)
  99314. * @see https://doc.babylonjs.com/how_to/parenting
  99315. */
  99316. set parent(parent: Nullable<Node>);
  99317. get parent(): Nullable<Node>;
  99318. /** @hidden */
  99319. _addToSceneRootNodes(): void;
  99320. /** @hidden */
  99321. _removeFromSceneRootNodes(): void;
  99322. private _animationPropertiesOverride;
  99323. /**
  99324. * Gets or sets the animation properties override
  99325. */
  99326. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  99327. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  99328. /**
  99329. * Gets a string idenfifying the name of the class
  99330. * @returns "Node" string
  99331. */
  99332. getClassName(): string;
  99333. /** @hidden */
  99334. readonly _isNode: boolean;
  99335. /**
  99336. * An event triggered when the mesh is disposed
  99337. */
  99338. onDisposeObservable: Observable<Node>;
  99339. private _onDisposeObserver;
  99340. /**
  99341. * Sets a callback that will be raised when the node will be disposed
  99342. */
  99343. set onDispose(callback: () => void);
  99344. /**
  99345. * Creates a new Node
  99346. * @param name the name and id to be given to this node
  99347. * @param scene the scene this node will be added to
  99348. */
  99349. constructor(name: string, scene?: Nullable<Scene>);
  99350. /**
  99351. * Gets the scene of the node
  99352. * @returns a scene
  99353. */
  99354. getScene(): Scene;
  99355. /**
  99356. * Gets the engine of the node
  99357. * @returns a Engine
  99358. */
  99359. getEngine(): Engine;
  99360. private _behaviors;
  99361. /**
  99362. * Attach a behavior to the node
  99363. * @see http://doc.babylonjs.com/features/behaviour
  99364. * @param behavior defines the behavior to attach
  99365. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  99366. * @returns the current Node
  99367. */
  99368. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  99369. /**
  99370. * Remove an attached behavior
  99371. * @see http://doc.babylonjs.com/features/behaviour
  99372. * @param behavior defines the behavior to attach
  99373. * @returns the current Node
  99374. */
  99375. removeBehavior(behavior: Behavior<Node>): Node;
  99376. /**
  99377. * Gets the list of attached behaviors
  99378. * @see http://doc.babylonjs.com/features/behaviour
  99379. */
  99380. get behaviors(): Behavior<Node>[];
  99381. /**
  99382. * Gets an attached behavior by name
  99383. * @param name defines the name of the behavior to look for
  99384. * @see http://doc.babylonjs.com/features/behaviour
  99385. * @returns null if behavior was not found else the requested behavior
  99386. */
  99387. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  99388. /**
  99389. * Returns the latest update of the World matrix
  99390. * @returns a Matrix
  99391. */
  99392. getWorldMatrix(): Matrix;
  99393. /** @hidden */
  99394. _getWorldMatrixDeterminant(): number;
  99395. /**
  99396. * Returns directly the latest state of the mesh World matrix.
  99397. * A Matrix is returned.
  99398. */
  99399. get worldMatrixFromCache(): Matrix;
  99400. /** @hidden */
  99401. _initCache(): void;
  99402. /** @hidden */
  99403. updateCache(force?: boolean): void;
  99404. /** @hidden */
  99405. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  99406. /** @hidden */
  99407. _updateCache(ignoreParentClass?: boolean): void;
  99408. /** @hidden */
  99409. _isSynchronized(): boolean;
  99410. /** @hidden */
  99411. _markSyncedWithParent(): void;
  99412. /** @hidden */
  99413. isSynchronizedWithParent(): boolean;
  99414. /** @hidden */
  99415. isSynchronized(): boolean;
  99416. /**
  99417. * Is this node ready to be used/rendered
  99418. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99419. * @return true if the node is ready
  99420. */
  99421. isReady(completeCheck?: boolean): boolean;
  99422. /**
  99423. * Is this node enabled?
  99424. * 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
  99425. * @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
  99426. * @return whether this node (and its parent) is enabled
  99427. */
  99428. isEnabled(checkAncestors?: boolean): boolean;
  99429. /** @hidden */
  99430. protected _syncParentEnabledState(): void;
  99431. /**
  99432. * Set the enabled state of this node
  99433. * @param value defines the new enabled state
  99434. */
  99435. setEnabled(value: boolean): void;
  99436. /**
  99437. * Is this node a descendant of the given node?
  99438. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  99439. * @param ancestor defines the parent node to inspect
  99440. * @returns a boolean indicating if this node is a descendant of the given node
  99441. */
  99442. isDescendantOf(ancestor: Node): boolean;
  99443. /** @hidden */
  99444. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  99445. /**
  99446. * Will return all nodes that have this node as ascendant
  99447. * @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
  99448. * @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
  99449. * @return all children nodes of all types
  99450. */
  99451. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  99452. /**
  99453. * Get all child-meshes of this node
  99454. * @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)
  99455. * @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
  99456. * @returns an array of AbstractMesh
  99457. */
  99458. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  99459. /**
  99460. * Get all direct children of this node
  99461. * @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
  99462. * @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)
  99463. * @returns an array of Node
  99464. */
  99465. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  99466. /** @hidden */
  99467. _setReady(state: boolean): void;
  99468. /**
  99469. * Get an animation by name
  99470. * @param name defines the name of the animation to look for
  99471. * @returns null if not found else the requested animation
  99472. */
  99473. getAnimationByName(name: string): Nullable<Animation>;
  99474. /**
  99475. * Creates an animation range for this node
  99476. * @param name defines the name of the range
  99477. * @param from defines the starting key
  99478. * @param to defines the end key
  99479. */
  99480. createAnimationRange(name: string, from: number, to: number): void;
  99481. /**
  99482. * Delete a specific animation range
  99483. * @param name defines the name of the range to delete
  99484. * @param deleteFrames defines if animation frames from the range must be deleted as well
  99485. */
  99486. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  99487. /**
  99488. * Get an animation range by name
  99489. * @param name defines the name of the animation range to look for
  99490. * @returns null if not found else the requested animation range
  99491. */
  99492. getAnimationRange(name: string): Nullable<AnimationRange>;
  99493. /**
  99494. * Gets the list of all animation ranges defined on this node
  99495. * @returns an array
  99496. */
  99497. getAnimationRanges(): Nullable<AnimationRange>[];
  99498. /**
  99499. * Will start the animation sequence
  99500. * @param name defines the range frames for animation sequence
  99501. * @param loop defines if the animation should loop (false by default)
  99502. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  99503. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  99504. * @returns the object created for this animation. If range does not exist, it will return null
  99505. */
  99506. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  99507. /**
  99508. * Serialize animation ranges into a JSON compatible object
  99509. * @returns serialization object
  99510. */
  99511. serializeAnimationRanges(): any;
  99512. /**
  99513. * Computes the world matrix of the node
  99514. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99515. * @returns the world matrix
  99516. */
  99517. computeWorldMatrix(force?: boolean): Matrix;
  99518. /**
  99519. * Releases resources associated with this node.
  99520. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99521. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99522. */
  99523. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99524. /**
  99525. * Parse animation range data from a serialization object and store them into a given node
  99526. * @param node defines where to store the animation ranges
  99527. * @param parsedNode defines the serialization object to read data from
  99528. * @param scene defines the hosting scene
  99529. */
  99530. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  99531. /**
  99532. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  99533. * @param includeDescendants Include bounding info from descendants as well (true by default)
  99534. * @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
  99535. * @returns the new bounding vectors
  99536. */
  99537. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  99538. min: Vector3;
  99539. max: Vector3;
  99540. };
  99541. }
  99542. }
  99543. declare module BABYLON {
  99544. /**
  99545. * @hidden
  99546. */
  99547. export class _IAnimationState {
  99548. key: number;
  99549. repeatCount: number;
  99550. workValue?: any;
  99551. loopMode?: number;
  99552. offsetValue?: any;
  99553. highLimitValue?: any;
  99554. }
  99555. /**
  99556. * Class used to store any kind of animation
  99557. */
  99558. export class Animation {
  99559. /**Name of the animation */
  99560. name: string;
  99561. /**Property to animate */
  99562. targetProperty: string;
  99563. /**The frames per second of the animation */
  99564. framePerSecond: number;
  99565. /**The data type of the animation */
  99566. dataType: number;
  99567. /**The loop mode of the animation */
  99568. loopMode?: number | undefined;
  99569. /**Specifies if blending should be enabled */
  99570. enableBlending?: boolean | undefined;
  99571. /**
  99572. * Use matrix interpolation instead of using direct key value when animating matrices
  99573. */
  99574. static AllowMatricesInterpolation: boolean;
  99575. /**
  99576. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  99577. */
  99578. static AllowMatrixDecomposeForInterpolation: boolean;
  99579. /**
  99580. * Stores the key frames of the animation
  99581. */
  99582. private _keys;
  99583. /**
  99584. * Stores the easing function of the animation
  99585. */
  99586. private _easingFunction;
  99587. /**
  99588. * @hidden Internal use only
  99589. */
  99590. _runtimeAnimations: RuntimeAnimation[];
  99591. /**
  99592. * The set of event that will be linked to this animation
  99593. */
  99594. private _events;
  99595. /**
  99596. * Stores an array of target property paths
  99597. */
  99598. targetPropertyPath: string[];
  99599. /**
  99600. * Stores the blending speed of the animation
  99601. */
  99602. blendingSpeed: number;
  99603. /**
  99604. * Stores the animation ranges for the animation
  99605. */
  99606. private _ranges;
  99607. /**
  99608. * @hidden Internal use
  99609. */
  99610. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  99611. /**
  99612. * Sets up an animation
  99613. * @param property The property to animate
  99614. * @param animationType The animation type to apply
  99615. * @param framePerSecond The frames per second of the animation
  99616. * @param easingFunction The easing function used in the animation
  99617. * @returns The created animation
  99618. */
  99619. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  99620. /**
  99621. * Create and start an animation on a node
  99622. * @param name defines the name of the global animation that will be run on all nodes
  99623. * @param node defines the root node where the animation will take place
  99624. * @param targetProperty defines property to animate
  99625. * @param framePerSecond defines the number of frame per second yo use
  99626. * @param totalFrame defines the number of frames in total
  99627. * @param from defines the initial value
  99628. * @param to defines the final value
  99629. * @param loopMode defines which loop mode you want to use (off by default)
  99630. * @param easingFunction defines the easing function to use (linear by default)
  99631. * @param onAnimationEnd defines the callback to call when animation end
  99632. * @returns the animatable created for this animation
  99633. */
  99634. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99635. /**
  99636. * Create and start an animation on a node and its descendants
  99637. * @param name defines the name of the global animation that will be run on all nodes
  99638. * @param node defines the root node where the animation will take place
  99639. * @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
  99640. * @param targetProperty defines property to animate
  99641. * @param framePerSecond defines the number of frame per second to use
  99642. * @param totalFrame defines the number of frames in total
  99643. * @param from defines the initial value
  99644. * @param to defines the final value
  99645. * @param loopMode defines which loop mode you want to use (off by default)
  99646. * @param easingFunction defines the easing function to use (linear by default)
  99647. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  99648. * @returns the list of animatables created for all nodes
  99649. * @example https://www.babylonjs-playground.com/#MH0VLI
  99650. */
  99651. 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[]>;
  99652. /**
  99653. * Creates a new animation, merges it with the existing animations and starts it
  99654. * @param name Name of the animation
  99655. * @param node Node which contains the scene that begins the animations
  99656. * @param targetProperty Specifies which property to animate
  99657. * @param framePerSecond The frames per second of the animation
  99658. * @param totalFrame The total number of frames
  99659. * @param from The frame at the beginning of the animation
  99660. * @param to The frame at the end of the animation
  99661. * @param loopMode Specifies the loop mode of the animation
  99662. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  99663. * @param onAnimationEnd Callback to run once the animation is complete
  99664. * @returns Nullable animation
  99665. */
  99666. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99667. /**
  99668. * Transition property of an host to the target Value
  99669. * @param property The property to transition
  99670. * @param targetValue The target Value of the property
  99671. * @param host The object where the property to animate belongs
  99672. * @param scene Scene used to run the animation
  99673. * @param frameRate Framerate (in frame/s) to use
  99674. * @param transition The transition type we want to use
  99675. * @param duration The duration of the animation, in milliseconds
  99676. * @param onAnimationEnd Callback trigger at the end of the animation
  99677. * @returns Nullable animation
  99678. */
  99679. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  99680. /**
  99681. * Return the array of runtime animations currently using this animation
  99682. */
  99683. get runtimeAnimations(): RuntimeAnimation[];
  99684. /**
  99685. * Specifies if any of the runtime animations are currently running
  99686. */
  99687. get hasRunningRuntimeAnimations(): boolean;
  99688. /**
  99689. * Initializes the animation
  99690. * @param name Name of the animation
  99691. * @param targetProperty Property to animate
  99692. * @param framePerSecond The frames per second of the animation
  99693. * @param dataType The data type of the animation
  99694. * @param loopMode The loop mode of the animation
  99695. * @param enableBlending Specifies if blending should be enabled
  99696. */
  99697. constructor(
  99698. /**Name of the animation */
  99699. name: string,
  99700. /**Property to animate */
  99701. targetProperty: string,
  99702. /**The frames per second of the animation */
  99703. framePerSecond: number,
  99704. /**The data type of the animation */
  99705. dataType: number,
  99706. /**The loop mode of the animation */
  99707. loopMode?: number | undefined,
  99708. /**Specifies if blending should be enabled */
  99709. enableBlending?: boolean | undefined);
  99710. /**
  99711. * Converts the animation to a string
  99712. * @param fullDetails support for multiple levels of logging within scene loading
  99713. * @returns String form of the animation
  99714. */
  99715. toString(fullDetails?: boolean): string;
  99716. /**
  99717. * Add an event to this animation
  99718. * @param event Event to add
  99719. */
  99720. addEvent(event: AnimationEvent): void;
  99721. /**
  99722. * Remove all events found at the given frame
  99723. * @param frame The frame to remove events from
  99724. */
  99725. removeEvents(frame: number): void;
  99726. /**
  99727. * Retrieves all the events from the animation
  99728. * @returns Events from the animation
  99729. */
  99730. getEvents(): AnimationEvent[];
  99731. /**
  99732. * Creates an animation range
  99733. * @param name Name of the animation range
  99734. * @param from Starting frame of the animation range
  99735. * @param to Ending frame of the animation
  99736. */
  99737. createRange(name: string, from: number, to: number): void;
  99738. /**
  99739. * Deletes an animation range by name
  99740. * @param name Name of the animation range to delete
  99741. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  99742. */
  99743. deleteRange(name: string, deleteFrames?: boolean): void;
  99744. /**
  99745. * Gets the animation range by name, or null if not defined
  99746. * @param name Name of the animation range
  99747. * @returns Nullable animation range
  99748. */
  99749. getRange(name: string): Nullable<AnimationRange>;
  99750. /**
  99751. * Gets the key frames from the animation
  99752. * @returns The key frames of the animation
  99753. */
  99754. getKeys(): Array<IAnimationKey>;
  99755. /**
  99756. * Gets the highest frame rate of the animation
  99757. * @returns Highest frame rate of the animation
  99758. */
  99759. getHighestFrame(): number;
  99760. /**
  99761. * Gets the easing function of the animation
  99762. * @returns Easing function of the animation
  99763. */
  99764. getEasingFunction(): IEasingFunction;
  99765. /**
  99766. * Sets the easing function of the animation
  99767. * @param easingFunction A custom mathematical formula for animation
  99768. */
  99769. setEasingFunction(easingFunction: EasingFunction): void;
  99770. /**
  99771. * Interpolates a scalar linearly
  99772. * @param startValue Start value of the animation curve
  99773. * @param endValue End value of the animation curve
  99774. * @param gradient Scalar amount to interpolate
  99775. * @returns Interpolated scalar value
  99776. */
  99777. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  99778. /**
  99779. * Interpolates a scalar cubically
  99780. * @param startValue Start value of the animation curve
  99781. * @param outTangent End tangent of the animation
  99782. * @param endValue End value of the animation curve
  99783. * @param inTangent Start tangent of the animation curve
  99784. * @param gradient Scalar amount to interpolate
  99785. * @returns Interpolated scalar value
  99786. */
  99787. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  99788. /**
  99789. * Interpolates a quaternion using a spherical linear interpolation
  99790. * @param startValue Start value of the animation curve
  99791. * @param endValue End value of the animation curve
  99792. * @param gradient Scalar amount to interpolate
  99793. * @returns Interpolated quaternion value
  99794. */
  99795. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  99796. /**
  99797. * Interpolates a quaternion cubically
  99798. * @param startValue Start value of the animation curve
  99799. * @param outTangent End tangent of the animation curve
  99800. * @param endValue End value of the animation curve
  99801. * @param inTangent Start tangent of the animation curve
  99802. * @param gradient Scalar amount to interpolate
  99803. * @returns Interpolated quaternion value
  99804. */
  99805. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  99806. /**
  99807. * Interpolates a Vector3 linearl
  99808. * @param startValue Start value of the animation curve
  99809. * @param endValue End value of the animation curve
  99810. * @param gradient Scalar amount to interpolate
  99811. * @returns Interpolated scalar value
  99812. */
  99813. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  99814. /**
  99815. * Interpolates a Vector3 cubically
  99816. * @param startValue Start value of the animation curve
  99817. * @param outTangent End tangent of the animation
  99818. * @param endValue End value of the animation curve
  99819. * @param inTangent Start tangent of the animation curve
  99820. * @param gradient Scalar amount to interpolate
  99821. * @returns InterpolatedVector3 value
  99822. */
  99823. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  99824. /**
  99825. * Interpolates a Vector2 linearly
  99826. * @param startValue Start value of the animation curve
  99827. * @param endValue End value of the animation curve
  99828. * @param gradient Scalar amount to interpolate
  99829. * @returns Interpolated Vector2 value
  99830. */
  99831. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  99832. /**
  99833. * Interpolates a Vector2 cubically
  99834. * @param startValue Start value of the animation curve
  99835. * @param outTangent End tangent of the animation
  99836. * @param endValue End value of the animation curve
  99837. * @param inTangent Start tangent of the animation curve
  99838. * @param gradient Scalar amount to interpolate
  99839. * @returns Interpolated Vector2 value
  99840. */
  99841. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  99842. /**
  99843. * Interpolates a size linearly
  99844. * @param startValue Start value of the animation curve
  99845. * @param endValue End value of the animation curve
  99846. * @param gradient Scalar amount to interpolate
  99847. * @returns Interpolated Size value
  99848. */
  99849. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  99850. /**
  99851. * Interpolates a Color3 linearly
  99852. * @param startValue Start value of the animation curve
  99853. * @param endValue End value of the animation curve
  99854. * @param gradient Scalar amount to interpolate
  99855. * @returns Interpolated Color3 value
  99856. */
  99857. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  99858. /**
  99859. * Interpolates a Color4 linearly
  99860. * @param startValue Start value of the animation curve
  99861. * @param endValue End value of the animation curve
  99862. * @param gradient Scalar amount to interpolate
  99863. * @returns Interpolated Color3 value
  99864. */
  99865. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  99866. /**
  99867. * @hidden Internal use only
  99868. */
  99869. _getKeyValue(value: any): any;
  99870. /**
  99871. * @hidden Internal use only
  99872. */
  99873. _interpolate(currentFrame: number, state: _IAnimationState): any;
  99874. /**
  99875. * Defines the function to use to interpolate matrices
  99876. * @param startValue defines the start matrix
  99877. * @param endValue defines the end matrix
  99878. * @param gradient defines the gradient between both matrices
  99879. * @param result defines an optional target matrix where to store the interpolation
  99880. * @returns the interpolated matrix
  99881. */
  99882. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  99883. /**
  99884. * Makes a copy of the animation
  99885. * @returns Cloned animation
  99886. */
  99887. clone(): Animation;
  99888. /**
  99889. * Sets the key frames of the animation
  99890. * @param values The animation key frames to set
  99891. */
  99892. setKeys(values: Array<IAnimationKey>): void;
  99893. /**
  99894. * Serializes the animation to an object
  99895. * @returns Serialized object
  99896. */
  99897. serialize(): any;
  99898. /**
  99899. * Float animation type
  99900. */
  99901. static readonly ANIMATIONTYPE_FLOAT: number;
  99902. /**
  99903. * Vector3 animation type
  99904. */
  99905. static readonly ANIMATIONTYPE_VECTOR3: number;
  99906. /**
  99907. * Quaternion animation type
  99908. */
  99909. static readonly ANIMATIONTYPE_QUATERNION: number;
  99910. /**
  99911. * Matrix animation type
  99912. */
  99913. static readonly ANIMATIONTYPE_MATRIX: number;
  99914. /**
  99915. * Color3 animation type
  99916. */
  99917. static readonly ANIMATIONTYPE_COLOR3: number;
  99918. /**
  99919. * Color3 animation type
  99920. */
  99921. static readonly ANIMATIONTYPE_COLOR4: number;
  99922. /**
  99923. * Vector2 animation type
  99924. */
  99925. static readonly ANIMATIONTYPE_VECTOR2: number;
  99926. /**
  99927. * Size animation type
  99928. */
  99929. static readonly ANIMATIONTYPE_SIZE: number;
  99930. /**
  99931. * Relative Loop Mode
  99932. */
  99933. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  99934. /**
  99935. * Cycle Loop Mode
  99936. */
  99937. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  99938. /**
  99939. * Constant Loop Mode
  99940. */
  99941. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  99942. /** @hidden */
  99943. static _UniversalLerp(left: any, right: any, amount: number): any;
  99944. /**
  99945. * Parses an animation object and creates an animation
  99946. * @param parsedAnimation Parsed animation object
  99947. * @returns Animation object
  99948. */
  99949. static Parse(parsedAnimation: any): Animation;
  99950. /**
  99951. * Appends the serialized animations from the source animations
  99952. * @param source Source containing the animations
  99953. * @param destination Target to store the animations
  99954. */
  99955. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99956. }
  99957. }
  99958. declare module BABYLON {
  99959. /**
  99960. * Interface containing an array of animations
  99961. */
  99962. export interface IAnimatable {
  99963. /**
  99964. * Array of animations
  99965. */
  99966. animations: Nullable<Array<Animation>>;
  99967. }
  99968. }
  99969. declare module BABYLON {
  99970. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  99971. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99972. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99973. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99974. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99975. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99976. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99977. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99978. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99979. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99980. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99981. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99982. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99983. /**
  99984. * Decorator used to define property that can be serialized as reference to a camera
  99985. * @param sourceName defines the name of the property to decorate
  99986. */
  99987. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99988. /**
  99989. * Class used to help serialization objects
  99990. */
  99991. export class SerializationHelper {
  99992. /** @hidden */
  99993. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  99994. /** @hidden */
  99995. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  99996. /** @hidden */
  99997. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  99998. /** @hidden */
  99999. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  100000. /**
  100001. * Appends the serialized animations from the source animations
  100002. * @param source Source containing the animations
  100003. * @param destination Target to store the animations
  100004. */
  100005. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  100006. /**
  100007. * Static function used to serialized a specific entity
  100008. * @param entity defines the entity to serialize
  100009. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  100010. * @returns a JSON compatible object representing the serialization of the entity
  100011. */
  100012. static Serialize<T>(entity: T, serializationObject?: any): any;
  100013. /**
  100014. * Creates a new entity from a serialization data object
  100015. * @param creationFunction defines a function used to instanciated the new entity
  100016. * @param source defines the source serialization data
  100017. * @param scene defines the hosting scene
  100018. * @param rootUrl defines the root url for resources
  100019. * @returns a new entity
  100020. */
  100021. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  100022. /**
  100023. * Clones an object
  100024. * @param creationFunction defines the function used to instanciate the new object
  100025. * @param source defines the source object
  100026. * @returns the cloned object
  100027. */
  100028. static Clone<T>(creationFunction: () => T, source: T): T;
  100029. /**
  100030. * Instanciates a new object based on a source one (some data will be shared between both object)
  100031. * @param creationFunction defines the function used to instanciate the new object
  100032. * @param source defines the source object
  100033. * @returns the new object
  100034. */
  100035. static Instanciate<T>(creationFunction: () => T, source: T): T;
  100036. }
  100037. }
  100038. declare module BABYLON {
  100039. /**
  100040. * Class used to manipulate GUIDs
  100041. */
  100042. export class GUID {
  100043. /**
  100044. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100045. * Be aware Math.random() could cause collisions, but:
  100046. * "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"
  100047. * @returns a pseudo random id
  100048. */
  100049. static RandomId(): string;
  100050. }
  100051. }
  100052. declare module BABYLON {
  100053. /**
  100054. * Base class of all the textures in babylon.
  100055. * It groups all the common properties the materials, post process, lights... might need
  100056. * in order to make a correct use of the texture.
  100057. */
  100058. export class BaseTexture implements IAnimatable {
  100059. /**
  100060. * Default anisotropic filtering level for the application.
  100061. * It is set to 4 as a good tradeoff between perf and quality.
  100062. */
  100063. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  100064. /**
  100065. * Gets or sets the unique id of the texture
  100066. */
  100067. uniqueId: number;
  100068. /**
  100069. * Define the name of the texture.
  100070. */
  100071. name: string;
  100072. /**
  100073. * Gets or sets an object used to store user defined information.
  100074. */
  100075. metadata: any;
  100076. /**
  100077. * For internal use only. Please do not use.
  100078. */
  100079. reservedDataStore: any;
  100080. private _hasAlpha;
  100081. /**
  100082. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  100083. */
  100084. set hasAlpha(value: boolean);
  100085. get hasAlpha(): boolean;
  100086. /**
  100087. * Defines if the alpha value should be determined via the rgb values.
  100088. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  100089. */
  100090. getAlphaFromRGB: boolean;
  100091. /**
  100092. * Intensity or strength of the texture.
  100093. * It is commonly used by materials to fine tune the intensity of the texture
  100094. */
  100095. level: number;
  100096. /**
  100097. * Define the UV chanel to use starting from 0 and defaulting to 0.
  100098. * This is part of the texture as textures usually maps to one uv set.
  100099. */
  100100. coordinatesIndex: number;
  100101. private _coordinatesMode;
  100102. /**
  100103. * How a texture is mapped.
  100104. *
  100105. * | Value | Type | Description |
  100106. * | ----- | ----------------------------------- | ----------- |
  100107. * | 0 | EXPLICIT_MODE | |
  100108. * | 1 | SPHERICAL_MODE | |
  100109. * | 2 | PLANAR_MODE | |
  100110. * | 3 | CUBIC_MODE | |
  100111. * | 4 | PROJECTION_MODE | |
  100112. * | 5 | SKYBOX_MODE | |
  100113. * | 6 | INVCUBIC_MODE | |
  100114. * | 7 | EQUIRECTANGULAR_MODE | |
  100115. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  100116. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  100117. */
  100118. set coordinatesMode(value: number);
  100119. get coordinatesMode(): number;
  100120. /**
  100121. * | Value | Type | Description |
  100122. * | ----- | ------------------ | ----------- |
  100123. * | 0 | CLAMP_ADDRESSMODE | |
  100124. * | 1 | WRAP_ADDRESSMODE | |
  100125. * | 2 | MIRROR_ADDRESSMODE | |
  100126. */
  100127. wrapU: number;
  100128. /**
  100129. * | Value | Type | Description |
  100130. * | ----- | ------------------ | ----------- |
  100131. * | 0 | CLAMP_ADDRESSMODE | |
  100132. * | 1 | WRAP_ADDRESSMODE | |
  100133. * | 2 | MIRROR_ADDRESSMODE | |
  100134. */
  100135. wrapV: number;
  100136. /**
  100137. * | Value | Type | Description |
  100138. * | ----- | ------------------ | ----------- |
  100139. * | 0 | CLAMP_ADDRESSMODE | |
  100140. * | 1 | WRAP_ADDRESSMODE | |
  100141. * | 2 | MIRROR_ADDRESSMODE | |
  100142. */
  100143. wrapR: number;
  100144. /**
  100145. * With compliant hardware and browser (supporting anisotropic filtering)
  100146. * this defines the level of anisotropic filtering in the texture.
  100147. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  100148. */
  100149. anisotropicFilteringLevel: number;
  100150. /**
  100151. * Define if the texture is a cube texture or if false a 2d texture.
  100152. */
  100153. get isCube(): boolean;
  100154. set isCube(value: boolean);
  100155. /**
  100156. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  100157. */
  100158. get is3D(): boolean;
  100159. set is3D(value: boolean);
  100160. /**
  100161. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  100162. */
  100163. get is2DArray(): boolean;
  100164. set is2DArray(value: boolean);
  100165. /**
  100166. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  100167. * HDR texture are usually stored in linear space.
  100168. * This only impacts the PBR and Background materials
  100169. */
  100170. gammaSpace: boolean;
  100171. /**
  100172. * Gets or sets whether or not the texture contains RGBD data.
  100173. */
  100174. get isRGBD(): boolean;
  100175. set isRGBD(value: boolean);
  100176. /**
  100177. * Is Z inverted in the texture (useful in a cube texture).
  100178. */
  100179. invertZ: boolean;
  100180. /**
  100181. * Are mip maps generated for this texture or not.
  100182. */
  100183. get noMipmap(): boolean;
  100184. /**
  100185. * @hidden
  100186. */
  100187. lodLevelInAlpha: boolean;
  100188. /**
  100189. * With prefiltered texture, defined the offset used during the prefiltering steps.
  100190. */
  100191. get lodGenerationOffset(): number;
  100192. set lodGenerationOffset(value: number);
  100193. /**
  100194. * With prefiltered texture, defined the scale used during the prefiltering steps.
  100195. */
  100196. get lodGenerationScale(): number;
  100197. set lodGenerationScale(value: number);
  100198. /**
  100199. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  100200. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  100201. * average roughness values.
  100202. */
  100203. get linearSpecularLOD(): boolean;
  100204. set linearSpecularLOD(value: boolean);
  100205. /**
  100206. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  100207. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  100208. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  100209. */
  100210. get irradianceTexture(): Nullable<BaseTexture>;
  100211. set irradianceTexture(value: Nullable<BaseTexture>);
  100212. /**
  100213. * Define if the texture is a render target.
  100214. */
  100215. isRenderTarget: boolean;
  100216. /**
  100217. * Define the unique id of the texture in the scene.
  100218. */
  100219. get uid(): string;
  100220. /**
  100221. * Return a string representation of the texture.
  100222. * @returns the texture as a string
  100223. */
  100224. toString(): string;
  100225. /**
  100226. * Get the class name of the texture.
  100227. * @returns "BaseTexture"
  100228. */
  100229. getClassName(): string;
  100230. /**
  100231. * Define the list of animation attached to the texture.
  100232. */
  100233. animations: Animation[];
  100234. /**
  100235. * An event triggered when the texture is disposed.
  100236. */
  100237. onDisposeObservable: Observable<BaseTexture>;
  100238. private _onDisposeObserver;
  100239. /**
  100240. * Callback triggered when the texture has been disposed.
  100241. * Kept for back compatibility, you can use the onDisposeObservable instead.
  100242. */
  100243. set onDispose(callback: () => void);
  100244. /**
  100245. * Define the current state of the loading sequence when in delayed load mode.
  100246. */
  100247. delayLoadState: number;
  100248. private _scene;
  100249. /** @hidden */
  100250. _texture: Nullable<InternalTexture>;
  100251. private _uid;
  100252. /**
  100253. * Define if the texture is preventinga material to render or not.
  100254. * If not and the texture is not ready, the engine will use a default black texture instead.
  100255. */
  100256. get isBlocking(): boolean;
  100257. /**
  100258. * Instantiates a new BaseTexture.
  100259. * Base class of all the textures in babylon.
  100260. * It groups all the common properties the materials, post process, lights... might need
  100261. * in order to make a correct use of the texture.
  100262. * @param scene Define the scene the texture blongs to
  100263. */
  100264. constructor(scene: Nullable<Scene>);
  100265. /**
  100266. * Get the scene the texture belongs to.
  100267. * @returns the scene or null if undefined
  100268. */
  100269. getScene(): Nullable<Scene>;
  100270. /**
  100271. * Get the texture transform matrix used to offset tile the texture for istance.
  100272. * @returns the transformation matrix
  100273. */
  100274. getTextureMatrix(): Matrix;
  100275. /**
  100276. * Get the texture reflection matrix used to rotate/transform the reflection.
  100277. * @returns the reflection matrix
  100278. */
  100279. getReflectionTextureMatrix(): Matrix;
  100280. /**
  100281. * Get the underlying lower level texture from Babylon.
  100282. * @returns the insternal texture
  100283. */
  100284. getInternalTexture(): Nullable<InternalTexture>;
  100285. /**
  100286. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  100287. * @returns true if ready or not blocking
  100288. */
  100289. isReadyOrNotBlocking(): boolean;
  100290. /**
  100291. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  100292. * @returns true if fully ready
  100293. */
  100294. isReady(): boolean;
  100295. private _cachedSize;
  100296. /**
  100297. * Get the size of the texture.
  100298. * @returns the texture size.
  100299. */
  100300. getSize(): ISize;
  100301. /**
  100302. * Get the base size of the texture.
  100303. * It can be different from the size if the texture has been resized for POT for instance
  100304. * @returns the base size
  100305. */
  100306. getBaseSize(): ISize;
  100307. /**
  100308. * Update the sampling mode of the texture.
  100309. * Default is Trilinear mode.
  100310. *
  100311. * | Value | Type | Description |
  100312. * | ----- | ------------------ | ----------- |
  100313. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  100314. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  100315. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  100316. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  100317. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  100318. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  100319. * | 7 | NEAREST_LINEAR | |
  100320. * | 8 | NEAREST_NEAREST | |
  100321. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  100322. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  100323. * | 11 | LINEAR_LINEAR | |
  100324. * | 12 | LINEAR_NEAREST | |
  100325. *
  100326. * > _mag_: magnification filter (close to the viewer)
  100327. * > _min_: minification filter (far from the viewer)
  100328. * > _mip_: filter used between mip map levels
  100329. *@param samplingMode Define the new sampling mode of the texture
  100330. */
  100331. updateSamplingMode(samplingMode: number): void;
  100332. /**
  100333. * Scales the texture if is `canRescale()`
  100334. * @param ratio the resize factor we want to use to rescale
  100335. */
  100336. scale(ratio: number): void;
  100337. /**
  100338. * Get if the texture can rescale.
  100339. */
  100340. get canRescale(): boolean;
  100341. /** @hidden */
  100342. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  100343. /** @hidden */
  100344. _rebuild(): void;
  100345. /**
  100346. * Triggers the load sequence in delayed load mode.
  100347. */
  100348. delayLoad(): void;
  100349. /**
  100350. * Clones the texture.
  100351. * @returns the cloned texture
  100352. */
  100353. clone(): Nullable<BaseTexture>;
  100354. /**
  100355. * Get the texture underlying type (INT, FLOAT...)
  100356. */
  100357. get textureType(): number;
  100358. /**
  100359. * Get the texture underlying format (RGB, RGBA...)
  100360. */
  100361. get textureFormat(): number;
  100362. /**
  100363. * Indicates that textures need to be re-calculated for all materials
  100364. */
  100365. protected _markAllSubMeshesAsTexturesDirty(): void;
  100366. /**
  100367. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  100368. * This will returns an RGBA array buffer containing either in values (0-255) or
  100369. * float values (0-1) depending of the underlying buffer type.
  100370. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  100371. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  100372. * @param buffer defines a user defined buffer to fill with data (can be null)
  100373. * @returns The Array buffer containing the pixels data.
  100374. */
  100375. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  100376. /**
  100377. * Release and destroy the underlying lower level texture aka internalTexture.
  100378. */
  100379. releaseInternalTexture(): void;
  100380. /** @hidden */
  100381. get _lodTextureHigh(): Nullable<BaseTexture>;
  100382. /** @hidden */
  100383. get _lodTextureMid(): Nullable<BaseTexture>;
  100384. /** @hidden */
  100385. get _lodTextureLow(): Nullable<BaseTexture>;
  100386. /**
  100387. * Dispose the texture and release its associated resources.
  100388. */
  100389. dispose(): void;
  100390. /**
  100391. * Serialize the texture into a JSON representation that can be parsed later on.
  100392. * @returns the JSON representation of the texture
  100393. */
  100394. serialize(): any;
  100395. /**
  100396. * Helper function to be called back once a list of texture contains only ready textures.
  100397. * @param textures Define the list of textures to wait for
  100398. * @param callback Define the callback triggered once the entire list will be ready
  100399. */
  100400. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  100401. }
  100402. }
  100403. declare module BABYLON {
  100404. /**
  100405. * Options to be used when creating an effect.
  100406. */
  100407. export interface IEffectCreationOptions {
  100408. /**
  100409. * Atrributes that will be used in the shader.
  100410. */
  100411. attributes: string[];
  100412. /**
  100413. * Uniform varible names that will be set in the shader.
  100414. */
  100415. uniformsNames: string[];
  100416. /**
  100417. * Uniform buffer variable names that will be set in the shader.
  100418. */
  100419. uniformBuffersNames: string[];
  100420. /**
  100421. * Sampler texture variable names that will be set in the shader.
  100422. */
  100423. samplers: string[];
  100424. /**
  100425. * Define statements that will be set in the shader.
  100426. */
  100427. defines: any;
  100428. /**
  100429. * Possible fallbacks for this effect to improve performance when needed.
  100430. */
  100431. fallbacks: Nullable<IEffectFallbacks>;
  100432. /**
  100433. * Callback that will be called when the shader is compiled.
  100434. */
  100435. onCompiled: Nullable<(effect: Effect) => void>;
  100436. /**
  100437. * Callback that will be called if an error occurs during shader compilation.
  100438. */
  100439. onError: Nullable<(effect: Effect, errors: string) => void>;
  100440. /**
  100441. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100442. */
  100443. indexParameters?: any;
  100444. /**
  100445. * Max number of lights that can be used in the shader.
  100446. */
  100447. maxSimultaneousLights?: number;
  100448. /**
  100449. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  100450. */
  100451. transformFeedbackVaryings?: Nullable<string[]>;
  100452. }
  100453. /**
  100454. * Effect containing vertex and fragment shader that can be executed on an object.
  100455. */
  100456. export class Effect implements IDisposable {
  100457. /**
  100458. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  100459. */
  100460. static ShadersRepository: string;
  100461. /**
  100462. * Name of the effect.
  100463. */
  100464. name: any;
  100465. /**
  100466. * String container all the define statements that should be set on the shader.
  100467. */
  100468. defines: string;
  100469. /**
  100470. * Callback that will be called when the shader is compiled.
  100471. */
  100472. onCompiled: Nullable<(effect: Effect) => void>;
  100473. /**
  100474. * Callback that will be called if an error occurs during shader compilation.
  100475. */
  100476. onError: Nullable<(effect: Effect, errors: string) => void>;
  100477. /**
  100478. * Callback that will be called when effect is bound.
  100479. */
  100480. onBind: Nullable<(effect: Effect) => void>;
  100481. /**
  100482. * Unique ID of the effect.
  100483. */
  100484. uniqueId: number;
  100485. /**
  100486. * Observable that will be called when the shader is compiled.
  100487. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  100488. */
  100489. onCompileObservable: Observable<Effect>;
  100490. /**
  100491. * Observable that will be called if an error occurs during shader compilation.
  100492. */
  100493. onErrorObservable: Observable<Effect>;
  100494. /** @hidden */
  100495. _onBindObservable: Nullable<Observable<Effect>>;
  100496. /**
  100497. * @hidden
  100498. * Specifies if the effect was previously ready
  100499. */
  100500. _wasPreviouslyReady: boolean;
  100501. /**
  100502. * Observable that will be called when effect is bound.
  100503. */
  100504. get onBindObservable(): Observable<Effect>;
  100505. /** @hidden */
  100506. _bonesComputationForcedToCPU: boolean;
  100507. private static _uniqueIdSeed;
  100508. private _engine;
  100509. private _uniformBuffersNames;
  100510. private _uniformsNames;
  100511. private _samplerList;
  100512. private _samplers;
  100513. private _isReady;
  100514. private _compilationError;
  100515. private _allFallbacksProcessed;
  100516. private _attributesNames;
  100517. private _attributes;
  100518. private _attributeLocationByName;
  100519. private _uniforms;
  100520. /**
  100521. * Key for the effect.
  100522. * @hidden
  100523. */
  100524. _key: string;
  100525. private _indexParameters;
  100526. private _fallbacks;
  100527. private _vertexSourceCode;
  100528. private _fragmentSourceCode;
  100529. private _vertexSourceCodeOverride;
  100530. private _fragmentSourceCodeOverride;
  100531. private _transformFeedbackVaryings;
  100532. /**
  100533. * Compiled shader to webGL program.
  100534. * @hidden
  100535. */
  100536. _pipelineContext: Nullable<IPipelineContext>;
  100537. private _valueCache;
  100538. private static _baseCache;
  100539. /**
  100540. * Instantiates an effect.
  100541. * An effect can be used to create/manage/execute vertex and fragment shaders.
  100542. * @param baseName Name of the effect.
  100543. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  100544. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  100545. * @param samplers List of sampler variables that will be passed to the shader.
  100546. * @param engine Engine to be used to render the effect
  100547. * @param defines Define statements to be added to the shader.
  100548. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  100549. * @param onCompiled Callback that will be called when the shader is compiled.
  100550. * @param onError Callback that will be called if an error occurs during shader compilation.
  100551. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100552. */
  100553. 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);
  100554. private _useFinalCode;
  100555. /**
  100556. * Unique key for this effect
  100557. */
  100558. get key(): string;
  100559. /**
  100560. * If the effect has been compiled and prepared.
  100561. * @returns if the effect is compiled and prepared.
  100562. */
  100563. isReady(): boolean;
  100564. private _isReadyInternal;
  100565. /**
  100566. * The engine the effect was initialized with.
  100567. * @returns the engine.
  100568. */
  100569. getEngine(): Engine;
  100570. /**
  100571. * The pipeline context for this effect
  100572. * @returns the associated pipeline context
  100573. */
  100574. getPipelineContext(): Nullable<IPipelineContext>;
  100575. /**
  100576. * The set of names of attribute variables for the shader.
  100577. * @returns An array of attribute names.
  100578. */
  100579. getAttributesNames(): string[];
  100580. /**
  100581. * Returns the attribute at the given index.
  100582. * @param index The index of the attribute.
  100583. * @returns The location of the attribute.
  100584. */
  100585. getAttributeLocation(index: number): number;
  100586. /**
  100587. * Returns the attribute based on the name of the variable.
  100588. * @param name of the attribute to look up.
  100589. * @returns the attribute location.
  100590. */
  100591. getAttributeLocationByName(name: string): number;
  100592. /**
  100593. * The number of attributes.
  100594. * @returns the numnber of attributes.
  100595. */
  100596. getAttributesCount(): number;
  100597. /**
  100598. * Gets the index of a uniform variable.
  100599. * @param uniformName of the uniform to look up.
  100600. * @returns the index.
  100601. */
  100602. getUniformIndex(uniformName: string): number;
  100603. /**
  100604. * Returns the attribute based on the name of the variable.
  100605. * @param uniformName of the uniform to look up.
  100606. * @returns the location of the uniform.
  100607. */
  100608. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  100609. /**
  100610. * Returns an array of sampler variable names
  100611. * @returns The array of sampler variable neames.
  100612. */
  100613. getSamplers(): string[];
  100614. /**
  100615. * The error from the last compilation.
  100616. * @returns the error string.
  100617. */
  100618. getCompilationError(): string;
  100619. /**
  100620. * Gets a boolean indicating that all fallbacks were used during compilation
  100621. * @returns true if all fallbacks were used
  100622. */
  100623. allFallbacksProcessed(): boolean;
  100624. /**
  100625. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  100626. * @param func The callback to be used.
  100627. */
  100628. executeWhenCompiled(func: (effect: Effect) => void): void;
  100629. private _checkIsReady;
  100630. private _loadShader;
  100631. /**
  100632. * Recompiles the webGL program
  100633. * @param vertexSourceCode The source code for the vertex shader.
  100634. * @param fragmentSourceCode The source code for the fragment shader.
  100635. * @param onCompiled Callback called when completed.
  100636. * @param onError Callback called on error.
  100637. * @hidden
  100638. */
  100639. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  100640. /**
  100641. * Prepares the effect
  100642. * @hidden
  100643. */
  100644. _prepareEffect(): void;
  100645. private _processCompilationErrors;
  100646. /**
  100647. * Checks if the effect is supported. (Must be called after compilation)
  100648. */
  100649. get isSupported(): boolean;
  100650. /**
  100651. * Binds a texture to the engine to be used as output of the shader.
  100652. * @param channel Name of the output variable.
  100653. * @param texture Texture to bind.
  100654. * @hidden
  100655. */
  100656. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  100657. /**
  100658. * Sets a texture on the engine to be used in the shader.
  100659. * @param channel Name of the sampler variable.
  100660. * @param texture Texture to set.
  100661. */
  100662. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  100663. /**
  100664. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  100665. * @param channel Name of the sampler variable.
  100666. * @param texture Texture to set.
  100667. */
  100668. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  100669. /**
  100670. * Sets an array of textures on the engine to be used in the shader.
  100671. * @param channel Name of the variable.
  100672. * @param textures Textures to set.
  100673. */
  100674. setTextureArray(channel: string, textures: BaseTexture[]): void;
  100675. /**
  100676. * 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)
  100677. * @param channel Name of the sampler variable.
  100678. * @param postProcess Post process to get the input texture from.
  100679. */
  100680. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  100681. /**
  100682. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  100683. * 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)
  100684. * @param channel Name of the sampler variable.
  100685. * @param postProcess Post process to get the output texture from.
  100686. */
  100687. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  100688. /** @hidden */
  100689. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  100690. /** @hidden */
  100691. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  100692. /** @hidden */
  100693. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  100694. /** @hidden */
  100695. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  100696. /**
  100697. * Binds a buffer to a uniform.
  100698. * @param buffer Buffer to bind.
  100699. * @param name Name of the uniform variable to bind to.
  100700. */
  100701. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  100702. /**
  100703. * Binds block to a uniform.
  100704. * @param blockName Name of the block to bind.
  100705. * @param index Index to bind.
  100706. */
  100707. bindUniformBlock(blockName: string, index: number): void;
  100708. /**
  100709. * Sets an interger value on a uniform variable.
  100710. * @param uniformName Name of the variable.
  100711. * @param value Value to be set.
  100712. * @returns this effect.
  100713. */
  100714. setInt(uniformName: string, value: number): Effect;
  100715. /**
  100716. * Sets an int array on a uniform variable.
  100717. * @param uniformName Name of the variable.
  100718. * @param array array to be set.
  100719. * @returns this effect.
  100720. */
  100721. setIntArray(uniformName: string, array: Int32Array): Effect;
  100722. /**
  100723. * 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)
  100724. * @param uniformName Name of the variable.
  100725. * @param array array to be set.
  100726. * @returns this effect.
  100727. */
  100728. setIntArray2(uniformName: string, array: Int32Array): Effect;
  100729. /**
  100730. * 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)
  100731. * @param uniformName Name of the variable.
  100732. * @param array array to be set.
  100733. * @returns this effect.
  100734. */
  100735. setIntArray3(uniformName: string, array: Int32Array): Effect;
  100736. /**
  100737. * 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)
  100738. * @param uniformName Name of the variable.
  100739. * @param array array to be set.
  100740. * @returns this effect.
  100741. */
  100742. setIntArray4(uniformName: string, array: Int32Array): Effect;
  100743. /**
  100744. * Sets an float array on a uniform variable.
  100745. * @param uniformName Name of the variable.
  100746. * @param array array to be set.
  100747. * @returns this effect.
  100748. */
  100749. setFloatArray(uniformName: string, array: Float32Array): Effect;
  100750. /**
  100751. * 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)
  100752. * @param uniformName Name of the variable.
  100753. * @param array array to be set.
  100754. * @returns this effect.
  100755. */
  100756. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  100757. /**
  100758. * 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)
  100759. * @param uniformName Name of the variable.
  100760. * @param array array to be set.
  100761. * @returns this effect.
  100762. */
  100763. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  100764. /**
  100765. * 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)
  100766. * @param uniformName Name of the variable.
  100767. * @param array array to be set.
  100768. * @returns this effect.
  100769. */
  100770. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  100771. /**
  100772. * Sets an array on a uniform variable.
  100773. * @param uniformName Name of the variable.
  100774. * @param array array to be set.
  100775. * @returns this effect.
  100776. */
  100777. setArray(uniformName: string, array: number[]): Effect;
  100778. /**
  100779. * 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)
  100780. * @param uniformName Name of the variable.
  100781. * @param array array to be set.
  100782. * @returns this effect.
  100783. */
  100784. setArray2(uniformName: string, array: number[]): Effect;
  100785. /**
  100786. * 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)
  100787. * @param uniformName Name of the variable.
  100788. * @param array array to be set.
  100789. * @returns this effect.
  100790. */
  100791. setArray3(uniformName: string, array: number[]): Effect;
  100792. /**
  100793. * 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)
  100794. * @param uniformName Name of the variable.
  100795. * @param array array to be set.
  100796. * @returns this effect.
  100797. */
  100798. setArray4(uniformName: string, array: number[]): Effect;
  100799. /**
  100800. * Sets matrices on a uniform variable.
  100801. * @param uniformName Name of the variable.
  100802. * @param matrices matrices to be set.
  100803. * @returns this effect.
  100804. */
  100805. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  100806. /**
  100807. * Sets matrix on a uniform variable.
  100808. * @param uniformName Name of the variable.
  100809. * @param matrix matrix to be set.
  100810. * @returns this effect.
  100811. */
  100812. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  100813. /**
  100814. * 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)
  100815. * @param uniformName Name of the variable.
  100816. * @param matrix matrix to be set.
  100817. * @returns this effect.
  100818. */
  100819. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  100820. /**
  100821. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  100822. * @param uniformName Name of the variable.
  100823. * @param matrix matrix to be set.
  100824. * @returns this effect.
  100825. */
  100826. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  100827. /**
  100828. * Sets a float on a uniform variable.
  100829. * @param uniformName Name of the variable.
  100830. * @param value value to be set.
  100831. * @returns this effect.
  100832. */
  100833. setFloat(uniformName: string, value: number): Effect;
  100834. /**
  100835. * Sets a boolean on a uniform variable.
  100836. * @param uniformName Name of the variable.
  100837. * @param bool value to be set.
  100838. * @returns this effect.
  100839. */
  100840. setBool(uniformName: string, bool: boolean): Effect;
  100841. /**
  100842. * Sets a Vector2 on a uniform variable.
  100843. * @param uniformName Name of the variable.
  100844. * @param vector2 vector2 to be set.
  100845. * @returns this effect.
  100846. */
  100847. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  100848. /**
  100849. * Sets a float2 on a uniform variable.
  100850. * @param uniformName Name of the variable.
  100851. * @param x First float in float2.
  100852. * @param y Second float in float2.
  100853. * @returns this effect.
  100854. */
  100855. setFloat2(uniformName: string, x: number, y: number): Effect;
  100856. /**
  100857. * Sets a Vector3 on a uniform variable.
  100858. * @param uniformName Name of the variable.
  100859. * @param vector3 Value to be set.
  100860. * @returns this effect.
  100861. */
  100862. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  100863. /**
  100864. * Sets a float3 on a uniform variable.
  100865. * @param uniformName Name of the variable.
  100866. * @param x First float in float3.
  100867. * @param y Second float in float3.
  100868. * @param z Third float in float3.
  100869. * @returns this effect.
  100870. */
  100871. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  100872. /**
  100873. * Sets a Vector4 on a uniform variable.
  100874. * @param uniformName Name of the variable.
  100875. * @param vector4 Value to be set.
  100876. * @returns this effect.
  100877. */
  100878. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  100879. /**
  100880. * Sets a float4 on a uniform variable.
  100881. * @param uniformName Name of the variable.
  100882. * @param x First float in float4.
  100883. * @param y Second float in float4.
  100884. * @param z Third float in float4.
  100885. * @param w Fourth float in float4.
  100886. * @returns this effect.
  100887. */
  100888. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  100889. /**
  100890. * Sets a Color3 on a uniform variable.
  100891. * @param uniformName Name of the variable.
  100892. * @param color3 Value to be set.
  100893. * @returns this effect.
  100894. */
  100895. setColor3(uniformName: string, color3: IColor3Like): Effect;
  100896. /**
  100897. * Sets a Color4 on a uniform variable.
  100898. * @param uniformName Name of the variable.
  100899. * @param color3 Value to be set.
  100900. * @param alpha Alpha value to be set.
  100901. * @returns this effect.
  100902. */
  100903. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  100904. /**
  100905. * Sets a Color4 on a uniform variable
  100906. * @param uniformName defines the name of the variable
  100907. * @param color4 defines the value to be set
  100908. * @returns this effect.
  100909. */
  100910. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  100911. /** Release all associated resources */
  100912. dispose(): void;
  100913. /**
  100914. * This function will add a new shader to the shader store
  100915. * @param name the name of the shader
  100916. * @param pixelShader optional pixel shader content
  100917. * @param vertexShader optional vertex shader content
  100918. */
  100919. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  100920. /**
  100921. * Store of each shader (The can be looked up using effect.key)
  100922. */
  100923. static ShadersStore: {
  100924. [key: string]: string;
  100925. };
  100926. /**
  100927. * Store of each included file for a shader (The can be looked up using effect.key)
  100928. */
  100929. static IncludesShadersStore: {
  100930. [key: string]: string;
  100931. };
  100932. /**
  100933. * Resets the cache of effects.
  100934. */
  100935. static ResetCache(): void;
  100936. }
  100937. }
  100938. declare module BABYLON {
  100939. /**
  100940. * Interface used to describe the capabilities of the engine relatively to the current browser
  100941. */
  100942. export interface EngineCapabilities {
  100943. /** Maximum textures units per fragment shader */
  100944. maxTexturesImageUnits: number;
  100945. /** Maximum texture units per vertex shader */
  100946. maxVertexTextureImageUnits: number;
  100947. /** Maximum textures units in the entire pipeline */
  100948. maxCombinedTexturesImageUnits: number;
  100949. /** Maximum texture size */
  100950. maxTextureSize: number;
  100951. /** Maximum texture samples */
  100952. maxSamples?: number;
  100953. /** Maximum cube texture size */
  100954. maxCubemapTextureSize: number;
  100955. /** Maximum render texture size */
  100956. maxRenderTextureSize: number;
  100957. /** Maximum number of vertex attributes */
  100958. maxVertexAttribs: number;
  100959. /** Maximum number of varyings */
  100960. maxVaryingVectors: number;
  100961. /** Maximum number of uniforms per vertex shader */
  100962. maxVertexUniformVectors: number;
  100963. /** Maximum number of uniforms per fragment shader */
  100964. maxFragmentUniformVectors: number;
  100965. /** Defines if standard derivates (dx/dy) are supported */
  100966. standardDerivatives: boolean;
  100967. /** Defines if s3tc texture compression is supported */
  100968. s3tc?: WEBGL_compressed_texture_s3tc;
  100969. /** Defines if pvrtc texture compression is supported */
  100970. pvrtc: any;
  100971. /** Defines if etc1 texture compression is supported */
  100972. etc1: any;
  100973. /** Defines if etc2 texture compression is supported */
  100974. etc2: any;
  100975. /** Defines if astc texture compression is supported */
  100976. astc: any;
  100977. /** Defines if float textures are supported */
  100978. textureFloat: boolean;
  100979. /** Defines if vertex array objects are supported */
  100980. vertexArrayObject: boolean;
  100981. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  100982. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  100983. /** Gets the maximum level of anisotropy supported */
  100984. maxAnisotropy: number;
  100985. /** Defines if instancing is supported */
  100986. instancedArrays: boolean;
  100987. /** Defines if 32 bits indices are supported */
  100988. uintIndices: boolean;
  100989. /** Defines if high precision shaders are supported */
  100990. highPrecisionShaderSupported: boolean;
  100991. /** Defines if depth reading in the fragment shader is supported */
  100992. fragmentDepthSupported: boolean;
  100993. /** Defines if float texture linear filtering is supported*/
  100994. textureFloatLinearFiltering: boolean;
  100995. /** Defines if rendering to float textures is supported */
  100996. textureFloatRender: boolean;
  100997. /** Defines if half float textures are supported*/
  100998. textureHalfFloat: boolean;
  100999. /** Defines if half float texture linear filtering is supported*/
  101000. textureHalfFloatLinearFiltering: boolean;
  101001. /** Defines if rendering to half float textures is supported */
  101002. textureHalfFloatRender: boolean;
  101003. /** Defines if textureLOD shader command is supported */
  101004. textureLOD: boolean;
  101005. /** Defines if draw buffers extension is supported */
  101006. drawBuffersExtension: boolean;
  101007. /** Defines if depth textures are supported */
  101008. depthTextureExtension: boolean;
  101009. /** Defines if float color buffer are supported */
  101010. colorBufferFloat: boolean;
  101011. /** Gets disjoint timer query extension (null if not supported) */
  101012. timerQuery?: EXT_disjoint_timer_query;
  101013. /** Defines if timestamp can be used with timer query */
  101014. canUseTimestampForTimerQuery: boolean;
  101015. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  101016. multiview?: any;
  101017. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  101018. oculusMultiview?: any;
  101019. /** Function used to let the system compiles shaders in background */
  101020. parallelShaderCompile?: {
  101021. COMPLETION_STATUS_KHR: number;
  101022. };
  101023. /** Max number of texture samples for MSAA */
  101024. maxMSAASamples: number;
  101025. /** Defines if the blend min max extension is supported */
  101026. blendMinMax: boolean;
  101027. }
  101028. }
  101029. declare module BABYLON {
  101030. /**
  101031. * @hidden
  101032. **/
  101033. export class DepthCullingState {
  101034. private _isDepthTestDirty;
  101035. private _isDepthMaskDirty;
  101036. private _isDepthFuncDirty;
  101037. private _isCullFaceDirty;
  101038. private _isCullDirty;
  101039. private _isZOffsetDirty;
  101040. private _isFrontFaceDirty;
  101041. private _depthTest;
  101042. private _depthMask;
  101043. private _depthFunc;
  101044. private _cull;
  101045. private _cullFace;
  101046. private _zOffset;
  101047. private _frontFace;
  101048. /**
  101049. * Initializes the state.
  101050. */
  101051. constructor();
  101052. get isDirty(): boolean;
  101053. get zOffset(): number;
  101054. set zOffset(value: number);
  101055. get cullFace(): Nullable<number>;
  101056. set cullFace(value: Nullable<number>);
  101057. get cull(): Nullable<boolean>;
  101058. set cull(value: Nullable<boolean>);
  101059. get depthFunc(): Nullable<number>;
  101060. set depthFunc(value: Nullable<number>);
  101061. get depthMask(): boolean;
  101062. set depthMask(value: boolean);
  101063. get depthTest(): boolean;
  101064. set depthTest(value: boolean);
  101065. get frontFace(): Nullable<number>;
  101066. set frontFace(value: Nullable<number>);
  101067. reset(): void;
  101068. apply(gl: WebGLRenderingContext): void;
  101069. }
  101070. }
  101071. declare module BABYLON {
  101072. /**
  101073. * @hidden
  101074. **/
  101075. export class StencilState {
  101076. /** 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 */
  101077. static readonly ALWAYS: number;
  101078. /** Passed to stencilOperation to specify that stencil value must be kept */
  101079. static readonly KEEP: number;
  101080. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101081. static readonly REPLACE: number;
  101082. private _isStencilTestDirty;
  101083. private _isStencilMaskDirty;
  101084. private _isStencilFuncDirty;
  101085. private _isStencilOpDirty;
  101086. private _stencilTest;
  101087. private _stencilMask;
  101088. private _stencilFunc;
  101089. private _stencilFuncRef;
  101090. private _stencilFuncMask;
  101091. private _stencilOpStencilFail;
  101092. private _stencilOpDepthFail;
  101093. private _stencilOpStencilDepthPass;
  101094. get isDirty(): boolean;
  101095. get stencilFunc(): number;
  101096. set stencilFunc(value: number);
  101097. get stencilFuncRef(): number;
  101098. set stencilFuncRef(value: number);
  101099. get stencilFuncMask(): number;
  101100. set stencilFuncMask(value: number);
  101101. get stencilOpStencilFail(): number;
  101102. set stencilOpStencilFail(value: number);
  101103. get stencilOpDepthFail(): number;
  101104. set stencilOpDepthFail(value: number);
  101105. get stencilOpStencilDepthPass(): number;
  101106. set stencilOpStencilDepthPass(value: number);
  101107. get stencilMask(): number;
  101108. set stencilMask(value: number);
  101109. get stencilTest(): boolean;
  101110. set stencilTest(value: boolean);
  101111. constructor();
  101112. reset(): void;
  101113. apply(gl: WebGLRenderingContext): void;
  101114. }
  101115. }
  101116. declare module BABYLON {
  101117. /**
  101118. * @hidden
  101119. **/
  101120. export class AlphaState {
  101121. private _isAlphaBlendDirty;
  101122. private _isBlendFunctionParametersDirty;
  101123. private _isBlendEquationParametersDirty;
  101124. private _isBlendConstantsDirty;
  101125. private _alphaBlend;
  101126. private _blendFunctionParameters;
  101127. private _blendEquationParameters;
  101128. private _blendConstants;
  101129. /**
  101130. * Initializes the state.
  101131. */
  101132. constructor();
  101133. get isDirty(): boolean;
  101134. get alphaBlend(): boolean;
  101135. set alphaBlend(value: boolean);
  101136. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  101137. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  101138. setAlphaEquationParameters(rgb: number, alpha: number): void;
  101139. reset(): void;
  101140. apply(gl: WebGLRenderingContext): void;
  101141. }
  101142. }
  101143. declare module BABYLON {
  101144. /** @hidden */
  101145. export class WebGL2ShaderProcessor implements IShaderProcessor {
  101146. attributeProcessor(attribute: string): string;
  101147. varyingProcessor(varying: string, isFragment: boolean): string;
  101148. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  101149. }
  101150. }
  101151. declare module BABYLON {
  101152. /**
  101153. * Interface for attribute information associated with buffer instanciation
  101154. */
  101155. export interface InstancingAttributeInfo {
  101156. /**
  101157. * Name of the GLSL attribute
  101158. * if attribute index is not specified, this is used to retrieve the index from the effect
  101159. */
  101160. attributeName: string;
  101161. /**
  101162. * Index/offset of the attribute in the vertex shader
  101163. * if not specified, this will be computes from the name.
  101164. */
  101165. index?: number;
  101166. /**
  101167. * size of the attribute, 1, 2, 3 or 4
  101168. */
  101169. attributeSize: number;
  101170. /**
  101171. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  101172. */
  101173. offset: number;
  101174. /**
  101175. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  101176. * default to 1
  101177. */
  101178. divisor?: number;
  101179. /**
  101180. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  101181. * default is FLOAT
  101182. */
  101183. attributeType?: number;
  101184. /**
  101185. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  101186. */
  101187. normalized?: boolean;
  101188. }
  101189. }
  101190. declare module BABYLON {
  101191. interface ThinEngine {
  101192. /**
  101193. * Update a video texture
  101194. * @param texture defines the texture to update
  101195. * @param video defines the video element to use
  101196. * @param invertY defines if data must be stored with Y axis inverted
  101197. */
  101198. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  101199. }
  101200. }
  101201. declare module BABYLON {
  101202. /**
  101203. * Settings for finer control over video usage
  101204. */
  101205. export interface VideoTextureSettings {
  101206. /**
  101207. * Applies `autoplay` to video, if specified
  101208. */
  101209. autoPlay?: boolean;
  101210. /**
  101211. * Applies `loop` to video, if specified
  101212. */
  101213. loop?: boolean;
  101214. /**
  101215. * Automatically updates internal texture from video at every frame in the render loop
  101216. */
  101217. autoUpdateTexture: boolean;
  101218. /**
  101219. * Image src displayed during the video loading or until the user interacts with the video.
  101220. */
  101221. poster?: string;
  101222. }
  101223. /**
  101224. * If you want to display a video in your scene, this is the special texture for that.
  101225. * This special texture works similar to other textures, with the exception of a few parameters.
  101226. * @see https://doc.babylonjs.com/how_to/video_texture
  101227. */
  101228. export class VideoTexture extends Texture {
  101229. /**
  101230. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  101231. */
  101232. readonly autoUpdateTexture: boolean;
  101233. /**
  101234. * The video instance used by the texture internally
  101235. */
  101236. readonly video: HTMLVideoElement;
  101237. private _onUserActionRequestedObservable;
  101238. /**
  101239. * Event triggerd when a dom action is required by the user to play the video.
  101240. * This happens due to recent changes in browser policies preventing video to auto start.
  101241. */
  101242. get onUserActionRequestedObservable(): Observable<Texture>;
  101243. private _generateMipMaps;
  101244. private _engine;
  101245. private _stillImageCaptured;
  101246. private _displayingPosterTexture;
  101247. private _settings;
  101248. private _createInternalTextureOnEvent;
  101249. private _frameId;
  101250. /**
  101251. * Creates a video texture.
  101252. * If you want to display a video in your scene, this is the special texture for that.
  101253. * This special texture works similar to other textures, with the exception of a few parameters.
  101254. * @see https://doc.babylonjs.com/how_to/video_texture
  101255. * @param name optional name, will detect from video source, if not defined
  101256. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  101257. * @param scene is obviously the current scene.
  101258. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  101259. * @param invertY is false by default but can be used to invert video on Y axis
  101260. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  101261. * @param settings allows finer control over video usage
  101262. */
  101263. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  101264. private _getName;
  101265. private _getVideo;
  101266. private _createInternalTexture;
  101267. private reset;
  101268. /**
  101269. * @hidden Internal method to initiate `update`.
  101270. */
  101271. _rebuild(): void;
  101272. /**
  101273. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  101274. */
  101275. update(): void;
  101276. /**
  101277. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  101278. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  101279. */
  101280. updateTexture(isVisible: boolean): void;
  101281. protected _updateInternalTexture: () => void;
  101282. /**
  101283. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  101284. * @param url New url.
  101285. */
  101286. updateURL(url: string): void;
  101287. /**
  101288. * Dispose the texture and release its associated resources.
  101289. */
  101290. dispose(): void;
  101291. /**
  101292. * Creates a video texture straight from a stream.
  101293. * @param scene Define the scene the texture should be created in
  101294. * @param stream Define the stream the texture should be created from
  101295. * @returns The created video texture as a promise
  101296. */
  101297. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  101298. /**
  101299. * Creates a video texture straight from your WebCam video feed.
  101300. * @param scene Define the scene the texture should be created in
  101301. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101302. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101303. * @returns The created video texture as a promise
  101304. */
  101305. static CreateFromWebCamAsync(scene: Scene, constraints: {
  101306. minWidth: number;
  101307. maxWidth: number;
  101308. minHeight: number;
  101309. maxHeight: number;
  101310. deviceId: string;
  101311. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  101312. /**
  101313. * Creates a video texture straight from your WebCam video feed.
  101314. * @param scene Define the scene the texture should be created in
  101315. * @param onReady Define a callback to triggered once the texture will be ready
  101316. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101317. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101318. */
  101319. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  101320. minWidth: number;
  101321. maxWidth: number;
  101322. minHeight: number;
  101323. maxHeight: number;
  101324. deviceId: string;
  101325. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  101326. }
  101327. }
  101328. declare module BABYLON {
  101329. /**
  101330. * Defines the interface used by objects working like Scene
  101331. * @hidden
  101332. */
  101333. interface ISceneLike {
  101334. _addPendingData(data: any): void;
  101335. _removePendingData(data: any): void;
  101336. offlineProvider: IOfflineProvider;
  101337. }
  101338. /** Interface defining initialization parameters for Engine class */
  101339. export interface EngineOptions extends WebGLContextAttributes {
  101340. /**
  101341. * Defines if the engine should no exceed a specified device ratio
  101342. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  101343. */
  101344. limitDeviceRatio?: number;
  101345. /**
  101346. * Defines if webvr should be enabled automatically
  101347. * @see http://doc.babylonjs.com/how_to/webvr_camera
  101348. */
  101349. autoEnableWebVR?: boolean;
  101350. /**
  101351. * Defines if webgl2 should be turned off even if supported
  101352. * @see http://doc.babylonjs.com/features/webgl2
  101353. */
  101354. disableWebGL2Support?: boolean;
  101355. /**
  101356. * Defines if webaudio should be initialized as well
  101357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101358. */
  101359. audioEngine?: boolean;
  101360. /**
  101361. * Defines if animations should run using a deterministic lock step
  101362. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101363. */
  101364. deterministicLockstep?: boolean;
  101365. /** Defines the maximum steps to use with deterministic lock step mode */
  101366. lockstepMaxSteps?: number;
  101367. /** Defines the seconds between each deterministic lock step */
  101368. timeStep?: number;
  101369. /**
  101370. * Defines that engine should ignore context lost events
  101371. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  101372. */
  101373. doNotHandleContextLost?: boolean;
  101374. /**
  101375. * Defines that engine should ignore modifying touch action attribute and style
  101376. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  101377. */
  101378. doNotHandleTouchAction?: boolean;
  101379. /**
  101380. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  101381. */
  101382. useHighPrecisionFloats?: boolean;
  101383. }
  101384. /**
  101385. * The base engine class (root of all engines)
  101386. */
  101387. export class ThinEngine {
  101388. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  101389. static ExceptionList: ({
  101390. key: string;
  101391. capture: string;
  101392. captureConstraint: number;
  101393. targets: string[];
  101394. } | {
  101395. key: string;
  101396. capture: null;
  101397. captureConstraint: null;
  101398. targets: string[];
  101399. })[];
  101400. /** @hidden */
  101401. static _TextureLoaders: IInternalTextureLoader[];
  101402. /**
  101403. * Returns the current npm package of the sdk
  101404. */
  101405. static get NpmPackage(): string;
  101406. /**
  101407. * Returns the current version of the framework
  101408. */
  101409. static get Version(): string;
  101410. /**
  101411. * Returns a string describing the current engine
  101412. */
  101413. get description(): string;
  101414. /**
  101415. * Gets or sets the epsilon value used by collision engine
  101416. */
  101417. static CollisionsEpsilon: number;
  101418. /**
  101419. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  101420. */
  101421. static get ShadersRepository(): string;
  101422. static set ShadersRepository(value: string);
  101423. /**
  101424. * Gets or sets the textures that the engine should not attempt to load as compressed
  101425. */
  101426. protected _excludedCompressedTextures: string[];
  101427. /**
  101428. * Filters the compressed texture formats to only include
  101429. * files that are not included in the skippable list
  101430. *
  101431. * @param url the current extension
  101432. * @param textureFormatInUse the current compressed texture format
  101433. * @returns "format" string
  101434. */
  101435. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  101436. /** @hidden */
  101437. _shaderProcessor: IShaderProcessor;
  101438. /**
  101439. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  101440. */
  101441. forcePOTTextures: boolean;
  101442. /**
  101443. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  101444. */
  101445. isFullscreen: boolean;
  101446. /**
  101447. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  101448. */
  101449. cullBackFaces: boolean;
  101450. /**
  101451. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  101452. */
  101453. renderEvenInBackground: boolean;
  101454. /**
  101455. * Gets or sets a boolean indicating that cache can be kept between frames
  101456. */
  101457. preventCacheWipeBetweenFrames: boolean;
  101458. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  101459. validateShaderPrograms: boolean;
  101460. /**
  101461. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  101462. * This can provide greater z depth for distant objects.
  101463. */
  101464. useReverseDepthBuffer: boolean;
  101465. /**
  101466. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  101467. */
  101468. disableUniformBuffers: boolean;
  101469. /** @hidden */
  101470. _uniformBuffers: UniformBuffer[];
  101471. /**
  101472. * Gets a boolean indicating that the engine supports uniform buffers
  101473. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  101474. */
  101475. get supportsUniformBuffers(): boolean;
  101476. /** @hidden */
  101477. _gl: WebGLRenderingContext;
  101478. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  101479. protected _windowIsBackground: boolean;
  101480. protected _webGLVersion: number;
  101481. protected _creationOptions: EngineOptions;
  101482. protected _highPrecisionShadersAllowed: boolean;
  101483. /** @hidden */
  101484. get _shouldUseHighPrecisionShader(): boolean;
  101485. /**
  101486. * Gets a boolean indicating that only power of 2 textures are supported
  101487. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  101488. */
  101489. get needPOTTextures(): boolean;
  101490. /** @hidden */
  101491. _badOS: boolean;
  101492. /** @hidden */
  101493. _badDesktopOS: boolean;
  101494. private _hardwareScalingLevel;
  101495. /** @hidden */
  101496. _caps: EngineCapabilities;
  101497. private _isStencilEnable;
  101498. private _glVersion;
  101499. private _glRenderer;
  101500. private _glVendor;
  101501. /** @hidden */
  101502. _videoTextureSupported: boolean;
  101503. protected _renderingQueueLaunched: boolean;
  101504. protected _activeRenderLoops: (() => void)[];
  101505. /**
  101506. * Observable signaled when a context lost event is raised
  101507. */
  101508. onContextLostObservable: Observable<ThinEngine>;
  101509. /**
  101510. * Observable signaled when a context restored event is raised
  101511. */
  101512. onContextRestoredObservable: Observable<ThinEngine>;
  101513. private _onContextLost;
  101514. private _onContextRestored;
  101515. protected _contextWasLost: boolean;
  101516. /** @hidden */
  101517. _doNotHandleContextLost: boolean;
  101518. /**
  101519. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  101520. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  101521. */
  101522. get doNotHandleContextLost(): boolean;
  101523. set doNotHandleContextLost(value: boolean);
  101524. /**
  101525. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  101526. */
  101527. disableVertexArrayObjects: boolean;
  101528. /** @hidden */
  101529. protected _colorWrite: boolean;
  101530. /** @hidden */
  101531. protected _colorWriteChanged: boolean;
  101532. /** @hidden */
  101533. protected _depthCullingState: DepthCullingState;
  101534. /** @hidden */
  101535. protected _stencilState: StencilState;
  101536. /** @hidden */
  101537. _alphaState: AlphaState;
  101538. /** @hidden */
  101539. _alphaMode: number;
  101540. /** @hidden */
  101541. _alphaEquation: number;
  101542. /** @hidden */
  101543. _internalTexturesCache: InternalTexture[];
  101544. /** @hidden */
  101545. protected _activeChannel: number;
  101546. private _currentTextureChannel;
  101547. /** @hidden */
  101548. protected _boundTexturesCache: {
  101549. [key: string]: Nullable<InternalTexture>;
  101550. };
  101551. /** @hidden */
  101552. protected _currentEffect: Nullable<Effect>;
  101553. /** @hidden */
  101554. protected _currentProgram: Nullable<WebGLProgram>;
  101555. private _compiledEffects;
  101556. private _vertexAttribArraysEnabled;
  101557. /** @hidden */
  101558. protected _cachedViewport: Nullable<IViewportLike>;
  101559. private _cachedVertexArrayObject;
  101560. /** @hidden */
  101561. protected _cachedVertexBuffers: any;
  101562. /** @hidden */
  101563. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  101564. /** @hidden */
  101565. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  101566. /** @hidden */
  101567. _currentRenderTarget: Nullable<InternalTexture>;
  101568. private _uintIndicesCurrentlySet;
  101569. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  101570. /** @hidden */
  101571. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  101572. private _currentBufferPointers;
  101573. private _currentInstanceLocations;
  101574. private _currentInstanceBuffers;
  101575. private _textureUnits;
  101576. /** @hidden */
  101577. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  101578. /** @hidden */
  101579. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  101580. /** @hidden */
  101581. _boundRenderFunction: any;
  101582. private _vaoRecordInProgress;
  101583. private _mustWipeVertexAttributes;
  101584. private _emptyTexture;
  101585. private _emptyCubeTexture;
  101586. private _emptyTexture3D;
  101587. private _emptyTexture2DArray;
  101588. /** @hidden */
  101589. _frameHandler: number;
  101590. private _nextFreeTextureSlots;
  101591. private _maxSimultaneousTextures;
  101592. private _activeRequests;
  101593. protected _texturesSupported: string[];
  101594. /** @hidden */
  101595. _textureFormatInUse: Nullable<string>;
  101596. protected get _supportsHardwareTextureRescaling(): boolean;
  101597. /**
  101598. * Gets the list of texture formats supported
  101599. */
  101600. get texturesSupported(): Array<string>;
  101601. /**
  101602. * Gets the list of texture formats in use
  101603. */
  101604. get textureFormatInUse(): Nullable<string>;
  101605. /**
  101606. * Gets the current viewport
  101607. */
  101608. get currentViewport(): Nullable<IViewportLike>;
  101609. /**
  101610. * Gets the default empty texture
  101611. */
  101612. get emptyTexture(): InternalTexture;
  101613. /**
  101614. * Gets the default empty 3D texture
  101615. */
  101616. get emptyTexture3D(): InternalTexture;
  101617. /**
  101618. * Gets the default empty 2D array texture
  101619. */
  101620. get emptyTexture2DArray(): InternalTexture;
  101621. /**
  101622. * Gets the default empty cube texture
  101623. */
  101624. get emptyCubeTexture(): InternalTexture;
  101625. /**
  101626. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  101627. */
  101628. readonly premultipliedAlpha: boolean;
  101629. /**
  101630. * Observable event triggered before each texture is initialized
  101631. */
  101632. onBeforeTextureInitObservable: Observable<Texture>;
  101633. /**
  101634. * Creates a new engine
  101635. * @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
  101636. * @param antialias defines enable antialiasing (default: false)
  101637. * @param options defines further options to be sent to the getContext() function
  101638. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101639. */
  101640. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101641. private _rebuildInternalTextures;
  101642. private _rebuildEffects;
  101643. /**
  101644. * Gets a boolean indicating if all created effects are ready
  101645. * @returns true if all effects are ready
  101646. */
  101647. areAllEffectsReady(): boolean;
  101648. protected _rebuildBuffers(): void;
  101649. private _initGLContext;
  101650. /**
  101651. * Gets version of the current webGL context
  101652. */
  101653. get webGLVersion(): number;
  101654. /**
  101655. * Gets a string idenfifying the name of the class
  101656. * @returns "Engine" string
  101657. */
  101658. getClassName(): string;
  101659. /**
  101660. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  101661. */
  101662. get isStencilEnable(): boolean;
  101663. /** @hidden */
  101664. _prepareWorkingCanvas(): void;
  101665. /**
  101666. * Reset the texture cache to empty state
  101667. */
  101668. resetTextureCache(): void;
  101669. /**
  101670. * Gets an object containing information about the current webGL context
  101671. * @returns an object containing the vender, the renderer and the version of the current webGL context
  101672. */
  101673. getGlInfo(): {
  101674. vendor: string;
  101675. renderer: string;
  101676. version: string;
  101677. };
  101678. /**
  101679. * Defines the hardware scaling level.
  101680. * By default the hardware scaling level is computed from the window device ratio.
  101681. * 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.
  101682. * @param level defines the level to use
  101683. */
  101684. setHardwareScalingLevel(level: number): void;
  101685. /**
  101686. * Gets the current hardware scaling level.
  101687. * By default the hardware scaling level is computed from the window device ratio.
  101688. * 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.
  101689. * @returns a number indicating the current hardware scaling level
  101690. */
  101691. getHardwareScalingLevel(): number;
  101692. /**
  101693. * Gets the list of loaded textures
  101694. * @returns an array containing all loaded textures
  101695. */
  101696. getLoadedTexturesCache(): InternalTexture[];
  101697. /**
  101698. * Gets the object containing all engine capabilities
  101699. * @returns the EngineCapabilities object
  101700. */
  101701. getCaps(): EngineCapabilities;
  101702. /**
  101703. * stop executing a render loop function and remove it from the execution array
  101704. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  101705. */
  101706. stopRenderLoop(renderFunction?: () => void): void;
  101707. /** @hidden */
  101708. _renderLoop(): void;
  101709. /**
  101710. * Gets the HTML canvas attached with the current webGL context
  101711. * @returns a HTML canvas
  101712. */
  101713. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  101714. /**
  101715. * Gets host window
  101716. * @returns the host window object
  101717. */
  101718. getHostWindow(): Nullable<Window>;
  101719. /**
  101720. * Gets the current render width
  101721. * @param useScreen defines if screen size must be used (or the current render target if any)
  101722. * @returns a number defining the current render width
  101723. */
  101724. getRenderWidth(useScreen?: boolean): number;
  101725. /**
  101726. * Gets the current render height
  101727. * @param useScreen defines if screen size must be used (or the current render target if any)
  101728. * @returns a number defining the current render height
  101729. */
  101730. getRenderHeight(useScreen?: boolean): number;
  101731. /**
  101732. * Can be used to override the current requestAnimationFrame requester.
  101733. * @hidden
  101734. */
  101735. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  101736. /**
  101737. * Register and execute a render loop. The engine can have more than one render function
  101738. * @param renderFunction defines the function to continuously execute
  101739. */
  101740. runRenderLoop(renderFunction: () => void): void;
  101741. /**
  101742. * Clear the current render buffer or the current render target (if any is set up)
  101743. * @param color defines the color to use
  101744. * @param backBuffer defines if the back buffer must be cleared
  101745. * @param depth defines if the depth buffer must be cleared
  101746. * @param stencil defines if the stencil buffer must be cleared
  101747. */
  101748. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101749. private _viewportCached;
  101750. /** @hidden */
  101751. _viewport(x: number, y: number, width: number, height: number): void;
  101752. /**
  101753. * Set the WebGL's viewport
  101754. * @param viewport defines the viewport element to be used
  101755. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  101756. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  101757. */
  101758. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  101759. /**
  101760. * Begin a new frame
  101761. */
  101762. beginFrame(): void;
  101763. /**
  101764. * Enf the current frame
  101765. */
  101766. endFrame(): void;
  101767. /**
  101768. * Resize the view according to the canvas' size
  101769. */
  101770. resize(): void;
  101771. /**
  101772. * Force a specific size of the canvas
  101773. * @param width defines the new canvas' width
  101774. * @param height defines the new canvas' height
  101775. */
  101776. setSize(width: number, height: number): void;
  101777. /**
  101778. * Binds the frame buffer to the specified texture.
  101779. * @param texture The texture to render to or null for the default canvas
  101780. * @param faceIndex The face of the texture to render to in case of cube texture
  101781. * @param requiredWidth The width of the target to render to
  101782. * @param requiredHeight The height of the target to render to
  101783. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  101784. * @param depthStencilTexture The depth stencil texture to use to render
  101785. * @param lodLevel defines le lod level to bind to the frame buffer
  101786. */
  101787. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  101788. /** @hidden */
  101789. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  101790. /**
  101791. * Unbind the current render target texture from the webGL context
  101792. * @param texture defines the render target texture to unbind
  101793. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101794. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101795. */
  101796. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101797. /**
  101798. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  101799. */
  101800. flushFramebuffer(): void;
  101801. /**
  101802. * Unbind the current render target and bind the default framebuffer
  101803. */
  101804. restoreDefaultFramebuffer(): void;
  101805. /** @hidden */
  101806. protected _resetVertexBufferBinding(): void;
  101807. /**
  101808. * Creates a vertex buffer
  101809. * @param data the data for the vertex buffer
  101810. * @returns the new WebGL static buffer
  101811. */
  101812. createVertexBuffer(data: DataArray): DataBuffer;
  101813. private _createVertexBuffer;
  101814. /**
  101815. * Creates a dynamic vertex buffer
  101816. * @param data the data for the dynamic vertex buffer
  101817. * @returns the new WebGL dynamic buffer
  101818. */
  101819. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  101820. protected _resetIndexBufferBinding(): void;
  101821. /**
  101822. * Creates a new index buffer
  101823. * @param indices defines the content of the index buffer
  101824. * @param updatable defines if the index buffer must be updatable
  101825. * @returns a new webGL buffer
  101826. */
  101827. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  101828. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  101829. /**
  101830. * Bind a webGL buffer to the webGL context
  101831. * @param buffer defines the buffer to bind
  101832. */
  101833. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  101834. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  101835. private bindBuffer;
  101836. /**
  101837. * update the bound buffer with the given data
  101838. * @param data defines the data to update
  101839. */
  101840. updateArrayBuffer(data: Float32Array): void;
  101841. private _vertexAttribPointer;
  101842. private _bindIndexBufferWithCache;
  101843. private _bindVertexBuffersAttributes;
  101844. /**
  101845. * Records a vertex array object
  101846. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101847. * @param vertexBuffers defines the list of vertex buffers to store
  101848. * @param indexBuffer defines the index buffer to store
  101849. * @param effect defines the effect to store
  101850. * @returns the new vertex array object
  101851. */
  101852. recordVertexArrayObject(vertexBuffers: {
  101853. [key: string]: VertexBuffer;
  101854. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  101855. /**
  101856. * Bind a specific vertex array object
  101857. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101858. * @param vertexArrayObject defines the vertex array object to bind
  101859. * @param indexBuffer defines the index buffer to bind
  101860. */
  101861. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  101862. /**
  101863. * Bind webGl buffers directly to the webGL context
  101864. * @param vertexBuffer defines the vertex buffer to bind
  101865. * @param indexBuffer defines the index buffer to bind
  101866. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  101867. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  101868. * @param effect defines the effect associated with the vertex buffer
  101869. */
  101870. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  101871. private _unbindVertexArrayObject;
  101872. /**
  101873. * Bind a list of vertex buffers to the webGL context
  101874. * @param vertexBuffers defines the list of vertex buffers to bind
  101875. * @param indexBuffer defines the index buffer to bind
  101876. * @param effect defines the effect associated with the vertex buffers
  101877. */
  101878. bindBuffers(vertexBuffers: {
  101879. [key: string]: Nullable<VertexBuffer>;
  101880. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  101881. /**
  101882. * Unbind all instance attributes
  101883. */
  101884. unbindInstanceAttributes(): void;
  101885. /**
  101886. * Release and free the memory of a vertex array object
  101887. * @param vao defines the vertex array object to delete
  101888. */
  101889. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  101890. /** @hidden */
  101891. _releaseBuffer(buffer: DataBuffer): boolean;
  101892. protected _deleteBuffer(buffer: DataBuffer): void;
  101893. /**
  101894. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  101895. * @param instancesBuffer defines the webGL buffer to update and bind
  101896. * @param data defines the data to store in the buffer
  101897. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  101898. */
  101899. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  101900. /**
  101901. * Bind the content of a webGL buffer used with instanciation
  101902. * @param instancesBuffer defines the webGL buffer to bind
  101903. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  101904. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  101905. */
  101906. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  101907. /**
  101908. * Disable the instance attribute corresponding to the name in parameter
  101909. * @param name defines the name of the attribute to disable
  101910. */
  101911. disableInstanceAttributeByName(name: string): void;
  101912. /**
  101913. * Disable the instance attribute corresponding to the location in parameter
  101914. * @param attributeLocation defines the attribute location of the attribute to disable
  101915. */
  101916. disableInstanceAttribute(attributeLocation: number): void;
  101917. /**
  101918. * Disable the attribute corresponding to the location in parameter
  101919. * @param attributeLocation defines the attribute location of the attribute to disable
  101920. */
  101921. disableAttributeByIndex(attributeLocation: number): void;
  101922. /**
  101923. * Send a draw order
  101924. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101925. * @param indexStart defines the starting index
  101926. * @param indexCount defines the number of index to draw
  101927. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101928. */
  101929. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101930. /**
  101931. * Draw a list of points
  101932. * @param verticesStart defines the index of first vertex to draw
  101933. * @param verticesCount defines the count of vertices to draw
  101934. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101935. */
  101936. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101937. /**
  101938. * Draw a list of unindexed primitives
  101939. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101940. * @param verticesStart defines the index of first vertex to draw
  101941. * @param verticesCount defines the count of vertices to draw
  101942. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101943. */
  101944. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101945. /**
  101946. * Draw a list of indexed primitives
  101947. * @param fillMode defines the primitive to use
  101948. * @param indexStart defines the starting index
  101949. * @param indexCount defines the number of index to draw
  101950. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101951. */
  101952. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101953. /**
  101954. * Draw a list of unindexed primitives
  101955. * @param fillMode defines the primitive to use
  101956. * @param verticesStart defines the index of first vertex to draw
  101957. * @param verticesCount defines the count of vertices to draw
  101958. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101959. */
  101960. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101961. private _drawMode;
  101962. /** @hidden */
  101963. protected _reportDrawCall(): void;
  101964. /** @hidden */
  101965. _releaseEffect(effect: Effect): void;
  101966. /** @hidden */
  101967. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  101968. /**
  101969. * Create a new effect (used to store vertex/fragment shaders)
  101970. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  101971. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  101972. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  101973. * @param samplers defines an array of string used to represent textures
  101974. * @param defines defines the string containing the defines to use to compile the shaders
  101975. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  101976. * @param onCompiled defines a function to call when the effect creation is successful
  101977. * @param onError defines a function to call when the effect creation has failed
  101978. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  101979. * @returns the new Effect
  101980. */
  101981. 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;
  101982. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  101983. private _compileShader;
  101984. private _compileRawShader;
  101985. /**
  101986. * Directly creates a webGL program
  101987. * @param pipelineContext defines the pipeline context to attach to
  101988. * @param vertexCode defines the vertex shader code to use
  101989. * @param fragmentCode defines the fragment shader code to use
  101990. * @param context defines the webGL context to use (if not set, the current one will be used)
  101991. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101992. * @returns the new webGL program
  101993. */
  101994. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101995. /**
  101996. * Creates a webGL program
  101997. * @param pipelineContext defines the pipeline context to attach to
  101998. * @param vertexCode defines the vertex shader code to use
  101999. * @param fragmentCode defines the fragment shader code to use
  102000. * @param defines defines the string containing the defines to use to compile the shaders
  102001. * @param context defines the webGL context to use (if not set, the current one will be used)
  102002. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  102003. * @returns the new webGL program
  102004. */
  102005. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102006. /**
  102007. * Creates a new pipeline context
  102008. * @returns the new pipeline
  102009. */
  102010. createPipelineContext(): IPipelineContext;
  102011. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102012. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  102013. /** @hidden */
  102014. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  102015. /** @hidden */
  102016. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  102017. /** @hidden */
  102018. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  102019. /**
  102020. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  102021. * @param pipelineContext defines the pipeline context to use
  102022. * @param uniformsNames defines the list of uniform names
  102023. * @returns an array of webGL uniform locations
  102024. */
  102025. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  102026. /**
  102027. * Gets the lsit of active attributes for a given webGL program
  102028. * @param pipelineContext defines the pipeline context to use
  102029. * @param attributesNames defines the list of attribute names to get
  102030. * @returns an array of indices indicating the offset of each attribute
  102031. */
  102032. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  102033. /**
  102034. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  102035. * @param effect defines the effect to activate
  102036. */
  102037. enableEffect(effect: Nullable<Effect>): void;
  102038. /**
  102039. * Set the value of an uniform to a number (int)
  102040. * @param uniform defines the webGL uniform location where to store the value
  102041. * @param value defines the int number to store
  102042. */
  102043. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102044. /**
  102045. * Set the value of an uniform to an array of int32
  102046. * @param uniform defines the webGL uniform location where to store the value
  102047. * @param array defines the array of int32 to store
  102048. */
  102049. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102050. /**
  102051. * Set the value of an uniform to an array of int32 (stored as vec2)
  102052. * @param uniform defines the webGL uniform location where to store the value
  102053. * @param array defines the array of int32 to store
  102054. */
  102055. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102056. /**
  102057. * Set the value of an uniform to an array of int32 (stored as vec3)
  102058. * @param uniform defines the webGL uniform location where to store the value
  102059. * @param array defines the array of int32 to store
  102060. */
  102061. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102062. /**
  102063. * Set the value of an uniform to an array of int32 (stored as vec4)
  102064. * @param uniform defines the webGL uniform location where to store the value
  102065. * @param array defines the array of int32 to store
  102066. */
  102067. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102068. /**
  102069. * Set the value of an uniform to an array of number
  102070. * @param uniform defines the webGL uniform location where to store the value
  102071. * @param array defines the array of number to store
  102072. */
  102073. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102074. /**
  102075. * Set the value of an uniform to an array of number (stored as vec2)
  102076. * @param uniform defines the webGL uniform location where to store the value
  102077. * @param array defines the array of number to store
  102078. */
  102079. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102080. /**
  102081. * Set the value of an uniform to an array of number (stored as vec3)
  102082. * @param uniform defines the webGL uniform location where to store the value
  102083. * @param array defines the array of number to store
  102084. */
  102085. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102086. /**
  102087. * Set the value of an uniform to an array of number (stored as vec4)
  102088. * @param uniform defines the webGL uniform location where to store the value
  102089. * @param array defines the array of number to store
  102090. */
  102091. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102092. /**
  102093. * Set the value of an uniform to an array of float32 (stored as matrices)
  102094. * @param uniform defines the webGL uniform location where to store the value
  102095. * @param matrices defines the array of float32 to store
  102096. */
  102097. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  102098. /**
  102099. * Set the value of an uniform to a matrix (3x3)
  102100. * @param uniform defines the webGL uniform location where to store the value
  102101. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  102102. */
  102103. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102104. /**
  102105. * Set the value of an uniform to a matrix (2x2)
  102106. * @param uniform defines the webGL uniform location where to store the value
  102107. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  102108. */
  102109. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102110. /**
  102111. * Set the value of an uniform to a number (float)
  102112. * @param uniform defines the webGL uniform location where to store the value
  102113. * @param value defines the float number to store
  102114. */
  102115. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102116. /**
  102117. * Set the value of an uniform to a vec2
  102118. * @param uniform defines the webGL uniform location where to store the value
  102119. * @param x defines the 1st component of the value
  102120. * @param y defines the 2nd component of the value
  102121. */
  102122. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  102123. /**
  102124. * Set the value of an uniform to a vec3
  102125. * @param uniform defines the webGL uniform location where to store the value
  102126. * @param x defines the 1st component of the value
  102127. * @param y defines the 2nd component of the value
  102128. * @param z defines the 3rd component of the value
  102129. */
  102130. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  102131. /**
  102132. * Set the value of an uniform to a vec4
  102133. * @param uniform defines the webGL uniform location where to store the value
  102134. * @param x defines the 1st component of the value
  102135. * @param y defines the 2nd component of the value
  102136. * @param z defines the 3rd component of the value
  102137. * @param w defines the 4th component of the value
  102138. */
  102139. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  102140. /**
  102141. * Apply all cached states (depth, culling, stencil and alpha)
  102142. */
  102143. applyStates(): void;
  102144. /**
  102145. * Enable or disable color writing
  102146. * @param enable defines the state to set
  102147. */
  102148. setColorWrite(enable: boolean): void;
  102149. /**
  102150. * Gets a boolean indicating if color writing is enabled
  102151. * @returns the current color writing state
  102152. */
  102153. getColorWrite(): boolean;
  102154. /**
  102155. * Gets the depth culling state manager
  102156. */
  102157. get depthCullingState(): DepthCullingState;
  102158. /**
  102159. * Gets the alpha state manager
  102160. */
  102161. get alphaState(): AlphaState;
  102162. /**
  102163. * Gets the stencil state manager
  102164. */
  102165. get stencilState(): StencilState;
  102166. /**
  102167. * Clears the list of texture accessible through engine.
  102168. * This can help preventing texture load conflict due to name collision.
  102169. */
  102170. clearInternalTexturesCache(): void;
  102171. /**
  102172. * Force the entire cache to be cleared
  102173. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  102174. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  102175. */
  102176. wipeCaches(bruteForce?: boolean): void;
  102177. /** @hidden */
  102178. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  102179. min: number;
  102180. mag: number;
  102181. };
  102182. /** @hidden */
  102183. _createTexture(): WebGLTexture;
  102184. /**
  102185. * Usually called from Texture.ts.
  102186. * Passed information to create a WebGLTexture
  102187. * @param urlArg defines a value which contains one of the following:
  102188. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  102189. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  102190. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  102191. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  102192. * @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)
  102193. * @param scene needed for loading to the correct scene
  102194. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  102195. * @param onLoad optional callback to be called upon successful completion
  102196. * @param onError optional callback to be called upon failure
  102197. * @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
  102198. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  102199. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  102200. * @param forcedExtension defines the extension to use to pick the right loader
  102201. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  102202. * @param mimeType defines an optional mime type
  102203. * @returns a InternalTexture for assignment back into BABYLON.Texture
  102204. */
  102205. 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;
  102206. /**
  102207. * Loads an image as an HTMLImageElement.
  102208. * @param input url string, ArrayBuffer, or Blob to load
  102209. * @param onLoad callback called when the image successfully loads
  102210. * @param onError callback called when the image fails to load
  102211. * @param offlineProvider offline provider for caching
  102212. * @param mimeType optional mime type
  102213. * @returns the HTMLImageElement of the loaded image
  102214. * @hidden
  102215. */
  102216. 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>;
  102217. /**
  102218. * @hidden
  102219. */
  102220. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102221. /**
  102222. * Creates a raw texture
  102223. * @param data defines the data to store in the texture
  102224. * @param width defines the width of the texture
  102225. * @param height defines the height of the texture
  102226. * @param format defines the format of the data
  102227. * @param generateMipMaps defines if the engine should generate the mip levels
  102228. * @param invertY defines if data must be stored with Y axis inverted
  102229. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  102230. * @param compression defines the compression used (null by default)
  102231. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102232. * @returns the raw texture inside an InternalTexture
  102233. */
  102234. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  102235. /**
  102236. * Creates a new raw cube texture
  102237. * @param data defines the array of data to use to create each face
  102238. * @param size defines the size of the textures
  102239. * @param format defines the format of the data
  102240. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102241. * @param generateMipMaps defines if the engine should generate the mip levels
  102242. * @param invertY defines if data must be stored with Y axis inverted
  102243. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102244. * @param compression defines the compression used (null by default)
  102245. * @returns the cube texture as an InternalTexture
  102246. */
  102247. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  102248. /**
  102249. * Creates a new raw 3D texture
  102250. * @param data defines the data used to create the texture
  102251. * @param width defines the width of the texture
  102252. * @param height defines the height of the texture
  102253. * @param depth defines the depth of the texture
  102254. * @param format defines the format of the texture
  102255. * @param generateMipMaps defines if the engine must generate mip levels
  102256. * @param invertY defines if data must be stored with Y axis inverted
  102257. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102258. * @param compression defines the compressed used (can be null)
  102259. * @param textureType defines the compressed used (can be null)
  102260. * @returns a new raw 3D texture (stored in an InternalTexture)
  102261. */
  102262. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102263. /**
  102264. * Creates a new raw 2D array texture
  102265. * @param data defines the data used to create the texture
  102266. * @param width defines the width of the texture
  102267. * @param height defines the height of the texture
  102268. * @param depth defines the number of layers of the texture
  102269. * @param format defines the format of the texture
  102270. * @param generateMipMaps defines if the engine must generate mip levels
  102271. * @param invertY defines if data must be stored with Y axis inverted
  102272. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102273. * @param compression defines the compressed used (can be null)
  102274. * @param textureType defines the compressed used (can be null)
  102275. * @returns a new raw 2D array texture (stored in an InternalTexture)
  102276. */
  102277. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102278. private _unpackFlipYCached;
  102279. /**
  102280. * In case you are sharing the context with other applications, it might
  102281. * be interested to not cache the unpack flip y state to ensure a consistent
  102282. * value would be set.
  102283. */
  102284. enableUnpackFlipYCached: boolean;
  102285. /** @hidden */
  102286. _unpackFlipY(value: boolean): void;
  102287. /** @hidden */
  102288. _getUnpackAlignement(): number;
  102289. private _getTextureTarget;
  102290. /**
  102291. * Update the sampling mode of a given texture
  102292. * @param samplingMode defines the required sampling mode
  102293. * @param texture defines the texture to update
  102294. * @param generateMipMaps defines whether to generate mipmaps for the texture
  102295. */
  102296. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  102297. /**
  102298. * Update the sampling mode of a given texture
  102299. * @param texture defines the texture to update
  102300. * @param wrapU defines the texture wrap mode of the u coordinates
  102301. * @param wrapV defines the texture wrap mode of the v coordinates
  102302. * @param wrapR defines the texture wrap mode of the r coordinates
  102303. */
  102304. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  102305. /** @hidden */
  102306. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  102307. width: number;
  102308. height: number;
  102309. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  102310. /** @hidden */
  102311. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102312. /** @hidden */
  102313. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  102314. /** @hidden */
  102315. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102316. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  102317. private _prepareWebGLTexture;
  102318. /** @hidden */
  102319. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  102320. private _getDepthStencilBuffer;
  102321. /** @hidden */
  102322. _releaseFramebufferObjects(texture: InternalTexture): void;
  102323. /** @hidden */
  102324. _releaseTexture(texture: InternalTexture): void;
  102325. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  102326. protected _setProgram(program: WebGLProgram): void;
  102327. protected _boundUniforms: {
  102328. [key: number]: WebGLUniformLocation;
  102329. };
  102330. /**
  102331. * Binds an effect to the webGL context
  102332. * @param effect defines the effect to bind
  102333. */
  102334. bindSamplers(effect: Effect): void;
  102335. private _activateCurrentTexture;
  102336. /** @hidden */
  102337. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  102338. /** @hidden */
  102339. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  102340. /**
  102341. * Unbind all textures from the webGL context
  102342. */
  102343. unbindAllTextures(): void;
  102344. /**
  102345. * Sets a texture to the according uniform.
  102346. * @param channel The texture channel
  102347. * @param uniform The uniform to set
  102348. * @param texture The texture to apply
  102349. */
  102350. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  102351. private _bindSamplerUniformToChannel;
  102352. private _getTextureWrapMode;
  102353. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  102354. /**
  102355. * Sets an array of texture to the webGL context
  102356. * @param channel defines the channel where the texture array must be set
  102357. * @param uniform defines the associated uniform location
  102358. * @param textures defines the array of textures to bind
  102359. */
  102360. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  102361. /** @hidden */
  102362. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  102363. private _setTextureParameterFloat;
  102364. private _setTextureParameterInteger;
  102365. /**
  102366. * Unbind all vertex attributes from the webGL context
  102367. */
  102368. unbindAllAttributes(): void;
  102369. /**
  102370. * 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
  102371. */
  102372. releaseEffects(): void;
  102373. /**
  102374. * Dispose and release all associated resources
  102375. */
  102376. dispose(): void;
  102377. /**
  102378. * Attach a new callback raised when context lost event is fired
  102379. * @param callback defines the callback to call
  102380. */
  102381. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102382. /**
  102383. * Attach a new callback raised when context restored event is fired
  102384. * @param callback defines the callback to call
  102385. */
  102386. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102387. /**
  102388. * Get the current error code of the webGL context
  102389. * @returns the error code
  102390. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  102391. */
  102392. getError(): number;
  102393. private _canRenderToFloatFramebuffer;
  102394. private _canRenderToHalfFloatFramebuffer;
  102395. private _canRenderToFramebuffer;
  102396. /** @hidden */
  102397. _getWebGLTextureType(type: number): number;
  102398. /** @hidden */
  102399. _getInternalFormat(format: number): number;
  102400. /** @hidden */
  102401. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  102402. /** @hidden */
  102403. _getRGBAMultiSampleBufferFormat(type: number): number;
  102404. /** @hidden */
  102405. _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;
  102406. /**
  102407. * Loads a file from a url
  102408. * @param url url to load
  102409. * @param onSuccess callback called when the file successfully loads
  102410. * @param onProgress callback called while file is loading (if the server supports this mode)
  102411. * @param offlineProvider defines the offline provider for caching
  102412. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102413. * @param onError callback called when the file fails to load
  102414. * @returns a file request object
  102415. * @hidden
  102416. */
  102417. 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;
  102418. /**
  102419. * Reads pixels from the current frame buffer. Please note that this function can be slow
  102420. * @param x defines the x coordinate of the rectangle where pixels must be read
  102421. * @param y defines the y coordinate of the rectangle where pixels must be read
  102422. * @param width defines the width of the rectangle where pixels must be read
  102423. * @param height defines the height of the rectangle where pixels must be read
  102424. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  102425. * @returns a Uint8Array containing RGBA colors
  102426. */
  102427. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  102428. private static _isSupported;
  102429. /**
  102430. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  102431. * @returns true if the engine can be created
  102432. * @ignorenaming
  102433. */
  102434. static isSupported(): boolean;
  102435. /**
  102436. * Find the next highest power of two.
  102437. * @param x Number to start search from.
  102438. * @return Next highest power of two.
  102439. */
  102440. static CeilingPOT(x: number): number;
  102441. /**
  102442. * Find the next lowest power of two.
  102443. * @param x Number to start search from.
  102444. * @return Next lowest power of two.
  102445. */
  102446. static FloorPOT(x: number): number;
  102447. /**
  102448. * Find the nearest power of two.
  102449. * @param x Number to start search from.
  102450. * @return Next nearest power of two.
  102451. */
  102452. static NearestPOT(x: number): number;
  102453. /**
  102454. * Get the closest exponent of two
  102455. * @param value defines the value to approximate
  102456. * @param max defines the maximum value to return
  102457. * @param mode defines how to define the closest value
  102458. * @returns closest exponent of two of the given value
  102459. */
  102460. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  102461. /**
  102462. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  102463. * @param func - the function to be called
  102464. * @param requester - the object that will request the next frame. Falls back to window.
  102465. * @returns frame number
  102466. */
  102467. static QueueNewFrame(func: () => void, requester?: any): number;
  102468. /**
  102469. * Gets host document
  102470. * @returns the host document object
  102471. */
  102472. getHostDocument(): Nullable<Document>;
  102473. }
  102474. }
  102475. declare module BABYLON {
  102476. /**
  102477. * Class representing spherical harmonics coefficients to the 3rd degree
  102478. */
  102479. export class SphericalHarmonics {
  102480. /**
  102481. * Defines whether or not the harmonics have been prescaled for rendering.
  102482. */
  102483. preScaled: boolean;
  102484. /**
  102485. * The l0,0 coefficients of the spherical harmonics
  102486. */
  102487. l00: Vector3;
  102488. /**
  102489. * The l1,-1 coefficients of the spherical harmonics
  102490. */
  102491. l1_1: Vector3;
  102492. /**
  102493. * The l1,0 coefficients of the spherical harmonics
  102494. */
  102495. l10: Vector3;
  102496. /**
  102497. * The l1,1 coefficients of the spherical harmonics
  102498. */
  102499. l11: Vector3;
  102500. /**
  102501. * The l2,-2 coefficients of the spherical harmonics
  102502. */
  102503. l2_2: Vector3;
  102504. /**
  102505. * The l2,-1 coefficients of the spherical harmonics
  102506. */
  102507. l2_1: Vector3;
  102508. /**
  102509. * The l2,0 coefficients of the spherical harmonics
  102510. */
  102511. l20: Vector3;
  102512. /**
  102513. * The l2,1 coefficients of the spherical harmonics
  102514. */
  102515. l21: Vector3;
  102516. /**
  102517. * The l2,2 coefficients of the spherical harmonics
  102518. */
  102519. l22: Vector3;
  102520. /**
  102521. * Adds a light to the spherical harmonics
  102522. * @param direction the direction of the light
  102523. * @param color the color of the light
  102524. * @param deltaSolidAngle the delta solid angle of the light
  102525. */
  102526. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  102527. /**
  102528. * Scales the spherical harmonics by the given amount
  102529. * @param scale the amount to scale
  102530. */
  102531. scaleInPlace(scale: number): void;
  102532. /**
  102533. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  102534. *
  102535. * ```
  102536. * E_lm = A_l * L_lm
  102537. * ```
  102538. *
  102539. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  102540. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  102541. * the scaling factors are given in equation 9.
  102542. */
  102543. convertIncidentRadianceToIrradiance(): void;
  102544. /**
  102545. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  102546. *
  102547. * ```
  102548. * L = (1/pi) * E * rho
  102549. * ```
  102550. *
  102551. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  102552. */
  102553. convertIrradianceToLambertianRadiance(): void;
  102554. /**
  102555. * Integrates the reconstruction coefficients directly in to the SH preventing further
  102556. * required operations at run time.
  102557. *
  102558. * This is simply done by scaling back the SH with Ylm constants parameter.
  102559. * The trigonometric part being applied by the shader at run time.
  102560. */
  102561. preScaleForRendering(): void;
  102562. /**
  102563. * Constructs a spherical harmonics from an array.
  102564. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  102565. * @returns the spherical harmonics
  102566. */
  102567. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  102568. /**
  102569. * Gets the spherical harmonics from polynomial
  102570. * @param polynomial the spherical polynomial
  102571. * @returns the spherical harmonics
  102572. */
  102573. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  102574. }
  102575. /**
  102576. * Class representing spherical polynomial coefficients to the 3rd degree
  102577. */
  102578. export class SphericalPolynomial {
  102579. private _harmonics;
  102580. /**
  102581. * The spherical harmonics used to create the polynomials.
  102582. */
  102583. get preScaledHarmonics(): SphericalHarmonics;
  102584. /**
  102585. * The x coefficients of the spherical polynomial
  102586. */
  102587. x: Vector3;
  102588. /**
  102589. * The y coefficients of the spherical polynomial
  102590. */
  102591. y: Vector3;
  102592. /**
  102593. * The z coefficients of the spherical polynomial
  102594. */
  102595. z: Vector3;
  102596. /**
  102597. * The xx coefficients of the spherical polynomial
  102598. */
  102599. xx: Vector3;
  102600. /**
  102601. * The yy coefficients of the spherical polynomial
  102602. */
  102603. yy: Vector3;
  102604. /**
  102605. * The zz coefficients of the spherical polynomial
  102606. */
  102607. zz: Vector3;
  102608. /**
  102609. * The xy coefficients of the spherical polynomial
  102610. */
  102611. xy: Vector3;
  102612. /**
  102613. * The yz coefficients of the spherical polynomial
  102614. */
  102615. yz: Vector3;
  102616. /**
  102617. * The zx coefficients of the spherical polynomial
  102618. */
  102619. zx: Vector3;
  102620. /**
  102621. * Adds an ambient color to the spherical polynomial
  102622. * @param color the color to add
  102623. */
  102624. addAmbient(color: Color3): void;
  102625. /**
  102626. * Scales the spherical polynomial by the given amount
  102627. * @param scale the amount to scale
  102628. */
  102629. scaleInPlace(scale: number): void;
  102630. /**
  102631. * Gets the spherical polynomial from harmonics
  102632. * @param harmonics the spherical harmonics
  102633. * @returns the spherical polynomial
  102634. */
  102635. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  102636. /**
  102637. * Constructs a spherical polynomial from an array.
  102638. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  102639. * @returns the spherical polynomial
  102640. */
  102641. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  102642. }
  102643. }
  102644. declare module BABYLON {
  102645. /**
  102646. * Defines the source of the internal texture
  102647. */
  102648. export enum InternalTextureSource {
  102649. /**
  102650. * The source of the texture data is unknown
  102651. */
  102652. Unknown = 0,
  102653. /**
  102654. * Texture data comes from an URL
  102655. */
  102656. Url = 1,
  102657. /**
  102658. * Texture data is only used for temporary storage
  102659. */
  102660. Temp = 2,
  102661. /**
  102662. * Texture data comes from raw data (ArrayBuffer)
  102663. */
  102664. Raw = 3,
  102665. /**
  102666. * Texture content is dynamic (video or dynamic texture)
  102667. */
  102668. Dynamic = 4,
  102669. /**
  102670. * Texture content is generated by rendering to it
  102671. */
  102672. RenderTarget = 5,
  102673. /**
  102674. * Texture content is part of a multi render target process
  102675. */
  102676. MultiRenderTarget = 6,
  102677. /**
  102678. * Texture data comes from a cube data file
  102679. */
  102680. Cube = 7,
  102681. /**
  102682. * Texture data comes from a raw cube data
  102683. */
  102684. CubeRaw = 8,
  102685. /**
  102686. * Texture data come from a prefiltered cube data file
  102687. */
  102688. CubePrefiltered = 9,
  102689. /**
  102690. * Texture content is raw 3D data
  102691. */
  102692. Raw3D = 10,
  102693. /**
  102694. * Texture content is raw 2D array data
  102695. */
  102696. Raw2DArray = 11,
  102697. /**
  102698. * Texture content is a depth texture
  102699. */
  102700. Depth = 12,
  102701. /**
  102702. * Texture data comes from a raw cube data encoded with RGBD
  102703. */
  102704. CubeRawRGBD = 13
  102705. }
  102706. /**
  102707. * Class used to store data associated with WebGL texture data for the engine
  102708. * This class should not be used directly
  102709. */
  102710. export class InternalTexture {
  102711. /** @hidden */
  102712. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  102713. /**
  102714. * Defines if the texture is ready
  102715. */
  102716. isReady: boolean;
  102717. /**
  102718. * Defines if the texture is a cube texture
  102719. */
  102720. isCube: boolean;
  102721. /**
  102722. * Defines if the texture contains 3D data
  102723. */
  102724. is3D: boolean;
  102725. /**
  102726. * Defines if the texture contains 2D array data
  102727. */
  102728. is2DArray: boolean;
  102729. /**
  102730. * Defines if the texture contains multiview data
  102731. */
  102732. isMultiview: boolean;
  102733. /**
  102734. * Gets the URL used to load this texture
  102735. */
  102736. url: string;
  102737. /**
  102738. * Gets the sampling mode of the texture
  102739. */
  102740. samplingMode: number;
  102741. /**
  102742. * Gets a boolean indicating if the texture needs mipmaps generation
  102743. */
  102744. generateMipMaps: boolean;
  102745. /**
  102746. * Gets the number of samples used by the texture (WebGL2+ only)
  102747. */
  102748. samples: number;
  102749. /**
  102750. * Gets the type of the texture (int, float...)
  102751. */
  102752. type: number;
  102753. /**
  102754. * Gets the format of the texture (RGB, RGBA...)
  102755. */
  102756. format: number;
  102757. /**
  102758. * Observable called when the texture is loaded
  102759. */
  102760. onLoadedObservable: Observable<InternalTexture>;
  102761. /**
  102762. * Gets the width of the texture
  102763. */
  102764. width: number;
  102765. /**
  102766. * Gets the height of the texture
  102767. */
  102768. height: number;
  102769. /**
  102770. * Gets the depth of the texture
  102771. */
  102772. depth: number;
  102773. /**
  102774. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  102775. */
  102776. baseWidth: number;
  102777. /**
  102778. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  102779. */
  102780. baseHeight: number;
  102781. /**
  102782. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  102783. */
  102784. baseDepth: number;
  102785. /**
  102786. * Gets a boolean indicating if the texture is inverted on Y axis
  102787. */
  102788. invertY: boolean;
  102789. /** @hidden */
  102790. _invertVScale: boolean;
  102791. /** @hidden */
  102792. _associatedChannel: number;
  102793. /** @hidden */
  102794. _source: InternalTextureSource;
  102795. /** @hidden */
  102796. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102797. /** @hidden */
  102798. _bufferView: Nullable<ArrayBufferView>;
  102799. /** @hidden */
  102800. _bufferViewArray: Nullable<ArrayBufferView[]>;
  102801. /** @hidden */
  102802. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  102803. /** @hidden */
  102804. _size: number;
  102805. /** @hidden */
  102806. _extension: string;
  102807. /** @hidden */
  102808. _files: Nullable<string[]>;
  102809. /** @hidden */
  102810. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  102811. /** @hidden */
  102812. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  102813. /** @hidden */
  102814. _framebuffer: Nullable<WebGLFramebuffer>;
  102815. /** @hidden */
  102816. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  102817. /** @hidden */
  102818. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  102819. /** @hidden */
  102820. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  102821. /** @hidden */
  102822. _attachments: Nullable<number[]>;
  102823. /** @hidden */
  102824. _cachedCoordinatesMode: Nullable<number>;
  102825. /** @hidden */
  102826. _cachedWrapU: Nullable<number>;
  102827. /** @hidden */
  102828. _cachedWrapV: Nullable<number>;
  102829. /** @hidden */
  102830. _cachedWrapR: Nullable<number>;
  102831. /** @hidden */
  102832. _cachedAnisotropicFilteringLevel: Nullable<number>;
  102833. /** @hidden */
  102834. _isDisabled: boolean;
  102835. /** @hidden */
  102836. _compression: Nullable<string>;
  102837. /** @hidden */
  102838. _generateStencilBuffer: boolean;
  102839. /** @hidden */
  102840. _generateDepthBuffer: boolean;
  102841. /** @hidden */
  102842. _comparisonFunction: number;
  102843. /** @hidden */
  102844. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  102845. /** @hidden */
  102846. _lodGenerationScale: number;
  102847. /** @hidden */
  102848. _lodGenerationOffset: number;
  102849. /** @hidden */
  102850. _colorTextureArray: Nullable<WebGLTexture>;
  102851. /** @hidden */
  102852. _depthStencilTextureArray: Nullable<WebGLTexture>;
  102853. /** @hidden */
  102854. _lodTextureHigh: Nullable<BaseTexture>;
  102855. /** @hidden */
  102856. _lodTextureMid: Nullable<BaseTexture>;
  102857. /** @hidden */
  102858. _lodTextureLow: Nullable<BaseTexture>;
  102859. /** @hidden */
  102860. _isRGBD: boolean;
  102861. /** @hidden */
  102862. _linearSpecularLOD: boolean;
  102863. /** @hidden */
  102864. _irradianceTexture: Nullable<BaseTexture>;
  102865. /** @hidden */
  102866. _webGLTexture: Nullable<WebGLTexture>;
  102867. /** @hidden */
  102868. _references: number;
  102869. private _engine;
  102870. /**
  102871. * Gets the Engine the texture belongs to.
  102872. * @returns The babylon engine
  102873. */
  102874. getEngine(): ThinEngine;
  102875. /**
  102876. * Gets the data source type of the texture
  102877. */
  102878. get source(): InternalTextureSource;
  102879. /**
  102880. * Creates a new InternalTexture
  102881. * @param engine defines the engine to use
  102882. * @param source defines the type of data that will be used
  102883. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102884. */
  102885. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  102886. /**
  102887. * Increments the number of references (ie. the number of Texture that point to it)
  102888. */
  102889. incrementReferences(): void;
  102890. /**
  102891. * Change the size of the texture (not the size of the content)
  102892. * @param width defines the new width
  102893. * @param height defines the new height
  102894. * @param depth defines the new depth (1 by default)
  102895. */
  102896. updateSize(width: int, height: int, depth?: int): void;
  102897. /** @hidden */
  102898. _rebuild(): void;
  102899. /** @hidden */
  102900. _swapAndDie(target: InternalTexture): void;
  102901. /**
  102902. * Dispose the current allocated resources
  102903. */
  102904. dispose(): void;
  102905. }
  102906. }
  102907. declare module BABYLON {
  102908. /**
  102909. * Class used to work with sound analyzer using fast fourier transform (FFT)
  102910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102911. */
  102912. export class Analyser {
  102913. /**
  102914. * Gets or sets the smoothing
  102915. * @ignorenaming
  102916. */
  102917. SMOOTHING: number;
  102918. /**
  102919. * Gets or sets the FFT table size
  102920. * @ignorenaming
  102921. */
  102922. FFT_SIZE: number;
  102923. /**
  102924. * Gets or sets the bar graph amplitude
  102925. * @ignorenaming
  102926. */
  102927. BARGRAPHAMPLITUDE: number;
  102928. /**
  102929. * Gets or sets the position of the debug canvas
  102930. * @ignorenaming
  102931. */
  102932. DEBUGCANVASPOS: {
  102933. x: number;
  102934. y: number;
  102935. };
  102936. /**
  102937. * Gets or sets the debug canvas size
  102938. * @ignorenaming
  102939. */
  102940. DEBUGCANVASSIZE: {
  102941. width: number;
  102942. height: number;
  102943. };
  102944. private _byteFreqs;
  102945. private _byteTime;
  102946. private _floatFreqs;
  102947. private _webAudioAnalyser;
  102948. private _debugCanvas;
  102949. private _debugCanvasContext;
  102950. private _scene;
  102951. private _registerFunc;
  102952. private _audioEngine;
  102953. /**
  102954. * Creates a new analyser
  102955. * @param scene defines hosting scene
  102956. */
  102957. constructor(scene: Scene);
  102958. /**
  102959. * Get the number of data values you will have to play with for the visualization
  102960. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  102961. * @returns a number
  102962. */
  102963. getFrequencyBinCount(): number;
  102964. /**
  102965. * Gets the current frequency data as a byte array
  102966. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102967. * @returns a Uint8Array
  102968. */
  102969. getByteFrequencyData(): Uint8Array;
  102970. /**
  102971. * Gets the current waveform as a byte array
  102972. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  102973. * @returns a Uint8Array
  102974. */
  102975. getByteTimeDomainData(): Uint8Array;
  102976. /**
  102977. * Gets the current frequency data as a float array
  102978. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102979. * @returns a Float32Array
  102980. */
  102981. getFloatFrequencyData(): Float32Array;
  102982. /**
  102983. * Renders the debug canvas
  102984. */
  102985. drawDebugCanvas(): void;
  102986. /**
  102987. * Stops rendering the debug canvas and removes it
  102988. */
  102989. stopDebugCanvas(): void;
  102990. /**
  102991. * Connects two audio nodes
  102992. * @param inputAudioNode defines first node to connect
  102993. * @param outputAudioNode defines second node to connect
  102994. */
  102995. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  102996. /**
  102997. * Releases all associated resources
  102998. */
  102999. dispose(): void;
  103000. }
  103001. }
  103002. declare module BABYLON {
  103003. /**
  103004. * This represents an audio engine and it is responsible
  103005. * to play, synchronize and analyse sounds throughout the application.
  103006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103007. */
  103008. export interface IAudioEngine extends IDisposable {
  103009. /**
  103010. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  103011. */
  103012. readonly canUseWebAudio: boolean;
  103013. /**
  103014. * Gets the current AudioContext if available.
  103015. */
  103016. readonly audioContext: Nullable<AudioContext>;
  103017. /**
  103018. * The master gain node defines the global audio volume of your audio engine.
  103019. */
  103020. readonly masterGain: GainNode;
  103021. /**
  103022. * Gets whether or not mp3 are supported by your browser.
  103023. */
  103024. readonly isMP3supported: boolean;
  103025. /**
  103026. * Gets whether or not ogg are supported by your browser.
  103027. */
  103028. readonly isOGGsupported: boolean;
  103029. /**
  103030. * Defines if Babylon should emit a warning if WebAudio is not supported.
  103031. * @ignoreNaming
  103032. */
  103033. WarnedWebAudioUnsupported: boolean;
  103034. /**
  103035. * Defines if the audio engine relies on a custom unlocked button.
  103036. * In this case, the embedded button will not be displayed.
  103037. */
  103038. useCustomUnlockedButton: boolean;
  103039. /**
  103040. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  103041. */
  103042. readonly unlocked: boolean;
  103043. /**
  103044. * Event raised when audio has been unlocked on the browser.
  103045. */
  103046. onAudioUnlockedObservable: Observable<AudioEngine>;
  103047. /**
  103048. * Event raised when audio has been locked on the browser.
  103049. */
  103050. onAudioLockedObservable: Observable<AudioEngine>;
  103051. /**
  103052. * Flags the audio engine in Locked state.
  103053. * This happens due to new browser policies preventing audio to autoplay.
  103054. */
  103055. lock(): void;
  103056. /**
  103057. * Unlocks the audio engine once a user action has been done on the dom.
  103058. * This is helpful to resume play once browser policies have been satisfied.
  103059. */
  103060. unlock(): void;
  103061. }
  103062. /**
  103063. * This represents the default audio engine used in babylon.
  103064. * It is responsible to play, synchronize and analyse sounds throughout the application.
  103065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103066. */
  103067. export class AudioEngine implements IAudioEngine {
  103068. private _audioContext;
  103069. private _audioContextInitialized;
  103070. private _muteButton;
  103071. private _hostElement;
  103072. /**
  103073. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  103074. */
  103075. canUseWebAudio: boolean;
  103076. /**
  103077. * The master gain node defines the global audio volume of your audio engine.
  103078. */
  103079. masterGain: GainNode;
  103080. /**
  103081. * Defines if Babylon should emit a warning if WebAudio is not supported.
  103082. * @ignoreNaming
  103083. */
  103084. WarnedWebAudioUnsupported: boolean;
  103085. /**
  103086. * Gets whether or not mp3 are supported by your browser.
  103087. */
  103088. isMP3supported: boolean;
  103089. /**
  103090. * Gets whether or not ogg are supported by your browser.
  103091. */
  103092. isOGGsupported: boolean;
  103093. /**
  103094. * Gets whether audio has been unlocked on the device.
  103095. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  103096. * a user interaction has happened.
  103097. */
  103098. unlocked: boolean;
  103099. /**
  103100. * Defines if the audio engine relies on a custom unlocked button.
  103101. * In this case, the embedded button will not be displayed.
  103102. */
  103103. useCustomUnlockedButton: boolean;
  103104. /**
  103105. * Event raised when audio has been unlocked on the browser.
  103106. */
  103107. onAudioUnlockedObservable: Observable<AudioEngine>;
  103108. /**
  103109. * Event raised when audio has been locked on the browser.
  103110. */
  103111. onAudioLockedObservable: Observable<AudioEngine>;
  103112. /**
  103113. * Gets the current AudioContext if available.
  103114. */
  103115. get audioContext(): Nullable<AudioContext>;
  103116. private _connectedAnalyser;
  103117. /**
  103118. * Instantiates a new audio engine.
  103119. *
  103120. * There should be only one per page as some browsers restrict the number
  103121. * of audio contexts you can create.
  103122. * @param hostElement defines the host element where to display the mute icon if necessary
  103123. */
  103124. constructor(hostElement?: Nullable<HTMLElement>);
  103125. /**
  103126. * Flags the audio engine in Locked state.
  103127. * This happens due to new browser policies preventing audio to autoplay.
  103128. */
  103129. lock(): void;
  103130. /**
  103131. * Unlocks the audio engine once a user action has been done on the dom.
  103132. * This is helpful to resume play once browser policies have been satisfied.
  103133. */
  103134. unlock(): void;
  103135. private _resumeAudioContext;
  103136. private _initializeAudioContext;
  103137. private _tryToRun;
  103138. private _triggerRunningState;
  103139. private _triggerSuspendedState;
  103140. private _displayMuteButton;
  103141. private _moveButtonToTopLeft;
  103142. private _onResize;
  103143. private _hideMuteButton;
  103144. /**
  103145. * Destroy and release the resources associated with the audio ccontext.
  103146. */
  103147. dispose(): void;
  103148. /**
  103149. * Gets the global volume sets on the master gain.
  103150. * @returns the global volume if set or -1 otherwise
  103151. */
  103152. getGlobalVolume(): number;
  103153. /**
  103154. * Sets the global volume of your experience (sets on the master gain).
  103155. * @param newVolume Defines the new global volume of the application
  103156. */
  103157. setGlobalVolume(newVolume: number): void;
  103158. /**
  103159. * Connect the audio engine to an audio analyser allowing some amazing
  103160. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103162. * @param analyser The analyser to connect to the engine
  103163. */
  103164. connectToAnalyser(analyser: Analyser): void;
  103165. }
  103166. }
  103167. declare module BABYLON {
  103168. /**
  103169. * Interface used to present a loading screen while loading a scene
  103170. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103171. */
  103172. export interface ILoadingScreen {
  103173. /**
  103174. * Function called to display the loading screen
  103175. */
  103176. displayLoadingUI: () => void;
  103177. /**
  103178. * Function called to hide the loading screen
  103179. */
  103180. hideLoadingUI: () => void;
  103181. /**
  103182. * Gets or sets the color to use for the background
  103183. */
  103184. loadingUIBackgroundColor: string;
  103185. /**
  103186. * Gets or sets the text to display while loading
  103187. */
  103188. loadingUIText: string;
  103189. }
  103190. /**
  103191. * Class used for the default loading screen
  103192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103193. */
  103194. export class DefaultLoadingScreen implements ILoadingScreen {
  103195. private _renderingCanvas;
  103196. private _loadingText;
  103197. private _loadingDivBackgroundColor;
  103198. private _loadingDiv;
  103199. private _loadingTextDiv;
  103200. /** Gets or sets the logo url to use for the default loading screen */
  103201. static DefaultLogoUrl: string;
  103202. /** Gets or sets the spinner url to use for the default loading screen */
  103203. static DefaultSpinnerUrl: string;
  103204. /**
  103205. * Creates a new default loading screen
  103206. * @param _renderingCanvas defines the canvas used to render the scene
  103207. * @param _loadingText defines the default text to display
  103208. * @param _loadingDivBackgroundColor defines the default background color
  103209. */
  103210. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  103211. /**
  103212. * Function called to display the loading screen
  103213. */
  103214. displayLoadingUI(): void;
  103215. /**
  103216. * Function called to hide the loading screen
  103217. */
  103218. hideLoadingUI(): void;
  103219. /**
  103220. * Gets or sets the text to display while loading
  103221. */
  103222. set loadingUIText(text: string);
  103223. get loadingUIText(): string;
  103224. /**
  103225. * Gets or sets the color to use for the background
  103226. */
  103227. get loadingUIBackgroundColor(): string;
  103228. set loadingUIBackgroundColor(color: string);
  103229. private _resizeLoadingUI;
  103230. }
  103231. }
  103232. declare module BABYLON {
  103233. /**
  103234. * Interface for any object that can request an animation frame
  103235. */
  103236. export interface ICustomAnimationFrameRequester {
  103237. /**
  103238. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  103239. */
  103240. renderFunction?: Function;
  103241. /**
  103242. * Called to request the next frame to render to
  103243. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  103244. */
  103245. requestAnimationFrame: Function;
  103246. /**
  103247. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  103248. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  103249. */
  103250. requestID?: number;
  103251. }
  103252. }
  103253. declare module BABYLON {
  103254. /**
  103255. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  103256. */
  103257. export class PerformanceMonitor {
  103258. private _enabled;
  103259. private _rollingFrameTime;
  103260. private _lastFrameTimeMs;
  103261. /**
  103262. * constructor
  103263. * @param frameSampleSize The number of samples required to saturate the sliding window
  103264. */
  103265. constructor(frameSampleSize?: number);
  103266. /**
  103267. * Samples current frame
  103268. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  103269. */
  103270. sampleFrame(timeMs?: number): void;
  103271. /**
  103272. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103273. */
  103274. get averageFrameTime(): number;
  103275. /**
  103276. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103277. */
  103278. get averageFrameTimeVariance(): number;
  103279. /**
  103280. * Returns the frame time of the most recent frame
  103281. */
  103282. get instantaneousFrameTime(): number;
  103283. /**
  103284. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  103285. */
  103286. get averageFPS(): number;
  103287. /**
  103288. * Returns the average framerate in frames per second using the most recent frame time
  103289. */
  103290. get instantaneousFPS(): number;
  103291. /**
  103292. * Returns true if enough samples have been taken to completely fill the sliding window
  103293. */
  103294. get isSaturated(): boolean;
  103295. /**
  103296. * Enables contributions to the sliding window sample set
  103297. */
  103298. enable(): void;
  103299. /**
  103300. * Disables contributions to the sliding window sample set
  103301. * Samples will not be interpolated over the disabled period
  103302. */
  103303. disable(): void;
  103304. /**
  103305. * Returns true if sampling is enabled
  103306. */
  103307. get isEnabled(): boolean;
  103308. /**
  103309. * Resets performance monitor
  103310. */
  103311. reset(): void;
  103312. }
  103313. /**
  103314. * RollingAverage
  103315. *
  103316. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  103317. */
  103318. export class RollingAverage {
  103319. /**
  103320. * Current average
  103321. */
  103322. average: number;
  103323. /**
  103324. * Current variance
  103325. */
  103326. variance: number;
  103327. protected _samples: Array<number>;
  103328. protected _sampleCount: number;
  103329. protected _pos: number;
  103330. protected _m2: number;
  103331. /**
  103332. * constructor
  103333. * @param length The number of samples required to saturate the sliding window
  103334. */
  103335. constructor(length: number);
  103336. /**
  103337. * Adds a sample to the sample set
  103338. * @param v The sample value
  103339. */
  103340. add(v: number): void;
  103341. /**
  103342. * Returns previously added values or null if outside of history or outside the sliding window domain
  103343. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  103344. * @return Value previously recorded with add() or null if outside of range
  103345. */
  103346. history(i: number): number;
  103347. /**
  103348. * Returns true if enough samples have been taken to completely fill the sliding window
  103349. * @return true if sample-set saturated
  103350. */
  103351. isSaturated(): boolean;
  103352. /**
  103353. * Resets the rolling average (equivalent to 0 samples taken so far)
  103354. */
  103355. reset(): void;
  103356. /**
  103357. * Wraps a value around the sample range boundaries
  103358. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  103359. * @return Wrapped position in sample range
  103360. */
  103361. protected _wrapPosition(i: number): number;
  103362. }
  103363. }
  103364. declare module BABYLON {
  103365. /**
  103366. * This class is used to track a performance counter which is number based.
  103367. * The user has access to many properties which give statistics of different nature.
  103368. *
  103369. * The implementer can track two kinds of Performance Counter: time and count.
  103370. * 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.
  103371. * 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.
  103372. */
  103373. export class PerfCounter {
  103374. /**
  103375. * Gets or sets a global boolean to turn on and off all the counters
  103376. */
  103377. static Enabled: boolean;
  103378. /**
  103379. * Returns the smallest value ever
  103380. */
  103381. get min(): number;
  103382. /**
  103383. * Returns the biggest value ever
  103384. */
  103385. get max(): number;
  103386. /**
  103387. * Returns the average value since the performance counter is running
  103388. */
  103389. get average(): number;
  103390. /**
  103391. * Returns the average value of the last second the counter was monitored
  103392. */
  103393. get lastSecAverage(): number;
  103394. /**
  103395. * Returns the current value
  103396. */
  103397. get current(): number;
  103398. /**
  103399. * Gets the accumulated total
  103400. */
  103401. get total(): number;
  103402. /**
  103403. * Gets the total value count
  103404. */
  103405. get count(): number;
  103406. /**
  103407. * Creates a new counter
  103408. */
  103409. constructor();
  103410. /**
  103411. * Call this method to start monitoring a new frame.
  103412. * 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.
  103413. */
  103414. fetchNewFrame(): void;
  103415. /**
  103416. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  103417. * @param newCount the count value to add to the monitored count
  103418. * @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.
  103419. */
  103420. addCount(newCount: number, fetchResult: boolean): void;
  103421. /**
  103422. * Start monitoring this performance counter
  103423. */
  103424. beginMonitoring(): void;
  103425. /**
  103426. * Compute the time lapsed since the previous beginMonitoring() call.
  103427. * @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
  103428. */
  103429. endMonitoring(newFrame?: boolean): void;
  103430. private _fetchResult;
  103431. private _startMonitoringTime;
  103432. private _min;
  103433. private _max;
  103434. private _average;
  103435. private _current;
  103436. private _totalValueCount;
  103437. private _totalAccumulated;
  103438. private _lastSecAverage;
  103439. private _lastSecAccumulated;
  103440. private _lastSecTime;
  103441. private _lastSecValueCount;
  103442. }
  103443. }
  103444. declare module BABYLON {
  103445. interface ThinEngine {
  103446. /**
  103447. * Sets alpha constants used by some alpha blending modes
  103448. * @param r defines the red component
  103449. * @param g defines the green component
  103450. * @param b defines the blue component
  103451. * @param a defines the alpha component
  103452. */
  103453. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  103454. /**
  103455. * Sets the current alpha mode
  103456. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  103457. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  103458. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103459. */
  103460. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  103461. /**
  103462. * Gets the current alpha mode
  103463. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103464. * @returns the current alpha mode
  103465. */
  103466. getAlphaMode(): number;
  103467. /**
  103468. * Sets the current alpha equation
  103469. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  103470. */
  103471. setAlphaEquation(equation: number): void;
  103472. /**
  103473. * Gets the current alpha equation.
  103474. * @returns the current alpha equation
  103475. */
  103476. getAlphaEquation(): number;
  103477. }
  103478. }
  103479. declare module BABYLON {
  103480. /**
  103481. * Defines the interface used by display changed events
  103482. */
  103483. export interface IDisplayChangedEventArgs {
  103484. /** Gets the vrDisplay object (if any) */
  103485. vrDisplay: Nullable<any>;
  103486. /** Gets a boolean indicating if webVR is supported */
  103487. vrSupported: boolean;
  103488. }
  103489. /**
  103490. * Defines the interface used by objects containing a viewport (like a camera)
  103491. */
  103492. interface IViewportOwnerLike {
  103493. /**
  103494. * Gets or sets the viewport
  103495. */
  103496. viewport: IViewportLike;
  103497. }
  103498. /**
  103499. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  103500. */
  103501. export class Engine extends ThinEngine {
  103502. /** Defines that alpha blending is disabled */
  103503. static readonly ALPHA_DISABLE: number;
  103504. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  103505. static readonly ALPHA_ADD: number;
  103506. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  103507. static readonly ALPHA_COMBINE: number;
  103508. /** Defines that alpha blending to DEST - SRC * DEST */
  103509. static readonly ALPHA_SUBTRACT: number;
  103510. /** Defines that alpha blending to SRC * DEST */
  103511. static readonly ALPHA_MULTIPLY: number;
  103512. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  103513. static readonly ALPHA_MAXIMIZED: number;
  103514. /** Defines that alpha blending to SRC + DEST */
  103515. static readonly ALPHA_ONEONE: number;
  103516. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  103517. static readonly ALPHA_PREMULTIPLIED: number;
  103518. /**
  103519. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  103520. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  103521. */
  103522. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  103523. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  103524. static readonly ALPHA_INTERPOLATE: number;
  103525. /**
  103526. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  103527. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  103528. */
  103529. static readonly ALPHA_SCREENMODE: number;
  103530. /** Defines that the ressource is not delayed*/
  103531. static readonly DELAYLOADSTATE_NONE: number;
  103532. /** Defines that the ressource was successfully delay loaded */
  103533. static readonly DELAYLOADSTATE_LOADED: number;
  103534. /** Defines that the ressource is currently delay loading */
  103535. static readonly DELAYLOADSTATE_LOADING: number;
  103536. /** Defines that the ressource is delayed and has not started loading */
  103537. static readonly DELAYLOADSTATE_NOTLOADED: number;
  103538. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  103539. static readonly NEVER: number;
  103540. /** 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 */
  103541. static readonly ALWAYS: number;
  103542. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  103543. static readonly LESS: number;
  103544. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  103545. static readonly EQUAL: number;
  103546. /** 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 */
  103547. static readonly LEQUAL: number;
  103548. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  103549. static readonly GREATER: number;
  103550. /** 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 */
  103551. static readonly GEQUAL: number;
  103552. /** 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 */
  103553. static readonly NOTEQUAL: number;
  103554. /** Passed to stencilOperation to specify that stencil value must be kept */
  103555. static readonly KEEP: number;
  103556. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103557. static readonly REPLACE: number;
  103558. /** Passed to stencilOperation to specify that stencil value must be incremented */
  103559. static readonly INCR: number;
  103560. /** Passed to stencilOperation to specify that stencil value must be decremented */
  103561. static readonly DECR: number;
  103562. /** Passed to stencilOperation to specify that stencil value must be inverted */
  103563. static readonly INVERT: number;
  103564. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  103565. static readonly INCR_WRAP: number;
  103566. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  103567. static readonly DECR_WRAP: number;
  103568. /** Texture is not repeating outside of 0..1 UVs */
  103569. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  103570. /** Texture is repeating outside of 0..1 UVs */
  103571. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  103572. /** Texture is repeating and mirrored */
  103573. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  103574. /** ALPHA */
  103575. static readonly TEXTUREFORMAT_ALPHA: number;
  103576. /** LUMINANCE */
  103577. static readonly TEXTUREFORMAT_LUMINANCE: number;
  103578. /** LUMINANCE_ALPHA */
  103579. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  103580. /** RGB */
  103581. static readonly TEXTUREFORMAT_RGB: number;
  103582. /** RGBA */
  103583. static readonly TEXTUREFORMAT_RGBA: number;
  103584. /** RED */
  103585. static readonly TEXTUREFORMAT_RED: number;
  103586. /** RED (2nd reference) */
  103587. static readonly TEXTUREFORMAT_R: number;
  103588. /** RG */
  103589. static readonly TEXTUREFORMAT_RG: number;
  103590. /** RED_INTEGER */
  103591. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  103592. /** RED_INTEGER (2nd reference) */
  103593. static readonly TEXTUREFORMAT_R_INTEGER: number;
  103594. /** RG_INTEGER */
  103595. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  103596. /** RGB_INTEGER */
  103597. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  103598. /** RGBA_INTEGER */
  103599. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  103600. /** UNSIGNED_BYTE */
  103601. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  103602. /** UNSIGNED_BYTE (2nd reference) */
  103603. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  103604. /** FLOAT */
  103605. static readonly TEXTURETYPE_FLOAT: number;
  103606. /** HALF_FLOAT */
  103607. static readonly TEXTURETYPE_HALF_FLOAT: number;
  103608. /** BYTE */
  103609. static readonly TEXTURETYPE_BYTE: number;
  103610. /** SHORT */
  103611. static readonly TEXTURETYPE_SHORT: number;
  103612. /** UNSIGNED_SHORT */
  103613. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  103614. /** INT */
  103615. static readonly TEXTURETYPE_INT: number;
  103616. /** UNSIGNED_INT */
  103617. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  103618. /** UNSIGNED_SHORT_4_4_4_4 */
  103619. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  103620. /** UNSIGNED_SHORT_5_5_5_1 */
  103621. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  103622. /** UNSIGNED_SHORT_5_6_5 */
  103623. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  103624. /** UNSIGNED_INT_2_10_10_10_REV */
  103625. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  103626. /** UNSIGNED_INT_24_8 */
  103627. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  103628. /** UNSIGNED_INT_10F_11F_11F_REV */
  103629. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  103630. /** UNSIGNED_INT_5_9_9_9_REV */
  103631. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  103632. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  103633. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  103634. /** nearest is mag = nearest and min = nearest and mip = linear */
  103635. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  103636. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103637. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  103638. /** Trilinear is mag = linear and min = linear and mip = linear */
  103639. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  103640. /** nearest is mag = nearest and min = nearest and mip = linear */
  103641. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  103642. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103643. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  103644. /** Trilinear is mag = linear and min = linear and mip = linear */
  103645. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  103646. /** mag = nearest and min = nearest and mip = nearest */
  103647. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  103648. /** mag = nearest and min = linear and mip = nearest */
  103649. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  103650. /** mag = nearest and min = linear and mip = linear */
  103651. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  103652. /** mag = nearest and min = linear and mip = none */
  103653. static readonly TEXTURE_NEAREST_LINEAR: number;
  103654. /** mag = nearest and min = nearest and mip = none */
  103655. static readonly TEXTURE_NEAREST_NEAREST: number;
  103656. /** mag = linear and min = nearest and mip = nearest */
  103657. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  103658. /** mag = linear and min = nearest and mip = linear */
  103659. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  103660. /** mag = linear and min = linear and mip = none */
  103661. static readonly TEXTURE_LINEAR_LINEAR: number;
  103662. /** mag = linear and min = nearest and mip = none */
  103663. static readonly TEXTURE_LINEAR_NEAREST: number;
  103664. /** Explicit coordinates mode */
  103665. static readonly TEXTURE_EXPLICIT_MODE: number;
  103666. /** Spherical coordinates mode */
  103667. static readonly TEXTURE_SPHERICAL_MODE: number;
  103668. /** Planar coordinates mode */
  103669. static readonly TEXTURE_PLANAR_MODE: number;
  103670. /** Cubic coordinates mode */
  103671. static readonly TEXTURE_CUBIC_MODE: number;
  103672. /** Projection coordinates mode */
  103673. static readonly TEXTURE_PROJECTION_MODE: number;
  103674. /** Skybox coordinates mode */
  103675. static readonly TEXTURE_SKYBOX_MODE: number;
  103676. /** Inverse Cubic coordinates mode */
  103677. static readonly TEXTURE_INVCUBIC_MODE: number;
  103678. /** Equirectangular coordinates mode */
  103679. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  103680. /** Equirectangular Fixed coordinates mode */
  103681. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  103682. /** Equirectangular Fixed Mirrored coordinates mode */
  103683. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103684. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  103685. static readonly SCALEMODE_FLOOR: number;
  103686. /** Defines that texture rescaling will look for the nearest power of 2 size */
  103687. static readonly SCALEMODE_NEAREST: number;
  103688. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  103689. static readonly SCALEMODE_CEILING: number;
  103690. /**
  103691. * Returns the current npm package of the sdk
  103692. */
  103693. static get NpmPackage(): string;
  103694. /**
  103695. * Returns the current version of the framework
  103696. */
  103697. static get Version(): string;
  103698. /** Gets the list of created engines */
  103699. static get Instances(): Engine[];
  103700. /**
  103701. * Gets the latest created engine
  103702. */
  103703. static get LastCreatedEngine(): Nullable<Engine>;
  103704. /**
  103705. * Gets the latest created scene
  103706. */
  103707. static get LastCreatedScene(): Nullable<Scene>;
  103708. /**
  103709. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  103710. * @param flag defines which part of the materials must be marked as dirty
  103711. * @param predicate defines a predicate used to filter which materials should be affected
  103712. */
  103713. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103714. /**
  103715. * Method called to create the default loading screen.
  103716. * This can be overriden in your own app.
  103717. * @param canvas The rendering canvas element
  103718. * @returns The loading screen
  103719. */
  103720. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  103721. /**
  103722. * Method called to create the default rescale post process on each engine.
  103723. */
  103724. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  103725. /**
  103726. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  103727. **/
  103728. enableOfflineSupport: boolean;
  103729. /**
  103730. * 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)
  103731. **/
  103732. disableManifestCheck: boolean;
  103733. /**
  103734. * Gets the list of created scenes
  103735. */
  103736. scenes: Scene[];
  103737. /**
  103738. * Event raised when a new scene is created
  103739. */
  103740. onNewSceneAddedObservable: Observable<Scene>;
  103741. /**
  103742. * Gets the list of created postprocesses
  103743. */
  103744. postProcesses: PostProcess[];
  103745. /**
  103746. * Gets a boolean indicating if the pointer is currently locked
  103747. */
  103748. isPointerLock: boolean;
  103749. /**
  103750. * Observable event triggered each time the rendering canvas is resized
  103751. */
  103752. onResizeObservable: Observable<Engine>;
  103753. /**
  103754. * Observable event triggered each time the canvas loses focus
  103755. */
  103756. onCanvasBlurObservable: Observable<Engine>;
  103757. /**
  103758. * Observable event triggered each time the canvas gains focus
  103759. */
  103760. onCanvasFocusObservable: Observable<Engine>;
  103761. /**
  103762. * Observable event triggered each time the canvas receives pointerout event
  103763. */
  103764. onCanvasPointerOutObservable: Observable<PointerEvent>;
  103765. /**
  103766. * Observable raised when the engine begins a new frame
  103767. */
  103768. onBeginFrameObservable: Observable<Engine>;
  103769. /**
  103770. * If set, will be used to request the next animation frame for the render loop
  103771. */
  103772. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  103773. /**
  103774. * Observable raised when the engine ends the current frame
  103775. */
  103776. onEndFrameObservable: Observable<Engine>;
  103777. /**
  103778. * Observable raised when the engine is about to compile a shader
  103779. */
  103780. onBeforeShaderCompilationObservable: Observable<Engine>;
  103781. /**
  103782. * Observable raised when the engine has jsut compiled a shader
  103783. */
  103784. onAfterShaderCompilationObservable: Observable<Engine>;
  103785. /**
  103786. * Gets the audio engine
  103787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103788. * @ignorenaming
  103789. */
  103790. static audioEngine: IAudioEngine;
  103791. /**
  103792. * Default AudioEngine factory responsible of creating the Audio Engine.
  103793. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  103794. */
  103795. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  103796. /**
  103797. * Default offline support factory responsible of creating a tool used to store data locally.
  103798. * By default, this will create a Database object if the workload has been embedded.
  103799. */
  103800. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  103801. private _loadingScreen;
  103802. private _pointerLockRequested;
  103803. private _dummyFramebuffer;
  103804. private _rescalePostProcess;
  103805. private _deterministicLockstep;
  103806. private _lockstepMaxSteps;
  103807. private _timeStep;
  103808. protected get _supportsHardwareTextureRescaling(): boolean;
  103809. private _fps;
  103810. private _deltaTime;
  103811. /** @hidden */
  103812. _drawCalls: PerfCounter;
  103813. /**
  103814. * Turn this value on if you want to pause FPS computation when in background
  103815. */
  103816. disablePerformanceMonitorInBackground: boolean;
  103817. private _performanceMonitor;
  103818. /**
  103819. * Gets the performance monitor attached to this engine
  103820. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103821. */
  103822. get performanceMonitor(): PerformanceMonitor;
  103823. private _onFocus;
  103824. private _onBlur;
  103825. private _onCanvasPointerOut;
  103826. private _onCanvasBlur;
  103827. private _onCanvasFocus;
  103828. private _onFullscreenChange;
  103829. private _onPointerLockChange;
  103830. /**
  103831. * Gets the HTML element used to attach event listeners
  103832. * @returns a HTML element
  103833. */
  103834. getInputElement(): Nullable<HTMLElement>;
  103835. /**
  103836. * Creates a new engine
  103837. * @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
  103838. * @param antialias defines enable antialiasing (default: false)
  103839. * @param options defines further options to be sent to the getContext() function
  103840. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103841. */
  103842. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103843. /**
  103844. * Gets current aspect ratio
  103845. * @param viewportOwner defines the camera to use to get the aspect ratio
  103846. * @param useScreen defines if screen size must be used (or the current render target if any)
  103847. * @returns a number defining the aspect ratio
  103848. */
  103849. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  103850. /**
  103851. * Gets current screen aspect ratio
  103852. * @returns a number defining the aspect ratio
  103853. */
  103854. getScreenAspectRatio(): number;
  103855. /**
  103856. * Gets the client rect of the HTML canvas attached with the current webGL context
  103857. * @returns a client rectanglee
  103858. */
  103859. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  103860. /**
  103861. * Gets the client rect of the HTML element used for events
  103862. * @returns a client rectanglee
  103863. */
  103864. getInputElementClientRect(): Nullable<ClientRect>;
  103865. /**
  103866. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  103867. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103868. * @returns true if engine is in deterministic lock step mode
  103869. */
  103870. isDeterministicLockStep(): boolean;
  103871. /**
  103872. * Gets the max steps when engine is running in deterministic lock step
  103873. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103874. * @returns the max steps
  103875. */
  103876. getLockstepMaxSteps(): number;
  103877. /**
  103878. * Returns the time in ms between steps when using deterministic lock step.
  103879. * @returns time step in (ms)
  103880. */
  103881. getTimeStep(): number;
  103882. /**
  103883. * Force the mipmap generation for the given render target texture
  103884. * @param texture defines the render target texture to use
  103885. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  103886. */
  103887. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  103888. /** States */
  103889. /**
  103890. * Set various states to the webGL context
  103891. * @param culling defines backface culling state
  103892. * @param zOffset defines the value to apply to zOffset (0 by default)
  103893. * @param force defines if states must be applied even if cache is up to date
  103894. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  103895. */
  103896. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  103897. /**
  103898. * Set the z offset to apply to current rendering
  103899. * @param value defines the offset to apply
  103900. */
  103901. setZOffset(value: number): void;
  103902. /**
  103903. * Gets the current value of the zOffset
  103904. * @returns the current zOffset state
  103905. */
  103906. getZOffset(): number;
  103907. /**
  103908. * Enable or disable depth buffering
  103909. * @param enable defines the state to set
  103910. */
  103911. setDepthBuffer(enable: boolean): void;
  103912. /**
  103913. * Gets a boolean indicating if depth writing is enabled
  103914. * @returns the current depth writing state
  103915. */
  103916. getDepthWrite(): boolean;
  103917. /**
  103918. * Enable or disable depth writing
  103919. * @param enable defines the state to set
  103920. */
  103921. setDepthWrite(enable: boolean): void;
  103922. /**
  103923. * Gets a boolean indicating if stencil buffer is enabled
  103924. * @returns the current stencil buffer state
  103925. */
  103926. getStencilBuffer(): boolean;
  103927. /**
  103928. * Enable or disable the stencil buffer
  103929. * @param enable defines if the stencil buffer must be enabled or disabled
  103930. */
  103931. setStencilBuffer(enable: boolean): void;
  103932. /**
  103933. * Gets the current stencil mask
  103934. * @returns a number defining the new stencil mask to use
  103935. */
  103936. getStencilMask(): number;
  103937. /**
  103938. * Sets the current stencil mask
  103939. * @param mask defines the new stencil mask to use
  103940. */
  103941. setStencilMask(mask: number): void;
  103942. /**
  103943. * Gets the current stencil function
  103944. * @returns a number defining the stencil function to use
  103945. */
  103946. getStencilFunction(): number;
  103947. /**
  103948. * Gets the current stencil reference value
  103949. * @returns a number defining the stencil reference value to use
  103950. */
  103951. getStencilFunctionReference(): number;
  103952. /**
  103953. * Gets the current stencil mask
  103954. * @returns a number defining the stencil mask to use
  103955. */
  103956. getStencilFunctionMask(): number;
  103957. /**
  103958. * Sets the current stencil function
  103959. * @param stencilFunc defines the new stencil function to use
  103960. */
  103961. setStencilFunction(stencilFunc: number): void;
  103962. /**
  103963. * Sets the current stencil reference
  103964. * @param reference defines the new stencil reference to use
  103965. */
  103966. setStencilFunctionReference(reference: number): void;
  103967. /**
  103968. * Sets the current stencil mask
  103969. * @param mask defines the new stencil mask to use
  103970. */
  103971. setStencilFunctionMask(mask: number): void;
  103972. /**
  103973. * Gets the current stencil operation when stencil fails
  103974. * @returns a number defining stencil operation to use when stencil fails
  103975. */
  103976. getStencilOperationFail(): number;
  103977. /**
  103978. * Gets the current stencil operation when depth fails
  103979. * @returns a number defining stencil operation to use when depth fails
  103980. */
  103981. getStencilOperationDepthFail(): number;
  103982. /**
  103983. * Gets the current stencil operation when stencil passes
  103984. * @returns a number defining stencil operation to use when stencil passes
  103985. */
  103986. getStencilOperationPass(): number;
  103987. /**
  103988. * Sets the stencil operation to use when stencil fails
  103989. * @param operation defines the stencil operation to use when stencil fails
  103990. */
  103991. setStencilOperationFail(operation: number): void;
  103992. /**
  103993. * Sets the stencil operation to use when depth fails
  103994. * @param operation defines the stencil operation to use when depth fails
  103995. */
  103996. setStencilOperationDepthFail(operation: number): void;
  103997. /**
  103998. * Sets the stencil operation to use when stencil passes
  103999. * @param operation defines the stencil operation to use when stencil passes
  104000. */
  104001. setStencilOperationPass(operation: number): void;
  104002. /**
  104003. * Sets a boolean indicating if the dithering state is enabled or disabled
  104004. * @param value defines the dithering state
  104005. */
  104006. setDitheringState(value: boolean): void;
  104007. /**
  104008. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  104009. * @param value defines the rasterizer state
  104010. */
  104011. setRasterizerState(value: boolean): void;
  104012. /**
  104013. * Gets the current depth function
  104014. * @returns a number defining the depth function
  104015. */
  104016. getDepthFunction(): Nullable<number>;
  104017. /**
  104018. * Sets the current depth function
  104019. * @param depthFunc defines the function to use
  104020. */
  104021. setDepthFunction(depthFunc: number): void;
  104022. /**
  104023. * Sets the current depth function to GREATER
  104024. */
  104025. setDepthFunctionToGreater(): void;
  104026. /**
  104027. * Sets the current depth function to GEQUAL
  104028. */
  104029. setDepthFunctionToGreaterOrEqual(): void;
  104030. /**
  104031. * Sets the current depth function to LESS
  104032. */
  104033. setDepthFunctionToLess(): void;
  104034. /**
  104035. * Sets the current depth function to LEQUAL
  104036. */
  104037. setDepthFunctionToLessOrEqual(): void;
  104038. private _cachedStencilBuffer;
  104039. private _cachedStencilFunction;
  104040. private _cachedStencilMask;
  104041. private _cachedStencilOperationPass;
  104042. private _cachedStencilOperationFail;
  104043. private _cachedStencilOperationDepthFail;
  104044. private _cachedStencilReference;
  104045. /**
  104046. * Caches the the state of the stencil buffer
  104047. */
  104048. cacheStencilState(): void;
  104049. /**
  104050. * Restores the state of the stencil buffer
  104051. */
  104052. restoreStencilState(): void;
  104053. /**
  104054. * Directly set the WebGL Viewport
  104055. * @param x defines the x coordinate of the viewport (in screen space)
  104056. * @param y defines the y coordinate of the viewport (in screen space)
  104057. * @param width defines the width of the viewport (in screen space)
  104058. * @param height defines the height of the viewport (in screen space)
  104059. * @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
  104060. */
  104061. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  104062. /**
  104063. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  104064. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104065. * @param y defines the y-coordinate of the corner of the clear rectangle
  104066. * @param width defines the width of the clear rectangle
  104067. * @param height defines the height of the clear rectangle
  104068. * @param clearColor defines the clear color
  104069. */
  104070. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  104071. /**
  104072. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  104073. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104074. * @param y defines the y-coordinate of the corner of the clear rectangle
  104075. * @param width defines the width of the clear rectangle
  104076. * @param height defines the height of the clear rectangle
  104077. */
  104078. enableScissor(x: number, y: number, width: number, height: number): void;
  104079. /**
  104080. * Disable previously set scissor test rectangle
  104081. */
  104082. disableScissor(): void;
  104083. protected _reportDrawCall(): void;
  104084. /**
  104085. * Initializes a webVR display and starts listening to display change events
  104086. * The onVRDisplayChangedObservable will be notified upon these changes
  104087. * @returns The onVRDisplayChangedObservable
  104088. */
  104089. initWebVR(): Observable<IDisplayChangedEventArgs>;
  104090. /** @hidden */
  104091. _prepareVRComponent(): void;
  104092. /** @hidden */
  104093. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  104094. /** @hidden */
  104095. _submitVRFrame(): void;
  104096. /**
  104097. * Call this function to leave webVR mode
  104098. * Will do nothing if webVR is not supported or if there is no webVR device
  104099. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104100. */
  104101. disableVR(): void;
  104102. /**
  104103. * Gets a boolean indicating that the system is in VR mode and is presenting
  104104. * @returns true if VR mode is engaged
  104105. */
  104106. isVRPresenting(): boolean;
  104107. /** @hidden */
  104108. _requestVRFrame(): void;
  104109. /** @hidden */
  104110. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  104111. /**
  104112. * Gets the source code of the vertex shader associated with a specific webGL program
  104113. * @param program defines the program to use
  104114. * @returns a string containing the source code of the vertex shader associated with the program
  104115. */
  104116. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  104117. /**
  104118. * Gets the source code of the fragment shader associated with a specific webGL program
  104119. * @param program defines the program to use
  104120. * @returns a string containing the source code of the fragment shader associated with the program
  104121. */
  104122. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  104123. /**
  104124. * Sets a depth stencil texture from a render target to the according uniform.
  104125. * @param channel The texture channel
  104126. * @param uniform The uniform to set
  104127. * @param texture The render target texture containing the depth stencil texture to apply
  104128. */
  104129. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  104130. /**
  104131. * Sets a texture to the webGL context from a postprocess
  104132. * @param channel defines the channel to use
  104133. * @param postProcess defines the source postprocess
  104134. */
  104135. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  104136. /**
  104137. * Binds the output of the passed in post process to the texture channel specified
  104138. * @param channel The channel the texture should be bound to
  104139. * @param postProcess The post process which's output should be bound
  104140. */
  104141. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  104142. /** @hidden */
  104143. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  104144. protected _rebuildBuffers(): void;
  104145. /** @hidden */
  104146. _renderFrame(): void;
  104147. _renderLoop(): void;
  104148. /** @hidden */
  104149. _renderViews(): boolean;
  104150. /**
  104151. * Toggle full screen mode
  104152. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104153. */
  104154. switchFullscreen(requestPointerLock: boolean): void;
  104155. /**
  104156. * Enters full screen mode
  104157. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104158. */
  104159. enterFullscreen(requestPointerLock: boolean): void;
  104160. /**
  104161. * Exits full screen mode
  104162. */
  104163. exitFullscreen(): void;
  104164. /**
  104165. * Enters Pointerlock mode
  104166. */
  104167. enterPointerlock(): void;
  104168. /**
  104169. * Exits Pointerlock mode
  104170. */
  104171. exitPointerlock(): void;
  104172. /**
  104173. * Begin a new frame
  104174. */
  104175. beginFrame(): void;
  104176. /**
  104177. * Enf the current frame
  104178. */
  104179. endFrame(): void;
  104180. resize(): void;
  104181. /**
  104182. * Set the compressed texture format to use, based on the formats you have, and the formats
  104183. * supported by the hardware / browser.
  104184. *
  104185. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  104186. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  104187. * to API arguments needed to compressed textures. This puts the burden on the container
  104188. * generator to house the arcane code for determining these for current & future formats.
  104189. *
  104190. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104191. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104192. *
  104193. * Note: The result of this call is not taken into account when a texture is base64.
  104194. *
  104195. * @param formatsAvailable defines the list of those format families you have created
  104196. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  104197. *
  104198. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  104199. * @returns The extension selected.
  104200. */
  104201. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  104202. /**
  104203. * Set the compressed texture extensions or file names to skip.
  104204. *
  104205. * @param skippedFiles defines the list of those texture files you want to skip
  104206. * Example: [".dds", ".env", "myfile.png"]
  104207. */
  104208. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  104209. /**
  104210. * Force a specific size of the canvas
  104211. * @param width defines the new canvas' width
  104212. * @param height defines the new canvas' height
  104213. */
  104214. setSize(width: number, height: number): void;
  104215. /**
  104216. * Updates a dynamic vertex buffer.
  104217. * @param vertexBuffer the vertex buffer to update
  104218. * @param data the data used to update the vertex buffer
  104219. * @param byteOffset the byte offset of the data
  104220. * @param byteLength the byte length of the data
  104221. */
  104222. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  104223. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104224. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104225. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104226. _releaseTexture(texture: InternalTexture): void;
  104227. /**
  104228. * @hidden
  104229. * Rescales a texture
  104230. * @param source input texutre
  104231. * @param destination destination texture
  104232. * @param scene scene to use to render the resize
  104233. * @param internalFormat format to use when resizing
  104234. * @param onComplete callback to be called when resize has completed
  104235. */
  104236. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104237. /**
  104238. * Gets the current framerate
  104239. * @returns a number representing the framerate
  104240. */
  104241. getFps(): number;
  104242. /**
  104243. * Gets the time spent between current and previous frame
  104244. * @returns a number representing the delta time in ms
  104245. */
  104246. getDeltaTime(): number;
  104247. private _measureFps;
  104248. /** @hidden */
  104249. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  104250. /**
  104251. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  104252. * @param renderTarget The render target to set the frame buffer for
  104253. */
  104254. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  104255. /**
  104256. * Update a dynamic index buffer
  104257. * @param indexBuffer defines the target index buffer
  104258. * @param indices defines the data to update
  104259. * @param offset defines the offset in the target index buffer where update should start
  104260. */
  104261. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  104262. /**
  104263. * Updates the sample count of a render target texture
  104264. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104265. * @param texture defines the texture to update
  104266. * @param samples defines the sample count to set
  104267. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104268. */
  104269. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  104270. /**
  104271. * Updates a depth texture Comparison Mode and Function.
  104272. * If the comparison Function is equal to 0, the mode will be set to none.
  104273. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  104274. * @param texture The texture to set the comparison function for
  104275. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  104276. */
  104277. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  104278. /**
  104279. * Creates a webGL buffer to use with instanciation
  104280. * @param capacity defines the size of the buffer
  104281. * @returns the webGL buffer
  104282. */
  104283. createInstancesBuffer(capacity: number): DataBuffer;
  104284. /**
  104285. * Delete a webGL buffer used with instanciation
  104286. * @param buffer defines the webGL buffer to delete
  104287. */
  104288. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  104289. /** @hidden */
  104290. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  104291. dispose(): void;
  104292. private _disableTouchAction;
  104293. /**
  104294. * Display the loading screen
  104295. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104296. */
  104297. displayLoadingUI(): void;
  104298. /**
  104299. * Hide the loading screen
  104300. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104301. */
  104302. hideLoadingUI(): void;
  104303. /**
  104304. * Gets the current loading screen object
  104305. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104306. */
  104307. get loadingScreen(): ILoadingScreen;
  104308. /**
  104309. * Sets the current loading screen object
  104310. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104311. */
  104312. set loadingScreen(loadingScreen: ILoadingScreen);
  104313. /**
  104314. * Sets the current loading screen text
  104315. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104316. */
  104317. set loadingUIText(text: string);
  104318. /**
  104319. * Sets the current loading screen background color
  104320. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104321. */
  104322. set loadingUIBackgroundColor(color: string);
  104323. /** Pointerlock and fullscreen */
  104324. /**
  104325. * Ask the browser to promote the current element to pointerlock mode
  104326. * @param element defines the DOM element to promote
  104327. */
  104328. static _RequestPointerlock(element: HTMLElement): void;
  104329. /**
  104330. * Asks the browser to exit pointerlock mode
  104331. */
  104332. static _ExitPointerlock(): void;
  104333. /**
  104334. * Ask the browser to promote the current element to fullscreen rendering mode
  104335. * @param element defines the DOM element to promote
  104336. */
  104337. static _RequestFullscreen(element: HTMLElement): void;
  104338. /**
  104339. * Asks the browser to exit fullscreen mode
  104340. */
  104341. static _ExitFullscreen(): void;
  104342. }
  104343. }
  104344. declare module BABYLON {
  104345. /**
  104346. * The engine store class is responsible to hold all the instances of Engine and Scene created
  104347. * during the life time of the application.
  104348. */
  104349. export class EngineStore {
  104350. /** Gets the list of created engines */
  104351. static Instances: Engine[];
  104352. /** @hidden */
  104353. static _LastCreatedScene: Nullable<Scene>;
  104354. /**
  104355. * Gets the latest created engine
  104356. */
  104357. static get LastCreatedEngine(): Nullable<Engine>;
  104358. /**
  104359. * Gets the latest created scene
  104360. */
  104361. static get LastCreatedScene(): Nullable<Scene>;
  104362. /**
  104363. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104364. * @ignorenaming
  104365. */
  104366. static UseFallbackTexture: boolean;
  104367. /**
  104368. * Texture content used if a texture cannot loaded
  104369. * @ignorenaming
  104370. */
  104371. static FallbackTexture: string;
  104372. }
  104373. }
  104374. declare module BABYLON {
  104375. /**
  104376. * Helper class that provides a small promise polyfill
  104377. */
  104378. export class PromisePolyfill {
  104379. /**
  104380. * Static function used to check if the polyfill is required
  104381. * If this is the case then the function will inject the polyfill to window.Promise
  104382. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  104383. */
  104384. static Apply(force?: boolean): void;
  104385. }
  104386. }
  104387. declare module BABYLON {
  104388. /**
  104389. * Interface for screenshot methods with describe argument called `size` as object with options
  104390. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  104391. */
  104392. export interface IScreenshotSize {
  104393. /**
  104394. * number in pixels for canvas height
  104395. */
  104396. height?: number;
  104397. /**
  104398. * multiplier allowing render at a higher or lower resolution
  104399. * If value is defined then height and width will be ignored and taken from camera
  104400. */
  104401. precision?: number;
  104402. /**
  104403. * number in pixels for canvas width
  104404. */
  104405. width?: number;
  104406. }
  104407. }
  104408. declare module BABYLON {
  104409. interface IColor4Like {
  104410. r: float;
  104411. g: float;
  104412. b: float;
  104413. a: float;
  104414. }
  104415. /**
  104416. * Class containing a set of static utilities functions
  104417. */
  104418. export class Tools {
  104419. /**
  104420. * Gets or sets the base URL to use to load assets
  104421. */
  104422. static get BaseUrl(): string;
  104423. static set BaseUrl(value: string);
  104424. /**
  104425. * Enable/Disable Custom HTTP Request Headers globally.
  104426. * default = false
  104427. * @see CustomRequestHeaders
  104428. */
  104429. static UseCustomRequestHeaders: boolean;
  104430. /**
  104431. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  104432. * i.e. when loading files, where the server/service expects an Authorization header
  104433. */
  104434. static CustomRequestHeaders: {
  104435. [key: string]: string;
  104436. };
  104437. /**
  104438. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  104439. */
  104440. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  104441. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  104442. /**
  104443. * Default behaviour for cors in the application.
  104444. * It can be a string if the expected behavior is identical in the entire app.
  104445. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  104446. */
  104447. static CorsBehavior: string | ((url: string | string[]) => string);
  104448. /**
  104449. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104450. * @ignorenaming
  104451. */
  104452. static get UseFallbackTexture(): boolean;
  104453. static set UseFallbackTexture(value: boolean);
  104454. /**
  104455. * Use this object to register external classes like custom textures or material
  104456. * to allow the laoders to instantiate them
  104457. */
  104458. static get RegisteredExternalClasses(): {
  104459. [key: string]: Object;
  104460. };
  104461. static set RegisteredExternalClasses(classes: {
  104462. [key: string]: Object;
  104463. });
  104464. /**
  104465. * Texture content used if a texture cannot loaded
  104466. * @ignorenaming
  104467. */
  104468. static get fallbackTexture(): string;
  104469. static set fallbackTexture(value: string);
  104470. /**
  104471. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  104472. * @param u defines the coordinate on X axis
  104473. * @param v defines the coordinate on Y axis
  104474. * @param width defines the width of the source data
  104475. * @param height defines the height of the source data
  104476. * @param pixels defines the source byte array
  104477. * @param color defines the output color
  104478. */
  104479. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  104480. /**
  104481. * Interpolates between a and b via alpha
  104482. * @param a The lower value (returned when alpha = 0)
  104483. * @param b The upper value (returned when alpha = 1)
  104484. * @param alpha The interpolation-factor
  104485. * @return The mixed value
  104486. */
  104487. static Mix(a: number, b: number, alpha: number): number;
  104488. /**
  104489. * Tries to instantiate a new object from a given class name
  104490. * @param className defines the class name to instantiate
  104491. * @returns the new object or null if the system was not able to do the instantiation
  104492. */
  104493. static Instantiate(className: string): any;
  104494. /**
  104495. * Provides a slice function that will work even on IE
  104496. * @param data defines the array to slice
  104497. * @param start defines the start of the data (optional)
  104498. * @param end defines the end of the data (optional)
  104499. * @returns the new sliced array
  104500. */
  104501. static Slice<T>(data: T, start?: number, end?: number): T;
  104502. /**
  104503. * Polyfill for setImmediate
  104504. * @param action defines the action to execute after the current execution block
  104505. */
  104506. static SetImmediate(action: () => void): void;
  104507. /**
  104508. * Function indicating if a number is an exponent of 2
  104509. * @param value defines the value to test
  104510. * @returns true if the value is an exponent of 2
  104511. */
  104512. static IsExponentOfTwo(value: number): boolean;
  104513. private static _tmpFloatArray;
  104514. /**
  104515. * Returns the nearest 32-bit single precision float representation of a Number
  104516. * @param value A Number. If the parameter is of a different type, it will get converted
  104517. * to a number or to NaN if it cannot be converted
  104518. * @returns number
  104519. */
  104520. static FloatRound(value: number): number;
  104521. /**
  104522. * Extracts the filename from a path
  104523. * @param path defines the path to use
  104524. * @returns the filename
  104525. */
  104526. static GetFilename(path: string): string;
  104527. /**
  104528. * Extracts the "folder" part of a path (everything before the filename).
  104529. * @param uri The URI to extract the info from
  104530. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  104531. * @returns The "folder" part of the path
  104532. */
  104533. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  104534. /**
  104535. * Extracts text content from a DOM element hierarchy
  104536. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  104537. */
  104538. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  104539. /**
  104540. * Convert an angle in radians to degrees
  104541. * @param angle defines the angle to convert
  104542. * @returns the angle in degrees
  104543. */
  104544. static ToDegrees(angle: number): number;
  104545. /**
  104546. * Convert an angle in degrees to radians
  104547. * @param angle defines the angle to convert
  104548. * @returns the angle in radians
  104549. */
  104550. static ToRadians(angle: number): number;
  104551. /**
  104552. * Returns an array if obj is not an array
  104553. * @param obj defines the object to evaluate as an array
  104554. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  104555. * @returns either obj directly if obj is an array or a new array containing obj
  104556. */
  104557. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  104558. /**
  104559. * Gets the pointer prefix to use
  104560. * @returns "pointer" if touch is enabled. Else returns "mouse"
  104561. */
  104562. static GetPointerPrefix(): string;
  104563. /**
  104564. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  104565. * @param url define the url we are trying
  104566. * @param element define the dom element where to configure the cors policy
  104567. */
  104568. static SetCorsBehavior(url: string | string[], element: {
  104569. crossOrigin: string | null;
  104570. }): void;
  104571. /**
  104572. * Removes unwanted characters from an url
  104573. * @param url defines the url to clean
  104574. * @returns the cleaned url
  104575. */
  104576. static CleanUrl(url: string): string;
  104577. /**
  104578. * Gets or sets a function used to pre-process url before using them to load assets
  104579. */
  104580. static get PreprocessUrl(): (url: string) => string;
  104581. static set PreprocessUrl(processor: (url: string) => string);
  104582. /**
  104583. * Loads an image as an HTMLImageElement.
  104584. * @param input url string, ArrayBuffer, or Blob to load
  104585. * @param onLoad callback called when the image successfully loads
  104586. * @param onError callback called when the image fails to load
  104587. * @param offlineProvider offline provider for caching
  104588. * @param mimeType optional mime type
  104589. * @returns the HTMLImageElement of the loaded image
  104590. */
  104591. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  104592. /**
  104593. * Loads a file from a url
  104594. * @param url url string, ArrayBuffer, or Blob to load
  104595. * @param onSuccess callback called when the file successfully loads
  104596. * @param onProgress callback called while file is loading (if the server supports this mode)
  104597. * @param offlineProvider defines the offline provider for caching
  104598. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104599. * @param onError callback called when the file fails to load
  104600. * @returns a file request object
  104601. */
  104602. 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;
  104603. /**
  104604. * Loads a file from a url
  104605. * @param url the file url to load
  104606. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  104607. */
  104608. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  104609. /**
  104610. * Load a script (identified by an url). When the url returns, the
  104611. * content of this file is added into a new script element, attached to the DOM (body element)
  104612. * @param scriptUrl defines the url of the script to laod
  104613. * @param onSuccess defines the callback called when the script is loaded
  104614. * @param onError defines the callback to call if an error occurs
  104615. * @param scriptId defines the id of the script element
  104616. */
  104617. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  104618. /**
  104619. * Load an asynchronous script (identified by an url). When the url returns, the
  104620. * content of this file is added into a new script element, attached to the DOM (body element)
  104621. * @param scriptUrl defines the url of the script to laod
  104622. * @param scriptId defines the id of the script element
  104623. * @returns a promise request object
  104624. */
  104625. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  104626. /**
  104627. * Loads a file from a blob
  104628. * @param fileToLoad defines the blob to use
  104629. * @param callback defines the callback to call when data is loaded
  104630. * @param progressCallback defines the callback to call during loading process
  104631. * @returns a file request object
  104632. */
  104633. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  104634. /**
  104635. * Reads a file from a File object
  104636. * @param file defines the file to load
  104637. * @param onSuccess defines the callback to call when data is loaded
  104638. * @param onProgress defines the callback to call during loading process
  104639. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  104640. * @param onError defines the callback to call when an error occurs
  104641. * @returns a file request object
  104642. */
  104643. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  104644. /**
  104645. * Creates a data url from a given string content
  104646. * @param content defines the content to convert
  104647. * @returns the new data url link
  104648. */
  104649. static FileAsURL(content: string): string;
  104650. /**
  104651. * Format the given number to a specific decimal format
  104652. * @param value defines the number to format
  104653. * @param decimals defines the number of decimals to use
  104654. * @returns the formatted string
  104655. */
  104656. static Format(value: number, decimals?: number): string;
  104657. /**
  104658. * Tries to copy an object by duplicating every property
  104659. * @param source defines the source object
  104660. * @param destination defines the target object
  104661. * @param doNotCopyList defines a list of properties to avoid
  104662. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  104663. */
  104664. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  104665. /**
  104666. * Gets a boolean indicating if the given object has no own property
  104667. * @param obj defines the object to test
  104668. * @returns true if object has no own property
  104669. */
  104670. static IsEmpty(obj: any): boolean;
  104671. /**
  104672. * Function used to register events at window level
  104673. * @param windowElement defines the Window object to use
  104674. * @param events defines the events to register
  104675. */
  104676. static RegisterTopRootEvents(windowElement: Window, events: {
  104677. name: string;
  104678. handler: Nullable<(e: FocusEvent) => any>;
  104679. }[]): void;
  104680. /**
  104681. * Function used to unregister events from window level
  104682. * @param windowElement defines the Window object to use
  104683. * @param events defines the events to unregister
  104684. */
  104685. static UnregisterTopRootEvents(windowElement: Window, events: {
  104686. name: string;
  104687. handler: Nullable<(e: FocusEvent) => any>;
  104688. }[]): void;
  104689. /**
  104690. * @ignore
  104691. */
  104692. static _ScreenshotCanvas: HTMLCanvasElement;
  104693. /**
  104694. * Dumps the current bound framebuffer
  104695. * @param width defines the rendering width
  104696. * @param height defines the rendering height
  104697. * @param engine defines the hosting engine
  104698. * @param successCallback defines the callback triggered once the data are available
  104699. * @param mimeType defines the mime type of the result
  104700. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  104701. */
  104702. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104703. /**
  104704. * Converts the canvas data to blob.
  104705. * This acts as a polyfill for browsers not supporting the to blob function.
  104706. * @param canvas Defines the canvas to extract the data from
  104707. * @param successCallback Defines the callback triggered once the data are available
  104708. * @param mimeType Defines the mime type of the result
  104709. */
  104710. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  104711. /**
  104712. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  104713. * @param successCallback defines the callback triggered once the data are available
  104714. * @param mimeType defines the mime type of the result
  104715. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  104716. */
  104717. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104718. /**
  104719. * Downloads a blob in the browser
  104720. * @param blob defines the blob to download
  104721. * @param fileName defines the name of the downloaded file
  104722. */
  104723. static Download(blob: Blob, fileName: string): void;
  104724. /**
  104725. * Captures a screenshot of the current rendering
  104726. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104727. * @param engine defines the rendering engine
  104728. * @param camera defines the source camera
  104729. * @param size This parameter can be set to a single number or to an object with the
  104730. * following (optional) properties: precision, width, height. If a single number is passed,
  104731. * it will be used for both width and height. If an object is passed, the screenshot size
  104732. * will be derived from the parameters. The precision property is a multiplier allowing
  104733. * rendering at a higher or lower resolution
  104734. * @param successCallback defines the callback receives a single parameter which contains the
  104735. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104736. * src parameter of an <img> to display it
  104737. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104738. * Check your browser for supported MIME types
  104739. */
  104740. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  104741. /**
  104742. * Captures a screenshot of the current rendering
  104743. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104744. * @param engine defines the rendering engine
  104745. * @param camera defines the source camera
  104746. * @param size This parameter can be set to a single number or to an object with the
  104747. * following (optional) properties: precision, width, height. If a single number is passed,
  104748. * it will be used for both width and height. If an object is passed, the screenshot size
  104749. * will be derived from the parameters. The precision property is a multiplier allowing
  104750. * rendering at a higher or lower resolution
  104751. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104752. * Check your browser for supported MIME types
  104753. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104754. * to the src parameter of an <img> to display it
  104755. */
  104756. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  104757. /**
  104758. * Generates an image screenshot from the specified camera.
  104759. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104760. * @param engine The engine to use for rendering
  104761. * @param camera The camera to use for rendering
  104762. * @param size This parameter can be set to a single number or to an object with the
  104763. * following (optional) properties: precision, width, height. If a single number is passed,
  104764. * it will be used for both width and height. If an object is passed, the screenshot size
  104765. * will be derived from the parameters. The precision property is a multiplier allowing
  104766. * rendering at a higher or lower resolution
  104767. * @param successCallback The callback receives a single parameter which contains the
  104768. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104769. * src parameter of an <img> to display it
  104770. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104771. * Check your browser for supported MIME types
  104772. * @param samples Texture samples (default: 1)
  104773. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104774. * @param fileName A name for for the downloaded file.
  104775. */
  104776. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  104777. /**
  104778. * Generates an image screenshot from the specified camera.
  104779. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104780. * @param engine The engine to use for rendering
  104781. * @param camera The camera to use for rendering
  104782. * @param size This parameter can be set to a single number or to an object with the
  104783. * following (optional) properties: precision, width, height. If a single number is passed,
  104784. * it will be used for both width and height. If an object is passed, the screenshot size
  104785. * will be derived from the parameters. The precision property is a multiplier allowing
  104786. * rendering at a higher or lower resolution
  104787. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104788. * Check your browser for supported MIME types
  104789. * @param samples Texture samples (default: 1)
  104790. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104791. * @param fileName A name for for the downloaded file.
  104792. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104793. * to the src parameter of an <img> to display it
  104794. */
  104795. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  104796. /**
  104797. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104798. * Be aware Math.random() could cause collisions, but:
  104799. * "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"
  104800. * @returns a pseudo random id
  104801. */
  104802. static RandomId(): string;
  104803. /**
  104804. * Test if the given uri is a base64 string
  104805. * @param uri The uri to test
  104806. * @return True if the uri is a base64 string or false otherwise
  104807. */
  104808. static IsBase64(uri: string): boolean;
  104809. /**
  104810. * Decode the given base64 uri.
  104811. * @param uri The uri to decode
  104812. * @return The decoded base64 data.
  104813. */
  104814. static DecodeBase64(uri: string): ArrayBuffer;
  104815. /**
  104816. * Gets the absolute url.
  104817. * @param url the input url
  104818. * @return the absolute url
  104819. */
  104820. static GetAbsoluteUrl(url: string): string;
  104821. /**
  104822. * No log
  104823. */
  104824. static readonly NoneLogLevel: number;
  104825. /**
  104826. * Only message logs
  104827. */
  104828. static readonly MessageLogLevel: number;
  104829. /**
  104830. * Only warning logs
  104831. */
  104832. static readonly WarningLogLevel: number;
  104833. /**
  104834. * Only error logs
  104835. */
  104836. static readonly ErrorLogLevel: number;
  104837. /**
  104838. * All logs
  104839. */
  104840. static readonly AllLogLevel: number;
  104841. /**
  104842. * Gets a value indicating the number of loading errors
  104843. * @ignorenaming
  104844. */
  104845. static get errorsCount(): number;
  104846. /**
  104847. * Callback called when a new log is added
  104848. */
  104849. static OnNewCacheEntry: (entry: string) => void;
  104850. /**
  104851. * Log a message to the console
  104852. * @param message defines the message to log
  104853. */
  104854. static Log(message: string): void;
  104855. /**
  104856. * Write a warning message to the console
  104857. * @param message defines the message to log
  104858. */
  104859. static Warn(message: string): void;
  104860. /**
  104861. * Write an error message to the console
  104862. * @param message defines the message to log
  104863. */
  104864. static Error(message: string): void;
  104865. /**
  104866. * Gets current log cache (list of logs)
  104867. */
  104868. static get LogCache(): string;
  104869. /**
  104870. * Clears the log cache
  104871. */
  104872. static ClearLogCache(): void;
  104873. /**
  104874. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  104875. */
  104876. static set LogLevels(level: number);
  104877. /**
  104878. * Checks if the window object exists
  104879. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  104880. */
  104881. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  104882. /**
  104883. * No performance log
  104884. */
  104885. static readonly PerformanceNoneLogLevel: number;
  104886. /**
  104887. * Use user marks to log performance
  104888. */
  104889. static readonly PerformanceUserMarkLogLevel: number;
  104890. /**
  104891. * Log performance to the console
  104892. */
  104893. static readonly PerformanceConsoleLogLevel: number;
  104894. private static _performance;
  104895. /**
  104896. * Sets the current performance log level
  104897. */
  104898. static set PerformanceLogLevel(level: number);
  104899. private static _StartPerformanceCounterDisabled;
  104900. private static _EndPerformanceCounterDisabled;
  104901. private static _StartUserMark;
  104902. private static _EndUserMark;
  104903. private static _StartPerformanceConsole;
  104904. private static _EndPerformanceConsole;
  104905. /**
  104906. * Starts a performance counter
  104907. */
  104908. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104909. /**
  104910. * Ends a specific performance coutner
  104911. */
  104912. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104913. /**
  104914. * Gets either window.performance.now() if supported or Date.now() else
  104915. */
  104916. static get Now(): number;
  104917. /**
  104918. * This method will return the name of the class used to create the instance of the given object.
  104919. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  104920. * @param object the object to get the class name from
  104921. * @param isType defines if the object is actually a type
  104922. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  104923. */
  104924. static GetClassName(object: any, isType?: boolean): string;
  104925. /**
  104926. * Gets the first element of an array satisfying a given predicate
  104927. * @param array defines the array to browse
  104928. * @param predicate defines the predicate to use
  104929. * @returns null if not found or the element
  104930. */
  104931. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  104932. /**
  104933. * This method will return the name of the full name of the class, including its owning module (if any).
  104934. * 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).
  104935. * @param object the object to get the class name from
  104936. * @param isType defines if the object is actually a type
  104937. * @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.
  104938. * @ignorenaming
  104939. */
  104940. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  104941. /**
  104942. * Returns a promise that resolves after the given amount of time.
  104943. * @param delay Number of milliseconds to delay
  104944. * @returns Promise that resolves after the given amount of time
  104945. */
  104946. static DelayAsync(delay: number): Promise<void>;
  104947. }
  104948. /**
  104949. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  104950. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  104951. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  104952. * @param name The name of the class, case should be preserved
  104953. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  104954. */
  104955. export function className(name: string, module?: string): (target: Object) => void;
  104956. /**
  104957. * An implementation of a loop for asynchronous functions.
  104958. */
  104959. export class AsyncLoop {
  104960. /**
  104961. * Defines the number of iterations for the loop
  104962. */
  104963. iterations: number;
  104964. /**
  104965. * Defines the current index of the loop.
  104966. */
  104967. index: number;
  104968. private _done;
  104969. private _fn;
  104970. private _successCallback;
  104971. /**
  104972. * Constructor.
  104973. * @param iterations the number of iterations.
  104974. * @param func the function to run each iteration
  104975. * @param successCallback the callback that will be called upon succesful execution
  104976. * @param offset starting offset.
  104977. */
  104978. constructor(
  104979. /**
  104980. * Defines the number of iterations for the loop
  104981. */
  104982. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  104983. /**
  104984. * Execute the next iteration. Must be called after the last iteration was finished.
  104985. */
  104986. executeNext(): void;
  104987. /**
  104988. * Break the loop and run the success callback.
  104989. */
  104990. breakLoop(): void;
  104991. /**
  104992. * Create and run an async loop.
  104993. * @param iterations the number of iterations.
  104994. * @param fn the function to run each iteration
  104995. * @param successCallback the callback that will be called upon succesful execution
  104996. * @param offset starting offset.
  104997. * @returns the created async loop object
  104998. */
  104999. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  105000. /**
  105001. * A for-loop that will run a given number of iterations synchronous and the rest async.
  105002. * @param iterations total number of iterations
  105003. * @param syncedIterations number of synchronous iterations in each async iteration.
  105004. * @param fn the function to call each iteration.
  105005. * @param callback a success call back that will be called when iterating stops.
  105006. * @param breakFunction a break condition (optional)
  105007. * @param timeout timeout settings for the setTimeout function. default - 0.
  105008. * @returns the created async loop object
  105009. */
  105010. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  105011. }
  105012. }
  105013. declare module BABYLON {
  105014. /**
  105015. * This class implement a typical dictionary using a string as key and the generic type T as value.
  105016. * The underlying implementation relies on an associative array to ensure the best performances.
  105017. * The value can be anything including 'null' but except 'undefined'
  105018. */
  105019. export class StringDictionary<T> {
  105020. /**
  105021. * This will clear this dictionary and copy the content from the 'source' one.
  105022. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  105023. * @param source the dictionary to take the content from and copy to this dictionary
  105024. */
  105025. copyFrom(source: StringDictionary<T>): void;
  105026. /**
  105027. * Get a value based from its key
  105028. * @param key the given key to get the matching value from
  105029. * @return the value if found, otherwise undefined is returned
  105030. */
  105031. get(key: string): T | undefined;
  105032. /**
  105033. * Get a value from its key or add it if it doesn't exist.
  105034. * This method will ensure you that a given key/data will be present in the dictionary.
  105035. * @param key the given key to get the matching value from
  105036. * @param factory the factory that will create the value if the key is not present in the dictionary.
  105037. * The factory will only be invoked if there's no data for the given key.
  105038. * @return the value corresponding to the key.
  105039. */
  105040. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  105041. /**
  105042. * Get a value from its key if present in the dictionary otherwise add it
  105043. * @param key the key to get the value from
  105044. * @param val if there's no such key/value pair in the dictionary add it with this value
  105045. * @return the value corresponding to the key
  105046. */
  105047. getOrAdd(key: string, val: T): T;
  105048. /**
  105049. * Check if there's a given key in the dictionary
  105050. * @param key the key to check for
  105051. * @return true if the key is present, false otherwise
  105052. */
  105053. contains(key: string): boolean;
  105054. /**
  105055. * Add a new key and its corresponding value
  105056. * @param key the key to add
  105057. * @param value the value corresponding to the key
  105058. * @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
  105059. */
  105060. add(key: string, value: T): boolean;
  105061. /**
  105062. * Update a specific value associated to a key
  105063. * @param key defines the key to use
  105064. * @param value defines the value to store
  105065. * @returns true if the value was updated (or false if the key was not found)
  105066. */
  105067. set(key: string, value: T): boolean;
  105068. /**
  105069. * Get the element of the given key and remove it from the dictionary
  105070. * @param key defines the key to search
  105071. * @returns the value associated with the key or null if not found
  105072. */
  105073. getAndRemove(key: string): Nullable<T>;
  105074. /**
  105075. * Remove a key/value from the dictionary.
  105076. * @param key the key to remove
  105077. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  105078. */
  105079. remove(key: string): boolean;
  105080. /**
  105081. * Clear the whole content of the dictionary
  105082. */
  105083. clear(): void;
  105084. /**
  105085. * Gets the current count
  105086. */
  105087. get count(): number;
  105088. /**
  105089. * Execute a callback on each key/val of the dictionary.
  105090. * Note that you can remove any element in this dictionary in the callback implementation
  105091. * @param callback the callback to execute on a given key/value pair
  105092. */
  105093. forEach(callback: (key: string, val: T) => void): void;
  105094. /**
  105095. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  105096. * If the callback returns null or undefined the method will iterate to the next key/value pair
  105097. * Note that you can remove any element in this dictionary in the callback implementation
  105098. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  105099. * @returns the first item
  105100. */
  105101. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  105102. private _count;
  105103. private _data;
  105104. }
  105105. }
  105106. declare module BABYLON {
  105107. /** @hidden */
  105108. export interface ICollisionCoordinator {
  105109. createCollider(): Collider;
  105110. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105111. init(scene: Scene): void;
  105112. }
  105113. /** @hidden */
  105114. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  105115. private _scene;
  105116. private _scaledPosition;
  105117. private _scaledVelocity;
  105118. private _finalPosition;
  105119. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105120. createCollider(): Collider;
  105121. init(scene: Scene): void;
  105122. private _collideWithWorld;
  105123. }
  105124. }
  105125. declare module BABYLON {
  105126. /**
  105127. * Class used to manage all inputs for the scene.
  105128. */
  105129. export class InputManager {
  105130. /** The distance in pixel that you have to move to prevent some events */
  105131. static DragMovementThreshold: number;
  105132. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  105133. static LongPressDelay: number;
  105134. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  105135. static DoubleClickDelay: number;
  105136. /** If you need to check double click without raising a single click at first click, enable this flag */
  105137. static ExclusiveDoubleClickMode: boolean;
  105138. private _wheelEventName;
  105139. private _onPointerMove;
  105140. private _onPointerDown;
  105141. private _onPointerUp;
  105142. private _initClickEvent;
  105143. private _initActionManager;
  105144. private _delayedSimpleClick;
  105145. private _delayedSimpleClickTimeout;
  105146. private _previousDelayedSimpleClickTimeout;
  105147. private _meshPickProceed;
  105148. private _previousButtonPressed;
  105149. private _currentPickResult;
  105150. private _previousPickResult;
  105151. private _totalPointersPressed;
  105152. private _doubleClickOccured;
  105153. private _pointerOverMesh;
  105154. private _pickedDownMesh;
  105155. private _pickedUpMesh;
  105156. private _pointerX;
  105157. private _pointerY;
  105158. private _unTranslatedPointerX;
  105159. private _unTranslatedPointerY;
  105160. private _startingPointerPosition;
  105161. private _previousStartingPointerPosition;
  105162. private _startingPointerTime;
  105163. private _previousStartingPointerTime;
  105164. private _pointerCaptures;
  105165. private _onKeyDown;
  105166. private _onKeyUp;
  105167. private _onCanvasFocusObserver;
  105168. private _onCanvasBlurObserver;
  105169. private _scene;
  105170. /**
  105171. * Creates a new InputManager
  105172. * @param scene defines the hosting scene
  105173. */
  105174. constructor(scene: Scene);
  105175. /**
  105176. * Gets the mesh that is currently under the pointer
  105177. */
  105178. get meshUnderPointer(): Nullable<AbstractMesh>;
  105179. /**
  105180. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  105181. */
  105182. get unTranslatedPointer(): Vector2;
  105183. /**
  105184. * Gets or sets the current on-screen X position of the pointer
  105185. */
  105186. get pointerX(): number;
  105187. set pointerX(value: number);
  105188. /**
  105189. * Gets or sets the current on-screen Y position of the pointer
  105190. */
  105191. get pointerY(): number;
  105192. set pointerY(value: number);
  105193. private _updatePointerPosition;
  105194. private _processPointerMove;
  105195. private _setRayOnPointerInfo;
  105196. private _checkPrePointerObservable;
  105197. /**
  105198. * Use this method to simulate a pointer move on a mesh
  105199. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105200. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105201. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105202. */
  105203. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105204. /**
  105205. * Use this method to simulate a pointer down on a mesh
  105206. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105207. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105208. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105209. */
  105210. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105211. private _processPointerDown;
  105212. /** @hidden */
  105213. _isPointerSwiping(): boolean;
  105214. /**
  105215. * Use this method to simulate a pointer up on a mesh
  105216. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105217. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105218. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105219. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  105220. */
  105221. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  105222. private _processPointerUp;
  105223. /**
  105224. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  105225. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  105226. * @returns true if the pointer was captured
  105227. */
  105228. isPointerCaptured(pointerId?: number): boolean;
  105229. /**
  105230. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  105231. * @param attachUp defines if you want to attach events to pointerup
  105232. * @param attachDown defines if you want to attach events to pointerdown
  105233. * @param attachMove defines if you want to attach events to pointermove
  105234. */
  105235. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  105236. /**
  105237. * Detaches all event handlers
  105238. */
  105239. detachControl(): void;
  105240. /**
  105241. * Force the value of meshUnderPointer
  105242. * @param mesh defines the mesh to use
  105243. */
  105244. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105245. /**
  105246. * Gets the mesh under the pointer
  105247. * @returns a Mesh or null if no mesh is under the pointer
  105248. */
  105249. getPointerOverMesh(): Nullable<AbstractMesh>;
  105250. }
  105251. }
  105252. declare module BABYLON {
  105253. /**
  105254. * Helper class used to generate session unique ID
  105255. */
  105256. export class UniqueIdGenerator {
  105257. private static _UniqueIdCounter;
  105258. /**
  105259. * Gets an unique (relatively to the current scene) Id
  105260. */
  105261. static get UniqueId(): number;
  105262. }
  105263. }
  105264. declare module BABYLON {
  105265. /**
  105266. * This class defines the direct association between an animation and a target
  105267. */
  105268. export class TargetedAnimation {
  105269. /**
  105270. * Animation to perform
  105271. */
  105272. animation: Animation;
  105273. /**
  105274. * Target to animate
  105275. */
  105276. target: any;
  105277. /**
  105278. * Serialize the object
  105279. * @returns the JSON object representing the current entity
  105280. */
  105281. serialize(): any;
  105282. }
  105283. /**
  105284. * Use this class to create coordinated animations on multiple targets
  105285. */
  105286. export class AnimationGroup implements IDisposable {
  105287. /** The name of the animation group */
  105288. name: string;
  105289. private _scene;
  105290. private _targetedAnimations;
  105291. private _animatables;
  105292. private _from;
  105293. private _to;
  105294. private _isStarted;
  105295. private _isPaused;
  105296. private _speedRatio;
  105297. private _loopAnimation;
  105298. /**
  105299. * Gets or sets the unique id of the node
  105300. */
  105301. uniqueId: number;
  105302. /**
  105303. * This observable will notify when one animation have ended
  105304. */
  105305. onAnimationEndObservable: Observable<TargetedAnimation>;
  105306. /**
  105307. * Observer raised when one animation loops
  105308. */
  105309. onAnimationLoopObservable: Observable<TargetedAnimation>;
  105310. /**
  105311. * Observer raised when all animations have looped
  105312. */
  105313. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  105314. /**
  105315. * This observable will notify when all animations have ended.
  105316. */
  105317. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  105318. /**
  105319. * This observable will notify when all animations have paused.
  105320. */
  105321. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  105322. /**
  105323. * This observable will notify when all animations are playing.
  105324. */
  105325. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  105326. /**
  105327. * Gets the first frame
  105328. */
  105329. get from(): number;
  105330. /**
  105331. * Gets the last frame
  105332. */
  105333. get to(): number;
  105334. /**
  105335. * Define if the animations are started
  105336. */
  105337. get isStarted(): boolean;
  105338. /**
  105339. * Gets a value indicating that the current group is playing
  105340. */
  105341. get isPlaying(): boolean;
  105342. /**
  105343. * Gets or sets the speed ratio to use for all animations
  105344. */
  105345. get speedRatio(): number;
  105346. /**
  105347. * Gets or sets the speed ratio to use for all animations
  105348. */
  105349. set speedRatio(value: number);
  105350. /**
  105351. * Gets or sets if all animations should loop or not
  105352. */
  105353. get loopAnimation(): boolean;
  105354. set loopAnimation(value: boolean);
  105355. /**
  105356. * Gets the targeted animations for this animation group
  105357. */
  105358. get targetedAnimations(): Array<TargetedAnimation>;
  105359. /**
  105360. * returning the list of animatables controlled by this animation group.
  105361. */
  105362. get animatables(): Array<Animatable>;
  105363. /**
  105364. * Instantiates a new Animation Group.
  105365. * This helps managing several animations at once.
  105366. * @see http://doc.babylonjs.com/how_to/group
  105367. * @param name Defines the name of the group
  105368. * @param scene Defines the scene the group belongs to
  105369. */
  105370. constructor(
  105371. /** The name of the animation group */
  105372. name: string, scene?: Nullable<Scene>);
  105373. /**
  105374. * Add an animation (with its target) in the group
  105375. * @param animation defines the animation we want to add
  105376. * @param target defines the target of the animation
  105377. * @returns the TargetedAnimation object
  105378. */
  105379. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  105380. /**
  105381. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  105382. * It can add constant keys at begin or end
  105383. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  105384. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  105385. * @returns the animation group
  105386. */
  105387. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  105388. private _animationLoopCount;
  105389. private _animationLoopFlags;
  105390. private _processLoop;
  105391. /**
  105392. * Start all animations on given targets
  105393. * @param loop defines if animations must loop
  105394. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  105395. * @param from defines the from key (optional)
  105396. * @param to defines the to key (optional)
  105397. * @returns the current animation group
  105398. */
  105399. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  105400. /**
  105401. * Pause all animations
  105402. * @returns the animation group
  105403. */
  105404. pause(): AnimationGroup;
  105405. /**
  105406. * Play all animations to initial state
  105407. * This function will start() the animations if they were not started or will restart() them if they were paused
  105408. * @param loop defines if animations must loop
  105409. * @returns the animation group
  105410. */
  105411. play(loop?: boolean): AnimationGroup;
  105412. /**
  105413. * Reset all animations to initial state
  105414. * @returns the animation group
  105415. */
  105416. reset(): AnimationGroup;
  105417. /**
  105418. * Restart animations from key 0
  105419. * @returns the animation group
  105420. */
  105421. restart(): AnimationGroup;
  105422. /**
  105423. * Stop all animations
  105424. * @returns the animation group
  105425. */
  105426. stop(): AnimationGroup;
  105427. /**
  105428. * Set animation weight for all animatables
  105429. * @param weight defines the weight to use
  105430. * @return the animationGroup
  105431. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105432. */
  105433. setWeightForAllAnimatables(weight: number): AnimationGroup;
  105434. /**
  105435. * Synchronize and normalize all animatables with a source animatable
  105436. * @param root defines the root animatable to synchronize with
  105437. * @return the animationGroup
  105438. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105439. */
  105440. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  105441. /**
  105442. * Goes to a specific frame in this animation group
  105443. * @param frame the frame number to go to
  105444. * @return the animationGroup
  105445. */
  105446. goToFrame(frame: number): AnimationGroup;
  105447. /**
  105448. * Dispose all associated resources
  105449. */
  105450. dispose(): void;
  105451. private _checkAnimationGroupEnded;
  105452. /**
  105453. * Clone the current animation group and returns a copy
  105454. * @param newName defines the name of the new group
  105455. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  105456. * @returns the new aniamtion group
  105457. */
  105458. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  105459. /**
  105460. * Serializes the animationGroup to an object
  105461. * @returns Serialized object
  105462. */
  105463. serialize(): any;
  105464. /**
  105465. * Returns a new AnimationGroup object parsed from the source provided.
  105466. * @param parsedAnimationGroup defines the source
  105467. * @param scene defines the scene that will receive the animationGroup
  105468. * @returns a new AnimationGroup
  105469. */
  105470. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  105471. /**
  105472. * Returns the string "AnimationGroup"
  105473. * @returns "AnimationGroup"
  105474. */
  105475. getClassName(): string;
  105476. /**
  105477. * Creates a detailled string about the object
  105478. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  105479. * @returns a string representing the object
  105480. */
  105481. toString(fullDetails?: boolean): string;
  105482. }
  105483. }
  105484. declare module BABYLON {
  105485. /**
  105486. * Define an interface for all classes that will hold resources
  105487. */
  105488. export interface IDisposable {
  105489. /**
  105490. * Releases all held resources
  105491. */
  105492. dispose(): void;
  105493. }
  105494. /** Interface defining initialization parameters for Scene class */
  105495. export interface SceneOptions {
  105496. /**
  105497. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  105498. * It will improve performance when the number of geometries becomes important.
  105499. */
  105500. useGeometryUniqueIdsMap?: boolean;
  105501. /**
  105502. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  105503. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105504. */
  105505. useMaterialMeshMap?: boolean;
  105506. /**
  105507. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  105508. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105509. */
  105510. useClonedMeshMap?: boolean;
  105511. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  105512. virtual?: boolean;
  105513. }
  105514. /**
  105515. * Represents a scene to be rendered by the engine.
  105516. * @see http://doc.babylonjs.com/features/scene
  105517. */
  105518. export class Scene extends AbstractScene implements IAnimatable {
  105519. /** The fog is deactivated */
  105520. static readonly FOGMODE_NONE: number;
  105521. /** The fog density is following an exponential function */
  105522. static readonly FOGMODE_EXP: number;
  105523. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  105524. static readonly FOGMODE_EXP2: number;
  105525. /** The fog density is following a linear function. */
  105526. static readonly FOGMODE_LINEAR: number;
  105527. /**
  105528. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  105529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105530. */
  105531. static MinDeltaTime: number;
  105532. /**
  105533. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  105534. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105535. */
  105536. static MaxDeltaTime: number;
  105537. /**
  105538. * Factory used to create the default material.
  105539. * @param name The name of the material to create
  105540. * @param scene The scene to create the material for
  105541. * @returns The default material
  105542. */
  105543. static DefaultMaterialFactory(scene: Scene): Material;
  105544. /**
  105545. * Factory used to create the a collision coordinator.
  105546. * @returns The collision coordinator
  105547. */
  105548. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  105549. /** @hidden */
  105550. _inputManager: InputManager;
  105551. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  105552. cameraToUseForPointers: Nullable<Camera>;
  105553. /** @hidden */
  105554. readonly _isScene: boolean;
  105555. /**
  105556. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  105557. */
  105558. autoClear: boolean;
  105559. /**
  105560. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  105561. */
  105562. autoClearDepthAndStencil: boolean;
  105563. /**
  105564. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  105565. */
  105566. clearColor: Color4;
  105567. /**
  105568. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  105569. */
  105570. ambientColor: Color3;
  105571. /**
  105572. * This is use to store the default BRDF lookup for PBR materials in your scene.
  105573. * It should only be one of the following (if not the default embedded one):
  105574. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105575. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  105576. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105577. * The material properties need to be setup according to the type of texture in use.
  105578. */
  105579. environmentBRDFTexture: BaseTexture;
  105580. /** @hidden */
  105581. protected _environmentTexture: Nullable<BaseTexture>;
  105582. /**
  105583. * Texture used in all pbr material as the reflection texture.
  105584. * As in the majority of the scene they are the same (exception for multi room and so on),
  105585. * this is easier to reference from here than from all the materials.
  105586. */
  105587. get environmentTexture(): Nullable<BaseTexture>;
  105588. /**
  105589. * Texture used in all pbr material as the reflection texture.
  105590. * As in the majority of the scene they are the same (exception for multi room and so on),
  105591. * this is easier to set here than in all the materials.
  105592. */
  105593. set environmentTexture(value: Nullable<BaseTexture>);
  105594. /** @hidden */
  105595. protected _environmentIntensity: number;
  105596. /**
  105597. * Intensity of the environment in all pbr material.
  105598. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105599. * As in the majority of the scene they are the same (exception for multi room and so on),
  105600. * this is easier to reference from here than from all the materials.
  105601. */
  105602. get environmentIntensity(): number;
  105603. /**
  105604. * Intensity of the environment in all pbr material.
  105605. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105606. * As in the majority of the scene they are the same (exception for multi room and so on),
  105607. * this is easier to set here than in all the materials.
  105608. */
  105609. set environmentIntensity(value: number);
  105610. /** @hidden */
  105611. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105612. /**
  105613. * Default image processing configuration used either in the rendering
  105614. * Forward main pass or through the imageProcessingPostProcess if present.
  105615. * As in the majority of the scene they are the same (exception for multi camera),
  105616. * this is easier to reference from here than from all the materials and post process.
  105617. *
  105618. * No setter as we it is a shared configuration, you can set the values instead.
  105619. */
  105620. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105621. private _forceWireframe;
  105622. /**
  105623. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  105624. */
  105625. set forceWireframe(value: boolean);
  105626. get forceWireframe(): boolean;
  105627. private _skipFrustumClipping;
  105628. /**
  105629. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  105630. */
  105631. set skipFrustumClipping(value: boolean);
  105632. get skipFrustumClipping(): boolean;
  105633. private _forcePointsCloud;
  105634. /**
  105635. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  105636. */
  105637. set forcePointsCloud(value: boolean);
  105638. get forcePointsCloud(): boolean;
  105639. /**
  105640. * Gets or sets the active clipplane 1
  105641. */
  105642. clipPlane: Nullable<Plane>;
  105643. /**
  105644. * Gets or sets the active clipplane 2
  105645. */
  105646. clipPlane2: Nullable<Plane>;
  105647. /**
  105648. * Gets or sets the active clipplane 3
  105649. */
  105650. clipPlane3: Nullable<Plane>;
  105651. /**
  105652. * Gets or sets the active clipplane 4
  105653. */
  105654. clipPlane4: Nullable<Plane>;
  105655. /**
  105656. * Gets or sets the active clipplane 5
  105657. */
  105658. clipPlane5: Nullable<Plane>;
  105659. /**
  105660. * Gets or sets the active clipplane 6
  105661. */
  105662. clipPlane6: Nullable<Plane>;
  105663. /**
  105664. * Gets or sets a boolean indicating if animations are enabled
  105665. */
  105666. animationsEnabled: boolean;
  105667. private _animationPropertiesOverride;
  105668. /**
  105669. * Gets or sets the animation properties override
  105670. */
  105671. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105672. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105673. /**
  105674. * Gets or sets a boolean indicating if a constant deltatime has to be used
  105675. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  105676. */
  105677. useConstantAnimationDeltaTime: boolean;
  105678. /**
  105679. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  105680. * Please note that it requires to run a ray cast through the scene on every frame
  105681. */
  105682. constantlyUpdateMeshUnderPointer: boolean;
  105683. /**
  105684. * Defines the HTML cursor to use when hovering over interactive elements
  105685. */
  105686. hoverCursor: string;
  105687. /**
  105688. * Defines the HTML default cursor to use (empty by default)
  105689. */
  105690. defaultCursor: string;
  105691. /**
  105692. * Defines wether cursors are handled by the scene.
  105693. */
  105694. doNotHandleCursors: boolean;
  105695. /**
  105696. * This is used to call preventDefault() on pointer down
  105697. * in order to block unwanted artifacts like system double clicks
  105698. */
  105699. preventDefaultOnPointerDown: boolean;
  105700. /**
  105701. * This is used to call preventDefault() on pointer up
  105702. * in order to block unwanted artifacts like system double clicks
  105703. */
  105704. preventDefaultOnPointerUp: boolean;
  105705. /**
  105706. * Gets or sets user defined metadata
  105707. */
  105708. metadata: any;
  105709. /**
  105710. * For internal use only. Please do not use.
  105711. */
  105712. reservedDataStore: any;
  105713. /**
  105714. * Gets the name of the plugin used to load this scene (null by default)
  105715. */
  105716. loadingPluginName: string;
  105717. /**
  105718. * Use this array to add regular expressions used to disable offline support for specific urls
  105719. */
  105720. disableOfflineSupportExceptionRules: RegExp[];
  105721. /**
  105722. * An event triggered when the scene is disposed.
  105723. */
  105724. onDisposeObservable: Observable<Scene>;
  105725. private _onDisposeObserver;
  105726. /** Sets a function to be executed when this scene is disposed. */
  105727. set onDispose(callback: () => void);
  105728. /**
  105729. * An event triggered before rendering the scene (right after animations and physics)
  105730. */
  105731. onBeforeRenderObservable: Observable<Scene>;
  105732. private _onBeforeRenderObserver;
  105733. /** Sets a function to be executed before rendering this scene */
  105734. set beforeRender(callback: Nullable<() => void>);
  105735. /**
  105736. * An event triggered after rendering the scene
  105737. */
  105738. onAfterRenderObservable: Observable<Scene>;
  105739. /**
  105740. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  105741. */
  105742. onAfterRenderCameraObservable: Observable<Camera>;
  105743. private _onAfterRenderObserver;
  105744. /** Sets a function to be executed after rendering this scene */
  105745. set afterRender(callback: Nullable<() => void>);
  105746. /**
  105747. * An event triggered before animating the scene
  105748. */
  105749. onBeforeAnimationsObservable: Observable<Scene>;
  105750. /**
  105751. * An event triggered after animations processing
  105752. */
  105753. onAfterAnimationsObservable: Observable<Scene>;
  105754. /**
  105755. * An event triggered before draw calls are ready to be sent
  105756. */
  105757. onBeforeDrawPhaseObservable: Observable<Scene>;
  105758. /**
  105759. * An event triggered after draw calls have been sent
  105760. */
  105761. onAfterDrawPhaseObservable: Observable<Scene>;
  105762. /**
  105763. * An event triggered when the scene is ready
  105764. */
  105765. onReadyObservable: Observable<Scene>;
  105766. /**
  105767. * An event triggered before rendering a camera
  105768. */
  105769. onBeforeCameraRenderObservable: Observable<Camera>;
  105770. private _onBeforeCameraRenderObserver;
  105771. /** Sets a function to be executed before rendering a camera*/
  105772. set beforeCameraRender(callback: () => void);
  105773. /**
  105774. * An event triggered after rendering a camera
  105775. */
  105776. onAfterCameraRenderObservable: Observable<Camera>;
  105777. private _onAfterCameraRenderObserver;
  105778. /** Sets a function to be executed after rendering a camera*/
  105779. set afterCameraRender(callback: () => void);
  105780. /**
  105781. * An event triggered when active meshes evaluation is about to start
  105782. */
  105783. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  105784. /**
  105785. * An event triggered when active meshes evaluation is done
  105786. */
  105787. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  105788. /**
  105789. * An event triggered when particles rendering is about to start
  105790. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105791. */
  105792. onBeforeParticlesRenderingObservable: Observable<Scene>;
  105793. /**
  105794. * An event triggered when particles rendering is done
  105795. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105796. */
  105797. onAfterParticlesRenderingObservable: Observable<Scene>;
  105798. /**
  105799. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  105800. */
  105801. onDataLoadedObservable: Observable<Scene>;
  105802. /**
  105803. * An event triggered when a camera is created
  105804. */
  105805. onNewCameraAddedObservable: Observable<Camera>;
  105806. /**
  105807. * An event triggered when a camera is removed
  105808. */
  105809. onCameraRemovedObservable: Observable<Camera>;
  105810. /**
  105811. * An event triggered when a light is created
  105812. */
  105813. onNewLightAddedObservable: Observable<Light>;
  105814. /**
  105815. * An event triggered when a light is removed
  105816. */
  105817. onLightRemovedObservable: Observable<Light>;
  105818. /**
  105819. * An event triggered when a geometry is created
  105820. */
  105821. onNewGeometryAddedObservable: Observable<Geometry>;
  105822. /**
  105823. * An event triggered when a geometry is removed
  105824. */
  105825. onGeometryRemovedObservable: Observable<Geometry>;
  105826. /**
  105827. * An event triggered when a transform node is created
  105828. */
  105829. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  105830. /**
  105831. * An event triggered when a transform node is removed
  105832. */
  105833. onTransformNodeRemovedObservable: Observable<TransformNode>;
  105834. /**
  105835. * An event triggered when a mesh is created
  105836. */
  105837. onNewMeshAddedObservable: Observable<AbstractMesh>;
  105838. /**
  105839. * An event triggered when a mesh is removed
  105840. */
  105841. onMeshRemovedObservable: Observable<AbstractMesh>;
  105842. /**
  105843. * An event triggered when a skeleton is created
  105844. */
  105845. onNewSkeletonAddedObservable: Observable<Skeleton>;
  105846. /**
  105847. * An event triggered when a skeleton is removed
  105848. */
  105849. onSkeletonRemovedObservable: Observable<Skeleton>;
  105850. /**
  105851. * An event triggered when a material is created
  105852. */
  105853. onNewMaterialAddedObservable: Observable<Material>;
  105854. /**
  105855. * An event triggered when a material is removed
  105856. */
  105857. onMaterialRemovedObservable: Observable<Material>;
  105858. /**
  105859. * An event triggered when a texture is created
  105860. */
  105861. onNewTextureAddedObservable: Observable<BaseTexture>;
  105862. /**
  105863. * An event triggered when a texture is removed
  105864. */
  105865. onTextureRemovedObservable: Observable<BaseTexture>;
  105866. /**
  105867. * An event triggered when render targets are about to be rendered
  105868. * Can happen multiple times per frame.
  105869. */
  105870. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  105871. /**
  105872. * An event triggered when render targets were rendered.
  105873. * Can happen multiple times per frame.
  105874. */
  105875. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  105876. /**
  105877. * An event triggered before calculating deterministic simulation step
  105878. */
  105879. onBeforeStepObservable: Observable<Scene>;
  105880. /**
  105881. * An event triggered after calculating deterministic simulation step
  105882. */
  105883. onAfterStepObservable: Observable<Scene>;
  105884. /**
  105885. * An event triggered when the activeCamera property is updated
  105886. */
  105887. onActiveCameraChanged: Observable<Scene>;
  105888. /**
  105889. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  105890. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105891. * 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)
  105892. */
  105893. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105894. /**
  105895. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  105896. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105897. * 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)
  105898. */
  105899. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105900. /**
  105901. * This Observable will when a mesh has been imported into the scene.
  105902. */
  105903. onMeshImportedObservable: Observable<AbstractMesh>;
  105904. /**
  105905. * This Observable will when an animation file has been imported into the scene.
  105906. */
  105907. onAnimationFileImportedObservable: Observable<Scene>;
  105908. /**
  105909. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  105910. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  105911. */
  105912. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  105913. /** @hidden */
  105914. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  105915. /**
  105916. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  105917. */
  105918. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  105919. /**
  105920. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  105921. */
  105922. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  105923. /**
  105924. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  105925. */
  105926. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  105927. /** Callback called when a pointer move is detected */
  105928. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105929. /** Callback called when a pointer down is detected */
  105930. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105931. /** Callback called when a pointer up is detected */
  105932. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  105933. /** Callback called when a pointer pick is detected */
  105934. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  105935. /**
  105936. * 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).
  105937. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  105938. */
  105939. onPrePointerObservable: Observable<PointerInfoPre>;
  105940. /**
  105941. * Observable event triggered each time an input event is received from the rendering canvas
  105942. */
  105943. onPointerObservable: Observable<PointerInfo>;
  105944. /**
  105945. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  105946. */
  105947. get unTranslatedPointer(): Vector2;
  105948. /**
  105949. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  105950. */
  105951. static get DragMovementThreshold(): number;
  105952. static set DragMovementThreshold(value: number);
  105953. /**
  105954. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  105955. */
  105956. static get LongPressDelay(): number;
  105957. static set LongPressDelay(value: number);
  105958. /**
  105959. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  105960. */
  105961. static get DoubleClickDelay(): number;
  105962. static set DoubleClickDelay(value: number);
  105963. /** If you need to check double click without raising a single click at first click, enable this flag */
  105964. static get ExclusiveDoubleClickMode(): boolean;
  105965. static set ExclusiveDoubleClickMode(value: boolean);
  105966. /** @hidden */
  105967. _mirroredCameraPosition: Nullable<Vector3>;
  105968. /**
  105969. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  105970. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  105971. */
  105972. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  105973. /**
  105974. * Observable event triggered each time an keyboard event is received from the hosting window
  105975. */
  105976. onKeyboardObservable: Observable<KeyboardInfo>;
  105977. private _useRightHandedSystem;
  105978. /**
  105979. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  105980. */
  105981. set useRightHandedSystem(value: boolean);
  105982. get useRightHandedSystem(): boolean;
  105983. private _timeAccumulator;
  105984. private _currentStepId;
  105985. private _currentInternalStep;
  105986. /**
  105987. * Sets the step Id used by deterministic lock step
  105988. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105989. * @param newStepId defines the step Id
  105990. */
  105991. setStepId(newStepId: number): void;
  105992. /**
  105993. * Gets the step Id used by deterministic lock step
  105994. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105995. * @returns the step Id
  105996. */
  105997. getStepId(): number;
  105998. /**
  105999. * Gets the internal step used by deterministic lock step
  106000. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106001. * @returns the internal step
  106002. */
  106003. getInternalStep(): number;
  106004. private _fogEnabled;
  106005. /**
  106006. * Gets or sets a boolean indicating if fog is enabled on this scene
  106007. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106008. * (Default is true)
  106009. */
  106010. set fogEnabled(value: boolean);
  106011. get fogEnabled(): boolean;
  106012. private _fogMode;
  106013. /**
  106014. * Gets or sets the fog mode to use
  106015. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106016. * | mode | value |
  106017. * | --- | --- |
  106018. * | FOGMODE_NONE | 0 |
  106019. * | FOGMODE_EXP | 1 |
  106020. * | FOGMODE_EXP2 | 2 |
  106021. * | FOGMODE_LINEAR | 3 |
  106022. */
  106023. set fogMode(value: number);
  106024. get fogMode(): number;
  106025. /**
  106026. * Gets or sets the fog color to use
  106027. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106028. * (Default is Color3(0.2, 0.2, 0.3))
  106029. */
  106030. fogColor: Color3;
  106031. /**
  106032. * Gets or sets the fog density to use
  106033. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106034. * (Default is 0.1)
  106035. */
  106036. fogDensity: number;
  106037. /**
  106038. * Gets or sets the fog start distance to use
  106039. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106040. * (Default is 0)
  106041. */
  106042. fogStart: number;
  106043. /**
  106044. * Gets or sets the fog end distance to use
  106045. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106046. * (Default is 1000)
  106047. */
  106048. fogEnd: number;
  106049. private _shadowsEnabled;
  106050. /**
  106051. * Gets or sets a boolean indicating if shadows are enabled on this scene
  106052. */
  106053. set shadowsEnabled(value: boolean);
  106054. get shadowsEnabled(): boolean;
  106055. private _lightsEnabled;
  106056. /**
  106057. * Gets or sets a boolean indicating if lights are enabled on this scene
  106058. */
  106059. set lightsEnabled(value: boolean);
  106060. get lightsEnabled(): boolean;
  106061. /** All of the active cameras added to this scene. */
  106062. activeCameras: Camera[];
  106063. /** @hidden */
  106064. _activeCamera: Nullable<Camera>;
  106065. /** Gets or sets the current active camera */
  106066. get activeCamera(): Nullable<Camera>;
  106067. set activeCamera(value: Nullable<Camera>);
  106068. private _defaultMaterial;
  106069. /** The default material used on meshes when no material is affected */
  106070. get defaultMaterial(): Material;
  106071. /** The default material used on meshes when no material is affected */
  106072. set defaultMaterial(value: Material);
  106073. private _texturesEnabled;
  106074. /**
  106075. * Gets or sets a boolean indicating if textures are enabled on this scene
  106076. */
  106077. set texturesEnabled(value: boolean);
  106078. get texturesEnabled(): boolean;
  106079. /**
  106080. * Gets or sets a boolean indicating if particles are enabled on this scene
  106081. */
  106082. particlesEnabled: boolean;
  106083. /**
  106084. * Gets or sets a boolean indicating if sprites are enabled on this scene
  106085. */
  106086. spritesEnabled: boolean;
  106087. private _skeletonsEnabled;
  106088. /**
  106089. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  106090. */
  106091. set skeletonsEnabled(value: boolean);
  106092. get skeletonsEnabled(): boolean;
  106093. /**
  106094. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  106095. */
  106096. lensFlaresEnabled: boolean;
  106097. /**
  106098. * Gets or sets a boolean indicating if collisions are enabled on this scene
  106099. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106100. */
  106101. collisionsEnabled: boolean;
  106102. private _collisionCoordinator;
  106103. /** @hidden */
  106104. get collisionCoordinator(): ICollisionCoordinator;
  106105. /**
  106106. * Defines the gravity applied to this scene (used only for collisions)
  106107. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106108. */
  106109. gravity: Vector3;
  106110. /**
  106111. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  106112. */
  106113. postProcessesEnabled: boolean;
  106114. /**
  106115. * The list of postprocesses added to the scene
  106116. */
  106117. postProcesses: PostProcess[];
  106118. /**
  106119. * Gets the current postprocess manager
  106120. */
  106121. postProcessManager: PostProcessManager;
  106122. /**
  106123. * Gets or sets a boolean indicating if render targets are enabled on this scene
  106124. */
  106125. renderTargetsEnabled: boolean;
  106126. /**
  106127. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  106128. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  106129. */
  106130. dumpNextRenderTargets: boolean;
  106131. /**
  106132. * The list of user defined render targets added to the scene
  106133. */
  106134. customRenderTargets: RenderTargetTexture[];
  106135. /**
  106136. * Defines if texture loading must be delayed
  106137. * If true, textures will only be loaded when they need to be rendered
  106138. */
  106139. useDelayedTextureLoading: boolean;
  106140. /**
  106141. * Gets the list of meshes imported to the scene through SceneLoader
  106142. */
  106143. importedMeshesFiles: String[];
  106144. /**
  106145. * Gets or sets a boolean indicating if probes are enabled on this scene
  106146. */
  106147. probesEnabled: boolean;
  106148. /**
  106149. * Gets or sets the current offline provider to use to store scene data
  106150. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106151. */
  106152. offlineProvider: IOfflineProvider;
  106153. /**
  106154. * Gets or sets the action manager associated with the scene
  106155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106156. */
  106157. actionManager: AbstractActionManager;
  106158. private _meshesForIntersections;
  106159. /**
  106160. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  106161. */
  106162. proceduralTexturesEnabled: boolean;
  106163. private _engine;
  106164. private _totalVertices;
  106165. /** @hidden */
  106166. _activeIndices: PerfCounter;
  106167. /** @hidden */
  106168. _activeParticles: PerfCounter;
  106169. /** @hidden */
  106170. _activeBones: PerfCounter;
  106171. private _animationRatio;
  106172. /** @hidden */
  106173. _animationTimeLast: number;
  106174. /** @hidden */
  106175. _animationTime: number;
  106176. /**
  106177. * Gets or sets a general scale for animation speed
  106178. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  106179. */
  106180. animationTimeScale: number;
  106181. /** @hidden */
  106182. _cachedMaterial: Nullable<Material>;
  106183. /** @hidden */
  106184. _cachedEffect: Nullable<Effect>;
  106185. /** @hidden */
  106186. _cachedVisibility: Nullable<number>;
  106187. private _renderId;
  106188. private _frameId;
  106189. private _executeWhenReadyTimeoutId;
  106190. private _intermediateRendering;
  106191. private _viewUpdateFlag;
  106192. private _projectionUpdateFlag;
  106193. /** @hidden */
  106194. _toBeDisposed: Nullable<IDisposable>[];
  106195. private _activeRequests;
  106196. /** @hidden */
  106197. _pendingData: any[];
  106198. private _isDisposed;
  106199. /**
  106200. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  106201. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  106202. */
  106203. dispatchAllSubMeshesOfActiveMeshes: boolean;
  106204. private _activeMeshes;
  106205. private _processedMaterials;
  106206. private _renderTargets;
  106207. /** @hidden */
  106208. _activeParticleSystems: SmartArray<IParticleSystem>;
  106209. private _activeSkeletons;
  106210. private _softwareSkinnedMeshes;
  106211. private _renderingManager;
  106212. /** @hidden */
  106213. _activeAnimatables: Animatable[];
  106214. private _transformMatrix;
  106215. private _sceneUbo;
  106216. /** @hidden */
  106217. _viewMatrix: Matrix;
  106218. private _projectionMatrix;
  106219. /** @hidden */
  106220. _forcedViewPosition: Nullable<Vector3>;
  106221. /** @hidden */
  106222. _frustumPlanes: Plane[];
  106223. /**
  106224. * Gets the list of frustum planes (built from the active camera)
  106225. */
  106226. get frustumPlanes(): Plane[];
  106227. /**
  106228. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  106229. * This is useful if there are more lights that the maximum simulteanous authorized
  106230. */
  106231. requireLightSorting: boolean;
  106232. /** @hidden */
  106233. readonly useMaterialMeshMap: boolean;
  106234. /** @hidden */
  106235. readonly useClonedMeshMap: boolean;
  106236. private _externalData;
  106237. private _uid;
  106238. /**
  106239. * @hidden
  106240. * Backing store of defined scene components.
  106241. */
  106242. _components: ISceneComponent[];
  106243. /**
  106244. * @hidden
  106245. * Backing store of defined scene components.
  106246. */
  106247. _serializableComponents: ISceneSerializableComponent[];
  106248. /**
  106249. * List of components to register on the next registration step.
  106250. */
  106251. private _transientComponents;
  106252. /**
  106253. * Registers the transient components if needed.
  106254. */
  106255. private _registerTransientComponents;
  106256. /**
  106257. * @hidden
  106258. * Add a component to the scene.
  106259. * Note that the ccomponent could be registered on th next frame if this is called after
  106260. * the register component stage.
  106261. * @param component Defines the component to add to the scene
  106262. */
  106263. _addComponent(component: ISceneComponent): void;
  106264. /**
  106265. * @hidden
  106266. * Gets a component from the scene.
  106267. * @param name defines the name of the component to retrieve
  106268. * @returns the component or null if not present
  106269. */
  106270. _getComponent(name: string): Nullable<ISceneComponent>;
  106271. /**
  106272. * @hidden
  106273. * Defines the actions happening before camera updates.
  106274. */
  106275. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  106276. /**
  106277. * @hidden
  106278. * Defines the actions happening before clear the canvas.
  106279. */
  106280. _beforeClearStage: Stage<SimpleStageAction>;
  106281. /**
  106282. * @hidden
  106283. * Defines the actions when collecting render targets for the frame.
  106284. */
  106285. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106286. /**
  106287. * @hidden
  106288. * Defines the actions happening for one camera in the frame.
  106289. */
  106290. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106291. /**
  106292. * @hidden
  106293. * Defines the actions happening during the per mesh ready checks.
  106294. */
  106295. _isReadyForMeshStage: Stage<MeshStageAction>;
  106296. /**
  106297. * @hidden
  106298. * Defines the actions happening before evaluate active mesh checks.
  106299. */
  106300. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  106301. /**
  106302. * @hidden
  106303. * Defines the actions happening during the evaluate sub mesh checks.
  106304. */
  106305. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  106306. /**
  106307. * @hidden
  106308. * Defines the actions happening during the active mesh stage.
  106309. */
  106310. _activeMeshStage: Stage<ActiveMeshStageAction>;
  106311. /**
  106312. * @hidden
  106313. * Defines the actions happening during the per camera render target step.
  106314. */
  106315. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  106316. /**
  106317. * @hidden
  106318. * Defines the actions happening just before the active camera is drawing.
  106319. */
  106320. _beforeCameraDrawStage: Stage<CameraStageAction>;
  106321. /**
  106322. * @hidden
  106323. * Defines the actions happening just before a render target is drawing.
  106324. */
  106325. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106326. /**
  106327. * @hidden
  106328. * Defines the actions happening just before a rendering group is drawing.
  106329. */
  106330. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106331. /**
  106332. * @hidden
  106333. * Defines the actions happening just before a mesh is drawing.
  106334. */
  106335. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106336. /**
  106337. * @hidden
  106338. * Defines the actions happening just after a mesh has been drawn.
  106339. */
  106340. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106341. /**
  106342. * @hidden
  106343. * Defines the actions happening just after a rendering group has been drawn.
  106344. */
  106345. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106346. /**
  106347. * @hidden
  106348. * Defines the actions happening just after the active camera has been drawn.
  106349. */
  106350. _afterCameraDrawStage: Stage<CameraStageAction>;
  106351. /**
  106352. * @hidden
  106353. * Defines the actions happening just after a render target has been drawn.
  106354. */
  106355. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106356. /**
  106357. * @hidden
  106358. * Defines the actions happening just after rendering all cameras and computing intersections.
  106359. */
  106360. _afterRenderStage: Stage<SimpleStageAction>;
  106361. /**
  106362. * @hidden
  106363. * Defines the actions happening when a pointer move event happens.
  106364. */
  106365. _pointerMoveStage: Stage<PointerMoveStageAction>;
  106366. /**
  106367. * @hidden
  106368. * Defines the actions happening when a pointer down event happens.
  106369. */
  106370. _pointerDownStage: Stage<PointerUpDownStageAction>;
  106371. /**
  106372. * @hidden
  106373. * Defines the actions happening when a pointer up event happens.
  106374. */
  106375. _pointerUpStage: Stage<PointerUpDownStageAction>;
  106376. /**
  106377. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  106378. */
  106379. private geometriesByUniqueId;
  106380. /**
  106381. * Creates a new Scene
  106382. * @param engine defines the engine to use to render this scene
  106383. * @param options defines the scene options
  106384. */
  106385. constructor(engine: Engine, options?: SceneOptions);
  106386. /**
  106387. * Gets a string idenfifying the name of the class
  106388. * @returns "Scene" string
  106389. */
  106390. getClassName(): string;
  106391. private _defaultMeshCandidates;
  106392. /**
  106393. * @hidden
  106394. */
  106395. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106396. private _defaultSubMeshCandidates;
  106397. /**
  106398. * @hidden
  106399. */
  106400. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106401. /**
  106402. * Sets the default candidate providers for the scene.
  106403. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  106404. * and getCollidingSubMeshCandidates to their default function
  106405. */
  106406. setDefaultCandidateProviders(): void;
  106407. /**
  106408. * Gets the mesh that is currently under the pointer
  106409. */
  106410. get meshUnderPointer(): Nullable<AbstractMesh>;
  106411. /**
  106412. * Gets or sets the current on-screen X position of the pointer
  106413. */
  106414. get pointerX(): number;
  106415. set pointerX(value: number);
  106416. /**
  106417. * Gets or sets the current on-screen Y position of the pointer
  106418. */
  106419. get pointerY(): number;
  106420. set pointerY(value: number);
  106421. /**
  106422. * Gets the cached material (ie. the latest rendered one)
  106423. * @returns the cached material
  106424. */
  106425. getCachedMaterial(): Nullable<Material>;
  106426. /**
  106427. * Gets the cached effect (ie. the latest rendered one)
  106428. * @returns the cached effect
  106429. */
  106430. getCachedEffect(): Nullable<Effect>;
  106431. /**
  106432. * Gets the cached visibility state (ie. the latest rendered one)
  106433. * @returns the cached visibility state
  106434. */
  106435. getCachedVisibility(): Nullable<number>;
  106436. /**
  106437. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  106438. * @param material defines the current material
  106439. * @param effect defines the current effect
  106440. * @param visibility defines the current visibility state
  106441. * @returns true if one parameter is not cached
  106442. */
  106443. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  106444. /**
  106445. * Gets the engine associated with the scene
  106446. * @returns an Engine
  106447. */
  106448. getEngine(): Engine;
  106449. /**
  106450. * Gets the total number of vertices rendered per frame
  106451. * @returns the total number of vertices rendered per frame
  106452. */
  106453. getTotalVertices(): number;
  106454. /**
  106455. * Gets the performance counter for total vertices
  106456. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106457. */
  106458. get totalVerticesPerfCounter(): PerfCounter;
  106459. /**
  106460. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  106461. * @returns the total number of active indices rendered per frame
  106462. */
  106463. getActiveIndices(): number;
  106464. /**
  106465. * Gets the performance counter for active indices
  106466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106467. */
  106468. get totalActiveIndicesPerfCounter(): PerfCounter;
  106469. /**
  106470. * Gets the total number of active particles rendered per frame
  106471. * @returns the total number of active particles rendered per frame
  106472. */
  106473. getActiveParticles(): number;
  106474. /**
  106475. * Gets the performance counter for active particles
  106476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106477. */
  106478. get activeParticlesPerfCounter(): PerfCounter;
  106479. /**
  106480. * Gets the total number of active bones rendered per frame
  106481. * @returns the total number of active bones rendered per frame
  106482. */
  106483. getActiveBones(): number;
  106484. /**
  106485. * Gets the performance counter for active bones
  106486. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106487. */
  106488. get activeBonesPerfCounter(): PerfCounter;
  106489. /**
  106490. * Gets the array of active meshes
  106491. * @returns an array of AbstractMesh
  106492. */
  106493. getActiveMeshes(): SmartArray<AbstractMesh>;
  106494. /**
  106495. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  106496. * @returns a number
  106497. */
  106498. getAnimationRatio(): number;
  106499. /**
  106500. * Gets an unique Id for the current render phase
  106501. * @returns a number
  106502. */
  106503. getRenderId(): number;
  106504. /**
  106505. * Gets an unique Id for the current frame
  106506. * @returns a number
  106507. */
  106508. getFrameId(): number;
  106509. /** Call this function if you want to manually increment the render Id*/
  106510. incrementRenderId(): void;
  106511. private _createUbo;
  106512. /**
  106513. * Use this method to simulate a pointer move on a mesh
  106514. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106515. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106516. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106517. * @returns the current scene
  106518. */
  106519. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106520. /**
  106521. * Use this method to simulate a pointer down on a mesh
  106522. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106523. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106524. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106525. * @returns the current scene
  106526. */
  106527. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106528. /**
  106529. * Use this method to simulate a pointer up on a mesh
  106530. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106531. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106532. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106533. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  106534. * @returns the current scene
  106535. */
  106536. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  106537. /**
  106538. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  106539. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  106540. * @returns true if the pointer was captured
  106541. */
  106542. isPointerCaptured(pointerId?: number): boolean;
  106543. /**
  106544. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  106545. * @param attachUp defines if you want to attach events to pointerup
  106546. * @param attachDown defines if you want to attach events to pointerdown
  106547. * @param attachMove defines if you want to attach events to pointermove
  106548. */
  106549. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  106550. /** Detaches all event handlers*/
  106551. detachControl(): void;
  106552. /**
  106553. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  106554. * Delay loaded resources are not taking in account
  106555. * @return true if all required resources are ready
  106556. */
  106557. isReady(): boolean;
  106558. /** Resets all cached information relative to material (including effect and visibility) */
  106559. resetCachedMaterial(): void;
  106560. /**
  106561. * Registers a function to be called before every frame render
  106562. * @param func defines the function to register
  106563. */
  106564. registerBeforeRender(func: () => void): void;
  106565. /**
  106566. * Unregisters a function called before every frame render
  106567. * @param func defines the function to unregister
  106568. */
  106569. unregisterBeforeRender(func: () => void): void;
  106570. /**
  106571. * Registers a function to be called after every frame render
  106572. * @param func defines the function to register
  106573. */
  106574. registerAfterRender(func: () => void): void;
  106575. /**
  106576. * Unregisters a function called after every frame render
  106577. * @param func defines the function to unregister
  106578. */
  106579. unregisterAfterRender(func: () => void): void;
  106580. private _executeOnceBeforeRender;
  106581. /**
  106582. * The provided function will run before render once and will be disposed afterwards.
  106583. * A timeout delay can be provided so that the function will be executed in N ms.
  106584. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  106585. * @param func The function to be executed.
  106586. * @param timeout optional delay in ms
  106587. */
  106588. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  106589. /** @hidden */
  106590. _addPendingData(data: any): void;
  106591. /** @hidden */
  106592. _removePendingData(data: any): void;
  106593. /**
  106594. * Returns the number of items waiting to be loaded
  106595. * @returns the number of items waiting to be loaded
  106596. */
  106597. getWaitingItemsCount(): number;
  106598. /**
  106599. * Returns a boolean indicating if the scene is still loading data
  106600. */
  106601. get isLoading(): boolean;
  106602. /**
  106603. * Registers a function to be executed when the scene is ready
  106604. * @param {Function} func - the function to be executed
  106605. */
  106606. executeWhenReady(func: () => void): void;
  106607. /**
  106608. * Returns a promise that resolves when the scene is ready
  106609. * @returns A promise that resolves when the scene is ready
  106610. */
  106611. whenReadyAsync(): Promise<void>;
  106612. /** @hidden */
  106613. _checkIsReady(): void;
  106614. /**
  106615. * Gets all animatable attached to the scene
  106616. */
  106617. get animatables(): Animatable[];
  106618. /**
  106619. * Resets the last animation time frame.
  106620. * Useful to override when animations start running when loading a scene for the first time.
  106621. */
  106622. resetLastAnimationTimeFrame(): void;
  106623. /**
  106624. * Gets the current view matrix
  106625. * @returns a Matrix
  106626. */
  106627. getViewMatrix(): Matrix;
  106628. /**
  106629. * Gets the current projection matrix
  106630. * @returns a Matrix
  106631. */
  106632. getProjectionMatrix(): Matrix;
  106633. /**
  106634. * Gets the current transform matrix
  106635. * @returns a Matrix made of View * Projection
  106636. */
  106637. getTransformMatrix(): Matrix;
  106638. /**
  106639. * Sets the current transform matrix
  106640. * @param viewL defines the View matrix to use
  106641. * @param projectionL defines the Projection matrix to use
  106642. * @param viewR defines the right View matrix to use (if provided)
  106643. * @param projectionR defines the right Projection matrix to use (if provided)
  106644. */
  106645. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  106646. /**
  106647. * Gets the uniform buffer used to store scene data
  106648. * @returns a UniformBuffer
  106649. */
  106650. getSceneUniformBuffer(): UniformBuffer;
  106651. /**
  106652. * Gets an unique (relatively to the current scene) Id
  106653. * @returns an unique number for the scene
  106654. */
  106655. getUniqueId(): number;
  106656. /**
  106657. * Add a mesh to the list of scene's meshes
  106658. * @param newMesh defines the mesh to add
  106659. * @param recursive if all child meshes should also be added to the scene
  106660. */
  106661. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  106662. /**
  106663. * Remove a mesh for the list of scene's meshes
  106664. * @param toRemove defines the mesh to remove
  106665. * @param recursive if all child meshes should also be removed from the scene
  106666. * @returns the index where the mesh was in the mesh list
  106667. */
  106668. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  106669. /**
  106670. * Add a transform node to the list of scene's transform nodes
  106671. * @param newTransformNode defines the transform node to add
  106672. */
  106673. addTransformNode(newTransformNode: TransformNode): void;
  106674. /**
  106675. * Remove a transform node for the list of scene's transform nodes
  106676. * @param toRemove defines the transform node to remove
  106677. * @returns the index where the transform node was in the transform node list
  106678. */
  106679. removeTransformNode(toRemove: TransformNode): number;
  106680. /**
  106681. * Remove a skeleton for the list of scene's skeletons
  106682. * @param toRemove defines the skeleton to remove
  106683. * @returns the index where the skeleton was in the skeleton list
  106684. */
  106685. removeSkeleton(toRemove: Skeleton): number;
  106686. /**
  106687. * Remove a morph target for the list of scene's morph targets
  106688. * @param toRemove defines the morph target to remove
  106689. * @returns the index where the morph target was in the morph target list
  106690. */
  106691. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  106692. /**
  106693. * Remove a light for the list of scene's lights
  106694. * @param toRemove defines the light to remove
  106695. * @returns the index where the light was in the light list
  106696. */
  106697. removeLight(toRemove: Light): number;
  106698. /**
  106699. * Remove a camera for the list of scene's cameras
  106700. * @param toRemove defines the camera to remove
  106701. * @returns the index where the camera was in the camera list
  106702. */
  106703. removeCamera(toRemove: Camera): number;
  106704. /**
  106705. * Remove a particle system for the list of scene's particle systems
  106706. * @param toRemove defines the particle system to remove
  106707. * @returns the index where the particle system was in the particle system list
  106708. */
  106709. removeParticleSystem(toRemove: IParticleSystem): number;
  106710. /**
  106711. * Remove a animation for the list of scene's animations
  106712. * @param toRemove defines the animation to remove
  106713. * @returns the index where the animation was in the animation list
  106714. */
  106715. removeAnimation(toRemove: Animation): number;
  106716. /**
  106717. * Will stop the animation of the given target
  106718. * @param target - the target
  106719. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  106720. * @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)
  106721. */
  106722. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  106723. /**
  106724. * Removes the given animation group from this scene.
  106725. * @param toRemove The animation group to remove
  106726. * @returns The index of the removed animation group
  106727. */
  106728. removeAnimationGroup(toRemove: AnimationGroup): number;
  106729. /**
  106730. * Removes the given multi-material from this scene.
  106731. * @param toRemove The multi-material to remove
  106732. * @returns The index of the removed multi-material
  106733. */
  106734. removeMultiMaterial(toRemove: MultiMaterial): number;
  106735. /**
  106736. * Removes the given material from this scene.
  106737. * @param toRemove The material to remove
  106738. * @returns The index of the removed material
  106739. */
  106740. removeMaterial(toRemove: Material): number;
  106741. /**
  106742. * Removes the given action manager from this scene.
  106743. * @param toRemove The action manager to remove
  106744. * @returns The index of the removed action manager
  106745. */
  106746. removeActionManager(toRemove: AbstractActionManager): number;
  106747. /**
  106748. * Removes the given texture from this scene.
  106749. * @param toRemove The texture to remove
  106750. * @returns The index of the removed texture
  106751. */
  106752. removeTexture(toRemove: BaseTexture): number;
  106753. /**
  106754. * Adds the given light to this scene
  106755. * @param newLight The light to add
  106756. */
  106757. addLight(newLight: Light): void;
  106758. /**
  106759. * Sorts the list list based on light priorities
  106760. */
  106761. sortLightsByPriority(): void;
  106762. /**
  106763. * Adds the given camera to this scene
  106764. * @param newCamera The camera to add
  106765. */
  106766. addCamera(newCamera: Camera): void;
  106767. /**
  106768. * Adds the given skeleton to this scene
  106769. * @param newSkeleton The skeleton to add
  106770. */
  106771. addSkeleton(newSkeleton: Skeleton): void;
  106772. /**
  106773. * Adds the given particle system to this scene
  106774. * @param newParticleSystem The particle system to add
  106775. */
  106776. addParticleSystem(newParticleSystem: IParticleSystem): void;
  106777. /**
  106778. * Adds the given animation to this scene
  106779. * @param newAnimation The animation to add
  106780. */
  106781. addAnimation(newAnimation: Animation): void;
  106782. /**
  106783. * Adds the given animation group to this scene.
  106784. * @param newAnimationGroup The animation group to add
  106785. */
  106786. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  106787. /**
  106788. * Adds the given multi-material to this scene
  106789. * @param newMultiMaterial The multi-material to add
  106790. */
  106791. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  106792. /**
  106793. * Adds the given material to this scene
  106794. * @param newMaterial The material to add
  106795. */
  106796. addMaterial(newMaterial: Material): void;
  106797. /**
  106798. * Adds the given morph target to this scene
  106799. * @param newMorphTargetManager The morph target to add
  106800. */
  106801. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  106802. /**
  106803. * Adds the given geometry to this scene
  106804. * @param newGeometry The geometry to add
  106805. */
  106806. addGeometry(newGeometry: Geometry): void;
  106807. /**
  106808. * Adds the given action manager to this scene
  106809. * @param newActionManager The action manager to add
  106810. */
  106811. addActionManager(newActionManager: AbstractActionManager): void;
  106812. /**
  106813. * Adds the given texture to this scene.
  106814. * @param newTexture The texture to add
  106815. */
  106816. addTexture(newTexture: BaseTexture): void;
  106817. /**
  106818. * Switch active camera
  106819. * @param newCamera defines the new active camera
  106820. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  106821. */
  106822. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  106823. /**
  106824. * sets the active camera of the scene using its ID
  106825. * @param id defines the camera's ID
  106826. * @return the new active camera or null if none found.
  106827. */
  106828. setActiveCameraByID(id: string): Nullable<Camera>;
  106829. /**
  106830. * sets the active camera of the scene using its name
  106831. * @param name defines the camera's name
  106832. * @returns the new active camera or null if none found.
  106833. */
  106834. setActiveCameraByName(name: string): Nullable<Camera>;
  106835. /**
  106836. * get an animation group using its name
  106837. * @param name defines the material's name
  106838. * @return the animation group or null if none found.
  106839. */
  106840. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  106841. /**
  106842. * Get a material using its unique id
  106843. * @param uniqueId defines the material's unique id
  106844. * @return the material or null if none found.
  106845. */
  106846. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  106847. /**
  106848. * get a material using its id
  106849. * @param id defines the material's ID
  106850. * @return the material or null if none found.
  106851. */
  106852. getMaterialByID(id: string): Nullable<Material>;
  106853. /**
  106854. * Gets a the last added material using a given id
  106855. * @param id defines the material's ID
  106856. * @return the last material with the given id or null if none found.
  106857. */
  106858. getLastMaterialByID(id: string): Nullable<Material>;
  106859. /**
  106860. * Gets a material using its name
  106861. * @param name defines the material's name
  106862. * @return the material or null if none found.
  106863. */
  106864. getMaterialByName(name: string): Nullable<Material>;
  106865. /**
  106866. * Get a texture using its unique id
  106867. * @param uniqueId defines the texture's unique id
  106868. * @return the texture or null if none found.
  106869. */
  106870. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  106871. /**
  106872. * Gets a camera using its id
  106873. * @param id defines the id to look for
  106874. * @returns the camera or null if not found
  106875. */
  106876. getCameraByID(id: string): Nullable<Camera>;
  106877. /**
  106878. * Gets a camera using its unique id
  106879. * @param uniqueId defines the unique id to look for
  106880. * @returns the camera or null if not found
  106881. */
  106882. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  106883. /**
  106884. * Gets a camera using its name
  106885. * @param name defines the camera's name
  106886. * @return the camera or null if none found.
  106887. */
  106888. getCameraByName(name: string): Nullable<Camera>;
  106889. /**
  106890. * Gets a bone using its id
  106891. * @param id defines the bone's id
  106892. * @return the bone or null if not found
  106893. */
  106894. getBoneByID(id: string): Nullable<Bone>;
  106895. /**
  106896. * Gets a bone using its id
  106897. * @param name defines the bone's name
  106898. * @return the bone or null if not found
  106899. */
  106900. getBoneByName(name: string): Nullable<Bone>;
  106901. /**
  106902. * Gets a light node using its name
  106903. * @param name defines the the light's name
  106904. * @return the light or null if none found.
  106905. */
  106906. getLightByName(name: string): Nullable<Light>;
  106907. /**
  106908. * Gets a light node using its id
  106909. * @param id defines the light's id
  106910. * @return the light or null if none found.
  106911. */
  106912. getLightByID(id: string): Nullable<Light>;
  106913. /**
  106914. * Gets a light node using its scene-generated unique ID
  106915. * @param uniqueId defines the light's unique id
  106916. * @return the light or null if none found.
  106917. */
  106918. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  106919. /**
  106920. * Gets a particle system by id
  106921. * @param id defines the particle system id
  106922. * @return the corresponding system or null if none found
  106923. */
  106924. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  106925. /**
  106926. * Gets a geometry using its ID
  106927. * @param id defines the geometry's id
  106928. * @return the geometry or null if none found.
  106929. */
  106930. getGeometryByID(id: string): Nullable<Geometry>;
  106931. private _getGeometryByUniqueID;
  106932. /**
  106933. * Add a new geometry to this scene
  106934. * @param geometry defines the geometry to be added to the scene.
  106935. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  106936. * @return a boolean defining if the geometry was added or not
  106937. */
  106938. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  106939. /**
  106940. * Removes an existing geometry
  106941. * @param geometry defines the geometry to be removed from the scene
  106942. * @return a boolean defining if the geometry was removed or not
  106943. */
  106944. removeGeometry(geometry: Geometry): boolean;
  106945. /**
  106946. * Gets the list of geometries attached to the scene
  106947. * @returns an array of Geometry
  106948. */
  106949. getGeometries(): Geometry[];
  106950. /**
  106951. * Gets the first added mesh found of a given ID
  106952. * @param id defines the id to search for
  106953. * @return the mesh found or null if not found at all
  106954. */
  106955. getMeshByID(id: string): Nullable<AbstractMesh>;
  106956. /**
  106957. * Gets a list of meshes using their id
  106958. * @param id defines the id to search for
  106959. * @returns a list of meshes
  106960. */
  106961. getMeshesByID(id: string): Array<AbstractMesh>;
  106962. /**
  106963. * Gets the first added transform node found of a given ID
  106964. * @param id defines the id to search for
  106965. * @return the found transform node or null if not found at all.
  106966. */
  106967. getTransformNodeByID(id: string): Nullable<TransformNode>;
  106968. /**
  106969. * Gets a transform node with its auto-generated unique id
  106970. * @param uniqueId efines the unique id to search for
  106971. * @return the found transform node or null if not found at all.
  106972. */
  106973. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  106974. /**
  106975. * Gets a list of transform nodes using their id
  106976. * @param id defines the id to search for
  106977. * @returns a list of transform nodes
  106978. */
  106979. getTransformNodesByID(id: string): Array<TransformNode>;
  106980. /**
  106981. * Gets a mesh with its auto-generated unique id
  106982. * @param uniqueId defines the unique id to search for
  106983. * @return the found mesh or null if not found at all.
  106984. */
  106985. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  106986. /**
  106987. * Gets a the last added mesh using a given id
  106988. * @param id defines the id to search for
  106989. * @return the found mesh or null if not found at all.
  106990. */
  106991. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  106992. /**
  106993. * Gets a the last added node (Mesh, Camera, Light) using a given id
  106994. * @param id defines the id to search for
  106995. * @return the found node or null if not found at all
  106996. */
  106997. getLastEntryByID(id: string): Nullable<Node>;
  106998. /**
  106999. * Gets a node (Mesh, Camera, Light) using a given id
  107000. * @param id defines the id to search for
  107001. * @return the found node or null if not found at all
  107002. */
  107003. getNodeByID(id: string): Nullable<Node>;
  107004. /**
  107005. * Gets a node (Mesh, Camera, Light) using a given name
  107006. * @param name defines the name to search for
  107007. * @return the found node or null if not found at all.
  107008. */
  107009. getNodeByName(name: string): Nullable<Node>;
  107010. /**
  107011. * Gets a mesh using a given name
  107012. * @param name defines the name to search for
  107013. * @return the found mesh or null if not found at all.
  107014. */
  107015. getMeshByName(name: string): Nullable<AbstractMesh>;
  107016. /**
  107017. * Gets a transform node using a given name
  107018. * @param name defines the name to search for
  107019. * @return the found transform node or null if not found at all.
  107020. */
  107021. getTransformNodeByName(name: string): Nullable<TransformNode>;
  107022. /**
  107023. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  107024. * @param id defines the id to search for
  107025. * @return the found skeleton or null if not found at all.
  107026. */
  107027. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  107028. /**
  107029. * Gets a skeleton using a given auto generated unique id
  107030. * @param uniqueId defines the unique id to search for
  107031. * @return the found skeleton or null if not found at all.
  107032. */
  107033. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  107034. /**
  107035. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  107036. * @param id defines the id to search for
  107037. * @return the found skeleton or null if not found at all.
  107038. */
  107039. getSkeletonById(id: string): Nullable<Skeleton>;
  107040. /**
  107041. * Gets a skeleton using a given name
  107042. * @param name defines the name to search for
  107043. * @return the found skeleton or null if not found at all.
  107044. */
  107045. getSkeletonByName(name: string): Nullable<Skeleton>;
  107046. /**
  107047. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  107048. * @param id defines the id to search for
  107049. * @return the found morph target manager or null if not found at all.
  107050. */
  107051. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  107052. /**
  107053. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  107054. * @param id defines the id to search for
  107055. * @return the found morph target or null if not found at all.
  107056. */
  107057. getMorphTargetById(id: string): Nullable<MorphTarget>;
  107058. /**
  107059. * Gets a boolean indicating if the given mesh is active
  107060. * @param mesh defines the mesh to look for
  107061. * @returns true if the mesh is in the active list
  107062. */
  107063. isActiveMesh(mesh: AbstractMesh): boolean;
  107064. /**
  107065. * Return a unique id as a string which can serve as an identifier for the scene
  107066. */
  107067. get uid(): string;
  107068. /**
  107069. * Add an externaly attached data from its key.
  107070. * This method call will fail and return false, if such key already exists.
  107071. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  107072. * @param key the unique key that identifies the data
  107073. * @param data the data object to associate to the key for this Engine instance
  107074. * @return true if no such key were already present and the data was added successfully, false otherwise
  107075. */
  107076. addExternalData<T>(key: string, data: T): boolean;
  107077. /**
  107078. * Get an externaly attached data from its key
  107079. * @param key the unique key that identifies the data
  107080. * @return the associated data, if present (can be null), or undefined if not present
  107081. */
  107082. getExternalData<T>(key: string): Nullable<T>;
  107083. /**
  107084. * Get an externaly attached data from its key, create it using a factory if it's not already present
  107085. * @param key the unique key that identifies the data
  107086. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  107087. * @return the associated data, can be null if the factory returned null.
  107088. */
  107089. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  107090. /**
  107091. * Remove an externaly attached data from the Engine instance
  107092. * @param key the unique key that identifies the data
  107093. * @return true if the data was successfully removed, false if it doesn't exist
  107094. */
  107095. removeExternalData(key: string): boolean;
  107096. private _evaluateSubMesh;
  107097. /**
  107098. * Clear the processed materials smart array preventing retention point in material dispose.
  107099. */
  107100. freeProcessedMaterials(): void;
  107101. private _preventFreeActiveMeshesAndRenderingGroups;
  107102. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  107103. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  107104. * when disposing several meshes in a row or a hierarchy of meshes.
  107105. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  107106. */
  107107. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  107108. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  107109. /**
  107110. * Clear the active meshes smart array preventing retention point in mesh dispose.
  107111. */
  107112. freeActiveMeshes(): void;
  107113. /**
  107114. * Clear the info related to rendering groups preventing retention points during dispose.
  107115. */
  107116. freeRenderingGroups(): void;
  107117. /** @hidden */
  107118. _isInIntermediateRendering(): boolean;
  107119. /**
  107120. * Lambda returning the list of potentially active meshes.
  107121. */
  107122. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  107123. /**
  107124. * Lambda returning the list of potentially active sub meshes.
  107125. */
  107126. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  107127. /**
  107128. * Lambda returning the list of potentially intersecting sub meshes.
  107129. */
  107130. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  107131. /**
  107132. * Lambda returning the list of potentially colliding sub meshes.
  107133. */
  107134. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  107135. private _activeMeshesFrozen;
  107136. private _skipEvaluateActiveMeshesCompletely;
  107137. /**
  107138. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  107139. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  107140. * @returns the current scene
  107141. */
  107142. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  107143. /**
  107144. * Use this function to restart evaluating active meshes on every frame
  107145. * @returns the current scene
  107146. */
  107147. unfreezeActiveMeshes(): Scene;
  107148. private _evaluateActiveMeshes;
  107149. private _activeMesh;
  107150. /**
  107151. * Update the transform matrix to update from the current active camera
  107152. * @param force defines a boolean used to force the update even if cache is up to date
  107153. */
  107154. updateTransformMatrix(force?: boolean): void;
  107155. private _bindFrameBuffer;
  107156. /** @hidden */
  107157. _allowPostProcessClearColor: boolean;
  107158. /** @hidden */
  107159. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  107160. private _processSubCameras;
  107161. private _checkIntersections;
  107162. /** @hidden */
  107163. _advancePhysicsEngineStep(step: number): void;
  107164. /**
  107165. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  107166. */
  107167. getDeterministicFrameTime: () => number;
  107168. /** @hidden */
  107169. _animate(): void;
  107170. /** Execute all animations (for a frame) */
  107171. animate(): void;
  107172. /**
  107173. * Render the scene
  107174. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  107175. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  107176. */
  107177. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  107178. /**
  107179. * Freeze all materials
  107180. * A frozen material will not be updatable but should be faster to render
  107181. */
  107182. freezeMaterials(): void;
  107183. /**
  107184. * Unfreeze all materials
  107185. * A frozen material will not be updatable but should be faster to render
  107186. */
  107187. unfreezeMaterials(): void;
  107188. /**
  107189. * Releases all held ressources
  107190. */
  107191. dispose(): void;
  107192. /**
  107193. * Gets if the scene is already disposed
  107194. */
  107195. get isDisposed(): boolean;
  107196. /**
  107197. * Call this function to reduce memory footprint of the scene.
  107198. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  107199. */
  107200. clearCachedVertexData(): void;
  107201. /**
  107202. * This function will remove the local cached buffer data from texture.
  107203. * It will save memory but will prevent the texture from being rebuilt
  107204. */
  107205. cleanCachedTextureBuffer(): void;
  107206. /**
  107207. * Get the world extend vectors with an optional filter
  107208. *
  107209. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  107210. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  107211. */
  107212. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  107213. min: Vector3;
  107214. max: Vector3;
  107215. };
  107216. /**
  107217. * Creates a ray that can be used to pick in the scene
  107218. * @param x defines the x coordinate of the origin (on-screen)
  107219. * @param y defines the y coordinate of the origin (on-screen)
  107220. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107221. * @param camera defines the camera to use for the picking
  107222. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107223. * @returns a Ray
  107224. */
  107225. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  107226. /**
  107227. * Creates a ray that can be used to pick in the scene
  107228. * @param x defines the x coordinate of the origin (on-screen)
  107229. * @param y defines the y coordinate of the origin (on-screen)
  107230. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107231. * @param result defines the ray where to store the picking ray
  107232. * @param camera defines the camera to use for the picking
  107233. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107234. * @returns the current scene
  107235. */
  107236. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  107237. /**
  107238. * Creates a ray that can be used to pick in the scene
  107239. * @param x defines the x coordinate of the origin (on-screen)
  107240. * @param y defines the y coordinate of the origin (on-screen)
  107241. * @param camera defines the camera to use for the picking
  107242. * @returns a Ray
  107243. */
  107244. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  107245. /**
  107246. * Creates a ray that can be used to pick in the scene
  107247. * @param x defines the x coordinate of the origin (on-screen)
  107248. * @param y defines the y coordinate of the origin (on-screen)
  107249. * @param result defines the ray where to store the picking ray
  107250. * @param camera defines the camera to use for the picking
  107251. * @returns the current scene
  107252. */
  107253. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  107254. /** Launch a ray to try to pick a mesh in the scene
  107255. * @param x position on screen
  107256. * @param y position on screen
  107257. * @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
  107258. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  107259. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107260. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107261. * @returns a PickingInfo
  107262. */
  107263. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107264. /** Use the given ray to pick a mesh in the scene
  107265. * @param ray The ray to use to pick meshes
  107266. * @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
  107267. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  107268. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107269. * @returns a PickingInfo
  107270. */
  107271. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107272. /**
  107273. * Launch a ray to try to pick a mesh in the scene
  107274. * @param x X position on screen
  107275. * @param y Y position on screen
  107276. * @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
  107277. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107278. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107279. * @returns an array of PickingInfo
  107280. */
  107281. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107282. /**
  107283. * Launch a ray to try to pick a mesh in the scene
  107284. * @param ray Ray to use
  107285. * @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
  107286. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107287. * @returns an array of PickingInfo
  107288. */
  107289. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107290. /**
  107291. * Force the value of meshUnderPointer
  107292. * @param mesh defines the mesh to use
  107293. */
  107294. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107295. /**
  107296. * Gets the mesh under the pointer
  107297. * @returns a Mesh or null if no mesh is under the pointer
  107298. */
  107299. getPointerOverMesh(): Nullable<AbstractMesh>;
  107300. /** @hidden */
  107301. _rebuildGeometries(): void;
  107302. /** @hidden */
  107303. _rebuildTextures(): void;
  107304. private _getByTags;
  107305. /**
  107306. * Get a list of meshes by tags
  107307. * @param tagsQuery defines the tags query to use
  107308. * @param forEach defines a predicate used to filter results
  107309. * @returns an array of Mesh
  107310. */
  107311. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  107312. /**
  107313. * Get a list of cameras by tags
  107314. * @param tagsQuery defines the tags query to use
  107315. * @param forEach defines a predicate used to filter results
  107316. * @returns an array of Camera
  107317. */
  107318. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  107319. /**
  107320. * Get a list of lights by tags
  107321. * @param tagsQuery defines the tags query to use
  107322. * @param forEach defines a predicate used to filter results
  107323. * @returns an array of Light
  107324. */
  107325. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  107326. /**
  107327. * Get a list of materials by tags
  107328. * @param tagsQuery defines the tags query to use
  107329. * @param forEach defines a predicate used to filter results
  107330. * @returns an array of Material
  107331. */
  107332. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  107333. /**
  107334. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  107335. * This allowed control for front to back rendering or reversly depending of the special needs.
  107336. *
  107337. * @param renderingGroupId The rendering group id corresponding to its index
  107338. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  107339. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  107340. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  107341. */
  107342. 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;
  107343. /**
  107344. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  107345. *
  107346. * @param renderingGroupId The rendering group id corresponding to its index
  107347. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107348. * @param depth Automatically clears depth between groups if true and autoClear is true.
  107349. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  107350. */
  107351. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  107352. /**
  107353. * Gets the current auto clear configuration for one rendering group of the rendering
  107354. * manager.
  107355. * @param index the rendering group index to get the information for
  107356. * @returns The auto clear setup for the requested rendering group
  107357. */
  107358. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  107359. private _blockMaterialDirtyMechanism;
  107360. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  107361. get blockMaterialDirtyMechanism(): boolean;
  107362. set blockMaterialDirtyMechanism(value: boolean);
  107363. /**
  107364. * Will flag all materials as dirty to trigger new shader compilation
  107365. * @param flag defines the flag used to specify which material part must be marked as dirty
  107366. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  107367. */
  107368. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107369. /** @hidden */
  107370. _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;
  107371. /** @hidden */
  107372. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107373. /** @hidden */
  107374. _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;
  107375. /** @hidden */
  107376. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  107377. /** @hidden */
  107378. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107379. /** @hidden */
  107380. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107381. }
  107382. }
  107383. declare module BABYLON {
  107384. /**
  107385. * Set of assets to keep when moving a scene into an asset container.
  107386. */
  107387. export class KeepAssets extends AbstractScene {
  107388. }
  107389. /**
  107390. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  107391. */
  107392. export class InstantiatedEntries {
  107393. /**
  107394. * List of new root nodes (eg. nodes with no parent)
  107395. */
  107396. rootNodes: TransformNode[];
  107397. /**
  107398. * List of new skeletons
  107399. */
  107400. skeletons: Skeleton[];
  107401. /**
  107402. * List of new animation groups
  107403. */
  107404. animationGroups: AnimationGroup[];
  107405. }
  107406. /**
  107407. * Container with a set of assets that can be added or removed from a scene.
  107408. */
  107409. export class AssetContainer extends AbstractScene {
  107410. /**
  107411. * The scene the AssetContainer belongs to.
  107412. */
  107413. scene: Scene;
  107414. /**
  107415. * Instantiates an AssetContainer.
  107416. * @param scene The scene the AssetContainer belongs to.
  107417. */
  107418. constructor(scene: Scene);
  107419. /**
  107420. * Instantiate or clone all meshes and add the new ones to the scene.
  107421. * Skeletons and animation groups will all be cloned
  107422. * @param nameFunction defines an optional function used to get new names for clones
  107423. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  107424. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  107425. */
  107426. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  107427. /**
  107428. * Adds all the assets from the container to the scene.
  107429. */
  107430. addAllToScene(): void;
  107431. /**
  107432. * Removes all the assets in the container from the scene
  107433. */
  107434. removeAllFromScene(): void;
  107435. /**
  107436. * Disposes all the assets in the container
  107437. */
  107438. dispose(): void;
  107439. private _moveAssets;
  107440. /**
  107441. * Removes all the assets contained in the scene and adds them to the container.
  107442. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  107443. */
  107444. moveAllFromScene(keepAssets?: KeepAssets): void;
  107445. /**
  107446. * 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.
  107447. * @returns the root mesh
  107448. */
  107449. createRootMesh(): Mesh;
  107450. /**
  107451. * Merge animations from this asset container into a scene
  107452. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107453. * @param animatables set of animatables to retarget to a node from the scene
  107454. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  107455. */
  107456. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  107457. }
  107458. }
  107459. declare module BABYLON {
  107460. /**
  107461. * Defines how the parser contract is defined.
  107462. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  107463. */
  107464. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  107465. /**
  107466. * Defines how the individual parser contract is defined.
  107467. * These parser can parse an individual asset
  107468. */
  107469. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  107470. /**
  107471. * Base class of the scene acting as a container for the different elements composing a scene.
  107472. * This class is dynamically extended by the different components of the scene increasing
  107473. * flexibility and reducing coupling
  107474. */
  107475. export abstract class AbstractScene {
  107476. /**
  107477. * Stores the list of available parsers in the application.
  107478. */
  107479. private static _BabylonFileParsers;
  107480. /**
  107481. * Stores the list of available individual parsers in the application.
  107482. */
  107483. private static _IndividualBabylonFileParsers;
  107484. /**
  107485. * Adds a parser in the list of available ones
  107486. * @param name Defines the name of the parser
  107487. * @param parser Defines the parser to add
  107488. */
  107489. static AddParser(name: string, parser: BabylonFileParser): void;
  107490. /**
  107491. * Gets a general parser from the list of avaialble ones
  107492. * @param name Defines the name of the parser
  107493. * @returns the requested parser or null
  107494. */
  107495. static GetParser(name: string): Nullable<BabylonFileParser>;
  107496. /**
  107497. * Adds n individual parser in the list of available ones
  107498. * @param name Defines the name of the parser
  107499. * @param parser Defines the parser to add
  107500. */
  107501. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  107502. /**
  107503. * Gets an individual parser from the list of avaialble ones
  107504. * @param name Defines the name of the parser
  107505. * @returns the requested parser or null
  107506. */
  107507. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  107508. /**
  107509. * Parser json data and populate both a scene and its associated container object
  107510. * @param jsonData Defines the data to parse
  107511. * @param scene Defines the scene to parse the data for
  107512. * @param container Defines the container attached to the parsing sequence
  107513. * @param rootUrl Defines the root url of the data
  107514. */
  107515. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  107516. /**
  107517. * Gets the list of root nodes (ie. nodes with no parent)
  107518. */
  107519. rootNodes: Node[];
  107520. /** All of the cameras added to this scene
  107521. * @see http://doc.babylonjs.com/babylon101/cameras
  107522. */
  107523. cameras: Camera[];
  107524. /**
  107525. * All of the lights added to this scene
  107526. * @see http://doc.babylonjs.com/babylon101/lights
  107527. */
  107528. lights: Light[];
  107529. /**
  107530. * All of the (abstract) meshes added to this scene
  107531. */
  107532. meshes: AbstractMesh[];
  107533. /**
  107534. * The list of skeletons added to the scene
  107535. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  107536. */
  107537. skeletons: Skeleton[];
  107538. /**
  107539. * All of the particle systems added to this scene
  107540. * @see http://doc.babylonjs.com/babylon101/particles
  107541. */
  107542. particleSystems: IParticleSystem[];
  107543. /**
  107544. * Gets a list of Animations associated with the scene
  107545. */
  107546. animations: Animation[];
  107547. /**
  107548. * All of the animation groups added to this scene
  107549. * @see http://doc.babylonjs.com/how_to/group
  107550. */
  107551. animationGroups: AnimationGroup[];
  107552. /**
  107553. * All of the multi-materials added to this scene
  107554. * @see http://doc.babylonjs.com/how_to/multi_materials
  107555. */
  107556. multiMaterials: MultiMaterial[];
  107557. /**
  107558. * All of the materials added to this scene
  107559. * In the context of a Scene, it is not supposed to be modified manually.
  107560. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  107561. * Note also that the order of the Material within the array is not significant and might change.
  107562. * @see http://doc.babylonjs.com/babylon101/materials
  107563. */
  107564. materials: Material[];
  107565. /**
  107566. * The list of morph target managers added to the scene
  107567. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  107568. */
  107569. morphTargetManagers: MorphTargetManager[];
  107570. /**
  107571. * The list of geometries used in the scene.
  107572. */
  107573. geometries: Geometry[];
  107574. /**
  107575. * All of the tranform nodes added to this scene
  107576. * In the context of a Scene, it is not supposed to be modified manually.
  107577. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  107578. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  107579. * @see http://doc.babylonjs.com/how_to/transformnode
  107580. */
  107581. transformNodes: TransformNode[];
  107582. /**
  107583. * ActionManagers available on the scene.
  107584. */
  107585. actionManagers: AbstractActionManager[];
  107586. /**
  107587. * Textures to keep.
  107588. */
  107589. textures: BaseTexture[];
  107590. /**
  107591. * Environment texture for the scene
  107592. */
  107593. environmentTexture: Nullable<BaseTexture>;
  107594. /**
  107595. * @returns all meshes, lights, cameras, transformNodes and bones
  107596. */
  107597. getNodes(): Array<Node>;
  107598. }
  107599. }
  107600. declare module BABYLON {
  107601. /**
  107602. * Interface used to define options for Sound class
  107603. */
  107604. export interface ISoundOptions {
  107605. /**
  107606. * Does the sound autoplay once loaded.
  107607. */
  107608. autoplay?: boolean;
  107609. /**
  107610. * Does the sound loop after it finishes playing once.
  107611. */
  107612. loop?: boolean;
  107613. /**
  107614. * Sound's volume
  107615. */
  107616. volume?: number;
  107617. /**
  107618. * Is it a spatial sound?
  107619. */
  107620. spatialSound?: boolean;
  107621. /**
  107622. * Maximum distance to hear that sound
  107623. */
  107624. maxDistance?: number;
  107625. /**
  107626. * Uses user defined attenuation function
  107627. */
  107628. useCustomAttenuation?: boolean;
  107629. /**
  107630. * Define the roll off factor of spatial sounds.
  107631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107632. */
  107633. rolloffFactor?: number;
  107634. /**
  107635. * Define the reference distance the sound should be heard perfectly.
  107636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107637. */
  107638. refDistance?: number;
  107639. /**
  107640. * Define the distance attenuation model the sound will follow.
  107641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107642. */
  107643. distanceModel?: string;
  107644. /**
  107645. * Defines the playback speed (1 by default)
  107646. */
  107647. playbackRate?: number;
  107648. /**
  107649. * Defines if the sound is from a streaming source
  107650. */
  107651. streaming?: boolean;
  107652. /**
  107653. * Defines an optional length (in seconds) inside the sound file
  107654. */
  107655. length?: number;
  107656. /**
  107657. * Defines an optional offset (in seconds) inside the sound file
  107658. */
  107659. offset?: number;
  107660. /**
  107661. * If true, URLs will not be required to state the audio file codec to use.
  107662. */
  107663. skipCodecCheck?: boolean;
  107664. }
  107665. /**
  107666. * Defines a sound that can be played in the application.
  107667. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  107668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107669. */
  107670. export class Sound {
  107671. /**
  107672. * The name of the sound in the scene.
  107673. */
  107674. name: string;
  107675. /**
  107676. * Does the sound autoplay once loaded.
  107677. */
  107678. autoplay: boolean;
  107679. /**
  107680. * Does the sound loop after it finishes playing once.
  107681. */
  107682. loop: boolean;
  107683. /**
  107684. * Does the sound use a custom attenuation curve to simulate the falloff
  107685. * happening when the source gets further away from the camera.
  107686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107687. */
  107688. useCustomAttenuation: boolean;
  107689. /**
  107690. * The sound track id this sound belongs to.
  107691. */
  107692. soundTrackId: number;
  107693. /**
  107694. * Is this sound currently played.
  107695. */
  107696. isPlaying: boolean;
  107697. /**
  107698. * Is this sound currently paused.
  107699. */
  107700. isPaused: boolean;
  107701. /**
  107702. * Does this sound enables spatial sound.
  107703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107704. */
  107705. spatialSound: boolean;
  107706. /**
  107707. * Define the reference distance the sound should be heard perfectly.
  107708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107709. */
  107710. refDistance: number;
  107711. /**
  107712. * Define the roll off factor of spatial sounds.
  107713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107714. */
  107715. rolloffFactor: number;
  107716. /**
  107717. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  107718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107719. */
  107720. maxDistance: number;
  107721. /**
  107722. * Define the distance attenuation model the sound will follow.
  107723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107724. */
  107725. distanceModel: string;
  107726. /**
  107727. * @hidden
  107728. * Back Compat
  107729. **/
  107730. onended: () => any;
  107731. /**
  107732. * Observable event when the current playing sound finishes.
  107733. */
  107734. onEndedObservable: Observable<Sound>;
  107735. private _panningModel;
  107736. private _playbackRate;
  107737. private _streaming;
  107738. private _startTime;
  107739. private _startOffset;
  107740. private _position;
  107741. /** @hidden */
  107742. _positionInEmitterSpace: boolean;
  107743. private _localDirection;
  107744. private _volume;
  107745. private _isReadyToPlay;
  107746. private _isDirectional;
  107747. private _readyToPlayCallback;
  107748. private _audioBuffer;
  107749. private _soundSource;
  107750. private _streamingSource;
  107751. private _soundPanner;
  107752. private _soundGain;
  107753. private _inputAudioNode;
  107754. private _outputAudioNode;
  107755. private _coneInnerAngle;
  107756. private _coneOuterAngle;
  107757. private _coneOuterGain;
  107758. private _scene;
  107759. private _connectedTransformNode;
  107760. private _customAttenuationFunction;
  107761. private _registerFunc;
  107762. private _isOutputConnected;
  107763. private _htmlAudioElement;
  107764. private _urlType;
  107765. private _length?;
  107766. private _offset?;
  107767. /** @hidden */
  107768. static _SceneComponentInitialization: (scene: Scene) => void;
  107769. /**
  107770. * Create a sound and attach it to a scene
  107771. * @param name Name of your sound
  107772. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  107773. * @param scene defines the scene the sound belongs to
  107774. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  107775. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  107776. */
  107777. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  107778. /**
  107779. * Release the sound and its associated resources
  107780. */
  107781. dispose(): void;
  107782. /**
  107783. * Gets if the sounds is ready to be played or not.
  107784. * @returns true if ready, otherwise false
  107785. */
  107786. isReady(): boolean;
  107787. private _soundLoaded;
  107788. /**
  107789. * Sets the data of the sound from an audiobuffer
  107790. * @param audioBuffer The audioBuffer containing the data
  107791. */
  107792. setAudioBuffer(audioBuffer: AudioBuffer): void;
  107793. /**
  107794. * Updates the current sounds options such as maxdistance, loop...
  107795. * @param options A JSON object containing values named as the object properties
  107796. */
  107797. updateOptions(options: ISoundOptions): void;
  107798. private _createSpatialParameters;
  107799. private _updateSpatialParameters;
  107800. /**
  107801. * Switch the panning model to HRTF:
  107802. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107804. */
  107805. switchPanningModelToHRTF(): void;
  107806. /**
  107807. * Switch the panning model to Equal Power:
  107808. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107810. */
  107811. switchPanningModelToEqualPower(): void;
  107812. private _switchPanningModel;
  107813. /**
  107814. * Connect this sound to a sound track audio node like gain...
  107815. * @param soundTrackAudioNode the sound track audio node to connect to
  107816. */
  107817. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  107818. /**
  107819. * Transform this sound into a directional source
  107820. * @param coneInnerAngle Size of the inner cone in degree
  107821. * @param coneOuterAngle Size of the outer cone in degree
  107822. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  107823. */
  107824. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  107825. /**
  107826. * Gets or sets the inner angle for the directional cone.
  107827. */
  107828. get directionalConeInnerAngle(): number;
  107829. /**
  107830. * Gets or sets the inner angle for the directional cone.
  107831. */
  107832. set directionalConeInnerAngle(value: number);
  107833. /**
  107834. * Gets or sets the outer angle for the directional cone.
  107835. */
  107836. get directionalConeOuterAngle(): number;
  107837. /**
  107838. * Gets or sets the outer angle for the directional cone.
  107839. */
  107840. set directionalConeOuterAngle(value: number);
  107841. /**
  107842. * Sets the position of the emitter if spatial sound is enabled
  107843. * @param newPosition Defines the new posisiton
  107844. */
  107845. setPosition(newPosition: Vector3): void;
  107846. /**
  107847. * Sets the local direction of the emitter if spatial sound is enabled
  107848. * @param newLocalDirection Defines the new local direction
  107849. */
  107850. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  107851. private _updateDirection;
  107852. /** @hidden */
  107853. updateDistanceFromListener(): void;
  107854. /**
  107855. * Sets a new custom attenuation function for the sound.
  107856. * @param callback Defines the function used for the attenuation
  107857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107858. */
  107859. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  107860. /**
  107861. * Play the sound
  107862. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  107863. * @param offset (optional) Start the sound at a specific time in seconds
  107864. * @param length (optional) Sound duration (in seconds)
  107865. */
  107866. play(time?: number, offset?: number, length?: number): void;
  107867. private _onended;
  107868. /**
  107869. * Stop the sound
  107870. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  107871. */
  107872. stop(time?: number): void;
  107873. /**
  107874. * Put the sound in pause
  107875. */
  107876. pause(): void;
  107877. /**
  107878. * Sets a dedicated volume for this sounds
  107879. * @param newVolume Define the new volume of the sound
  107880. * @param time Define time for gradual change to new volume
  107881. */
  107882. setVolume(newVolume: number, time?: number): void;
  107883. /**
  107884. * Set the sound play back rate
  107885. * @param newPlaybackRate Define the playback rate the sound should be played at
  107886. */
  107887. setPlaybackRate(newPlaybackRate: number): void;
  107888. /**
  107889. * Gets the volume of the sound.
  107890. * @returns the volume of the sound
  107891. */
  107892. getVolume(): number;
  107893. /**
  107894. * Attach the sound to a dedicated mesh
  107895. * @param transformNode The transform node to connect the sound with
  107896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107897. */
  107898. attachToMesh(transformNode: TransformNode): void;
  107899. /**
  107900. * Detach the sound from the previously attached mesh
  107901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107902. */
  107903. detachFromMesh(): void;
  107904. private _onRegisterAfterWorldMatrixUpdate;
  107905. /**
  107906. * Clone the current sound in the scene.
  107907. * @returns the new sound clone
  107908. */
  107909. clone(): Nullable<Sound>;
  107910. /**
  107911. * Gets the current underlying audio buffer containing the data
  107912. * @returns the audio buffer
  107913. */
  107914. getAudioBuffer(): Nullable<AudioBuffer>;
  107915. /**
  107916. * Serializes the Sound in a JSON representation
  107917. * @returns the JSON representation of the sound
  107918. */
  107919. serialize(): any;
  107920. /**
  107921. * Parse a JSON representation of a sound to innstantiate in a given scene
  107922. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  107923. * @param scene Define the scene the new parsed sound should be created in
  107924. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  107925. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  107926. * @returns the newly parsed sound
  107927. */
  107928. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  107929. }
  107930. }
  107931. declare module BABYLON {
  107932. /**
  107933. * This defines an action helpful to play a defined sound on a triggered action.
  107934. */
  107935. export class PlaySoundAction extends Action {
  107936. private _sound;
  107937. /**
  107938. * Instantiate the action
  107939. * @param triggerOptions defines the trigger options
  107940. * @param sound defines the sound to play
  107941. * @param condition defines the trigger related conditions
  107942. */
  107943. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107944. /** @hidden */
  107945. _prepare(): void;
  107946. /**
  107947. * Execute the action and play the sound.
  107948. */
  107949. execute(): void;
  107950. /**
  107951. * Serializes the actions and its related information.
  107952. * @param parent defines the object to serialize in
  107953. * @returns the serialized object
  107954. */
  107955. serialize(parent: any): any;
  107956. }
  107957. /**
  107958. * This defines an action helpful to stop a defined sound on a triggered action.
  107959. */
  107960. export class StopSoundAction extends Action {
  107961. private _sound;
  107962. /**
  107963. * Instantiate the action
  107964. * @param triggerOptions defines the trigger options
  107965. * @param sound defines the sound to stop
  107966. * @param condition defines the trigger related conditions
  107967. */
  107968. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107969. /** @hidden */
  107970. _prepare(): void;
  107971. /**
  107972. * Execute the action and stop the sound.
  107973. */
  107974. execute(): void;
  107975. /**
  107976. * Serializes the actions and its related information.
  107977. * @param parent defines the object to serialize in
  107978. * @returns the serialized object
  107979. */
  107980. serialize(parent: any): any;
  107981. }
  107982. }
  107983. declare module BABYLON {
  107984. /**
  107985. * This defines an action responsible to change the value of a property
  107986. * by interpolating between its current value and the newly set one once triggered.
  107987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  107988. */
  107989. export class InterpolateValueAction extends Action {
  107990. /**
  107991. * Defines the path of the property where the value should be interpolated
  107992. */
  107993. propertyPath: string;
  107994. /**
  107995. * Defines the target value at the end of the interpolation.
  107996. */
  107997. value: any;
  107998. /**
  107999. * Defines the time it will take for the property to interpolate to the value.
  108000. */
  108001. duration: number;
  108002. /**
  108003. * Defines if the other scene animations should be stopped when the action has been triggered
  108004. */
  108005. stopOtherAnimations?: boolean;
  108006. /**
  108007. * Defines a callback raised once the interpolation animation has been done.
  108008. */
  108009. onInterpolationDone?: () => void;
  108010. /**
  108011. * Observable triggered once the interpolation animation has been done.
  108012. */
  108013. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  108014. private _target;
  108015. private _effectiveTarget;
  108016. private _property;
  108017. /**
  108018. * Instantiate the action
  108019. * @param triggerOptions defines the trigger options
  108020. * @param target defines the object containing the value to interpolate
  108021. * @param propertyPath defines the path to the property in the target object
  108022. * @param value defines the target value at the end of the interpolation
  108023. * @param duration deines the time it will take for the property to interpolate to the value.
  108024. * @param condition defines the trigger related conditions
  108025. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  108026. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  108027. */
  108028. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  108029. /** @hidden */
  108030. _prepare(): void;
  108031. /**
  108032. * Execute the action starts the value interpolation.
  108033. */
  108034. execute(): void;
  108035. /**
  108036. * Serializes the actions and its related information.
  108037. * @param parent defines the object to serialize in
  108038. * @returns the serialized object
  108039. */
  108040. serialize(parent: any): any;
  108041. }
  108042. }
  108043. declare module BABYLON {
  108044. /**
  108045. * Options allowed during the creation of a sound track.
  108046. */
  108047. export interface ISoundTrackOptions {
  108048. /**
  108049. * The volume the sound track should take during creation
  108050. */
  108051. volume?: number;
  108052. /**
  108053. * Define if the sound track is the main sound track of the scene
  108054. */
  108055. mainTrack?: boolean;
  108056. }
  108057. /**
  108058. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  108059. * It will be also used in a future release to apply effects on a specific track.
  108060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108061. */
  108062. export class SoundTrack {
  108063. /**
  108064. * The unique identifier of the sound track in the scene.
  108065. */
  108066. id: number;
  108067. /**
  108068. * The list of sounds included in the sound track.
  108069. */
  108070. soundCollection: Array<Sound>;
  108071. private _outputAudioNode;
  108072. private _scene;
  108073. private _connectedAnalyser;
  108074. private _options;
  108075. private _isInitialized;
  108076. /**
  108077. * Creates a new sound track.
  108078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108079. * @param scene Define the scene the sound track belongs to
  108080. * @param options
  108081. */
  108082. constructor(scene: Scene, options?: ISoundTrackOptions);
  108083. private _initializeSoundTrackAudioGraph;
  108084. /**
  108085. * Release the sound track and its associated resources
  108086. */
  108087. dispose(): void;
  108088. /**
  108089. * Adds a sound to this sound track
  108090. * @param sound define the cound to add
  108091. * @ignoreNaming
  108092. */
  108093. AddSound(sound: Sound): void;
  108094. /**
  108095. * Removes a sound to this sound track
  108096. * @param sound define the cound to remove
  108097. * @ignoreNaming
  108098. */
  108099. RemoveSound(sound: Sound): void;
  108100. /**
  108101. * Set a global volume for the full sound track.
  108102. * @param newVolume Define the new volume of the sound track
  108103. */
  108104. setVolume(newVolume: number): void;
  108105. /**
  108106. * Switch the panning model to HRTF:
  108107. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  108108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108109. */
  108110. switchPanningModelToHRTF(): void;
  108111. /**
  108112. * Switch the panning model to Equal Power:
  108113. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  108114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108115. */
  108116. switchPanningModelToEqualPower(): void;
  108117. /**
  108118. * Connect the sound track to an audio analyser allowing some amazing
  108119. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  108120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  108121. * @param analyser The analyser to connect to the engine
  108122. */
  108123. connectToAnalyser(analyser: Analyser): void;
  108124. }
  108125. }
  108126. declare module BABYLON {
  108127. interface AbstractScene {
  108128. /**
  108129. * The list of sounds used in the scene.
  108130. */
  108131. sounds: Nullable<Array<Sound>>;
  108132. }
  108133. interface Scene {
  108134. /**
  108135. * @hidden
  108136. * Backing field
  108137. */
  108138. _mainSoundTrack: SoundTrack;
  108139. /**
  108140. * The main sound track played by the scene.
  108141. * It cotains your primary collection of sounds.
  108142. */
  108143. mainSoundTrack: SoundTrack;
  108144. /**
  108145. * The list of sound tracks added to the scene
  108146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108147. */
  108148. soundTracks: Nullable<Array<SoundTrack>>;
  108149. /**
  108150. * Gets a sound using a given name
  108151. * @param name defines the name to search for
  108152. * @return the found sound or null if not found at all.
  108153. */
  108154. getSoundByName(name: string): Nullable<Sound>;
  108155. /**
  108156. * Gets or sets if audio support is enabled
  108157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108158. */
  108159. audioEnabled: boolean;
  108160. /**
  108161. * Gets or sets if audio will be output to headphones
  108162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108163. */
  108164. headphone: boolean;
  108165. /**
  108166. * Gets or sets custom audio listener position provider
  108167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108168. */
  108169. audioListenerPositionProvider: Nullable<() => Vector3>;
  108170. /**
  108171. * Gets or sets a refresh rate when using 3D audio positioning
  108172. */
  108173. audioPositioningRefreshRate: number;
  108174. }
  108175. /**
  108176. * Defines the sound scene component responsible to manage any sounds
  108177. * in a given scene.
  108178. */
  108179. export class AudioSceneComponent implements ISceneSerializableComponent {
  108180. /**
  108181. * The component name helpfull to identify the component in the list of scene components.
  108182. */
  108183. readonly name: string;
  108184. /**
  108185. * The scene the component belongs to.
  108186. */
  108187. scene: Scene;
  108188. private _audioEnabled;
  108189. /**
  108190. * Gets whether audio is enabled or not.
  108191. * Please use related enable/disable method to switch state.
  108192. */
  108193. get audioEnabled(): boolean;
  108194. private _headphone;
  108195. /**
  108196. * Gets whether audio is outputing to headphone or not.
  108197. * Please use the according Switch methods to change output.
  108198. */
  108199. get headphone(): boolean;
  108200. /**
  108201. * Gets or sets a refresh rate when using 3D audio positioning
  108202. */
  108203. audioPositioningRefreshRate: number;
  108204. private _audioListenerPositionProvider;
  108205. /**
  108206. * Gets the current audio listener position provider
  108207. */
  108208. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  108209. /**
  108210. * Sets a custom listener position for all sounds in the scene
  108211. * By default, this is the position of the first active camera
  108212. */
  108213. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  108214. /**
  108215. * Creates a new instance of the component for the given scene
  108216. * @param scene Defines the scene to register the component in
  108217. */
  108218. constructor(scene: Scene);
  108219. /**
  108220. * Registers the component in a given scene
  108221. */
  108222. register(): void;
  108223. /**
  108224. * Rebuilds the elements related to this component in case of
  108225. * context lost for instance.
  108226. */
  108227. rebuild(): void;
  108228. /**
  108229. * Serializes the component data to the specified json object
  108230. * @param serializationObject The object to serialize to
  108231. */
  108232. serialize(serializationObject: any): void;
  108233. /**
  108234. * Adds all the elements from the container to the scene
  108235. * @param container the container holding the elements
  108236. */
  108237. addFromContainer(container: AbstractScene): void;
  108238. /**
  108239. * Removes all the elements in the container from the scene
  108240. * @param container contains the elements to remove
  108241. * @param dispose if the removed element should be disposed (default: false)
  108242. */
  108243. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108244. /**
  108245. * Disposes the component and the associated ressources.
  108246. */
  108247. dispose(): void;
  108248. /**
  108249. * Disables audio in the associated scene.
  108250. */
  108251. disableAudio(): void;
  108252. /**
  108253. * Enables audio in the associated scene.
  108254. */
  108255. enableAudio(): void;
  108256. /**
  108257. * Switch audio to headphone output.
  108258. */
  108259. switchAudioModeForHeadphones(): void;
  108260. /**
  108261. * Switch audio to normal speakers.
  108262. */
  108263. switchAudioModeForNormalSpeakers(): void;
  108264. private _cachedCameraDirection;
  108265. private _cachedCameraPosition;
  108266. private _lastCheck;
  108267. private _afterRender;
  108268. }
  108269. }
  108270. declare module BABYLON {
  108271. /**
  108272. * Wraps one or more Sound objects and selects one with random weight for playback.
  108273. */
  108274. export class WeightedSound {
  108275. /** When true a Sound will be selected and played when the current playing Sound completes. */
  108276. loop: boolean;
  108277. private _coneInnerAngle;
  108278. private _coneOuterAngle;
  108279. private _volume;
  108280. /** A Sound is currently playing. */
  108281. isPlaying: boolean;
  108282. /** A Sound is currently paused. */
  108283. isPaused: boolean;
  108284. private _sounds;
  108285. private _weights;
  108286. private _currentIndex?;
  108287. /**
  108288. * Creates a new WeightedSound from the list of sounds given.
  108289. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  108290. * @param sounds Array of Sounds that will be selected from.
  108291. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  108292. */
  108293. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  108294. /**
  108295. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  108296. */
  108297. get directionalConeInnerAngle(): number;
  108298. /**
  108299. * The size of cone in degress for a directional sound in which there will be no attenuation.
  108300. */
  108301. set directionalConeInnerAngle(value: number);
  108302. /**
  108303. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108304. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108305. */
  108306. get directionalConeOuterAngle(): number;
  108307. /**
  108308. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108309. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108310. */
  108311. set directionalConeOuterAngle(value: number);
  108312. /**
  108313. * Playback volume.
  108314. */
  108315. get volume(): number;
  108316. /**
  108317. * Playback volume.
  108318. */
  108319. set volume(value: number);
  108320. private _onended;
  108321. /**
  108322. * Suspend playback
  108323. */
  108324. pause(): void;
  108325. /**
  108326. * Stop playback
  108327. */
  108328. stop(): void;
  108329. /**
  108330. * Start playback.
  108331. * @param startOffset Position the clip head at a specific time in seconds.
  108332. */
  108333. play(startOffset?: number): void;
  108334. }
  108335. }
  108336. declare module BABYLON {
  108337. /**
  108338. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  108339. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  108340. */
  108341. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  108342. /**
  108343. * Gets the name of the behavior.
  108344. */
  108345. get name(): string;
  108346. /**
  108347. * The easing function used by animations
  108348. */
  108349. static EasingFunction: BackEase;
  108350. /**
  108351. * The easing mode used by animations
  108352. */
  108353. static EasingMode: number;
  108354. /**
  108355. * The duration of the animation, in milliseconds
  108356. */
  108357. transitionDuration: number;
  108358. /**
  108359. * Length of the distance animated by the transition when lower radius is reached
  108360. */
  108361. lowerRadiusTransitionRange: number;
  108362. /**
  108363. * Length of the distance animated by the transition when upper radius is reached
  108364. */
  108365. upperRadiusTransitionRange: number;
  108366. private _autoTransitionRange;
  108367. /**
  108368. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108369. */
  108370. get autoTransitionRange(): boolean;
  108371. /**
  108372. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108373. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  108374. */
  108375. set autoTransitionRange(value: boolean);
  108376. private _attachedCamera;
  108377. private _onAfterCheckInputsObserver;
  108378. private _onMeshTargetChangedObserver;
  108379. /**
  108380. * Initializes the behavior.
  108381. */
  108382. init(): void;
  108383. /**
  108384. * Attaches the behavior to its arc rotate camera.
  108385. * @param camera Defines the camera to attach the behavior to
  108386. */
  108387. attach(camera: ArcRotateCamera): void;
  108388. /**
  108389. * Detaches the behavior from its current arc rotate camera.
  108390. */
  108391. detach(): void;
  108392. private _radiusIsAnimating;
  108393. private _radiusBounceTransition;
  108394. private _animatables;
  108395. private _cachedWheelPrecision;
  108396. /**
  108397. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  108398. * @param radiusLimit The limit to check against.
  108399. * @return Bool to indicate if at limit.
  108400. */
  108401. private _isRadiusAtLimit;
  108402. /**
  108403. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  108404. * @param radiusDelta The delta by which to animate to. Can be negative.
  108405. */
  108406. private _applyBoundRadiusAnimation;
  108407. /**
  108408. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  108409. */
  108410. protected _clearAnimationLocks(): void;
  108411. /**
  108412. * Stops and removes all animations that have been applied to the camera
  108413. */
  108414. stopAllAnimations(): void;
  108415. }
  108416. }
  108417. declare module BABYLON {
  108418. /**
  108419. * 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.
  108420. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  108421. */
  108422. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  108423. /**
  108424. * Gets the name of the behavior.
  108425. */
  108426. get name(): string;
  108427. private _mode;
  108428. private _radiusScale;
  108429. private _positionScale;
  108430. private _defaultElevation;
  108431. private _elevationReturnTime;
  108432. private _elevationReturnWaitTime;
  108433. private _zoomStopsAnimation;
  108434. private _framingTime;
  108435. /**
  108436. * The easing function used by animations
  108437. */
  108438. static EasingFunction: ExponentialEase;
  108439. /**
  108440. * The easing mode used by animations
  108441. */
  108442. static EasingMode: number;
  108443. /**
  108444. * Sets the current mode used by the behavior
  108445. */
  108446. set mode(mode: number);
  108447. /**
  108448. * Gets current mode used by the behavior.
  108449. */
  108450. get mode(): number;
  108451. /**
  108452. * Sets the scale applied to the radius (1 by default)
  108453. */
  108454. set radiusScale(radius: number);
  108455. /**
  108456. * Gets the scale applied to the radius
  108457. */
  108458. get radiusScale(): number;
  108459. /**
  108460. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108461. */
  108462. set positionScale(scale: number);
  108463. /**
  108464. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108465. */
  108466. get positionScale(): number;
  108467. /**
  108468. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108469. * behaviour is triggered, in radians.
  108470. */
  108471. set defaultElevation(elevation: number);
  108472. /**
  108473. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108474. * behaviour is triggered, in radians.
  108475. */
  108476. get defaultElevation(): number;
  108477. /**
  108478. * Sets the time (in milliseconds) taken to return to the default beta position.
  108479. * Negative value indicates camera should not return to default.
  108480. */
  108481. set elevationReturnTime(speed: number);
  108482. /**
  108483. * Gets the time (in milliseconds) taken to return to the default beta position.
  108484. * Negative value indicates camera should not return to default.
  108485. */
  108486. get elevationReturnTime(): number;
  108487. /**
  108488. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108489. */
  108490. set elevationReturnWaitTime(time: number);
  108491. /**
  108492. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108493. */
  108494. get elevationReturnWaitTime(): number;
  108495. /**
  108496. * Sets the flag that indicates if user zooming should stop animation.
  108497. */
  108498. set zoomStopsAnimation(flag: boolean);
  108499. /**
  108500. * Gets the flag that indicates if user zooming should stop animation.
  108501. */
  108502. get zoomStopsAnimation(): boolean;
  108503. /**
  108504. * Sets the transition time when framing the mesh, in milliseconds
  108505. */
  108506. set framingTime(time: number);
  108507. /**
  108508. * Gets the transition time when framing the mesh, in milliseconds
  108509. */
  108510. get framingTime(): number;
  108511. /**
  108512. * Define if the behavior should automatically change the configured
  108513. * camera limits and sensibilities.
  108514. */
  108515. autoCorrectCameraLimitsAndSensibility: boolean;
  108516. private _onPrePointerObservableObserver;
  108517. private _onAfterCheckInputsObserver;
  108518. private _onMeshTargetChangedObserver;
  108519. private _attachedCamera;
  108520. private _isPointerDown;
  108521. private _lastInteractionTime;
  108522. /**
  108523. * Initializes the behavior.
  108524. */
  108525. init(): void;
  108526. /**
  108527. * Attaches the behavior to its arc rotate camera.
  108528. * @param camera Defines the camera to attach the behavior to
  108529. */
  108530. attach(camera: ArcRotateCamera): void;
  108531. /**
  108532. * Detaches the behavior from its current arc rotate camera.
  108533. */
  108534. detach(): void;
  108535. private _animatables;
  108536. private _betaIsAnimating;
  108537. private _betaTransition;
  108538. private _radiusTransition;
  108539. private _vectorTransition;
  108540. /**
  108541. * Targets the given mesh and updates zoom level accordingly.
  108542. * @param mesh The mesh to target.
  108543. * @param radius Optional. If a cached radius position already exists, overrides default.
  108544. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108545. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108546. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108547. */
  108548. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108549. /**
  108550. * Targets the given mesh with its children and updates zoom level accordingly.
  108551. * @param mesh The mesh to target.
  108552. * @param radius Optional. If a cached radius position already exists, overrides default.
  108553. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108554. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108555. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108556. */
  108557. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108558. /**
  108559. * Targets the given meshes with their children and updates zoom level accordingly.
  108560. * @param meshes The mesh to target.
  108561. * @param radius Optional. If a cached radius position already exists, overrides default.
  108562. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108563. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108564. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108565. */
  108566. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108567. /**
  108568. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  108569. * @param minimumWorld Determines the smaller position of the bounding box extend
  108570. * @param maximumWorld Determines the bigger position of the bounding box extend
  108571. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108572. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108573. */
  108574. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108575. /**
  108576. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  108577. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  108578. * frustum width.
  108579. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  108580. * to fully enclose the mesh in the viewing frustum.
  108581. */
  108582. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  108583. /**
  108584. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  108585. * is automatically returned to its default position (expected to be above ground plane).
  108586. */
  108587. private _maintainCameraAboveGround;
  108588. /**
  108589. * Returns the frustum slope based on the canvas ratio and camera FOV
  108590. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  108591. */
  108592. private _getFrustumSlope;
  108593. /**
  108594. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  108595. */
  108596. private _clearAnimationLocks;
  108597. /**
  108598. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  108599. */
  108600. private _applyUserInteraction;
  108601. /**
  108602. * Stops and removes all animations that have been applied to the camera
  108603. */
  108604. stopAllAnimations(): void;
  108605. /**
  108606. * Gets a value indicating if the user is moving the camera
  108607. */
  108608. get isUserIsMoving(): boolean;
  108609. /**
  108610. * The camera can move all the way towards the mesh.
  108611. */
  108612. static IgnoreBoundsSizeMode: number;
  108613. /**
  108614. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  108615. */
  108616. static FitFrustumSidesMode: number;
  108617. }
  108618. }
  108619. declare module BABYLON {
  108620. /**
  108621. * Base class for Camera Pointer Inputs.
  108622. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  108623. * for example usage.
  108624. */
  108625. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  108626. /**
  108627. * Defines the camera the input is attached to.
  108628. */
  108629. abstract camera: Camera;
  108630. /**
  108631. * Whether keyboard modifier keys are pressed at time of last mouse event.
  108632. */
  108633. protected _altKey: boolean;
  108634. protected _ctrlKey: boolean;
  108635. protected _metaKey: boolean;
  108636. protected _shiftKey: boolean;
  108637. /**
  108638. * Which mouse buttons were pressed at time of last mouse event.
  108639. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  108640. */
  108641. protected _buttonsPressed: number;
  108642. /**
  108643. * Defines the buttons associated with the input to handle camera move.
  108644. */
  108645. buttons: number[];
  108646. /**
  108647. * Attach the input controls to a specific dom element to get the input from.
  108648. * @param element Defines the element the controls should be listened from
  108649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108650. */
  108651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108652. /**
  108653. * Detach the current controls from the specified dom element.
  108654. * @param element Defines the element to stop listening the inputs from
  108655. */
  108656. detachControl(element: Nullable<HTMLElement>): void;
  108657. /**
  108658. * Gets the class name of the current input.
  108659. * @returns the class name
  108660. */
  108661. getClassName(): string;
  108662. /**
  108663. * Get the friendly name associated with the input class.
  108664. * @returns the input friendly name
  108665. */
  108666. getSimpleName(): string;
  108667. /**
  108668. * Called on pointer POINTERDOUBLETAP event.
  108669. * Override this method to provide functionality on POINTERDOUBLETAP event.
  108670. */
  108671. protected onDoubleTap(type: string): void;
  108672. /**
  108673. * Called on pointer POINTERMOVE event if only a single touch is active.
  108674. * Override this method to provide functionality.
  108675. */
  108676. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108677. /**
  108678. * Called on pointer POINTERMOVE event if multiple touches are active.
  108679. * Override this method to provide functionality.
  108680. */
  108681. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108682. /**
  108683. * Called on JS contextmenu event.
  108684. * Override this method to provide functionality.
  108685. */
  108686. protected onContextMenu(evt: PointerEvent): void;
  108687. /**
  108688. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108689. * press.
  108690. * Override this method to provide functionality.
  108691. */
  108692. protected onButtonDown(evt: PointerEvent): void;
  108693. /**
  108694. * Called each time a new POINTERUP event occurs. Ie, for each button
  108695. * release.
  108696. * Override this method to provide functionality.
  108697. */
  108698. protected onButtonUp(evt: PointerEvent): void;
  108699. /**
  108700. * Called when window becomes inactive.
  108701. * Override this method to provide functionality.
  108702. */
  108703. protected onLostFocus(): void;
  108704. private _pointerInput;
  108705. private _observer;
  108706. private _onLostFocus;
  108707. private pointA;
  108708. private pointB;
  108709. }
  108710. }
  108711. declare module BABYLON {
  108712. /**
  108713. * Manage the pointers inputs to control an arc rotate camera.
  108714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108715. */
  108716. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  108717. /**
  108718. * Defines the camera the input is attached to.
  108719. */
  108720. camera: ArcRotateCamera;
  108721. /**
  108722. * Gets the class name of the current input.
  108723. * @returns the class name
  108724. */
  108725. getClassName(): string;
  108726. /**
  108727. * Defines the buttons associated with the input to handle camera move.
  108728. */
  108729. buttons: number[];
  108730. /**
  108731. * Defines the pointer angular sensibility along the X axis or how fast is
  108732. * the camera rotating.
  108733. */
  108734. angularSensibilityX: number;
  108735. /**
  108736. * Defines the pointer angular sensibility along the Y axis or how fast is
  108737. * the camera rotating.
  108738. */
  108739. angularSensibilityY: number;
  108740. /**
  108741. * Defines the pointer pinch precision or how fast is the camera zooming.
  108742. */
  108743. pinchPrecision: number;
  108744. /**
  108745. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108746. * from 0.
  108747. * It defines the percentage of current camera.radius to use as delta when
  108748. * pinch zoom is used.
  108749. */
  108750. pinchDeltaPercentage: number;
  108751. /**
  108752. * Defines the pointer panning sensibility or how fast is the camera moving.
  108753. */
  108754. panningSensibility: number;
  108755. /**
  108756. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  108757. */
  108758. multiTouchPanning: boolean;
  108759. /**
  108760. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  108761. * zoom (pinch) through multitouch.
  108762. */
  108763. multiTouchPanAndZoom: boolean;
  108764. /**
  108765. * Revers pinch action direction.
  108766. */
  108767. pinchInwards: boolean;
  108768. private _isPanClick;
  108769. private _twoFingerActivityCount;
  108770. private _isPinching;
  108771. /**
  108772. * Called on pointer POINTERMOVE event if only a single touch is active.
  108773. */
  108774. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108775. /**
  108776. * Called on pointer POINTERDOUBLETAP event.
  108777. */
  108778. protected onDoubleTap(type: string): void;
  108779. /**
  108780. * Called on pointer POINTERMOVE event if multiple touches are active.
  108781. */
  108782. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108783. /**
  108784. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108785. * press.
  108786. */
  108787. protected onButtonDown(evt: PointerEvent): void;
  108788. /**
  108789. * Called each time a new POINTERUP event occurs. Ie, for each button
  108790. * release.
  108791. */
  108792. protected onButtonUp(evt: PointerEvent): void;
  108793. /**
  108794. * Called when window becomes inactive.
  108795. */
  108796. protected onLostFocus(): void;
  108797. }
  108798. }
  108799. declare module BABYLON {
  108800. /**
  108801. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  108802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108803. */
  108804. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  108805. /**
  108806. * Defines the camera the input is attached to.
  108807. */
  108808. camera: ArcRotateCamera;
  108809. /**
  108810. * Defines the list of key codes associated with the up action (increase alpha)
  108811. */
  108812. keysUp: number[];
  108813. /**
  108814. * Defines the list of key codes associated with the down action (decrease alpha)
  108815. */
  108816. keysDown: number[];
  108817. /**
  108818. * Defines the list of key codes associated with the left action (increase beta)
  108819. */
  108820. keysLeft: number[];
  108821. /**
  108822. * Defines the list of key codes associated with the right action (decrease beta)
  108823. */
  108824. keysRight: number[];
  108825. /**
  108826. * Defines the list of key codes associated with the reset action.
  108827. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  108828. */
  108829. keysReset: number[];
  108830. /**
  108831. * Defines the panning sensibility of the inputs.
  108832. * (How fast is the camera paning)
  108833. */
  108834. panningSensibility: number;
  108835. /**
  108836. * Defines the zooming sensibility of the inputs.
  108837. * (How fast is the camera zooming)
  108838. */
  108839. zoomingSensibility: number;
  108840. /**
  108841. * Defines wether maintaining the alt key down switch the movement mode from
  108842. * orientation to zoom.
  108843. */
  108844. useAltToZoom: boolean;
  108845. /**
  108846. * Rotation speed of the camera
  108847. */
  108848. angularSpeed: number;
  108849. private _keys;
  108850. private _ctrlPressed;
  108851. private _altPressed;
  108852. private _onCanvasBlurObserver;
  108853. private _onKeyboardObserver;
  108854. private _engine;
  108855. private _scene;
  108856. /**
  108857. * Attach the input controls to a specific dom element to get the input from.
  108858. * @param element Defines the element the controls should be listened from
  108859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108860. */
  108861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108862. /**
  108863. * Detach the current controls from the specified dom element.
  108864. * @param element Defines the element to stop listening the inputs from
  108865. */
  108866. detachControl(element: Nullable<HTMLElement>): void;
  108867. /**
  108868. * Update the current camera state depending on the inputs that have been used this frame.
  108869. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108870. */
  108871. checkInputs(): void;
  108872. /**
  108873. * Gets the class name of the current intput.
  108874. * @returns the class name
  108875. */
  108876. getClassName(): string;
  108877. /**
  108878. * Get the friendly name associated with the input class.
  108879. * @returns the input friendly name
  108880. */
  108881. getSimpleName(): string;
  108882. }
  108883. }
  108884. declare module BABYLON {
  108885. /**
  108886. * Manage the mouse wheel inputs to control an arc rotate camera.
  108887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108888. */
  108889. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  108890. /**
  108891. * Defines the camera the input is attached to.
  108892. */
  108893. camera: ArcRotateCamera;
  108894. /**
  108895. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108896. */
  108897. wheelPrecision: number;
  108898. /**
  108899. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108900. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108901. */
  108902. wheelDeltaPercentage: number;
  108903. private _wheel;
  108904. private _observer;
  108905. private computeDeltaFromMouseWheelLegacyEvent;
  108906. /**
  108907. * Attach the input controls to a specific dom element to get the input from.
  108908. * @param element Defines the element the controls should be listened from
  108909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108910. */
  108911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108912. /**
  108913. * Detach the current controls from the specified dom element.
  108914. * @param element Defines the element to stop listening the inputs from
  108915. */
  108916. detachControl(element: Nullable<HTMLElement>): void;
  108917. /**
  108918. * Gets the class name of the current intput.
  108919. * @returns the class name
  108920. */
  108921. getClassName(): string;
  108922. /**
  108923. * Get the friendly name associated with the input class.
  108924. * @returns the input friendly name
  108925. */
  108926. getSimpleName(): string;
  108927. }
  108928. }
  108929. declare module BABYLON {
  108930. /**
  108931. * Default Inputs manager for the ArcRotateCamera.
  108932. * It groups all the default supported inputs for ease of use.
  108933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108934. */
  108935. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  108936. /**
  108937. * Instantiates a new ArcRotateCameraInputsManager.
  108938. * @param camera Defines the camera the inputs belong to
  108939. */
  108940. constructor(camera: ArcRotateCamera);
  108941. /**
  108942. * Add mouse wheel input support to the input manager.
  108943. * @returns the current input manager
  108944. */
  108945. addMouseWheel(): ArcRotateCameraInputsManager;
  108946. /**
  108947. * Add pointers input support to the input manager.
  108948. * @returns the current input manager
  108949. */
  108950. addPointers(): ArcRotateCameraInputsManager;
  108951. /**
  108952. * Add keyboard input support to the input manager.
  108953. * @returns the current input manager
  108954. */
  108955. addKeyboard(): ArcRotateCameraInputsManager;
  108956. }
  108957. }
  108958. declare module BABYLON {
  108959. /**
  108960. * This represents an orbital type of camera.
  108961. *
  108962. * 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.
  108963. * 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.
  108964. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  108965. */
  108966. export class ArcRotateCamera extends TargetCamera {
  108967. /**
  108968. * Defines the rotation angle of the camera along the longitudinal axis.
  108969. */
  108970. alpha: number;
  108971. /**
  108972. * Defines the rotation angle of the camera along the latitudinal axis.
  108973. */
  108974. beta: number;
  108975. /**
  108976. * Defines the radius of the camera from it s target point.
  108977. */
  108978. radius: number;
  108979. protected _target: Vector3;
  108980. protected _targetHost: Nullable<AbstractMesh>;
  108981. /**
  108982. * Defines the target point of the camera.
  108983. * The camera looks towards it form the radius distance.
  108984. */
  108985. get target(): Vector3;
  108986. set target(value: Vector3);
  108987. /**
  108988. * Define the current local position of the camera in the scene
  108989. */
  108990. get position(): Vector3;
  108991. set position(newPosition: Vector3);
  108992. protected _upVector: Vector3;
  108993. protected _upToYMatrix: Matrix;
  108994. protected _YToUpMatrix: Matrix;
  108995. /**
  108996. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  108997. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  108998. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  108999. */
  109000. set upVector(vec: Vector3);
  109001. get upVector(): Vector3;
  109002. /**
  109003. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  109004. */
  109005. setMatUp(): void;
  109006. /**
  109007. * Current inertia value on the longitudinal axis.
  109008. * The bigger this number the longer it will take for the camera to stop.
  109009. */
  109010. inertialAlphaOffset: number;
  109011. /**
  109012. * Current inertia value on the latitudinal axis.
  109013. * The bigger this number the longer it will take for the camera to stop.
  109014. */
  109015. inertialBetaOffset: number;
  109016. /**
  109017. * Current inertia value on the radius axis.
  109018. * The bigger this number the longer it will take for the camera to stop.
  109019. */
  109020. inertialRadiusOffset: number;
  109021. /**
  109022. * Minimum allowed angle on the longitudinal axis.
  109023. * This can help limiting how the Camera is able to move in the scene.
  109024. */
  109025. lowerAlphaLimit: Nullable<number>;
  109026. /**
  109027. * Maximum allowed angle on the longitudinal axis.
  109028. * This can help limiting how the Camera is able to move in the scene.
  109029. */
  109030. upperAlphaLimit: Nullable<number>;
  109031. /**
  109032. * Minimum allowed angle on the latitudinal axis.
  109033. * This can help limiting how the Camera is able to move in the scene.
  109034. */
  109035. lowerBetaLimit: number;
  109036. /**
  109037. * Maximum allowed angle on the latitudinal axis.
  109038. * This can help limiting how the Camera is able to move in the scene.
  109039. */
  109040. upperBetaLimit: number;
  109041. /**
  109042. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  109043. * This can help limiting how the Camera is able to move in the scene.
  109044. */
  109045. lowerRadiusLimit: Nullable<number>;
  109046. /**
  109047. * Maximum allowed distance of the camera to the target (The camera can not get further).
  109048. * This can help limiting how the Camera is able to move in the scene.
  109049. */
  109050. upperRadiusLimit: Nullable<number>;
  109051. /**
  109052. * Defines the current inertia value used during panning of the camera along the X axis.
  109053. */
  109054. inertialPanningX: number;
  109055. /**
  109056. * Defines the current inertia value used during panning of the camera along the Y axis.
  109057. */
  109058. inertialPanningY: number;
  109059. /**
  109060. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  109061. * Basically if your fingers moves away from more than this distance you will be considered
  109062. * in pinch mode.
  109063. */
  109064. pinchToPanMaxDistance: number;
  109065. /**
  109066. * Defines the maximum distance the camera can pan.
  109067. * This could help keeping the cammera always in your scene.
  109068. */
  109069. panningDistanceLimit: Nullable<number>;
  109070. /**
  109071. * Defines the target of the camera before paning.
  109072. */
  109073. panningOriginTarget: Vector3;
  109074. /**
  109075. * Defines the value of the inertia used during panning.
  109076. * 0 would mean stop inertia and one would mean no decelleration at all.
  109077. */
  109078. panningInertia: number;
  109079. /**
  109080. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  109081. */
  109082. get angularSensibilityX(): number;
  109083. set angularSensibilityX(value: number);
  109084. /**
  109085. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  109086. */
  109087. get angularSensibilityY(): number;
  109088. set angularSensibilityY(value: number);
  109089. /**
  109090. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  109091. */
  109092. get pinchPrecision(): number;
  109093. set pinchPrecision(value: number);
  109094. /**
  109095. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  109096. * It will be used instead of pinchDeltaPrecision if different from 0.
  109097. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109098. */
  109099. get pinchDeltaPercentage(): number;
  109100. set pinchDeltaPercentage(value: number);
  109101. /**
  109102. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  109103. */
  109104. get panningSensibility(): number;
  109105. set panningSensibility(value: number);
  109106. /**
  109107. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  109108. */
  109109. get keysUp(): number[];
  109110. set keysUp(value: number[]);
  109111. /**
  109112. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  109113. */
  109114. get keysDown(): number[];
  109115. set keysDown(value: number[]);
  109116. /**
  109117. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  109118. */
  109119. get keysLeft(): number[];
  109120. set keysLeft(value: number[]);
  109121. /**
  109122. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  109123. */
  109124. get keysRight(): number[];
  109125. set keysRight(value: number[]);
  109126. /**
  109127. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  109128. */
  109129. get wheelPrecision(): number;
  109130. set wheelPrecision(value: number);
  109131. /**
  109132. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  109133. * It will be used instead of pinchDeltaPrecision if different from 0.
  109134. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109135. */
  109136. get wheelDeltaPercentage(): number;
  109137. set wheelDeltaPercentage(value: number);
  109138. /**
  109139. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  109140. */
  109141. zoomOnFactor: number;
  109142. /**
  109143. * Defines a screen offset for the camera position.
  109144. */
  109145. targetScreenOffset: Vector2;
  109146. /**
  109147. * Allows the camera to be completely reversed.
  109148. * If false the camera can not arrive upside down.
  109149. */
  109150. allowUpsideDown: boolean;
  109151. /**
  109152. * Define if double tap/click is used to restore the previously saved state of the camera.
  109153. */
  109154. useInputToRestoreState: boolean;
  109155. /** @hidden */
  109156. _viewMatrix: Matrix;
  109157. /** @hidden */
  109158. _useCtrlForPanning: boolean;
  109159. /** @hidden */
  109160. _panningMouseButton: number;
  109161. /**
  109162. * Defines the input associated to the camera.
  109163. */
  109164. inputs: ArcRotateCameraInputsManager;
  109165. /** @hidden */
  109166. _reset: () => void;
  109167. /**
  109168. * Defines the allowed panning axis.
  109169. */
  109170. panningAxis: Vector3;
  109171. protected _localDirection: Vector3;
  109172. protected _transformedDirection: Vector3;
  109173. private _bouncingBehavior;
  109174. /**
  109175. * Gets the bouncing behavior of the camera if it has been enabled.
  109176. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109177. */
  109178. get bouncingBehavior(): Nullable<BouncingBehavior>;
  109179. /**
  109180. * Defines if the bouncing behavior of the camera is enabled on the camera.
  109181. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109182. */
  109183. get useBouncingBehavior(): boolean;
  109184. set useBouncingBehavior(value: boolean);
  109185. private _framingBehavior;
  109186. /**
  109187. * Gets the framing behavior of the camera if it has been enabled.
  109188. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109189. */
  109190. get framingBehavior(): Nullable<FramingBehavior>;
  109191. /**
  109192. * Defines if the framing behavior of the camera is enabled on the camera.
  109193. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109194. */
  109195. get useFramingBehavior(): boolean;
  109196. set useFramingBehavior(value: boolean);
  109197. private _autoRotationBehavior;
  109198. /**
  109199. * Gets the auto rotation behavior of the camera if it has been enabled.
  109200. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109201. */
  109202. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  109203. /**
  109204. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  109205. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109206. */
  109207. get useAutoRotationBehavior(): boolean;
  109208. set useAutoRotationBehavior(value: boolean);
  109209. /**
  109210. * Observable triggered when the mesh target has been changed on the camera.
  109211. */
  109212. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  109213. /**
  109214. * Event raised when the camera is colliding with a mesh.
  109215. */
  109216. onCollide: (collidedMesh: AbstractMesh) => void;
  109217. /**
  109218. * Defines whether the camera should check collision with the objects oh the scene.
  109219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  109220. */
  109221. checkCollisions: boolean;
  109222. /**
  109223. * Defines the collision radius of the camera.
  109224. * This simulates a sphere around the camera.
  109225. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109226. */
  109227. collisionRadius: Vector3;
  109228. protected _collider: Collider;
  109229. protected _previousPosition: Vector3;
  109230. protected _collisionVelocity: Vector3;
  109231. protected _newPosition: Vector3;
  109232. protected _previousAlpha: number;
  109233. protected _previousBeta: number;
  109234. protected _previousRadius: number;
  109235. protected _collisionTriggered: boolean;
  109236. protected _targetBoundingCenter: Nullable<Vector3>;
  109237. private _computationVector;
  109238. /**
  109239. * Instantiates a new ArcRotateCamera in a given scene
  109240. * @param name Defines the name of the camera
  109241. * @param alpha Defines the camera rotation along the logitudinal axis
  109242. * @param beta Defines the camera rotation along the latitudinal axis
  109243. * @param radius Defines the camera distance from its target
  109244. * @param target Defines the camera target
  109245. * @param scene Defines the scene the camera belongs to
  109246. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109247. */
  109248. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109249. /** @hidden */
  109250. _initCache(): void;
  109251. /** @hidden */
  109252. _updateCache(ignoreParentClass?: boolean): void;
  109253. protected _getTargetPosition(): Vector3;
  109254. private _storedAlpha;
  109255. private _storedBeta;
  109256. private _storedRadius;
  109257. private _storedTarget;
  109258. private _storedTargetScreenOffset;
  109259. /**
  109260. * Stores the current state of the camera (alpha, beta, radius and target)
  109261. * @returns the camera itself
  109262. */
  109263. storeState(): Camera;
  109264. /**
  109265. * @hidden
  109266. * Restored camera state. You must call storeState() first
  109267. */
  109268. _restoreStateValues(): boolean;
  109269. /** @hidden */
  109270. _isSynchronizedViewMatrix(): boolean;
  109271. /**
  109272. * Attached controls to the current camera.
  109273. * @param element Defines the element the controls should be listened from
  109274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109275. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  109276. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  109277. */
  109278. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  109279. /**
  109280. * Detach the current controls from the camera.
  109281. * The camera will stop reacting to inputs.
  109282. * @param element Defines the element to stop listening the inputs from
  109283. */
  109284. detachControl(element: HTMLElement): void;
  109285. /** @hidden */
  109286. _checkInputs(): void;
  109287. protected _checkLimits(): void;
  109288. /**
  109289. * Rebuilds angles (alpha, beta) and radius from the give position and target
  109290. */
  109291. rebuildAnglesAndRadius(): void;
  109292. /**
  109293. * Use a position to define the current camera related information like alpha, beta and radius
  109294. * @param position Defines the position to set the camera at
  109295. */
  109296. setPosition(position: Vector3): void;
  109297. /**
  109298. * Defines the target the camera should look at.
  109299. * This will automatically adapt alpha beta and radius to fit within the new target.
  109300. * @param target Defines the new target as a Vector or a mesh
  109301. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  109302. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  109303. */
  109304. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  109305. /** @hidden */
  109306. _getViewMatrix(): Matrix;
  109307. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  109308. /**
  109309. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  109310. * @param meshes Defines the mesh to zoom on
  109311. * @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)
  109312. */
  109313. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  109314. /**
  109315. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  109316. * The target will be changed but the radius
  109317. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  109318. * @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)
  109319. */
  109320. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  109321. min: Vector3;
  109322. max: Vector3;
  109323. distance: number;
  109324. }, doNotUpdateMaxZ?: boolean): void;
  109325. /**
  109326. * @override
  109327. * Override Camera.createRigCamera
  109328. */
  109329. createRigCamera(name: string, cameraIndex: number): Camera;
  109330. /**
  109331. * @hidden
  109332. * @override
  109333. * Override Camera._updateRigCameras
  109334. */
  109335. _updateRigCameras(): void;
  109336. /**
  109337. * Destroy the camera and release the current resources hold by it.
  109338. */
  109339. dispose(): void;
  109340. /**
  109341. * Gets the current object class name.
  109342. * @return the class name
  109343. */
  109344. getClassName(): string;
  109345. }
  109346. }
  109347. declare module BABYLON {
  109348. /**
  109349. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  109350. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109351. */
  109352. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  109353. /**
  109354. * Gets the name of the behavior.
  109355. */
  109356. get name(): string;
  109357. private _zoomStopsAnimation;
  109358. private _idleRotationSpeed;
  109359. private _idleRotationWaitTime;
  109360. private _idleRotationSpinupTime;
  109361. /**
  109362. * Sets the flag that indicates if user zooming should stop animation.
  109363. */
  109364. set zoomStopsAnimation(flag: boolean);
  109365. /**
  109366. * Gets the flag that indicates if user zooming should stop animation.
  109367. */
  109368. get zoomStopsAnimation(): boolean;
  109369. /**
  109370. * Sets the default speed at which the camera rotates around the model.
  109371. */
  109372. set idleRotationSpeed(speed: number);
  109373. /**
  109374. * Gets the default speed at which the camera rotates around the model.
  109375. */
  109376. get idleRotationSpeed(): number;
  109377. /**
  109378. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  109379. */
  109380. set idleRotationWaitTime(time: number);
  109381. /**
  109382. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  109383. */
  109384. get idleRotationWaitTime(): number;
  109385. /**
  109386. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109387. */
  109388. set idleRotationSpinupTime(time: number);
  109389. /**
  109390. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109391. */
  109392. get idleRotationSpinupTime(): number;
  109393. /**
  109394. * Gets a value indicating if the camera is currently rotating because of this behavior
  109395. */
  109396. get rotationInProgress(): boolean;
  109397. private _onPrePointerObservableObserver;
  109398. private _onAfterCheckInputsObserver;
  109399. private _attachedCamera;
  109400. private _isPointerDown;
  109401. private _lastFrameTime;
  109402. private _lastInteractionTime;
  109403. private _cameraRotationSpeed;
  109404. /**
  109405. * Initializes the behavior.
  109406. */
  109407. init(): void;
  109408. /**
  109409. * Attaches the behavior to its arc rotate camera.
  109410. * @param camera Defines the camera to attach the behavior to
  109411. */
  109412. attach(camera: ArcRotateCamera): void;
  109413. /**
  109414. * Detaches the behavior from its current arc rotate camera.
  109415. */
  109416. detach(): void;
  109417. /**
  109418. * Returns true if user is scrolling.
  109419. * @return true if user is scrolling.
  109420. */
  109421. private _userIsZooming;
  109422. private _lastFrameRadius;
  109423. private _shouldAnimationStopForInteraction;
  109424. /**
  109425. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  109426. */
  109427. private _applyUserInteraction;
  109428. private _userIsMoving;
  109429. }
  109430. }
  109431. declare module BABYLON {
  109432. /**
  109433. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  109434. */
  109435. export class AttachToBoxBehavior implements Behavior<Mesh> {
  109436. private ui;
  109437. /**
  109438. * The name of the behavior
  109439. */
  109440. name: string;
  109441. /**
  109442. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  109443. */
  109444. distanceAwayFromFace: number;
  109445. /**
  109446. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  109447. */
  109448. distanceAwayFromBottomOfFace: number;
  109449. private _faceVectors;
  109450. private _target;
  109451. private _scene;
  109452. private _onRenderObserver;
  109453. private _tmpMatrix;
  109454. private _tmpVector;
  109455. /**
  109456. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  109457. * @param ui The transform node that should be attched to the mesh
  109458. */
  109459. constructor(ui: TransformNode);
  109460. /**
  109461. * Initializes the behavior
  109462. */
  109463. init(): void;
  109464. private _closestFace;
  109465. private _zeroVector;
  109466. private _lookAtTmpMatrix;
  109467. private _lookAtToRef;
  109468. /**
  109469. * Attaches the AttachToBoxBehavior to the passed in mesh
  109470. * @param target The mesh that the specified node will be attached to
  109471. */
  109472. attach(target: Mesh): void;
  109473. /**
  109474. * Detaches the behavior from the mesh
  109475. */
  109476. detach(): void;
  109477. }
  109478. }
  109479. declare module BABYLON {
  109480. /**
  109481. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  109482. */
  109483. export class FadeInOutBehavior implements Behavior<Mesh> {
  109484. /**
  109485. * Time in milliseconds to delay before fading in (Default: 0)
  109486. */
  109487. delay: number;
  109488. /**
  109489. * Time in milliseconds for the mesh to fade in (Default: 300)
  109490. */
  109491. fadeInTime: number;
  109492. private _millisecondsPerFrame;
  109493. private _hovered;
  109494. private _hoverValue;
  109495. private _ownerNode;
  109496. /**
  109497. * Instatiates the FadeInOutBehavior
  109498. */
  109499. constructor();
  109500. /**
  109501. * The name of the behavior
  109502. */
  109503. get name(): string;
  109504. /**
  109505. * Initializes the behavior
  109506. */
  109507. init(): void;
  109508. /**
  109509. * Attaches the fade behavior on the passed in mesh
  109510. * @param ownerNode The mesh that will be faded in/out once attached
  109511. */
  109512. attach(ownerNode: Mesh): void;
  109513. /**
  109514. * Detaches the behavior from the mesh
  109515. */
  109516. detach(): void;
  109517. /**
  109518. * Triggers the mesh to begin fading in or out
  109519. * @param value if the object should fade in or out (true to fade in)
  109520. */
  109521. fadeIn(value: boolean): void;
  109522. private _update;
  109523. private _setAllVisibility;
  109524. }
  109525. }
  109526. declare module BABYLON {
  109527. /**
  109528. * Class containing a set of static utilities functions for managing Pivots
  109529. * @hidden
  109530. */
  109531. export class PivotTools {
  109532. private static _PivotCached;
  109533. private static _OldPivotPoint;
  109534. private static _PivotTranslation;
  109535. private static _PivotTmpVector;
  109536. /** @hidden */
  109537. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  109538. /** @hidden */
  109539. static _RestorePivotPoint(mesh: AbstractMesh): void;
  109540. }
  109541. }
  109542. declare module BABYLON {
  109543. /**
  109544. * Class containing static functions to help procedurally build meshes
  109545. */
  109546. export class PlaneBuilder {
  109547. /**
  109548. * Creates a plane mesh
  109549. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109550. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109551. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109555. * @param name defines the name of the mesh
  109556. * @param options defines the options used to create the mesh
  109557. * @param scene defines the hosting scene
  109558. * @returns the plane mesh
  109559. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109560. */
  109561. static CreatePlane(name: string, options: {
  109562. size?: number;
  109563. width?: number;
  109564. height?: number;
  109565. sideOrientation?: number;
  109566. frontUVs?: Vector4;
  109567. backUVs?: Vector4;
  109568. updatable?: boolean;
  109569. sourcePlane?: Plane;
  109570. }, scene?: Nullable<Scene>): Mesh;
  109571. }
  109572. }
  109573. declare module BABYLON {
  109574. /**
  109575. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  109576. */
  109577. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  109578. private static _AnyMouseID;
  109579. /**
  109580. * Abstract mesh the behavior is set on
  109581. */
  109582. attachedNode: AbstractMesh;
  109583. private _dragPlane;
  109584. private _scene;
  109585. private _pointerObserver;
  109586. private _beforeRenderObserver;
  109587. private static _planeScene;
  109588. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  109589. /**
  109590. * 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)
  109591. */
  109592. maxDragAngle: number;
  109593. /**
  109594. * @hidden
  109595. */
  109596. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  109597. /**
  109598. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109599. */
  109600. currentDraggingPointerID: number;
  109601. /**
  109602. * The last position where the pointer hit the drag plane in world space
  109603. */
  109604. lastDragPosition: Vector3;
  109605. /**
  109606. * If the behavior is currently in a dragging state
  109607. */
  109608. dragging: boolean;
  109609. /**
  109610. * 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)
  109611. */
  109612. dragDeltaRatio: number;
  109613. /**
  109614. * If the drag plane orientation should be updated during the dragging (Default: true)
  109615. */
  109616. updateDragPlane: boolean;
  109617. private _debugMode;
  109618. private _moving;
  109619. /**
  109620. * Fires each time the attached mesh is dragged with the pointer
  109621. * * delta between last drag position and current drag position in world space
  109622. * * dragDistance along the drag axis
  109623. * * dragPlaneNormal normal of the current drag plane used during the drag
  109624. * * dragPlanePoint in world space where the drag intersects the drag plane
  109625. */
  109626. onDragObservable: Observable<{
  109627. delta: Vector3;
  109628. dragPlanePoint: Vector3;
  109629. dragPlaneNormal: Vector3;
  109630. dragDistance: number;
  109631. pointerId: number;
  109632. }>;
  109633. /**
  109634. * Fires each time a drag begins (eg. mouse down on mesh)
  109635. */
  109636. onDragStartObservable: Observable<{
  109637. dragPlanePoint: Vector3;
  109638. pointerId: number;
  109639. }>;
  109640. /**
  109641. * Fires each time a drag ends (eg. mouse release after drag)
  109642. */
  109643. onDragEndObservable: Observable<{
  109644. dragPlanePoint: Vector3;
  109645. pointerId: number;
  109646. }>;
  109647. /**
  109648. * If the attached mesh should be moved when dragged
  109649. */
  109650. moveAttached: boolean;
  109651. /**
  109652. * If the drag behavior will react to drag events (Default: true)
  109653. */
  109654. enabled: boolean;
  109655. /**
  109656. * If pointer events should start and release the drag (Default: true)
  109657. */
  109658. startAndReleaseDragOnPointerEvents: boolean;
  109659. /**
  109660. * If camera controls should be detached during the drag
  109661. */
  109662. detachCameraControls: boolean;
  109663. /**
  109664. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  109665. */
  109666. useObjectOrientationForDragging: boolean;
  109667. private _options;
  109668. /**
  109669. * Gets the options used by the behavior
  109670. */
  109671. get options(): {
  109672. dragAxis?: Vector3;
  109673. dragPlaneNormal?: Vector3;
  109674. };
  109675. /**
  109676. * Sets the options used by the behavior
  109677. */
  109678. set options(options: {
  109679. dragAxis?: Vector3;
  109680. dragPlaneNormal?: Vector3;
  109681. });
  109682. /**
  109683. * Creates a pointer drag behavior that can be attached to a mesh
  109684. * @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)
  109685. */
  109686. constructor(options?: {
  109687. dragAxis?: Vector3;
  109688. dragPlaneNormal?: Vector3;
  109689. });
  109690. /**
  109691. * Predicate to determine if it is valid to move the object to a new position when it is moved
  109692. */
  109693. validateDrag: (targetPosition: Vector3) => boolean;
  109694. /**
  109695. * The name of the behavior
  109696. */
  109697. get name(): string;
  109698. /**
  109699. * Initializes the behavior
  109700. */
  109701. init(): void;
  109702. private _tmpVector;
  109703. private _alternatePickedPoint;
  109704. private _worldDragAxis;
  109705. private _targetPosition;
  109706. private _attachedElement;
  109707. /**
  109708. * Attaches the drag behavior the passed in mesh
  109709. * @param ownerNode The mesh that will be dragged around once attached
  109710. * @param predicate Predicate to use for pick filtering
  109711. */
  109712. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  109713. /**
  109714. * Force relase the drag action by code.
  109715. */
  109716. releaseDrag(): void;
  109717. private _startDragRay;
  109718. private _lastPointerRay;
  109719. /**
  109720. * Simulates the start of a pointer drag event on the behavior
  109721. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  109722. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  109723. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  109724. */
  109725. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  109726. private _startDrag;
  109727. private _dragDelta;
  109728. private _moveDrag;
  109729. private _pickWithRayOnDragPlane;
  109730. private _pointA;
  109731. private _pointB;
  109732. private _pointC;
  109733. private _lineA;
  109734. private _lineB;
  109735. private _localAxis;
  109736. private _lookAt;
  109737. private _updateDragPlanePosition;
  109738. /**
  109739. * Detaches the behavior from the mesh
  109740. */
  109741. detach(): void;
  109742. }
  109743. }
  109744. declare module BABYLON {
  109745. /**
  109746. * A behavior that when attached to a mesh will allow the mesh to be scaled
  109747. */
  109748. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  109749. private _dragBehaviorA;
  109750. private _dragBehaviorB;
  109751. private _startDistance;
  109752. private _initialScale;
  109753. private _targetScale;
  109754. private _ownerNode;
  109755. private _sceneRenderObserver;
  109756. /**
  109757. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  109758. */
  109759. constructor();
  109760. /**
  109761. * The name of the behavior
  109762. */
  109763. get name(): string;
  109764. /**
  109765. * Initializes the behavior
  109766. */
  109767. init(): void;
  109768. private _getCurrentDistance;
  109769. /**
  109770. * Attaches the scale behavior the passed in mesh
  109771. * @param ownerNode The mesh that will be scaled around once attached
  109772. */
  109773. attach(ownerNode: Mesh): void;
  109774. /**
  109775. * Detaches the behavior from the mesh
  109776. */
  109777. detach(): void;
  109778. }
  109779. }
  109780. declare module BABYLON {
  109781. /**
  109782. * 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
  109783. */
  109784. export class SixDofDragBehavior implements Behavior<Mesh> {
  109785. private static _virtualScene;
  109786. private _ownerNode;
  109787. private _sceneRenderObserver;
  109788. private _scene;
  109789. private _targetPosition;
  109790. private _virtualOriginMesh;
  109791. private _virtualDragMesh;
  109792. private _pointerObserver;
  109793. private _moving;
  109794. private _startingOrientation;
  109795. /**
  109796. * 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)
  109797. */
  109798. private zDragFactor;
  109799. /**
  109800. * If the object should rotate to face the drag origin
  109801. */
  109802. rotateDraggedObject: boolean;
  109803. /**
  109804. * If the behavior is currently in a dragging state
  109805. */
  109806. dragging: boolean;
  109807. /**
  109808. * 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)
  109809. */
  109810. dragDeltaRatio: number;
  109811. /**
  109812. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109813. */
  109814. currentDraggingPointerID: number;
  109815. /**
  109816. * If camera controls should be detached during the drag
  109817. */
  109818. detachCameraControls: boolean;
  109819. /**
  109820. * Fires each time a drag starts
  109821. */
  109822. onDragStartObservable: Observable<{}>;
  109823. /**
  109824. * Fires each time a drag ends (eg. mouse release after drag)
  109825. */
  109826. onDragEndObservable: Observable<{}>;
  109827. /**
  109828. * 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
  109829. */
  109830. constructor();
  109831. /**
  109832. * The name of the behavior
  109833. */
  109834. get name(): string;
  109835. /**
  109836. * Initializes the behavior
  109837. */
  109838. init(): void;
  109839. /**
  109840. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  109841. */
  109842. private get _pointerCamera();
  109843. /**
  109844. * Attaches the scale behavior the passed in mesh
  109845. * @param ownerNode The mesh that will be scaled around once attached
  109846. */
  109847. attach(ownerNode: Mesh): void;
  109848. /**
  109849. * Detaches the behavior from the mesh
  109850. */
  109851. detach(): void;
  109852. }
  109853. }
  109854. declare module BABYLON {
  109855. /**
  109856. * Class used to apply inverse kinematics to bones
  109857. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  109858. */
  109859. export class BoneIKController {
  109860. private static _tmpVecs;
  109861. private static _tmpQuat;
  109862. private static _tmpMats;
  109863. /**
  109864. * Gets or sets the target mesh
  109865. */
  109866. targetMesh: AbstractMesh;
  109867. /** Gets or sets the mesh used as pole */
  109868. poleTargetMesh: AbstractMesh;
  109869. /**
  109870. * Gets or sets the bone used as pole
  109871. */
  109872. poleTargetBone: Nullable<Bone>;
  109873. /**
  109874. * Gets or sets the target position
  109875. */
  109876. targetPosition: Vector3;
  109877. /**
  109878. * Gets or sets the pole target position
  109879. */
  109880. poleTargetPosition: Vector3;
  109881. /**
  109882. * Gets or sets the pole target local offset
  109883. */
  109884. poleTargetLocalOffset: Vector3;
  109885. /**
  109886. * Gets or sets the pole angle
  109887. */
  109888. poleAngle: number;
  109889. /**
  109890. * Gets or sets the mesh associated with the controller
  109891. */
  109892. mesh: AbstractMesh;
  109893. /**
  109894. * 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)
  109895. */
  109896. slerpAmount: number;
  109897. private _bone1Quat;
  109898. private _bone1Mat;
  109899. private _bone2Ang;
  109900. private _bone1;
  109901. private _bone2;
  109902. private _bone1Length;
  109903. private _bone2Length;
  109904. private _maxAngle;
  109905. private _maxReach;
  109906. private _rightHandedSystem;
  109907. private _bendAxis;
  109908. private _slerping;
  109909. private _adjustRoll;
  109910. /**
  109911. * Gets or sets maximum allowed angle
  109912. */
  109913. get maxAngle(): number;
  109914. set maxAngle(value: number);
  109915. /**
  109916. * Creates a new BoneIKController
  109917. * @param mesh defines the mesh to control
  109918. * @param bone defines the bone to control
  109919. * @param options defines options to set up the controller
  109920. */
  109921. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  109922. targetMesh?: AbstractMesh;
  109923. poleTargetMesh?: AbstractMesh;
  109924. poleTargetBone?: Bone;
  109925. poleTargetLocalOffset?: Vector3;
  109926. poleAngle?: number;
  109927. bendAxis?: Vector3;
  109928. maxAngle?: number;
  109929. slerpAmount?: number;
  109930. });
  109931. private _setMaxAngle;
  109932. /**
  109933. * Force the controller to update the bones
  109934. */
  109935. update(): void;
  109936. }
  109937. }
  109938. declare module BABYLON {
  109939. /**
  109940. * Class used to make a bone look toward a point in space
  109941. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  109942. */
  109943. export class BoneLookController {
  109944. private static _tmpVecs;
  109945. private static _tmpQuat;
  109946. private static _tmpMats;
  109947. /**
  109948. * The target Vector3 that the bone will look at
  109949. */
  109950. target: Vector3;
  109951. /**
  109952. * The mesh that the bone is attached to
  109953. */
  109954. mesh: AbstractMesh;
  109955. /**
  109956. * The bone that will be looking to the target
  109957. */
  109958. bone: Bone;
  109959. /**
  109960. * The up axis of the coordinate system that is used when the bone is rotated
  109961. */
  109962. upAxis: Vector3;
  109963. /**
  109964. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  109965. */
  109966. upAxisSpace: Space;
  109967. /**
  109968. * Used to make an adjustment to the yaw of the bone
  109969. */
  109970. adjustYaw: number;
  109971. /**
  109972. * Used to make an adjustment to the pitch of the bone
  109973. */
  109974. adjustPitch: number;
  109975. /**
  109976. * Used to make an adjustment to the roll of the bone
  109977. */
  109978. adjustRoll: number;
  109979. /**
  109980. * 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)
  109981. */
  109982. slerpAmount: number;
  109983. private _minYaw;
  109984. private _maxYaw;
  109985. private _minPitch;
  109986. private _maxPitch;
  109987. private _minYawSin;
  109988. private _minYawCos;
  109989. private _maxYawSin;
  109990. private _maxYawCos;
  109991. private _midYawConstraint;
  109992. private _minPitchTan;
  109993. private _maxPitchTan;
  109994. private _boneQuat;
  109995. private _slerping;
  109996. private _transformYawPitch;
  109997. private _transformYawPitchInv;
  109998. private _firstFrameSkipped;
  109999. private _yawRange;
  110000. private _fowardAxis;
  110001. /**
  110002. * Gets or sets the minimum yaw angle that the bone can look to
  110003. */
  110004. get minYaw(): number;
  110005. set minYaw(value: number);
  110006. /**
  110007. * Gets or sets the maximum yaw angle that the bone can look to
  110008. */
  110009. get maxYaw(): number;
  110010. set maxYaw(value: number);
  110011. /**
  110012. * Gets or sets the minimum pitch angle that the bone can look to
  110013. */
  110014. get minPitch(): number;
  110015. set minPitch(value: number);
  110016. /**
  110017. * Gets or sets the maximum pitch angle that the bone can look to
  110018. */
  110019. get maxPitch(): number;
  110020. set maxPitch(value: number);
  110021. /**
  110022. * Create a BoneLookController
  110023. * @param mesh the mesh that the bone belongs to
  110024. * @param bone the bone that will be looking to the target
  110025. * @param target the target Vector3 to look at
  110026. * @param options optional settings:
  110027. * * maxYaw: the maximum angle the bone will yaw to
  110028. * * minYaw: the minimum angle the bone will yaw to
  110029. * * maxPitch: the maximum angle the bone will pitch to
  110030. * * minPitch: the minimum angle the bone will yaw to
  110031. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  110032. * * upAxis: the up axis of the coordinate system
  110033. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  110034. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  110035. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  110036. * * adjustYaw: used to make an adjustment to the yaw of the bone
  110037. * * adjustPitch: used to make an adjustment to the pitch of the bone
  110038. * * adjustRoll: used to make an adjustment to the roll of the bone
  110039. **/
  110040. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  110041. maxYaw?: number;
  110042. minYaw?: number;
  110043. maxPitch?: number;
  110044. minPitch?: number;
  110045. slerpAmount?: number;
  110046. upAxis?: Vector3;
  110047. upAxisSpace?: Space;
  110048. yawAxis?: Vector3;
  110049. pitchAxis?: Vector3;
  110050. adjustYaw?: number;
  110051. adjustPitch?: number;
  110052. adjustRoll?: number;
  110053. });
  110054. /**
  110055. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  110056. */
  110057. update(): void;
  110058. private _getAngleDiff;
  110059. private _getAngleBetween;
  110060. private _isAngleBetween;
  110061. }
  110062. }
  110063. declare module BABYLON {
  110064. /**
  110065. * Manage the gamepad inputs to control an arc rotate camera.
  110066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110067. */
  110068. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  110069. /**
  110070. * Defines the camera the input is attached to.
  110071. */
  110072. camera: ArcRotateCamera;
  110073. /**
  110074. * Defines the gamepad the input is gathering event from.
  110075. */
  110076. gamepad: Nullable<Gamepad>;
  110077. /**
  110078. * Defines the gamepad rotation sensiblity.
  110079. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110080. */
  110081. gamepadRotationSensibility: number;
  110082. /**
  110083. * Defines the gamepad move sensiblity.
  110084. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110085. */
  110086. gamepadMoveSensibility: number;
  110087. private _yAxisScale;
  110088. /**
  110089. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  110090. */
  110091. get invertYAxis(): boolean;
  110092. set invertYAxis(value: boolean);
  110093. private _onGamepadConnectedObserver;
  110094. private _onGamepadDisconnectedObserver;
  110095. /**
  110096. * Attach the input controls to a specific dom element to get the input from.
  110097. * @param element Defines the element the controls should be listened from
  110098. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110099. */
  110100. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110101. /**
  110102. * Detach the current controls from the specified dom element.
  110103. * @param element Defines the element to stop listening the inputs from
  110104. */
  110105. detachControl(element: Nullable<HTMLElement>): void;
  110106. /**
  110107. * Update the current camera state depending on the inputs that have been used this frame.
  110108. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110109. */
  110110. checkInputs(): void;
  110111. /**
  110112. * Gets the class name of the current intput.
  110113. * @returns the class name
  110114. */
  110115. getClassName(): string;
  110116. /**
  110117. * Get the friendly name associated with the input class.
  110118. * @returns the input friendly name
  110119. */
  110120. getSimpleName(): string;
  110121. }
  110122. }
  110123. declare module BABYLON {
  110124. interface ArcRotateCameraInputsManager {
  110125. /**
  110126. * Add orientation input support to the input manager.
  110127. * @returns the current input manager
  110128. */
  110129. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  110130. }
  110131. /**
  110132. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  110133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110134. */
  110135. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  110136. /**
  110137. * Defines the camera the input is attached to.
  110138. */
  110139. camera: ArcRotateCamera;
  110140. /**
  110141. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  110142. */
  110143. alphaCorrection: number;
  110144. /**
  110145. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  110146. */
  110147. gammaCorrection: number;
  110148. private _alpha;
  110149. private _gamma;
  110150. private _dirty;
  110151. private _deviceOrientationHandler;
  110152. /**
  110153. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  110154. */
  110155. constructor();
  110156. /**
  110157. * Attach the input controls to a specific dom element to get the input from.
  110158. * @param element Defines the element the controls should be listened from
  110159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110160. */
  110161. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110162. /** @hidden */
  110163. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  110164. /**
  110165. * Update the current camera state depending on the inputs that have been used this frame.
  110166. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110167. */
  110168. checkInputs(): void;
  110169. /**
  110170. * Detach the current controls from the specified dom element.
  110171. * @param element Defines the element to stop listening the inputs from
  110172. */
  110173. detachControl(element: Nullable<HTMLElement>): void;
  110174. /**
  110175. * Gets the class name of the current intput.
  110176. * @returns the class name
  110177. */
  110178. getClassName(): string;
  110179. /**
  110180. * Get the friendly name associated with the input class.
  110181. * @returns the input friendly name
  110182. */
  110183. getSimpleName(): string;
  110184. }
  110185. }
  110186. declare module BABYLON {
  110187. /**
  110188. * Listen to mouse events to control the camera.
  110189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110190. */
  110191. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  110192. /**
  110193. * Defines the camera the input is attached to.
  110194. */
  110195. camera: FlyCamera;
  110196. /**
  110197. * Defines if touch is enabled. (Default is true.)
  110198. */
  110199. touchEnabled: boolean;
  110200. /**
  110201. * Defines the buttons associated with the input to handle camera rotation.
  110202. */
  110203. buttons: number[];
  110204. /**
  110205. * Assign buttons for Yaw control.
  110206. */
  110207. buttonsYaw: number[];
  110208. /**
  110209. * Assign buttons for Pitch control.
  110210. */
  110211. buttonsPitch: number[];
  110212. /**
  110213. * Assign buttons for Roll control.
  110214. */
  110215. buttonsRoll: number[];
  110216. /**
  110217. * Detect if any button is being pressed while mouse is moved.
  110218. * -1 = Mouse locked.
  110219. * 0 = Left button.
  110220. * 1 = Middle Button.
  110221. * 2 = Right Button.
  110222. */
  110223. activeButton: number;
  110224. /**
  110225. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  110226. * Higher values reduce its sensitivity.
  110227. */
  110228. angularSensibility: number;
  110229. private _mousemoveCallback;
  110230. private _observer;
  110231. private _rollObserver;
  110232. private previousPosition;
  110233. private noPreventDefault;
  110234. private element;
  110235. /**
  110236. * Listen to mouse events to control the camera.
  110237. * @param touchEnabled Define if touch is enabled. (Default is true.)
  110238. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110239. */
  110240. constructor(touchEnabled?: boolean);
  110241. /**
  110242. * Attach the mouse control to the HTML DOM element.
  110243. * @param element Defines the element that listens to the input events.
  110244. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  110245. */
  110246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110247. /**
  110248. * Detach the current controls from the specified dom element.
  110249. * @param element Defines the element to stop listening the inputs from
  110250. */
  110251. detachControl(element: Nullable<HTMLElement>): void;
  110252. /**
  110253. * Gets the class name of the current input.
  110254. * @returns the class name.
  110255. */
  110256. getClassName(): string;
  110257. /**
  110258. * Get the friendly name associated with the input class.
  110259. * @returns the input's friendly name.
  110260. */
  110261. getSimpleName(): string;
  110262. private _pointerInput;
  110263. private _onMouseMove;
  110264. /**
  110265. * Rotate camera by mouse offset.
  110266. */
  110267. private rotateCamera;
  110268. }
  110269. }
  110270. declare module BABYLON {
  110271. /**
  110272. * Default Inputs manager for the FlyCamera.
  110273. * It groups all the default supported inputs for ease of use.
  110274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110275. */
  110276. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  110277. /**
  110278. * Instantiates a new FlyCameraInputsManager.
  110279. * @param camera Defines the camera the inputs belong to.
  110280. */
  110281. constructor(camera: FlyCamera);
  110282. /**
  110283. * Add keyboard input support to the input manager.
  110284. * @returns the new FlyCameraKeyboardMoveInput().
  110285. */
  110286. addKeyboard(): FlyCameraInputsManager;
  110287. /**
  110288. * Add mouse input support to the input manager.
  110289. * @param touchEnabled Enable touch screen support.
  110290. * @returns the new FlyCameraMouseInput().
  110291. */
  110292. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  110293. }
  110294. }
  110295. declare module BABYLON {
  110296. /**
  110297. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110298. * such as in a 3D Space Shooter or a Flight Simulator.
  110299. */
  110300. export class FlyCamera extends TargetCamera {
  110301. /**
  110302. * Define the collision ellipsoid of the camera.
  110303. * This is helpful for simulating a camera body, like a player's body.
  110304. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  110305. */
  110306. ellipsoid: Vector3;
  110307. /**
  110308. * Define an offset for the position of the ellipsoid around the camera.
  110309. * This can be helpful if the camera is attached away from the player's body center,
  110310. * such as at its head.
  110311. */
  110312. ellipsoidOffset: Vector3;
  110313. /**
  110314. * Enable or disable collisions of the camera with the rest of the scene objects.
  110315. */
  110316. checkCollisions: boolean;
  110317. /**
  110318. * Enable or disable gravity on the camera.
  110319. */
  110320. applyGravity: boolean;
  110321. /**
  110322. * Define the current direction the camera is moving to.
  110323. */
  110324. cameraDirection: Vector3;
  110325. /**
  110326. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  110327. * This overrides and empties cameraRotation.
  110328. */
  110329. rotationQuaternion: Quaternion;
  110330. /**
  110331. * Track Roll to maintain the wanted Rolling when looking around.
  110332. */
  110333. _trackRoll: number;
  110334. /**
  110335. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  110336. */
  110337. rollCorrect: number;
  110338. /**
  110339. * Mimic a banked turn, Rolling the camera when Yawing.
  110340. * It's recommended to use rollCorrect = 10 for faster banking correction.
  110341. */
  110342. bankedTurn: boolean;
  110343. /**
  110344. * Limit in radians for how much Roll banking will add. (Default: 90°)
  110345. */
  110346. bankedTurnLimit: number;
  110347. /**
  110348. * Value of 0 disables the banked Roll.
  110349. * Value of 1 is equal to the Yaw angle in radians.
  110350. */
  110351. bankedTurnMultiplier: number;
  110352. /**
  110353. * The inputs manager loads all the input sources, such as keyboard and mouse.
  110354. */
  110355. inputs: FlyCameraInputsManager;
  110356. /**
  110357. * Gets the input sensibility for mouse input.
  110358. * Higher values reduce sensitivity.
  110359. */
  110360. get angularSensibility(): number;
  110361. /**
  110362. * Sets the input sensibility for a mouse input.
  110363. * Higher values reduce sensitivity.
  110364. */
  110365. set angularSensibility(value: number);
  110366. /**
  110367. * Get the keys for camera movement forward.
  110368. */
  110369. get keysForward(): number[];
  110370. /**
  110371. * Set the keys for camera movement forward.
  110372. */
  110373. set keysForward(value: number[]);
  110374. /**
  110375. * Get the keys for camera movement backward.
  110376. */
  110377. get keysBackward(): number[];
  110378. set keysBackward(value: number[]);
  110379. /**
  110380. * Get the keys for camera movement up.
  110381. */
  110382. get keysUp(): number[];
  110383. /**
  110384. * Set the keys for camera movement up.
  110385. */
  110386. set keysUp(value: number[]);
  110387. /**
  110388. * Get the keys for camera movement down.
  110389. */
  110390. get keysDown(): number[];
  110391. /**
  110392. * Set the keys for camera movement down.
  110393. */
  110394. set keysDown(value: number[]);
  110395. /**
  110396. * Get the keys for camera movement left.
  110397. */
  110398. get keysLeft(): number[];
  110399. /**
  110400. * Set the keys for camera movement left.
  110401. */
  110402. set keysLeft(value: number[]);
  110403. /**
  110404. * Set the keys for camera movement right.
  110405. */
  110406. get keysRight(): number[];
  110407. /**
  110408. * Set the keys for camera movement right.
  110409. */
  110410. set keysRight(value: number[]);
  110411. /**
  110412. * Event raised when the camera collides with a mesh in the scene.
  110413. */
  110414. onCollide: (collidedMesh: AbstractMesh) => void;
  110415. private _collider;
  110416. private _needMoveForGravity;
  110417. private _oldPosition;
  110418. private _diffPosition;
  110419. private _newPosition;
  110420. /** @hidden */
  110421. _localDirection: Vector3;
  110422. /** @hidden */
  110423. _transformedDirection: Vector3;
  110424. /**
  110425. * Instantiates a FlyCamera.
  110426. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110427. * such as in a 3D Space Shooter or a Flight Simulator.
  110428. * @param name Define the name of the camera in the scene.
  110429. * @param position Define the starting position of the camera in the scene.
  110430. * @param scene Define the scene the camera belongs to.
  110431. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  110432. */
  110433. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110434. /**
  110435. * Attach a control to the HTML DOM element.
  110436. * @param element Defines the element that listens to the input events.
  110437. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  110438. */
  110439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110440. /**
  110441. * Detach a control from the HTML DOM element.
  110442. * The camera will stop reacting to that input.
  110443. * @param element Defines the element that listens to the input events.
  110444. */
  110445. detachControl(element: HTMLElement): void;
  110446. private _collisionMask;
  110447. /**
  110448. * Get the mask that the camera ignores in collision events.
  110449. */
  110450. get collisionMask(): number;
  110451. /**
  110452. * Set the mask that the camera ignores in collision events.
  110453. */
  110454. set collisionMask(mask: number);
  110455. /** @hidden */
  110456. _collideWithWorld(displacement: Vector3): void;
  110457. /** @hidden */
  110458. private _onCollisionPositionChange;
  110459. /** @hidden */
  110460. _checkInputs(): void;
  110461. /** @hidden */
  110462. _decideIfNeedsToMove(): boolean;
  110463. /** @hidden */
  110464. _updatePosition(): void;
  110465. /**
  110466. * Restore the Roll to its target value at the rate specified.
  110467. * @param rate - Higher means slower restoring.
  110468. * @hidden
  110469. */
  110470. restoreRoll(rate: number): void;
  110471. /**
  110472. * Destroy the camera and release the current resources held by it.
  110473. */
  110474. dispose(): void;
  110475. /**
  110476. * Get the current object class name.
  110477. * @returns the class name.
  110478. */
  110479. getClassName(): string;
  110480. }
  110481. }
  110482. declare module BABYLON {
  110483. /**
  110484. * Listen to keyboard events to control the camera.
  110485. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110486. */
  110487. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  110488. /**
  110489. * Defines the camera the input is attached to.
  110490. */
  110491. camera: FlyCamera;
  110492. /**
  110493. * The list of keyboard keys used to control the forward move of the camera.
  110494. */
  110495. keysForward: number[];
  110496. /**
  110497. * The list of keyboard keys used to control the backward move of the camera.
  110498. */
  110499. keysBackward: number[];
  110500. /**
  110501. * The list of keyboard keys used to control the forward move of the camera.
  110502. */
  110503. keysUp: number[];
  110504. /**
  110505. * The list of keyboard keys used to control the backward move of the camera.
  110506. */
  110507. keysDown: number[];
  110508. /**
  110509. * The list of keyboard keys used to control the right strafe move of the camera.
  110510. */
  110511. keysRight: number[];
  110512. /**
  110513. * The list of keyboard keys used to control the left strafe move of the camera.
  110514. */
  110515. keysLeft: number[];
  110516. private _keys;
  110517. private _onCanvasBlurObserver;
  110518. private _onKeyboardObserver;
  110519. private _engine;
  110520. private _scene;
  110521. /**
  110522. * Attach the input controls to a specific dom element to get the input from.
  110523. * @param element Defines the element the controls should be listened from
  110524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110525. */
  110526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110527. /**
  110528. * Detach the current controls from the specified dom element.
  110529. * @param element Defines the element to stop listening the inputs from
  110530. */
  110531. detachControl(element: Nullable<HTMLElement>): void;
  110532. /**
  110533. * Gets the class name of the current intput.
  110534. * @returns the class name
  110535. */
  110536. getClassName(): string;
  110537. /** @hidden */
  110538. _onLostFocus(e: FocusEvent): void;
  110539. /**
  110540. * Get the friendly name associated with the input class.
  110541. * @returns the input friendly name
  110542. */
  110543. getSimpleName(): string;
  110544. /**
  110545. * Update the current camera state depending on the inputs that have been used this frame.
  110546. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110547. */
  110548. checkInputs(): void;
  110549. }
  110550. }
  110551. declare module BABYLON {
  110552. /**
  110553. * Manage the mouse wheel inputs to control a follow camera.
  110554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110555. */
  110556. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  110557. /**
  110558. * Defines the camera the input is attached to.
  110559. */
  110560. camera: FollowCamera;
  110561. /**
  110562. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  110563. */
  110564. axisControlRadius: boolean;
  110565. /**
  110566. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  110567. */
  110568. axisControlHeight: boolean;
  110569. /**
  110570. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  110571. */
  110572. axisControlRotation: boolean;
  110573. /**
  110574. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  110575. * relation to mouseWheel events.
  110576. */
  110577. wheelPrecision: number;
  110578. /**
  110579. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  110580. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  110581. */
  110582. wheelDeltaPercentage: number;
  110583. private _wheel;
  110584. private _observer;
  110585. /**
  110586. * Attach the input controls to a specific dom element to get the input from.
  110587. * @param element Defines the element the controls should be listened from
  110588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110589. */
  110590. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110591. /**
  110592. * Detach the current controls from the specified dom element.
  110593. * @param element Defines the element to stop listening the inputs from
  110594. */
  110595. detachControl(element: Nullable<HTMLElement>): void;
  110596. /**
  110597. * Gets the class name of the current intput.
  110598. * @returns the class name
  110599. */
  110600. getClassName(): string;
  110601. /**
  110602. * Get the friendly name associated with the input class.
  110603. * @returns the input friendly name
  110604. */
  110605. getSimpleName(): string;
  110606. }
  110607. }
  110608. declare module BABYLON {
  110609. /**
  110610. * Manage the pointers inputs to control an follow camera.
  110611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110612. */
  110613. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  110614. /**
  110615. * Defines the camera the input is attached to.
  110616. */
  110617. camera: FollowCamera;
  110618. /**
  110619. * Gets the class name of the current input.
  110620. * @returns the class name
  110621. */
  110622. getClassName(): string;
  110623. /**
  110624. * Defines the pointer angular sensibility along the X axis or how fast is
  110625. * the camera rotating.
  110626. * A negative number will reverse the axis direction.
  110627. */
  110628. angularSensibilityX: number;
  110629. /**
  110630. * Defines the pointer angular sensibility along the Y axis or how fast is
  110631. * the camera rotating.
  110632. * A negative number will reverse the axis direction.
  110633. */
  110634. angularSensibilityY: number;
  110635. /**
  110636. * Defines the pointer pinch precision or how fast is the camera zooming.
  110637. * A negative number will reverse the axis direction.
  110638. */
  110639. pinchPrecision: number;
  110640. /**
  110641. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  110642. * from 0.
  110643. * It defines the percentage of current camera.radius to use as delta when
  110644. * pinch zoom is used.
  110645. */
  110646. pinchDeltaPercentage: number;
  110647. /**
  110648. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  110649. */
  110650. axisXControlRadius: boolean;
  110651. /**
  110652. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  110653. */
  110654. axisXControlHeight: boolean;
  110655. /**
  110656. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  110657. */
  110658. axisXControlRotation: boolean;
  110659. /**
  110660. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  110661. */
  110662. axisYControlRadius: boolean;
  110663. /**
  110664. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  110665. */
  110666. axisYControlHeight: boolean;
  110667. /**
  110668. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  110669. */
  110670. axisYControlRotation: boolean;
  110671. /**
  110672. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  110673. */
  110674. axisPinchControlRadius: boolean;
  110675. /**
  110676. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  110677. */
  110678. axisPinchControlHeight: boolean;
  110679. /**
  110680. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  110681. */
  110682. axisPinchControlRotation: boolean;
  110683. /**
  110684. * Log error messages if basic misconfiguration has occurred.
  110685. */
  110686. warningEnable: boolean;
  110687. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110688. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110689. private _warningCounter;
  110690. private _warning;
  110691. }
  110692. }
  110693. declare module BABYLON {
  110694. /**
  110695. * Default Inputs manager for the FollowCamera.
  110696. * It groups all the default supported inputs for ease of use.
  110697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110698. */
  110699. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  110700. /**
  110701. * Instantiates a new FollowCameraInputsManager.
  110702. * @param camera Defines the camera the inputs belong to
  110703. */
  110704. constructor(camera: FollowCamera);
  110705. /**
  110706. * Add keyboard input support to the input manager.
  110707. * @returns the current input manager
  110708. */
  110709. addKeyboard(): FollowCameraInputsManager;
  110710. /**
  110711. * Add mouse wheel input support to the input manager.
  110712. * @returns the current input manager
  110713. */
  110714. addMouseWheel(): FollowCameraInputsManager;
  110715. /**
  110716. * Add pointers input support to the input manager.
  110717. * @returns the current input manager
  110718. */
  110719. addPointers(): FollowCameraInputsManager;
  110720. /**
  110721. * Add orientation input support to the input manager.
  110722. * @returns the current input manager
  110723. */
  110724. addVRDeviceOrientation(): FollowCameraInputsManager;
  110725. }
  110726. }
  110727. declare module BABYLON {
  110728. /**
  110729. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  110730. * an arc rotate version arcFollowCamera are available.
  110731. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110732. */
  110733. export class FollowCamera extends TargetCamera {
  110734. /**
  110735. * Distance the follow camera should follow an object at
  110736. */
  110737. radius: number;
  110738. /**
  110739. * Minimum allowed distance of the camera to the axis of rotation
  110740. * (The camera can not get closer).
  110741. * This can help limiting how the Camera is able to move in the scene.
  110742. */
  110743. lowerRadiusLimit: Nullable<number>;
  110744. /**
  110745. * Maximum allowed distance of the camera to the axis of rotation
  110746. * (The camera can not get further).
  110747. * This can help limiting how the Camera is able to move in the scene.
  110748. */
  110749. upperRadiusLimit: Nullable<number>;
  110750. /**
  110751. * Define a rotation offset between the camera and the object it follows
  110752. */
  110753. rotationOffset: number;
  110754. /**
  110755. * Minimum allowed angle to camera position relative to target object.
  110756. * This can help limiting how the Camera is able to move in the scene.
  110757. */
  110758. lowerRotationOffsetLimit: Nullable<number>;
  110759. /**
  110760. * Maximum allowed angle to camera position relative to target object.
  110761. * This can help limiting how the Camera is able to move in the scene.
  110762. */
  110763. upperRotationOffsetLimit: Nullable<number>;
  110764. /**
  110765. * Define a height offset between the camera and the object it follows.
  110766. * It can help following an object from the top (like a car chaing a plane)
  110767. */
  110768. heightOffset: number;
  110769. /**
  110770. * Minimum allowed height of camera position relative to target object.
  110771. * This can help limiting how the Camera is able to move in the scene.
  110772. */
  110773. lowerHeightOffsetLimit: Nullable<number>;
  110774. /**
  110775. * Maximum allowed height of camera position relative to target object.
  110776. * This can help limiting how the Camera is able to move in the scene.
  110777. */
  110778. upperHeightOffsetLimit: Nullable<number>;
  110779. /**
  110780. * Define how fast the camera can accelerate to follow it s target.
  110781. */
  110782. cameraAcceleration: number;
  110783. /**
  110784. * Define the speed limit of the camera following an object.
  110785. */
  110786. maxCameraSpeed: number;
  110787. /**
  110788. * Define the target of the camera.
  110789. */
  110790. lockedTarget: Nullable<AbstractMesh>;
  110791. /**
  110792. * Defines the input associated with the camera.
  110793. */
  110794. inputs: FollowCameraInputsManager;
  110795. /**
  110796. * Instantiates the follow camera.
  110797. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110798. * @param name Define the name of the camera in the scene
  110799. * @param position Define the position of the camera
  110800. * @param scene Define the scene the camera belong to
  110801. * @param lockedTarget Define the target of the camera
  110802. */
  110803. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  110804. private _follow;
  110805. /**
  110806. * Attached controls to the current camera.
  110807. * @param element Defines the element the controls should be listened from
  110808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110809. */
  110810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110811. /**
  110812. * Detach the current controls from the camera.
  110813. * The camera will stop reacting to inputs.
  110814. * @param element Defines the element to stop listening the inputs from
  110815. */
  110816. detachControl(element: HTMLElement): void;
  110817. /** @hidden */
  110818. _checkInputs(): void;
  110819. private _checkLimits;
  110820. /**
  110821. * Gets the camera class name.
  110822. * @returns the class name
  110823. */
  110824. getClassName(): string;
  110825. }
  110826. /**
  110827. * Arc Rotate version of the follow camera.
  110828. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  110829. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110830. */
  110831. export class ArcFollowCamera extends TargetCamera {
  110832. /** The longitudinal angle of the camera */
  110833. alpha: number;
  110834. /** The latitudinal angle of the camera */
  110835. beta: number;
  110836. /** The radius of the camera from its target */
  110837. radius: number;
  110838. /** Define the camera target (the messh it should follow) */
  110839. target: Nullable<AbstractMesh>;
  110840. private _cartesianCoordinates;
  110841. /**
  110842. * Instantiates a new ArcFollowCamera
  110843. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110844. * @param name Define the name of the camera
  110845. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  110846. * @param beta Define the rotation angle of the camera around the elevation axis
  110847. * @param radius Define the radius of the camera from its target point
  110848. * @param target Define the target of the camera
  110849. * @param scene Define the scene the camera belongs to
  110850. */
  110851. constructor(name: string,
  110852. /** The longitudinal angle of the camera */
  110853. alpha: number,
  110854. /** The latitudinal angle of the camera */
  110855. beta: number,
  110856. /** The radius of the camera from its target */
  110857. radius: number,
  110858. /** Define the camera target (the messh it should follow) */
  110859. target: Nullable<AbstractMesh>, scene: Scene);
  110860. private _follow;
  110861. /** @hidden */
  110862. _checkInputs(): void;
  110863. /**
  110864. * Returns the class name of the object.
  110865. * It is mostly used internally for serialization purposes.
  110866. */
  110867. getClassName(): string;
  110868. }
  110869. }
  110870. declare module BABYLON {
  110871. /**
  110872. * Manage the keyboard inputs to control the movement of a follow camera.
  110873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110874. */
  110875. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  110876. /**
  110877. * Defines the camera the input is attached to.
  110878. */
  110879. camera: FollowCamera;
  110880. /**
  110881. * Defines the list of key codes associated with the up action (increase heightOffset)
  110882. */
  110883. keysHeightOffsetIncr: number[];
  110884. /**
  110885. * Defines the list of key codes associated with the down action (decrease heightOffset)
  110886. */
  110887. keysHeightOffsetDecr: number[];
  110888. /**
  110889. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  110890. */
  110891. keysHeightOffsetModifierAlt: boolean;
  110892. /**
  110893. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  110894. */
  110895. keysHeightOffsetModifierCtrl: boolean;
  110896. /**
  110897. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  110898. */
  110899. keysHeightOffsetModifierShift: boolean;
  110900. /**
  110901. * Defines the list of key codes associated with the left action (increase rotationOffset)
  110902. */
  110903. keysRotationOffsetIncr: number[];
  110904. /**
  110905. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  110906. */
  110907. keysRotationOffsetDecr: number[];
  110908. /**
  110909. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  110910. */
  110911. keysRotationOffsetModifierAlt: boolean;
  110912. /**
  110913. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  110914. */
  110915. keysRotationOffsetModifierCtrl: boolean;
  110916. /**
  110917. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  110918. */
  110919. keysRotationOffsetModifierShift: boolean;
  110920. /**
  110921. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  110922. */
  110923. keysRadiusIncr: number[];
  110924. /**
  110925. * Defines the list of key codes associated with the zoom-out action (increase radius)
  110926. */
  110927. keysRadiusDecr: number[];
  110928. /**
  110929. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  110930. */
  110931. keysRadiusModifierAlt: boolean;
  110932. /**
  110933. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  110934. */
  110935. keysRadiusModifierCtrl: boolean;
  110936. /**
  110937. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  110938. */
  110939. keysRadiusModifierShift: boolean;
  110940. /**
  110941. * Defines the rate of change of heightOffset.
  110942. */
  110943. heightSensibility: number;
  110944. /**
  110945. * Defines the rate of change of rotationOffset.
  110946. */
  110947. rotationSensibility: number;
  110948. /**
  110949. * Defines the rate of change of radius.
  110950. */
  110951. radiusSensibility: number;
  110952. private _keys;
  110953. private _ctrlPressed;
  110954. private _altPressed;
  110955. private _shiftPressed;
  110956. private _onCanvasBlurObserver;
  110957. private _onKeyboardObserver;
  110958. private _engine;
  110959. private _scene;
  110960. /**
  110961. * Attach the input controls to a specific dom element to get the input from.
  110962. * @param element Defines the element the controls should be listened from
  110963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110964. */
  110965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110966. /**
  110967. * Detach the current controls from the specified dom element.
  110968. * @param element Defines the element to stop listening the inputs from
  110969. */
  110970. detachControl(element: Nullable<HTMLElement>): void;
  110971. /**
  110972. * Update the current camera state depending on the inputs that have been used this frame.
  110973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110974. */
  110975. checkInputs(): void;
  110976. /**
  110977. * Gets the class name of the current input.
  110978. * @returns the class name
  110979. */
  110980. getClassName(): string;
  110981. /**
  110982. * Get the friendly name associated with the input class.
  110983. * @returns the input friendly name
  110984. */
  110985. getSimpleName(): string;
  110986. /**
  110987. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110988. * allow modification of the heightOffset value.
  110989. */
  110990. private _modifierHeightOffset;
  110991. /**
  110992. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110993. * allow modification of the rotationOffset value.
  110994. */
  110995. private _modifierRotationOffset;
  110996. /**
  110997. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110998. * allow modification of the radius value.
  110999. */
  111000. private _modifierRadius;
  111001. }
  111002. }
  111003. declare module BABYLON {
  111004. interface FreeCameraInputsManager {
  111005. /**
  111006. * @hidden
  111007. */
  111008. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  111009. /**
  111010. * Add orientation input support to the input manager.
  111011. * @returns the current input manager
  111012. */
  111013. addDeviceOrientation(): FreeCameraInputsManager;
  111014. }
  111015. /**
  111016. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  111017. * Screen rotation is taken into account.
  111018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111019. */
  111020. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  111021. private _camera;
  111022. private _screenOrientationAngle;
  111023. private _constantTranform;
  111024. private _screenQuaternion;
  111025. private _alpha;
  111026. private _beta;
  111027. private _gamma;
  111028. /**
  111029. * Can be used to detect if a device orientation sensor is available on a device
  111030. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  111031. * @returns a promise that will resolve on orientation change
  111032. */
  111033. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  111034. /**
  111035. * @hidden
  111036. */
  111037. _onDeviceOrientationChangedObservable: Observable<void>;
  111038. /**
  111039. * Instantiates a new input
  111040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111041. */
  111042. constructor();
  111043. /**
  111044. * Define the camera controlled by the input.
  111045. */
  111046. get camera(): FreeCamera;
  111047. set camera(camera: FreeCamera);
  111048. /**
  111049. * Attach the input controls to a specific dom element to get the input from.
  111050. * @param element Defines the element the controls should be listened from
  111051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111052. */
  111053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111054. private _orientationChanged;
  111055. private _deviceOrientation;
  111056. /**
  111057. * Detach the current controls from the specified dom element.
  111058. * @param element Defines the element to stop listening the inputs from
  111059. */
  111060. detachControl(element: Nullable<HTMLElement>): void;
  111061. /**
  111062. * Update the current camera state depending on the inputs that have been used this frame.
  111063. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111064. */
  111065. checkInputs(): void;
  111066. /**
  111067. * Gets the class name of the current intput.
  111068. * @returns the class name
  111069. */
  111070. getClassName(): string;
  111071. /**
  111072. * Get the friendly name associated with the input class.
  111073. * @returns the input friendly name
  111074. */
  111075. getSimpleName(): string;
  111076. }
  111077. }
  111078. declare module BABYLON {
  111079. /**
  111080. * Manage the gamepad inputs to control a free camera.
  111081. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111082. */
  111083. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  111084. /**
  111085. * Define the camera the input is attached to.
  111086. */
  111087. camera: FreeCamera;
  111088. /**
  111089. * Define the Gamepad controlling the input
  111090. */
  111091. gamepad: Nullable<Gamepad>;
  111092. /**
  111093. * Defines the gamepad rotation sensiblity.
  111094. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111095. */
  111096. gamepadAngularSensibility: number;
  111097. /**
  111098. * Defines the gamepad move sensiblity.
  111099. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111100. */
  111101. gamepadMoveSensibility: number;
  111102. private _yAxisScale;
  111103. /**
  111104. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  111105. */
  111106. get invertYAxis(): boolean;
  111107. set invertYAxis(value: boolean);
  111108. private _onGamepadConnectedObserver;
  111109. private _onGamepadDisconnectedObserver;
  111110. private _cameraTransform;
  111111. private _deltaTransform;
  111112. private _vector3;
  111113. private _vector2;
  111114. /**
  111115. * Attach the input controls to a specific dom element to get the input from.
  111116. * @param element Defines the element the controls should be listened from
  111117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111118. */
  111119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111120. /**
  111121. * Detach the current controls from the specified dom element.
  111122. * @param element Defines the element to stop listening the inputs from
  111123. */
  111124. detachControl(element: Nullable<HTMLElement>): void;
  111125. /**
  111126. * Update the current camera state depending on the inputs that have been used this frame.
  111127. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111128. */
  111129. checkInputs(): void;
  111130. /**
  111131. * Gets the class name of the current intput.
  111132. * @returns the class name
  111133. */
  111134. getClassName(): string;
  111135. /**
  111136. * Get the friendly name associated with the input class.
  111137. * @returns the input friendly name
  111138. */
  111139. getSimpleName(): string;
  111140. }
  111141. }
  111142. declare module BABYLON {
  111143. /**
  111144. * Defines the potential axis of a Joystick
  111145. */
  111146. export enum JoystickAxis {
  111147. /** X axis */
  111148. X = 0,
  111149. /** Y axis */
  111150. Y = 1,
  111151. /** Z axis */
  111152. Z = 2
  111153. }
  111154. /**
  111155. * Class used to define virtual joystick (used in touch mode)
  111156. */
  111157. export class VirtualJoystick {
  111158. /**
  111159. * Gets or sets a boolean indicating that left and right values must be inverted
  111160. */
  111161. reverseLeftRight: boolean;
  111162. /**
  111163. * Gets or sets a boolean indicating that up and down values must be inverted
  111164. */
  111165. reverseUpDown: boolean;
  111166. /**
  111167. * Gets the offset value for the position (ie. the change of the position value)
  111168. */
  111169. deltaPosition: Vector3;
  111170. /**
  111171. * Gets a boolean indicating if the virtual joystick was pressed
  111172. */
  111173. pressed: boolean;
  111174. /**
  111175. * Canvas the virtual joystick will render onto, default z-index of this is 5
  111176. */
  111177. static Canvas: Nullable<HTMLCanvasElement>;
  111178. private static _globalJoystickIndex;
  111179. private static vjCanvasContext;
  111180. private static vjCanvasWidth;
  111181. private static vjCanvasHeight;
  111182. private static halfWidth;
  111183. private _action;
  111184. private _axisTargetedByLeftAndRight;
  111185. private _axisTargetedByUpAndDown;
  111186. private _joystickSensibility;
  111187. private _inversedSensibility;
  111188. private _joystickPointerID;
  111189. private _joystickColor;
  111190. private _joystickPointerPos;
  111191. private _joystickPreviousPointerPos;
  111192. private _joystickPointerStartPos;
  111193. private _deltaJoystickVector;
  111194. private _leftJoystick;
  111195. private _touches;
  111196. private _onPointerDownHandlerRef;
  111197. private _onPointerMoveHandlerRef;
  111198. private _onPointerUpHandlerRef;
  111199. private _onResize;
  111200. /**
  111201. * Creates a new virtual joystick
  111202. * @param leftJoystick defines that the joystick is for left hand (false by default)
  111203. */
  111204. constructor(leftJoystick?: boolean);
  111205. /**
  111206. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  111207. * @param newJoystickSensibility defines the new sensibility
  111208. */
  111209. setJoystickSensibility(newJoystickSensibility: number): void;
  111210. private _onPointerDown;
  111211. private _onPointerMove;
  111212. private _onPointerUp;
  111213. /**
  111214. * Change the color of the virtual joystick
  111215. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  111216. */
  111217. setJoystickColor(newColor: string): void;
  111218. /**
  111219. * Defines a callback to call when the joystick is touched
  111220. * @param action defines the callback
  111221. */
  111222. setActionOnTouch(action: () => any): void;
  111223. /**
  111224. * Defines which axis you'd like to control for left & right
  111225. * @param axis defines the axis to use
  111226. */
  111227. setAxisForLeftRight(axis: JoystickAxis): void;
  111228. /**
  111229. * Defines which axis you'd like to control for up & down
  111230. * @param axis defines the axis to use
  111231. */
  111232. setAxisForUpDown(axis: JoystickAxis): void;
  111233. private _drawVirtualJoystick;
  111234. /**
  111235. * Release internal HTML canvas
  111236. */
  111237. releaseCanvas(): void;
  111238. }
  111239. }
  111240. declare module BABYLON {
  111241. interface FreeCameraInputsManager {
  111242. /**
  111243. * Add virtual joystick input support to the input manager.
  111244. * @returns the current input manager
  111245. */
  111246. addVirtualJoystick(): FreeCameraInputsManager;
  111247. }
  111248. /**
  111249. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  111250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111251. */
  111252. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  111253. /**
  111254. * Defines the camera the input is attached to.
  111255. */
  111256. camera: FreeCamera;
  111257. private _leftjoystick;
  111258. private _rightjoystick;
  111259. /**
  111260. * Gets the left stick of the virtual joystick.
  111261. * @returns The virtual Joystick
  111262. */
  111263. getLeftJoystick(): VirtualJoystick;
  111264. /**
  111265. * Gets the right stick of the virtual joystick.
  111266. * @returns The virtual Joystick
  111267. */
  111268. getRightJoystick(): VirtualJoystick;
  111269. /**
  111270. * Update the current camera state depending on the inputs that have been used this frame.
  111271. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111272. */
  111273. checkInputs(): void;
  111274. /**
  111275. * Attach the input controls to a specific dom element to get the input from.
  111276. * @param element Defines the element the controls should be listened from
  111277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111278. */
  111279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111280. /**
  111281. * Detach the current controls from the specified dom element.
  111282. * @param element Defines the element to stop listening the inputs from
  111283. */
  111284. detachControl(element: Nullable<HTMLElement>): void;
  111285. /**
  111286. * Gets the class name of the current intput.
  111287. * @returns the class name
  111288. */
  111289. getClassName(): string;
  111290. /**
  111291. * Get the friendly name associated with the input class.
  111292. * @returns the input friendly name
  111293. */
  111294. getSimpleName(): string;
  111295. }
  111296. }
  111297. declare module BABYLON {
  111298. /**
  111299. * This represents a FPS type of camera controlled by touch.
  111300. * This is like a universal camera minus the Gamepad controls.
  111301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111302. */
  111303. export class TouchCamera extends FreeCamera {
  111304. /**
  111305. * Defines the touch sensibility for rotation.
  111306. * The higher the faster.
  111307. */
  111308. get touchAngularSensibility(): number;
  111309. set touchAngularSensibility(value: number);
  111310. /**
  111311. * Defines the touch sensibility for move.
  111312. * The higher the faster.
  111313. */
  111314. get touchMoveSensibility(): number;
  111315. set touchMoveSensibility(value: number);
  111316. /**
  111317. * Instantiates a new touch camera.
  111318. * This represents a FPS type of camera controlled by touch.
  111319. * This is like a universal camera minus the Gamepad controls.
  111320. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111321. * @param name Define the name of the camera in the scene
  111322. * @param position Define the start position of the camera in the scene
  111323. * @param scene Define the scene the camera belongs to
  111324. */
  111325. constructor(name: string, position: Vector3, scene: Scene);
  111326. /**
  111327. * Gets the current object class name.
  111328. * @return the class name
  111329. */
  111330. getClassName(): string;
  111331. /** @hidden */
  111332. _setupInputs(): void;
  111333. }
  111334. }
  111335. declare module BABYLON {
  111336. /**
  111337. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  111338. * being tilted forward or back and left or right.
  111339. */
  111340. export class DeviceOrientationCamera extends FreeCamera {
  111341. private _initialQuaternion;
  111342. private _quaternionCache;
  111343. private _tmpDragQuaternion;
  111344. private _disablePointerInputWhenUsingDeviceOrientation;
  111345. /**
  111346. * Creates a new device orientation camera
  111347. * @param name The name of the camera
  111348. * @param position The start position camera
  111349. * @param scene The scene the camera belongs to
  111350. */
  111351. constructor(name: string, position: Vector3, scene: Scene);
  111352. /**
  111353. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  111354. */
  111355. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  111356. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  111357. private _dragFactor;
  111358. /**
  111359. * Enabled turning on the y axis when the orientation sensor is active
  111360. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  111361. */
  111362. enableHorizontalDragging(dragFactor?: number): void;
  111363. /**
  111364. * Gets the current instance class name ("DeviceOrientationCamera").
  111365. * This helps avoiding instanceof at run time.
  111366. * @returns the class name
  111367. */
  111368. getClassName(): string;
  111369. /**
  111370. * @hidden
  111371. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  111372. */
  111373. _checkInputs(): void;
  111374. /**
  111375. * Reset the camera to its default orientation on the specified axis only.
  111376. * @param axis The axis to reset
  111377. */
  111378. resetToCurrentRotation(axis?: Axis): void;
  111379. }
  111380. }
  111381. declare module BABYLON {
  111382. /**
  111383. * Defines supported buttons for XBox360 compatible gamepads
  111384. */
  111385. export enum Xbox360Button {
  111386. /** A */
  111387. A = 0,
  111388. /** B */
  111389. B = 1,
  111390. /** X */
  111391. X = 2,
  111392. /** Y */
  111393. Y = 3,
  111394. /** Start */
  111395. Start = 4,
  111396. /** Back */
  111397. Back = 5,
  111398. /** Left button */
  111399. LB = 6,
  111400. /** Right button */
  111401. RB = 7,
  111402. /** Left stick */
  111403. LeftStick = 8,
  111404. /** Right stick */
  111405. RightStick = 9
  111406. }
  111407. /** Defines values for XBox360 DPad */
  111408. export enum Xbox360Dpad {
  111409. /** Up */
  111410. Up = 0,
  111411. /** Down */
  111412. Down = 1,
  111413. /** Left */
  111414. Left = 2,
  111415. /** Right */
  111416. Right = 3
  111417. }
  111418. /**
  111419. * Defines a XBox360 gamepad
  111420. */
  111421. export class Xbox360Pad extends Gamepad {
  111422. private _leftTrigger;
  111423. private _rightTrigger;
  111424. private _onlefttriggerchanged;
  111425. private _onrighttriggerchanged;
  111426. private _onbuttondown;
  111427. private _onbuttonup;
  111428. private _ondpaddown;
  111429. private _ondpadup;
  111430. /** Observable raised when a button is pressed */
  111431. onButtonDownObservable: Observable<Xbox360Button>;
  111432. /** Observable raised when a button is released */
  111433. onButtonUpObservable: Observable<Xbox360Button>;
  111434. /** Observable raised when a pad is pressed */
  111435. onPadDownObservable: Observable<Xbox360Dpad>;
  111436. /** Observable raised when a pad is released */
  111437. onPadUpObservable: Observable<Xbox360Dpad>;
  111438. private _buttonA;
  111439. private _buttonB;
  111440. private _buttonX;
  111441. private _buttonY;
  111442. private _buttonBack;
  111443. private _buttonStart;
  111444. private _buttonLB;
  111445. private _buttonRB;
  111446. private _buttonLeftStick;
  111447. private _buttonRightStick;
  111448. private _dPadUp;
  111449. private _dPadDown;
  111450. private _dPadLeft;
  111451. private _dPadRight;
  111452. private _isXboxOnePad;
  111453. /**
  111454. * Creates a new XBox360 gamepad object
  111455. * @param id defines the id of this gamepad
  111456. * @param index defines its index
  111457. * @param gamepad defines the internal HTML gamepad object
  111458. * @param xboxOne defines if it is a XBox One gamepad
  111459. */
  111460. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  111461. /**
  111462. * Defines the callback to call when left trigger is pressed
  111463. * @param callback defines the callback to use
  111464. */
  111465. onlefttriggerchanged(callback: (value: number) => void): void;
  111466. /**
  111467. * Defines the callback to call when right trigger is pressed
  111468. * @param callback defines the callback to use
  111469. */
  111470. onrighttriggerchanged(callback: (value: number) => void): void;
  111471. /**
  111472. * Gets the left trigger value
  111473. */
  111474. get leftTrigger(): number;
  111475. /**
  111476. * Sets the left trigger value
  111477. */
  111478. set leftTrigger(newValue: number);
  111479. /**
  111480. * Gets the right trigger value
  111481. */
  111482. get rightTrigger(): number;
  111483. /**
  111484. * Sets the right trigger value
  111485. */
  111486. set rightTrigger(newValue: number);
  111487. /**
  111488. * Defines the callback to call when a button is pressed
  111489. * @param callback defines the callback to use
  111490. */
  111491. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  111492. /**
  111493. * Defines the callback to call when a button is released
  111494. * @param callback defines the callback to use
  111495. */
  111496. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  111497. /**
  111498. * Defines the callback to call when a pad is pressed
  111499. * @param callback defines the callback to use
  111500. */
  111501. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  111502. /**
  111503. * Defines the callback to call when a pad is released
  111504. * @param callback defines the callback to use
  111505. */
  111506. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  111507. private _setButtonValue;
  111508. private _setDPadValue;
  111509. /**
  111510. * Gets the value of the `A` button
  111511. */
  111512. get buttonA(): number;
  111513. /**
  111514. * Sets the value of the `A` button
  111515. */
  111516. set buttonA(value: number);
  111517. /**
  111518. * Gets the value of the `B` button
  111519. */
  111520. get buttonB(): number;
  111521. /**
  111522. * Sets the value of the `B` button
  111523. */
  111524. set buttonB(value: number);
  111525. /**
  111526. * Gets the value of the `X` button
  111527. */
  111528. get buttonX(): number;
  111529. /**
  111530. * Sets the value of the `X` button
  111531. */
  111532. set buttonX(value: number);
  111533. /**
  111534. * Gets the value of the `Y` button
  111535. */
  111536. get buttonY(): number;
  111537. /**
  111538. * Sets the value of the `Y` button
  111539. */
  111540. set buttonY(value: number);
  111541. /**
  111542. * Gets the value of the `Start` button
  111543. */
  111544. get buttonStart(): number;
  111545. /**
  111546. * Sets the value of the `Start` button
  111547. */
  111548. set buttonStart(value: number);
  111549. /**
  111550. * Gets the value of the `Back` button
  111551. */
  111552. get buttonBack(): number;
  111553. /**
  111554. * Sets the value of the `Back` button
  111555. */
  111556. set buttonBack(value: number);
  111557. /**
  111558. * Gets the value of the `Left` button
  111559. */
  111560. get buttonLB(): number;
  111561. /**
  111562. * Sets the value of the `Left` button
  111563. */
  111564. set buttonLB(value: number);
  111565. /**
  111566. * Gets the value of the `Right` button
  111567. */
  111568. get buttonRB(): number;
  111569. /**
  111570. * Sets the value of the `Right` button
  111571. */
  111572. set buttonRB(value: number);
  111573. /**
  111574. * Gets the value of the Left joystick
  111575. */
  111576. get buttonLeftStick(): number;
  111577. /**
  111578. * Sets the value of the Left joystick
  111579. */
  111580. set buttonLeftStick(value: number);
  111581. /**
  111582. * Gets the value of the Right joystick
  111583. */
  111584. get buttonRightStick(): number;
  111585. /**
  111586. * Sets the value of the Right joystick
  111587. */
  111588. set buttonRightStick(value: number);
  111589. /**
  111590. * Gets the value of D-pad up
  111591. */
  111592. get dPadUp(): number;
  111593. /**
  111594. * Sets the value of D-pad up
  111595. */
  111596. set dPadUp(value: number);
  111597. /**
  111598. * Gets the value of D-pad down
  111599. */
  111600. get dPadDown(): number;
  111601. /**
  111602. * Sets the value of D-pad down
  111603. */
  111604. set dPadDown(value: number);
  111605. /**
  111606. * Gets the value of D-pad left
  111607. */
  111608. get dPadLeft(): number;
  111609. /**
  111610. * Sets the value of D-pad left
  111611. */
  111612. set dPadLeft(value: number);
  111613. /**
  111614. * Gets the value of D-pad right
  111615. */
  111616. get dPadRight(): number;
  111617. /**
  111618. * Sets the value of D-pad right
  111619. */
  111620. set dPadRight(value: number);
  111621. /**
  111622. * Force the gamepad to synchronize with device values
  111623. */
  111624. update(): void;
  111625. /**
  111626. * Disposes the gamepad
  111627. */
  111628. dispose(): void;
  111629. }
  111630. }
  111631. declare module BABYLON {
  111632. /**
  111633. * Defines supported buttons for DualShock compatible gamepads
  111634. */
  111635. export enum DualShockButton {
  111636. /** Cross */
  111637. Cross = 0,
  111638. /** Circle */
  111639. Circle = 1,
  111640. /** Square */
  111641. Square = 2,
  111642. /** Triangle */
  111643. Triangle = 3,
  111644. /** Options */
  111645. Options = 4,
  111646. /** Share */
  111647. Share = 5,
  111648. /** L1 */
  111649. L1 = 6,
  111650. /** R1 */
  111651. R1 = 7,
  111652. /** Left stick */
  111653. LeftStick = 8,
  111654. /** Right stick */
  111655. RightStick = 9
  111656. }
  111657. /** Defines values for DualShock DPad */
  111658. export enum DualShockDpad {
  111659. /** Up */
  111660. Up = 0,
  111661. /** Down */
  111662. Down = 1,
  111663. /** Left */
  111664. Left = 2,
  111665. /** Right */
  111666. Right = 3
  111667. }
  111668. /**
  111669. * Defines a DualShock gamepad
  111670. */
  111671. export class DualShockPad extends Gamepad {
  111672. private _leftTrigger;
  111673. private _rightTrigger;
  111674. private _onlefttriggerchanged;
  111675. private _onrighttriggerchanged;
  111676. private _onbuttondown;
  111677. private _onbuttonup;
  111678. private _ondpaddown;
  111679. private _ondpadup;
  111680. /** Observable raised when a button is pressed */
  111681. onButtonDownObservable: Observable<DualShockButton>;
  111682. /** Observable raised when a button is released */
  111683. onButtonUpObservable: Observable<DualShockButton>;
  111684. /** Observable raised when a pad is pressed */
  111685. onPadDownObservable: Observable<DualShockDpad>;
  111686. /** Observable raised when a pad is released */
  111687. onPadUpObservable: Observable<DualShockDpad>;
  111688. private _buttonCross;
  111689. private _buttonCircle;
  111690. private _buttonSquare;
  111691. private _buttonTriangle;
  111692. private _buttonShare;
  111693. private _buttonOptions;
  111694. private _buttonL1;
  111695. private _buttonR1;
  111696. private _buttonLeftStick;
  111697. private _buttonRightStick;
  111698. private _dPadUp;
  111699. private _dPadDown;
  111700. private _dPadLeft;
  111701. private _dPadRight;
  111702. /**
  111703. * Creates a new DualShock gamepad object
  111704. * @param id defines the id of this gamepad
  111705. * @param index defines its index
  111706. * @param gamepad defines the internal HTML gamepad object
  111707. */
  111708. constructor(id: string, index: number, gamepad: any);
  111709. /**
  111710. * Defines the callback to call when left trigger is pressed
  111711. * @param callback defines the callback to use
  111712. */
  111713. onlefttriggerchanged(callback: (value: number) => void): void;
  111714. /**
  111715. * Defines the callback to call when right trigger is pressed
  111716. * @param callback defines the callback to use
  111717. */
  111718. onrighttriggerchanged(callback: (value: number) => void): void;
  111719. /**
  111720. * Gets the left trigger value
  111721. */
  111722. get leftTrigger(): number;
  111723. /**
  111724. * Sets the left trigger value
  111725. */
  111726. set leftTrigger(newValue: number);
  111727. /**
  111728. * Gets the right trigger value
  111729. */
  111730. get rightTrigger(): number;
  111731. /**
  111732. * Sets the right trigger value
  111733. */
  111734. set rightTrigger(newValue: number);
  111735. /**
  111736. * Defines the callback to call when a button is pressed
  111737. * @param callback defines the callback to use
  111738. */
  111739. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  111740. /**
  111741. * Defines the callback to call when a button is released
  111742. * @param callback defines the callback to use
  111743. */
  111744. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  111745. /**
  111746. * Defines the callback to call when a pad is pressed
  111747. * @param callback defines the callback to use
  111748. */
  111749. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  111750. /**
  111751. * Defines the callback to call when a pad is released
  111752. * @param callback defines the callback to use
  111753. */
  111754. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  111755. private _setButtonValue;
  111756. private _setDPadValue;
  111757. /**
  111758. * Gets the value of the `Cross` button
  111759. */
  111760. get buttonCross(): number;
  111761. /**
  111762. * Sets the value of the `Cross` button
  111763. */
  111764. set buttonCross(value: number);
  111765. /**
  111766. * Gets the value of the `Circle` button
  111767. */
  111768. get buttonCircle(): number;
  111769. /**
  111770. * Sets the value of the `Circle` button
  111771. */
  111772. set buttonCircle(value: number);
  111773. /**
  111774. * Gets the value of the `Square` button
  111775. */
  111776. get buttonSquare(): number;
  111777. /**
  111778. * Sets the value of the `Square` button
  111779. */
  111780. set buttonSquare(value: number);
  111781. /**
  111782. * Gets the value of the `Triangle` button
  111783. */
  111784. get buttonTriangle(): number;
  111785. /**
  111786. * Sets the value of the `Triangle` button
  111787. */
  111788. set buttonTriangle(value: number);
  111789. /**
  111790. * Gets the value of the `Options` button
  111791. */
  111792. get buttonOptions(): number;
  111793. /**
  111794. * Sets the value of the `Options` button
  111795. */
  111796. set buttonOptions(value: number);
  111797. /**
  111798. * Gets the value of the `Share` button
  111799. */
  111800. get buttonShare(): number;
  111801. /**
  111802. * Sets the value of the `Share` button
  111803. */
  111804. set buttonShare(value: number);
  111805. /**
  111806. * Gets the value of the `L1` button
  111807. */
  111808. get buttonL1(): number;
  111809. /**
  111810. * Sets the value of the `L1` button
  111811. */
  111812. set buttonL1(value: number);
  111813. /**
  111814. * Gets the value of the `R1` button
  111815. */
  111816. get buttonR1(): number;
  111817. /**
  111818. * Sets the value of the `R1` button
  111819. */
  111820. set buttonR1(value: number);
  111821. /**
  111822. * Gets the value of the Left joystick
  111823. */
  111824. get buttonLeftStick(): number;
  111825. /**
  111826. * Sets the value of the Left joystick
  111827. */
  111828. set buttonLeftStick(value: number);
  111829. /**
  111830. * Gets the value of the Right joystick
  111831. */
  111832. get buttonRightStick(): number;
  111833. /**
  111834. * Sets the value of the Right joystick
  111835. */
  111836. set buttonRightStick(value: number);
  111837. /**
  111838. * Gets the value of D-pad up
  111839. */
  111840. get dPadUp(): number;
  111841. /**
  111842. * Sets the value of D-pad up
  111843. */
  111844. set dPadUp(value: number);
  111845. /**
  111846. * Gets the value of D-pad down
  111847. */
  111848. get dPadDown(): number;
  111849. /**
  111850. * Sets the value of D-pad down
  111851. */
  111852. set dPadDown(value: number);
  111853. /**
  111854. * Gets the value of D-pad left
  111855. */
  111856. get dPadLeft(): number;
  111857. /**
  111858. * Sets the value of D-pad left
  111859. */
  111860. set dPadLeft(value: number);
  111861. /**
  111862. * Gets the value of D-pad right
  111863. */
  111864. get dPadRight(): number;
  111865. /**
  111866. * Sets the value of D-pad right
  111867. */
  111868. set dPadRight(value: number);
  111869. /**
  111870. * Force the gamepad to synchronize with device values
  111871. */
  111872. update(): void;
  111873. /**
  111874. * Disposes the gamepad
  111875. */
  111876. dispose(): void;
  111877. }
  111878. }
  111879. declare module BABYLON {
  111880. /**
  111881. * Manager for handling gamepads
  111882. */
  111883. export class GamepadManager {
  111884. private _scene?;
  111885. private _babylonGamepads;
  111886. private _oneGamepadConnected;
  111887. /** @hidden */
  111888. _isMonitoring: boolean;
  111889. private _gamepadEventSupported;
  111890. private _gamepadSupport?;
  111891. /**
  111892. * observable to be triggered when the gamepad controller has been connected
  111893. */
  111894. onGamepadConnectedObservable: Observable<Gamepad>;
  111895. /**
  111896. * observable to be triggered when the gamepad controller has been disconnected
  111897. */
  111898. onGamepadDisconnectedObservable: Observable<Gamepad>;
  111899. private _onGamepadConnectedEvent;
  111900. private _onGamepadDisconnectedEvent;
  111901. /**
  111902. * Initializes the gamepad manager
  111903. * @param _scene BabylonJS scene
  111904. */
  111905. constructor(_scene?: Scene | undefined);
  111906. /**
  111907. * The gamepads in the game pad manager
  111908. */
  111909. get gamepads(): Gamepad[];
  111910. /**
  111911. * Get the gamepad controllers based on type
  111912. * @param type The type of gamepad controller
  111913. * @returns Nullable gamepad
  111914. */
  111915. getGamepadByType(type?: number): Nullable<Gamepad>;
  111916. /**
  111917. * Disposes the gamepad manager
  111918. */
  111919. dispose(): void;
  111920. private _addNewGamepad;
  111921. private _startMonitoringGamepads;
  111922. private _stopMonitoringGamepads;
  111923. /** @hidden */
  111924. _checkGamepadsStatus(): void;
  111925. private _updateGamepadObjects;
  111926. }
  111927. }
  111928. declare module BABYLON {
  111929. interface Scene {
  111930. /** @hidden */
  111931. _gamepadManager: Nullable<GamepadManager>;
  111932. /**
  111933. * Gets the gamepad manager associated with the scene
  111934. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  111935. */
  111936. gamepadManager: GamepadManager;
  111937. }
  111938. /**
  111939. * Interface representing a free camera inputs manager
  111940. */
  111941. interface FreeCameraInputsManager {
  111942. /**
  111943. * Adds gamepad input support to the FreeCameraInputsManager.
  111944. * @returns the FreeCameraInputsManager
  111945. */
  111946. addGamepad(): FreeCameraInputsManager;
  111947. }
  111948. /**
  111949. * Interface representing an arc rotate camera inputs manager
  111950. */
  111951. interface ArcRotateCameraInputsManager {
  111952. /**
  111953. * Adds gamepad input support to the ArcRotateCamera InputManager.
  111954. * @returns the camera inputs manager
  111955. */
  111956. addGamepad(): ArcRotateCameraInputsManager;
  111957. }
  111958. /**
  111959. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  111960. */
  111961. export class GamepadSystemSceneComponent implements ISceneComponent {
  111962. /**
  111963. * The component name helpfull to identify the component in the list of scene components.
  111964. */
  111965. readonly name: string;
  111966. /**
  111967. * The scene the component belongs to.
  111968. */
  111969. scene: Scene;
  111970. /**
  111971. * Creates a new instance of the component for the given scene
  111972. * @param scene Defines the scene to register the component in
  111973. */
  111974. constructor(scene: Scene);
  111975. /**
  111976. * Registers the component in a given scene
  111977. */
  111978. register(): void;
  111979. /**
  111980. * Rebuilds the elements related to this component in case of
  111981. * context lost for instance.
  111982. */
  111983. rebuild(): void;
  111984. /**
  111985. * Disposes the component and the associated ressources
  111986. */
  111987. dispose(): void;
  111988. private _beforeCameraUpdate;
  111989. }
  111990. }
  111991. declare module BABYLON {
  111992. /**
  111993. * 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,
  111994. * which still works and will still be found in many Playgrounds.
  111995. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111996. */
  111997. export class UniversalCamera extends TouchCamera {
  111998. /**
  111999. * Defines the gamepad rotation sensiblity.
  112000. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112001. */
  112002. get gamepadAngularSensibility(): number;
  112003. set gamepadAngularSensibility(value: number);
  112004. /**
  112005. * Defines the gamepad move sensiblity.
  112006. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112007. */
  112008. get gamepadMoveSensibility(): number;
  112009. set gamepadMoveSensibility(value: number);
  112010. /**
  112011. * 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,
  112012. * which still works and will still be found in many Playgrounds.
  112013. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112014. * @param name Define the name of the camera in the scene
  112015. * @param position Define the start position of the camera in the scene
  112016. * @param scene Define the scene the camera belongs to
  112017. */
  112018. constructor(name: string, position: Vector3, scene: Scene);
  112019. /**
  112020. * Gets the current object class name.
  112021. * @return the class name
  112022. */
  112023. getClassName(): string;
  112024. }
  112025. }
  112026. declare module BABYLON {
  112027. /**
  112028. * This represents a FPS type of camera. This is only here for back compat purpose.
  112029. * Please use the UniversalCamera instead as both are identical.
  112030. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112031. */
  112032. export class GamepadCamera extends UniversalCamera {
  112033. /**
  112034. * Instantiates a new Gamepad Camera
  112035. * This represents a FPS type of camera. This is only here for back compat purpose.
  112036. * Please use the UniversalCamera instead as both are identical.
  112037. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112038. * @param name Define the name of the camera in the scene
  112039. * @param position Define the start position of the camera in the scene
  112040. * @param scene Define the scene the camera belongs to
  112041. */
  112042. constructor(name: string, position: Vector3, scene: Scene);
  112043. /**
  112044. * Gets the current object class name.
  112045. * @return the class name
  112046. */
  112047. getClassName(): string;
  112048. }
  112049. }
  112050. declare module BABYLON {
  112051. /** @hidden */
  112052. export var passPixelShader: {
  112053. name: string;
  112054. shader: string;
  112055. };
  112056. }
  112057. declare module BABYLON {
  112058. /** @hidden */
  112059. export var passCubePixelShader: {
  112060. name: string;
  112061. shader: string;
  112062. };
  112063. }
  112064. declare module BABYLON {
  112065. /**
  112066. * PassPostProcess which produces an output the same as it's input
  112067. */
  112068. export class PassPostProcess extends PostProcess {
  112069. /**
  112070. * Creates the PassPostProcess
  112071. * @param name The name of the effect.
  112072. * @param options The required width/height ratio to downsize to before computing the render pass.
  112073. * @param camera The camera to apply the render pass to.
  112074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112075. * @param engine The engine which the post process will be applied. (default: current engine)
  112076. * @param reusable If the post process can be reused on the same frame. (default: false)
  112077. * @param textureType The type of texture to be used when performing the post processing.
  112078. * @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)
  112079. */
  112080. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112081. }
  112082. /**
  112083. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  112084. */
  112085. export class PassCubePostProcess extends PostProcess {
  112086. private _face;
  112087. /**
  112088. * Gets or sets the cube face to display.
  112089. * * 0 is +X
  112090. * * 1 is -X
  112091. * * 2 is +Y
  112092. * * 3 is -Y
  112093. * * 4 is +Z
  112094. * * 5 is -Z
  112095. */
  112096. get face(): number;
  112097. set face(value: number);
  112098. /**
  112099. * Creates the PassCubePostProcess
  112100. * @param name The name of the effect.
  112101. * @param options The required width/height ratio to downsize to before computing the render pass.
  112102. * @param camera The camera to apply the render pass to.
  112103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112104. * @param engine The engine which the post process will be applied. (default: current engine)
  112105. * @param reusable If the post process can be reused on the same frame. (default: false)
  112106. * @param textureType The type of texture to be used when performing the post processing.
  112107. * @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)
  112108. */
  112109. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112110. }
  112111. }
  112112. declare module BABYLON {
  112113. /** @hidden */
  112114. export var anaglyphPixelShader: {
  112115. name: string;
  112116. shader: string;
  112117. };
  112118. }
  112119. declare module BABYLON {
  112120. /**
  112121. * Postprocess used to generate anaglyphic rendering
  112122. */
  112123. export class AnaglyphPostProcess extends PostProcess {
  112124. private _passedProcess;
  112125. /**
  112126. * Creates a new AnaglyphPostProcess
  112127. * @param name defines postprocess name
  112128. * @param options defines creation options or target ratio scale
  112129. * @param rigCameras defines cameras using this postprocess
  112130. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  112131. * @param engine defines hosting engine
  112132. * @param reusable defines if the postprocess will be reused multiple times per frame
  112133. */
  112134. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  112135. }
  112136. }
  112137. declare module BABYLON {
  112138. /**
  112139. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  112140. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112141. */
  112142. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  112143. /**
  112144. * Creates a new AnaglyphArcRotateCamera
  112145. * @param name defines camera name
  112146. * @param alpha defines alpha angle (in radians)
  112147. * @param beta defines beta angle (in radians)
  112148. * @param radius defines radius
  112149. * @param target defines camera target
  112150. * @param interaxialDistance defines distance between each color axis
  112151. * @param scene defines the hosting scene
  112152. */
  112153. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  112154. /**
  112155. * Gets camera class name
  112156. * @returns AnaglyphArcRotateCamera
  112157. */
  112158. getClassName(): string;
  112159. }
  112160. }
  112161. declare module BABYLON {
  112162. /**
  112163. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  112164. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112165. */
  112166. export class AnaglyphFreeCamera extends FreeCamera {
  112167. /**
  112168. * Creates a new AnaglyphFreeCamera
  112169. * @param name defines camera name
  112170. * @param position defines initial position
  112171. * @param interaxialDistance defines distance between each color axis
  112172. * @param scene defines the hosting scene
  112173. */
  112174. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112175. /**
  112176. * Gets camera class name
  112177. * @returns AnaglyphFreeCamera
  112178. */
  112179. getClassName(): string;
  112180. }
  112181. }
  112182. declare module BABYLON {
  112183. /**
  112184. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  112185. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112186. */
  112187. export class AnaglyphGamepadCamera extends GamepadCamera {
  112188. /**
  112189. * Creates a new AnaglyphGamepadCamera
  112190. * @param name defines camera name
  112191. * @param position defines initial position
  112192. * @param interaxialDistance defines distance between each color axis
  112193. * @param scene defines the hosting scene
  112194. */
  112195. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112196. /**
  112197. * Gets camera class name
  112198. * @returns AnaglyphGamepadCamera
  112199. */
  112200. getClassName(): string;
  112201. }
  112202. }
  112203. declare module BABYLON {
  112204. /**
  112205. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  112206. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112207. */
  112208. export class AnaglyphUniversalCamera extends UniversalCamera {
  112209. /**
  112210. * Creates a new AnaglyphUniversalCamera
  112211. * @param name defines camera name
  112212. * @param position defines initial position
  112213. * @param interaxialDistance defines distance between each color axis
  112214. * @param scene defines the hosting scene
  112215. */
  112216. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112217. /**
  112218. * Gets camera class name
  112219. * @returns AnaglyphUniversalCamera
  112220. */
  112221. getClassName(): string;
  112222. }
  112223. }
  112224. declare module BABYLON {
  112225. /** @hidden */
  112226. export var stereoscopicInterlacePixelShader: {
  112227. name: string;
  112228. shader: string;
  112229. };
  112230. }
  112231. declare module BABYLON {
  112232. /**
  112233. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  112234. */
  112235. export class StereoscopicInterlacePostProcess extends PostProcess {
  112236. private _stepSize;
  112237. private _passedProcess;
  112238. /**
  112239. * Initializes a StereoscopicInterlacePostProcess
  112240. * @param name The name of the effect.
  112241. * @param rigCameras The rig cameras to be appled to the post process
  112242. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  112243. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112244. * @param engine The engine which the post process will be applied. (default: current engine)
  112245. * @param reusable If the post process can be reused on the same frame. (default: false)
  112246. */
  112247. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112248. }
  112249. }
  112250. declare module BABYLON {
  112251. /**
  112252. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  112253. * @see http://doc.babylonjs.com/features/cameras
  112254. */
  112255. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  112256. /**
  112257. * Creates a new StereoscopicArcRotateCamera
  112258. * @param name defines camera name
  112259. * @param alpha defines alpha angle (in radians)
  112260. * @param beta defines beta angle (in radians)
  112261. * @param radius defines radius
  112262. * @param target defines camera target
  112263. * @param interaxialDistance defines distance between each color axis
  112264. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112265. * @param scene defines the hosting scene
  112266. */
  112267. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112268. /**
  112269. * Gets camera class name
  112270. * @returns StereoscopicArcRotateCamera
  112271. */
  112272. getClassName(): string;
  112273. }
  112274. }
  112275. declare module BABYLON {
  112276. /**
  112277. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  112278. * @see http://doc.babylonjs.com/features/cameras
  112279. */
  112280. export class StereoscopicFreeCamera extends FreeCamera {
  112281. /**
  112282. * Creates a new StereoscopicFreeCamera
  112283. * @param name defines camera name
  112284. * @param position defines initial position
  112285. * @param interaxialDistance defines distance between each color axis
  112286. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112287. * @param scene defines the hosting scene
  112288. */
  112289. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112290. /**
  112291. * Gets camera class name
  112292. * @returns StereoscopicFreeCamera
  112293. */
  112294. getClassName(): string;
  112295. }
  112296. }
  112297. declare module BABYLON {
  112298. /**
  112299. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  112300. * @see http://doc.babylonjs.com/features/cameras
  112301. */
  112302. export class StereoscopicGamepadCamera extends GamepadCamera {
  112303. /**
  112304. * Creates a new StereoscopicGamepadCamera
  112305. * @param name defines camera name
  112306. * @param position defines initial position
  112307. * @param interaxialDistance defines distance between each color axis
  112308. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112309. * @param scene defines the hosting scene
  112310. */
  112311. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112312. /**
  112313. * Gets camera class name
  112314. * @returns StereoscopicGamepadCamera
  112315. */
  112316. getClassName(): string;
  112317. }
  112318. }
  112319. declare module BABYLON {
  112320. /**
  112321. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  112322. * @see http://doc.babylonjs.com/features/cameras
  112323. */
  112324. export class StereoscopicUniversalCamera extends UniversalCamera {
  112325. /**
  112326. * Creates a new StereoscopicUniversalCamera
  112327. * @param name defines camera name
  112328. * @param position defines initial position
  112329. * @param interaxialDistance defines distance between each color axis
  112330. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112331. * @param scene defines the hosting scene
  112332. */
  112333. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112334. /**
  112335. * Gets camera class name
  112336. * @returns StereoscopicUniversalCamera
  112337. */
  112338. getClassName(): string;
  112339. }
  112340. }
  112341. declare module BABYLON {
  112342. /**
  112343. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  112344. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112345. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112346. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112347. */
  112348. export class VirtualJoysticksCamera extends FreeCamera {
  112349. /**
  112350. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  112351. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112352. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112353. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112354. * @param name Define the name of the camera in the scene
  112355. * @param position Define the start position of the camera in the scene
  112356. * @param scene Define the scene the camera belongs to
  112357. */
  112358. constructor(name: string, position: Vector3, scene: Scene);
  112359. /**
  112360. * Gets the current object class name.
  112361. * @return the class name
  112362. */
  112363. getClassName(): string;
  112364. }
  112365. }
  112366. declare module BABYLON {
  112367. /**
  112368. * This represents all the required metrics to create a VR camera.
  112369. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  112370. */
  112371. export class VRCameraMetrics {
  112372. /**
  112373. * Define the horizontal resolution off the screen.
  112374. */
  112375. hResolution: number;
  112376. /**
  112377. * Define the vertical resolution off the screen.
  112378. */
  112379. vResolution: number;
  112380. /**
  112381. * Define the horizontal screen size.
  112382. */
  112383. hScreenSize: number;
  112384. /**
  112385. * Define the vertical screen size.
  112386. */
  112387. vScreenSize: number;
  112388. /**
  112389. * Define the vertical screen center position.
  112390. */
  112391. vScreenCenter: number;
  112392. /**
  112393. * Define the distance of the eyes to the screen.
  112394. */
  112395. eyeToScreenDistance: number;
  112396. /**
  112397. * Define the distance between both lenses
  112398. */
  112399. lensSeparationDistance: number;
  112400. /**
  112401. * Define the distance between both viewer's eyes.
  112402. */
  112403. interpupillaryDistance: number;
  112404. /**
  112405. * Define the distortion factor of the VR postprocess.
  112406. * Please, touch with care.
  112407. */
  112408. distortionK: number[];
  112409. /**
  112410. * Define the chromatic aberration correction factors for the VR post process.
  112411. */
  112412. chromaAbCorrection: number[];
  112413. /**
  112414. * Define the scale factor of the post process.
  112415. * The smaller the better but the slower.
  112416. */
  112417. postProcessScaleFactor: number;
  112418. /**
  112419. * Define an offset for the lens center.
  112420. */
  112421. lensCenterOffset: number;
  112422. /**
  112423. * Define if the current vr camera should compensate the distortion of the lense or not.
  112424. */
  112425. compensateDistortion: boolean;
  112426. /**
  112427. * Defines if multiview should be enabled when rendering (Default: false)
  112428. */
  112429. multiviewEnabled: boolean;
  112430. /**
  112431. * Gets the rendering aspect ratio based on the provided resolutions.
  112432. */
  112433. get aspectRatio(): number;
  112434. /**
  112435. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  112436. */
  112437. get aspectRatioFov(): number;
  112438. /**
  112439. * @hidden
  112440. */
  112441. get leftHMatrix(): Matrix;
  112442. /**
  112443. * @hidden
  112444. */
  112445. get rightHMatrix(): Matrix;
  112446. /**
  112447. * @hidden
  112448. */
  112449. get leftPreViewMatrix(): Matrix;
  112450. /**
  112451. * @hidden
  112452. */
  112453. get rightPreViewMatrix(): Matrix;
  112454. /**
  112455. * Get the default VRMetrics based on the most generic setup.
  112456. * @returns the default vr metrics
  112457. */
  112458. static GetDefault(): VRCameraMetrics;
  112459. }
  112460. }
  112461. declare module BABYLON {
  112462. /** @hidden */
  112463. export var vrDistortionCorrectionPixelShader: {
  112464. name: string;
  112465. shader: string;
  112466. };
  112467. }
  112468. declare module BABYLON {
  112469. /**
  112470. * VRDistortionCorrectionPostProcess used for mobile VR
  112471. */
  112472. export class VRDistortionCorrectionPostProcess extends PostProcess {
  112473. private _isRightEye;
  112474. private _distortionFactors;
  112475. private _postProcessScaleFactor;
  112476. private _lensCenterOffset;
  112477. private _scaleIn;
  112478. private _scaleFactor;
  112479. private _lensCenter;
  112480. /**
  112481. * Initializes the VRDistortionCorrectionPostProcess
  112482. * @param name The name of the effect.
  112483. * @param camera The camera to apply the render pass to.
  112484. * @param isRightEye If this is for the right eye distortion
  112485. * @param vrMetrics All the required metrics for the VR camera
  112486. */
  112487. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  112488. }
  112489. }
  112490. declare module BABYLON {
  112491. /**
  112492. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  112493. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112494. */
  112495. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  112496. /**
  112497. * Creates a new VRDeviceOrientationArcRotateCamera
  112498. * @param name defines camera name
  112499. * @param alpha defines the camera rotation along the logitudinal axis
  112500. * @param beta defines the camera rotation along the latitudinal axis
  112501. * @param radius defines the camera distance from its target
  112502. * @param target defines the camera target
  112503. * @param scene defines the scene the camera belongs to
  112504. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112505. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112506. */
  112507. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112508. /**
  112509. * Gets camera class name
  112510. * @returns VRDeviceOrientationArcRotateCamera
  112511. */
  112512. getClassName(): string;
  112513. }
  112514. }
  112515. declare module BABYLON {
  112516. /**
  112517. * Camera used to simulate VR rendering (based on FreeCamera)
  112518. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112519. */
  112520. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  112521. /**
  112522. * Creates a new VRDeviceOrientationFreeCamera
  112523. * @param name defines camera name
  112524. * @param position defines the start position of the camera
  112525. * @param scene defines the scene the camera belongs to
  112526. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112527. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112528. */
  112529. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112530. /**
  112531. * Gets camera class name
  112532. * @returns VRDeviceOrientationFreeCamera
  112533. */
  112534. getClassName(): string;
  112535. }
  112536. }
  112537. declare module BABYLON {
  112538. /**
  112539. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  112540. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112541. */
  112542. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  112543. /**
  112544. * Creates a new VRDeviceOrientationGamepadCamera
  112545. * @param name defines camera name
  112546. * @param position defines the start position of the camera
  112547. * @param scene defines the scene the camera belongs to
  112548. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112549. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112550. */
  112551. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112552. /**
  112553. * Gets camera class name
  112554. * @returns VRDeviceOrientationGamepadCamera
  112555. */
  112556. getClassName(): string;
  112557. }
  112558. }
  112559. declare module BABYLON {
  112560. /** @hidden */
  112561. export var imageProcessingPixelShader: {
  112562. name: string;
  112563. shader: string;
  112564. };
  112565. }
  112566. declare module BABYLON {
  112567. /**
  112568. * ImageProcessingPostProcess
  112569. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  112570. */
  112571. export class ImageProcessingPostProcess extends PostProcess {
  112572. /**
  112573. * Default configuration related to image processing available in the PBR Material.
  112574. */
  112575. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112576. /**
  112577. * Gets the image processing configuration used either in this material.
  112578. */
  112579. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  112580. /**
  112581. * Sets the Default image processing configuration used either in the this material.
  112582. *
  112583. * If sets to null, the scene one is in use.
  112584. */
  112585. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  112586. /**
  112587. * Keep track of the image processing observer to allow dispose and replace.
  112588. */
  112589. private _imageProcessingObserver;
  112590. /**
  112591. * Attaches a new image processing configuration to the PBR Material.
  112592. * @param configuration
  112593. */
  112594. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  112595. /**
  112596. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112597. */
  112598. get colorCurves(): Nullable<ColorCurves>;
  112599. /**
  112600. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112601. */
  112602. set colorCurves(value: Nullable<ColorCurves>);
  112603. /**
  112604. * Gets wether the color curves effect is enabled.
  112605. */
  112606. get colorCurvesEnabled(): boolean;
  112607. /**
  112608. * Sets wether the color curves effect is enabled.
  112609. */
  112610. set colorCurvesEnabled(value: boolean);
  112611. /**
  112612. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112613. */
  112614. get colorGradingTexture(): Nullable<BaseTexture>;
  112615. /**
  112616. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112617. */
  112618. set colorGradingTexture(value: Nullable<BaseTexture>);
  112619. /**
  112620. * Gets wether the color grading effect is enabled.
  112621. */
  112622. get colorGradingEnabled(): boolean;
  112623. /**
  112624. * Gets wether the color grading effect is enabled.
  112625. */
  112626. set colorGradingEnabled(value: boolean);
  112627. /**
  112628. * Gets exposure used in the effect.
  112629. */
  112630. get exposure(): number;
  112631. /**
  112632. * Sets exposure used in the effect.
  112633. */
  112634. set exposure(value: number);
  112635. /**
  112636. * Gets wether tonemapping is enabled or not.
  112637. */
  112638. get toneMappingEnabled(): boolean;
  112639. /**
  112640. * Sets wether tonemapping is enabled or not
  112641. */
  112642. set toneMappingEnabled(value: boolean);
  112643. /**
  112644. * Gets the type of tone mapping effect.
  112645. */
  112646. get toneMappingType(): number;
  112647. /**
  112648. * Sets the type of tone mapping effect.
  112649. */
  112650. set toneMappingType(value: number);
  112651. /**
  112652. * Gets contrast used in the effect.
  112653. */
  112654. get contrast(): number;
  112655. /**
  112656. * Sets contrast used in the effect.
  112657. */
  112658. set contrast(value: number);
  112659. /**
  112660. * Gets Vignette stretch size.
  112661. */
  112662. get vignetteStretch(): number;
  112663. /**
  112664. * Sets Vignette stretch size.
  112665. */
  112666. set vignetteStretch(value: number);
  112667. /**
  112668. * Gets Vignette centre X Offset.
  112669. */
  112670. get vignetteCentreX(): number;
  112671. /**
  112672. * Sets Vignette centre X Offset.
  112673. */
  112674. set vignetteCentreX(value: number);
  112675. /**
  112676. * Gets Vignette centre Y Offset.
  112677. */
  112678. get vignetteCentreY(): number;
  112679. /**
  112680. * Sets Vignette centre Y Offset.
  112681. */
  112682. set vignetteCentreY(value: number);
  112683. /**
  112684. * Gets Vignette weight or intensity of the vignette effect.
  112685. */
  112686. get vignetteWeight(): number;
  112687. /**
  112688. * Sets Vignette weight or intensity of the vignette effect.
  112689. */
  112690. set vignetteWeight(value: number);
  112691. /**
  112692. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112693. * if vignetteEnabled is set to true.
  112694. */
  112695. get vignetteColor(): Color4;
  112696. /**
  112697. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112698. * if vignetteEnabled is set to true.
  112699. */
  112700. set vignetteColor(value: Color4);
  112701. /**
  112702. * Gets Camera field of view used by the Vignette effect.
  112703. */
  112704. get vignetteCameraFov(): number;
  112705. /**
  112706. * Sets Camera field of view used by the Vignette effect.
  112707. */
  112708. set vignetteCameraFov(value: number);
  112709. /**
  112710. * Gets the vignette blend mode allowing different kind of effect.
  112711. */
  112712. get vignetteBlendMode(): number;
  112713. /**
  112714. * Sets the vignette blend mode allowing different kind of effect.
  112715. */
  112716. set vignetteBlendMode(value: number);
  112717. /**
  112718. * Gets wether the vignette effect is enabled.
  112719. */
  112720. get vignetteEnabled(): boolean;
  112721. /**
  112722. * Sets wether the vignette effect is enabled.
  112723. */
  112724. set vignetteEnabled(value: boolean);
  112725. private _fromLinearSpace;
  112726. /**
  112727. * Gets wether the input of the processing is in Gamma or Linear Space.
  112728. */
  112729. get fromLinearSpace(): boolean;
  112730. /**
  112731. * Sets wether the input of the processing is in Gamma or Linear Space.
  112732. */
  112733. set fromLinearSpace(value: boolean);
  112734. /**
  112735. * Defines cache preventing GC.
  112736. */
  112737. private _defines;
  112738. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  112739. /**
  112740. * "ImageProcessingPostProcess"
  112741. * @returns "ImageProcessingPostProcess"
  112742. */
  112743. getClassName(): string;
  112744. protected _updateParameters(): void;
  112745. dispose(camera?: Camera): void;
  112746. }
  112747. }
  112748. declare module BABYLON {
  112749. /**
  112750. * Class containing static functions to help procedurally build meshes
  112751. */
  112752. export class GroundBuilder {
  112753. /**
  112754. * Creates a ground mesh
  112755. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  112756. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  112757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112758. * @param name defines the name of the mesh
  112759. * @param options defines the options used to create the mesh
  112760. * @param scene defines the hosting scene
  112761. * @returns the ground mesh
  112762. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  112763. */
  112764. static CreateGround(name: string, options: {
  112765. width?: number;
  112766. height?: number;
  112767. subdivisions?: number;
  112768. subdivisionsX?: number;
  112769. subdivisionsY?: number;
  112770. updatable?: boolean;
  112771. }, scene: any): Mesh;
  112772. /**
  112773. * Creates a tiled ground mesh
  112774. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  112775. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  112776. * * 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
  112777. * * 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
  112778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112779. * @param name defines the name of the mesh
  112780. * @param options defines the options used to create the mesh
  112781. * @param scene defines the hosting scene
  112782. * @returns the tiled ground mesh
  112783. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  112784. */
  112785. static CreateTiledGround(name: string, options: {
  112786. xmin: number;
  112787. zmin: number;
  112788. xmax: number;
  112789. zmax: number;
  112790. subdivisions?: {
  112791. w: number;
  112792. h: number;
  112793. };
  112794. precision?: {
  112795. w: number;
  112796. h: number;
  112797. };
  112798. updatable?: boolean;
  112799. }, scene?: Nullable<Scene>): Mesh;
  112800. /**
  112801. * Creates a ground mesh from a height map
  112802. * * The parameter `url` sets the URL of the height map image resource.
  112803. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  112804. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  112805. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  112806. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  112807. * * 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.
  112808. * * 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).
  112809. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  112810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112811. * @param name defines the name of the mesh
  112812. * @param url defines the url to the height map
  112813. * @param options defines the options used to create the mesh
  112814. * @param scene defines the hosting scene
  112815. * @returns the ground mesh
  112816. * @see https://doc.babylonjs.com/babylon101/height_map
  112817. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  112818. */
  112819. static CreateGroundFromHeightMap(name: string, url: string, options: {
  112820. width?: number;
  112821. height?: number;
  112822. subdivisions?: number;
  112823. minHeight?: number;
  112824. maxHeight?: number;
  112825. colorFilter?: Color3;
  112826. alphaFilter?: number;
  112827. updatable?: boolean;
  112828. onReady?: (mesh: GroundMesh) => void;
  112829. }, scene?: Nullable<Scene>): GroundMesh;
  112830. }
  112831. }
  112832. declare module BABYLON {
  112833. /**
  112834. * Class containing static functions to help procedurally build meshes
  112835. */
  112836. export class TorusBuilder {
  112837. /**
  112838. * Creates a torus mesh
  112839. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  112840. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  112841. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  112842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112845. * @param name defines the name of the mesh
  112846. * @param options defines the options used to create the mesh
  112847. * @param scene defines the hosting scene
  112848. * @returns the torus mesh
  112849. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  112850. */
  112851. static CreateTorus(name: string, options: {
  112852. diameter?: number;
  112853. thickness?: number;
  112854. tessellation?: number;
  112855. updatable?: boolean;
  112856. sideOrientation?: number;
  112857. frontUVs?: Vector4;
  112858. backUVs?: Vector4;
  112859. }, scene: any): Mesh;
  112860. }
  112861. }
  112862. declare module BABYLON {
  112863. /**
  112864. * Class containing static functions to help procedurally build meshes
  112865. */
  112866. export class CylinderBuilder {
  112867. /**
  112868. * Creates a cylinder or a cone mesh
  112869. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  112870. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  112871. * * 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.
  112872. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  112873. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  112874. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  112875. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  112876. * * 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).
  112877. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  112878. * * 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).
  112879. * * 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
  112880. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  112881. * * 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
  112882. * * 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.
  112883. * * If `enclose` is false, a ring surface is one element.
  112884. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  112885. * * 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
  112886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112889. * @param name defines the name of the mesh
  112890. * @param options defines the options used to create the mesh
  112891. * @param scene defines the hosting scene
  112892. * @returns the cylinder mesh
  112893. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  112894. */
  112895. static CreateCylinder(name: string, options: {
  112896. height?: number;
  112897. diameterTop?: number;
  112898. diameterBottom?: number;
  112899. diameter?: number;
  112900. tessellation?: number;
  112901. subdivisions?: number;
  112902. arc?: number;
  112903. faceColors?: Color4[];
  112904. faceUV?: Vector4[];
  112905. updatable?: boolean;
  112906. hasRings?: boolean;
  112907. enclose?: boolean;
  112908. cap?: number;
  112909. sideOrientation?: number;
  112910. frontUVs?: Vector4;
  112911. backUVs?: Vector4;
  112912. }, scene: any): Mesh;
  112913. }
  112914. }
  112915. declare module BABYLON {
  112916. /**
  112917. * States of the webXR experience
  112918. */
  112919. export enum WebXRState {
  112920. /**
  112921. * Transitioning to being in XR mode
  112922. */
  112923. ENTERING_XR = 0,
  112924. /**
  112925. * Transitioning to non XR mode
  112926. */
  112927. EXITING_XR = 1,
  112928. /**
  112929. * In XR mode and presenting
  112930. */
  112931. IN_XR = 2,
  112932. /**
  112933. * Not entered XR mode
  112934. */
  112935. NOT_IN_XR = 3
  112936. }
  112937. /**
  112938. * Abstraction of the XR render target
  112939. */
  112940. export interface WebXRRenderTarget extends IDisposable {
  112941. /**
  112942. * xrpresent context of the canvas which can be used to display/mirror xr content
  112943. */
  112944. canvasContext: WebGLRenderingContext;
  112945. /**
  112946. * xr layer for the canvas
  112947. */
  112948. xrLayer: Nullable<XRWebGLLayer>;
  112949. /**
  112950. * Initializes the xr layer for the session
  112951. * @param xrSession xr session
  112952. * @returns a promise that will resolve once the XR Layer has been created
  112953. */
  112954. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  112955. }
  112956. }
  112957. declare module BABYLON {
  112958. /**
  112959. * COnfiguration object for WebXR output canvas
  112960. */
  112961. export class WebXRManagedOutputCanvasOptions {
  112962. /**
  112963. * Options for this XR Layer output
  112964. */
  112965. canvasOptions: XRWebGLLayerOptions;
  112966. /**
  112967. * CSS styling for a newly created canvas (if not provided)
  112968. */
  112969. newCanvasCssStyle?: string;
  112970. /**
  112971. * Get the default values of the configuration object
  112972. * @returns default values of this configuration object
  112973. */
  112974. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  112975. }
  112976. /**
  112977. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  112978. */
  112979. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  112980. private configuration;
  112981. private _engine;
  112982. private _canvas;
  112983. /**
  112984. * xrpresent context of the canvas which can be used to display/mirror xr content
  112985. */
  112986. canvasContext: WebGLRenderingContext;
  112987. /**
  112988. * xr layer for the canvas
  112989. */
  112990. xrLayer: Nullable<XRWebGLLayer>;
  112991. /**
  112992. * Initializes the xr layer for the session
  112993. * @param xrSession xr session
  112994. * @returns a promise that will resolve once the XR Layer has been created
  112995. */
  112996. initializeXRLayerAsync(xrSession: any): any;
  112997. /**
  112998. * Initializes the canvas to be added/removed upon entering/exiting xr
  112999. * @param engine the Babylon engine
  113000. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  113001. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  113002. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  113003. */
  113004. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  113005. /**
  113006. * Disposes of the object
  113007. */
  113008. dispose(): void;
  113009. private _setManagedOutputCanvas;
  113010. private _addCanvas;
  113011. private _removeCanvas;
  113012. }
  113013. }
  113014. declare module BABYLON {
  113015. /**
  113016. * Manages an XRSession to work with Babylon's engine
  113017. * @see https://doc.babylonjs.com/how_to/webxr
  113018. */
  113019. export class WebXRSessionManager implements IDisposable {
  113020. /** The scene which the session should be created for */
  113021. scene: Scene;
  113022. /**
  113023. * Fires every time a new xrFrame arrives which can be used to update the camera
  113024. */
  113025. onXRFrameObservable: Observable<XRFrame>;
  113026. /**
  113027. * Fires when the xr session is ended either by the device or manually done
  113028. */
  113029. onXRSessionEnded: Observable<any>;
  113030. /**
  113031. * Fires when the xr session is ended either by the device or manually done
  113032. */
  113033. onXRSessionInit: Observable<XRSession>;
  113034. /**
  113035. * Underlying xr session
  113036. */
  113037. session: XRSession;
  113038. /**
  113039. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  113040. * or get the offset the player is currently at.
  113041. */
  113042. viewerReferenceSpace: XRReferenceSpace;
  113043. /**
  113044. * The current reference space used in this session. This reference space can constantly change!
  113045. * It is mainly used to offset the camera's position.
  113046. */
  113047. referenceSpace: XRReferenceSpace;
  113048. /**
  113049. * The base reference space from which the session started. good if you want to reset your
  113050. * reference space
  113051. */
  113052. baseReferenceSpace: XRReferenceSpace;
  113053. /**
  113054. * Used just in case of a failure to initialize an immersive session.
  113055. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  113056. */
  113057. defaultHeightCompensation: number;
  113058. /**
  113059. * Current XR frame
  113060. */
  113061. currentFrame: Nullable<XRFrame>;
  113062. /** WebXR timestamp updated every frame */
  113063. currentTimestamp: number;
  113064. private _xrNavigator;
  113065. private baseLayer;
  113066. private _rttProvider;
  113067. private _sessionEnded;
  113068. /**
  113069. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  113070. * @param scene The scene which the session should be created for
  113071. */
  113072. constructor(
  113073. /** The scene which the session should be created for */
  113074. scene: Scene);
  113075. /**
  113076. * Initializes the manager
  113077. * After initialization enterXR can be called to start an XR session
  113078. * @returns Promise which resolves after it is initialized
  113079. */
  113080. initializeAsync(): Promise<void>;
  113081. /**
  113082. * Initializes an xr session
  113083. * @param xrSessionMode mode to initialize
  113084. * @param optionalFeatures defines optional values to pass to the session builder
  113085. * @returns a promise which will resolve once the session has been initialized
  113086. */
  113087. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  113088. /**
  113089. * Sets the reference space on the xr session
  113090. * @param referenceSpace space to set
  113091. * @returns a promise that will resolve once the reference space has been set
  113092. */
  113093. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  113094. /**
  113095. * Updates the render state of the session
  113096. * @param state state to set
  113097. * @returns a promise that resolves once the render state has been updated
  113098. */
  113099. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  113100. /**
  113101. * Starts rendering to the xr layer
  113102. * @returns a promise that will resolve once rendering has started
  113103. */
  113104. startRenderingToXRAsync(): Promise<void>;
  113105. /**
  113106. * Gets the correct render target texture to be rendered this frame for this eye
  113107. * @param eye the eye for which to get the render target
  113108. * @returns the render target for the specified eye
  113109. */
  113110. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  113111. /**
  113112. * Stops the xrSession and restores the renderloop
  113113. * @returns Promise which resolves after it exits XR
  113114. */
  113115. exitXRAsync(): Promise<void>;
  113116. /**
  113117. * Checks if a session would be supported for the creation options specified
  113118. * @param sessionMode session mode to check if supported eg. immersive-vr
  113119. * @returns true if supported
  113120. */
  113121. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113122. /**
  113123. * Creates a WebXRRenderTarget object for the XR session
  113124. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  113125. * @param options optional options to provide when creating a new render target
  113126. * @returns a WebXR render target to which the session can render
  113127. */
  113128. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  113129. /**
  113130. * @hidden
  113131. * Converts the render layer of xrSession to a render target
  113132. * @param session session to create render target for
  113133. * @param scene scene the new render target should be created for
  113134. * @param baseLayer the webgl layer to create the render target for
  113135. */
  113136. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  113137. /**
  113138. * Disposes of the session manager
  113139. */
  113140. dispose(): void;
  113141. /**
  113142. * Gets a promise returning true when fullfiled if the given session mode is supported
  113143. * @param sessionMode defines the session to test
  113144. * @returns a promise
  113145. */
  113146. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113147. }
  113148. }
  113149. declare module BABYLON {
  113150. /**
  113151. * WebXR Camera which holds the views for the xrSession
  113152. * @see https://doc.babylonjs.com/how_to/webxr
  113153. */
  113154. export class WebXRCamera extends FreeCamera {
  113155. private _xrSessionManager;
  113156. /**
  113157. * Is the camera in debug mode. Used when using an emulator
  113158. */
  113159. debugMode: boolean;
  113160. private _firstFrame;
  113161. private _referencedPosition;
  113162. private _referenceQuaternion;
  113163. private _xrInvPositionCache;
  113164. private _xrInvQuaternionCache;
  113165. /**
  113166. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  113167. * @param name the name of the camera
  113168. * @param scene the scene to add the camera to
  113169. */
  113170. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  113171. private _updateNumberOfRigCameras;
  113172. /** @hidden */
  113173. _updateForDualEyeDebugging(): void;
  113174. /**
  113175. * Updates the cameras position from the current pose information of the XR session
  113176. * @param xrSessionManager the session containing pose information
  113177. */
  113178. update(): void;
  113179. private _updateReferenceSpace;
  113180. private _updateReferenceSpaceOffset;
  113181. private _updateFromXRSession;
  113182. }
  113183. }
  113184. declare module BABYLON {
  113185. /**
  113186. * Defining the interface required for a (webxr) feature
  113187. */
  113188. export interface IWebXRFeature extends IDisposable {
  113189. /**
  113190. * Attach the feature to the session
  113191. * Will usually be called by the features manager
  113192. *
  113193. * @returns true if successful.
  113194. */
  113195. attach(): boolean;
  113196. /**
  113197. * Detach the feature from the session
  113198. * Will usually be called by the features manager
  113199. *
  113200. * @returns true if successful.
  113201. */
  113202. detach(): boolean;
  113203. }
  113204. /**
  113205. * Defining the constructor of a feature. Used to register the modules.
  113206. */
  113207. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  113208. /**
  113209. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  113210. * It is mainly used in AR sessions.
  113211. *
  113212. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  113213. */
  113214. export class WebXRFeaturesManager implements IDisposable {
  113215. private _xrSessionManager;
  113216. private static readonly _AvailableFeatures;
  113217. /**
  113218. * Used to register a module. After calling this function a developer can use this feature in the scene.
  113219. * Mainly used internally.
  113220. *
  113221. * @param featureName the name of the feature to register
  113222. * @param constructorFunction the function used to construct the module
  113223. * @param version the (babylon) version of the module
  113224. * @param stable is that a stable version of this module
  113225. */
  113226. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  113227. /**
  113228. * Returns a constructor of a specific feature.
  113229. *
  113230. * @param featureName the name of the feature to construct
  113231. * @param version the version of the feature to load
  113232. * @param xrSessionManager the xrSessionManager. Used to construct the module
  113233. * @param options optional options provided to the module.
  113234. * @returns a function that, when called, will return a new instance of this feature
  113235. */
  113236. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  113237. /**
  113238. * Return the latest unstable version of this feature
  113239. * @param featureName the name of the feature to search
  113240. * @returns the version number. if not found will return -1
  113241. */
  113242. static GetLatestVersionOfFeature(featureName: string): number;
  113243. /**
  113244. * Return the latest stable version of this feature
  113245. * @param featureName the name of the feature to search
  113246. * @returns the version number. if not found will return -1
  113247. */
  113248. static GetStableVersionOfFeature(featureName: string): number;
  113249. /**
  113250. * Can be used to return the list of features currently registered
  113251. *
  113252. * @returns an Array of available features
  113253. */
  113254. static GetAvailableFeatures(): string[];
  113255. /**
  113256. * Gets the versions available for a specific feature
  113257. * @param featureName the name of the feature
  113258. * @returns an array with the available versions
  113259. */
  113260. static GetAvailableVersions(featureName: string): string[];
  113261. private _features;
  113262. /**
  113263. * constructs a new features manages.
  113264. *
  113265. * @param _xrSessionManager an instance of WebXRSessionManager
  113266. */
  113267. constructor(_xrSessionManager: WebXRSessionManager);
  113268. /**
  113269. * 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.
  113270. *
  113271. * @param featureName the name of the feature to load or the class of the feature
  113272. * @param version optional version to load. if not provided the latest version will be enabled
  113273. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  113274. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  113275. * @returns a new constructed feature or throws an error if feature not found.
  113276. */
  113277. enableFeature(featureName: string | {
  113278. Name: string;
  113279. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  113280. /**
  113281. * Used to disable an already-enabled feature
  113282. * @param featureName the feature to disable
  113283. * @returns true if disable was successful
  113284. */
  113285. disableFeature(featureName: string | {
  113286. Name: string;
  113287. }): boolean;
  113288. /**
  113289. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  113290. * Can be used during a session to start a feature
  113291. * @param featureName the name of feature to attach
  113292. */
  113293. attachFeature(featureName: string): void;
  113294. /**
  113295. * Can be used inside a session or when the session ends to detach a specific feature
  113296. * @param featureName the name of the feature to detach
  113297. */
  113298. detachFeature(featureName: string): void;
  113299. /**
  113300. * Get the list of enabled features
  113301. * @returns an array of enabled features
  113302. */
  113303. getEnabledFeatures(): string[];
  113304. /**
  113305. * get the implementation of an enabled feature.
  113306. * @param featureName the name of the feature to load
  113307. * @returns the feature class, if found
  113308. */
  113309. getEnabledFeature(featureName: string): IWebXRFeature;
  113310. /**
  113311. * dispose this features manager
  113312. */
  113313. dispose(): void;
  113314. }
  113315. }
  113316. declare module BABYLON {
  113317. /**
  113318. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  113319. * @see https://doc.babylonjs.com/how_to/webxr
  113320. */
  113321. export class WebXRExperienceHelper implements IDisposable {
  113322. private scene;
  113323. /**
  113324. * Camera used to render xr content
  113325. */
  113326. camera: WebXRCamera;
  113327. /**
  113328. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  113329. */
  113330. state: WebXRState;
  113331. private _setState;
  113332. /**
  113333. * Fires when the state of the experience helper has changed
  113334. */
  113335. onStateChangedObservable: Observable<WebXRState>;
  113336. /**
  113337. * Observers registered here will be triggered after the camera's initial transformation is set
  113338. * This can be used to set a different ground level or an extra rotation.
  113339. *
  113340. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  113341. * to the position set after this observable is done executing.
  113342. */
  113343. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  113344. /** Session manager used to keep track of xr session */
  113345. sessionManager: WebXRSessionManager;
  113346. /** A features manager for this xr session */
  113347. featuresManager: WebXRFeaturesManager;
  113348. private _nonVRCamera;
  113349. private _originalSceneAutoClear;
  113350. private _supported;
  113351. /**
  113352. * Creates the experience helper
  113353. * @param scene the scene to attach the experience helper to
  113354. * @returns a promise for the experience helper
  113355. */
  113356. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  113357. /**
  113358. * Creates a WebXRExperienceHelper
  113359. * @param scene The scene the helper should be created in
  113360. */
  113361. private constructor();
  113362. /**
  113363. * Exits XR mode and returns the scene to its original state
  113364. * @returns promise that resolves after xr mode has exited
  113365. */
  113366. exitXRAsync(): Promise<void>;
  113367. /**
  113368. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  113369. * @param sessionMode options for the XR session
  113370. * @param referenceSpaceType frame of reference of the XR session
  113371. * @param renderTarget the output canvas that will be used to enter XR mode
  113372. * @returns promise that resolves after xr mode has entered
  113373. */
  113374. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  113375. /**
  113376. * Disposes of the experience helper
  113377. */
  113378. dispose(): void;
  113379. private _nonXRToXRCamera;
  113380. }
  113381. }
  113382. declare module BABYLON {
  113383. /**
  113384. * Represents an XR input
  113385. */
  113386. export class WebXRController {
  113387. private scene;
  113388. /** The underlying input source for the controller */
  113389. inputSource: XRInputSource;
  113390. private parentContainer;
  113391. /**
  113392. * 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
  113393. */
  113394. grip?: AbstractMesh;
  113395. /**
  113396. * Pointer which can be used to select objects or attach a visible laser to
  113397. */
  113398. pointer: AbstractMesh;
  113399. private _gamepadMode;
  113400. /**
  113401. * If available, this is the gamepad object related to this controller.
  113402. * Using this object it is possible to get click events and trackpad changes of the
  113403. * webxr controller that is currently being used.
  113404. */
  113405. gamepadController?: WebVRController;
  113406. /**
  113407. * Event that fires when the controller is removed/disposed
  113408. */
  113409. onDisposeObservable: Observable<{}>;
  113410. private _tmpQuaternion;
  113411. private _tmpVector;
  113412. /**
  113413. * Creates the controller
  113414. * @see https://doc.babylonjs.com/how_to/webxr
  113415. * @param scene the scene which the controller should be associated to
  113416. * @param inputSource the underlying input source for the controller
  113417. * @param parentContainer parent that the controller meshes should be children of
  113418. */
  113419. constructor(scene: Scene,
  113420. /** The underlying input source for the controller */
  113421. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  113422. /**
  113423. * Updates the controller pose based on the given XRFrame
  113424. * @param xrFrame xr frame to update the pose with
  113425. * @param referenceSpace reference space to use
  113426. */
  113427. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  113428. /**
  113429. * Gets a world space ray coming from the controller
  113430. * @param result the resulting ray
  113431. */
  113432. getWorldPointerRayToRef(result: Ray): void;
  113433. /**
  113434. * Get the scene associated with this controller
  113435. * @returns the scene object
  113436. */
  113437. getScene(): Scene;
  113438. /**
  113439. * Disposes of the object
  113440. */
  113441. dispose(): void;
  113442. }
  113443. }
  113444. declare module BABYLON {
  113445. /**
  113446. * XR input used to track XR inputs such as controllers/rays
  113447. */
  113448. export class WebXRInput implements IDisposable {
  113449. /**
  113450. * Base experience the input listens to
  113451. */
  113452. baseExperience: WebXRExperienceHelper;
  113453. /**
  113454. * XR controllers being tracked
  113455. */
  113456. controllers: Array<WebXRController>;
  113457. private _frameObserver;
  113458. private _stateObserver;
  113459. /**
  113460. * Event when a controller has been connected/added
  113461. */
  113462. onControllerAddedObservable: Observable<WebXRController>;
  113463. /**
  113464. * Event when a controller has been removed/disconnected
  113465. */
  113466. onControllerRemovedObservable: Observable<WebXRController>;
  113467. /**
  113468. * Initializes the WebXRInput
  113469. * @param baseExperience experience helper which the input should be created for
  113470. */
  113471. constructor(
  113472. /**
  113473. * Base experience the input listens to
  113474. */
  113475. baseExperience: WebXRExperienceHelper);
  113476. private _onInputSourcesChange;
  113477. private _addAndRemoveControllers;
  113478. /**
  113479. * Disposes of the object
  113480. */
  113481. dispose(): void;
  113482. }
  113483. }
  113484. declare module BABYLON {
  113485. /**
  113486. * Class used to represent data loading progression
  113487. */
  113488. export class SceneLoaderProgressEvent {
  113489. /** defines if data length to load can be evaluated */
  113490. readonly lengthComputable: boolean;
  113491. /** defines the loaded data length */
  113492. readonly loaded: number;
  113493. /** defines the data length to load */
  113494. readonly total: number;
  113495. /**
  113496. * Create a new progress event
  113497. * @param lengthComputable defines if data length to load can be evaluated
  113498. * @param loaded defines the loaded data length
  113499. * @param total defines the data length to load
  113500. */
  113501. constructor(
  113502. /** defines if data length to load can be evaluated */
  113503. lengthComputable: boolean,
  113504. /** defines the loaded data length */
  113505. loaded: number,
  113506. /** defines the data length to load */
  113507. total: number);
  113508. /**
  113509. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  113510. * @param event defines the source event
  113511. * @returns a new SceneLoaderProgressEvent
  113512. */
  113513. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  113514. }
  113515. /**
  113516. * Interface used by SceneLoader plugins to define supported file extensions
  113517. */
  113518. export interface ISceneLoaderPluginExtensions {
  113519. /**
  113520. * Defines the list of supported extensions
  113521. */
  113522. [extension: string]: {
  113523. isBinary: boolean;
  113524. };
  113525. }
  113526. /**
  113527. * Interface used by SceneLoader plugin factory
  113528. */
  113529. export interface ISceneLoaderPluginFactory {
  113530. /**
  113531. * Defines the name of the factory
  113532. */
  113533. name: string;
  113534. /**
  113535. * Function called to create a new plugin
  113536. * @return the new plugin
  113537. */
  113538. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  113539. /**
  113540. * The callback that returns true if the data can be directly loaded.
  113541. * @param data string containing the file data
  113542. * @returns if the data can be loaded directly
  113543. */
  113544. canDirectLoad?(data: string): boolean;
  113545. }
  113546. /**
  113547. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  113548. */
  113549. export interface ISceneLoaderPluginBase {
  113550. /**
  113551. * The friendly name of this plugin.
  113552. */
  113553. name: string;
  113554. /**
  113555. * The file extensions supported by this plugin.
  113556. */
  113557. extensions: string | ISceneLoaderPluginExtensions;
  113558. /**
  113559. * The callback called when loading from a url.
  113560. * @param scene scene loading this url
  113561. * @param url url to load
  113562. * @param onSuccess callback called when the file successfully loads
  113563. * @param onProgress callback called while file is loading (if the server supports this mode)
  113564. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113565. * @param onError callback called when the file fails to load
  113566. * @returns a file request object
  113567. */
  113568. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113569. /**
  113570. * The callback called when loading from a file object.
  113571. * @param scene scene loading this file
  113572. * @param file defines the file to load
  113573. * @param onSuccess defines the callback to call when data is loaded
  113574. * @param onProgress defines the callback to call during loading process
  113575. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  113576. * @param onError defines the callback to call when an error occurs
  113577. * @returns a file request object
  113578. */
  113579. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113580. /**
  113581. * The callback that returns true if the data can be directly loaded.
  113582. * @param data string containing the file data
  113583. * @returns if the data can be loaded directly
  113584. */
  113585. canDirectLoad?(data: string): boolean;
  113586. /**
  113587. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  113588. * @param scene scene loading this data
  113589. * @param data string containing the data
  113590. * @returns data to pass to the plugin
  113591. */
  113592. directLoad?(scene: Scene, data: string): any;
  113593. /**
  113594. * The callback that allows custom handling of the root url based on the response url.
  113595. * @param rootUrl the original root url
  113596. * @param responseURL the response url if available
  113597. * @returns the new root url
  113598. */
  113599. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  113600. }
  113601. /**
  113602. * Interface used to define a SceneLoader plugin
  113603. */
  113604. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  113605. /**
  113606. * Import meshes into a scene.
  113607. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113608. * @param scene The scene to import into
  113609. * @param data The data to import
  113610. * @param rootUrl The root url for scene and resources
  113611. * @param meshes The meshes array to import into
  113612. * @param particleSystems The particle systems array to import into
  113613. * @param skeletons The skeletons array to import into
  113614. * @param onError The callback when import fails
  113615. * @returns True if successful or false otherwise
  113616. */
  113617. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  113618. /**
  113619. * Load into a scene.
  113620. * @param scene The scene to load into
  113621. * @param data The data to import
  113622. * @param rootUrl The root url for scene and resources
  113623. * @param onError The callback when import fails
  113624. * @returns True if successful or false otherwise
  113625. */
  113626. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  113627. /**
  113628. * Load into an asset container.
  113629. * @param scene The scene to load into
  113630. * @param data The data to import
  113631. * @param rootUrl The root url for scene and resources
  113632. * @param onError The callback when import fails
  113633. * @returns The loaded asset container
  113634. */
  113635. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  113636. }
  113637. /**
  113638. * Interface used to define an async SceneLoader plugin
  113639. */
  113640. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  113641. /**
  113642. * Import meshes into a scene.
  113643. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113644. * @param scene The scene to import into
  113645. * @param data The data to import
  113646. * @param rootUrl The root url for scene and resources
  113647. * @param onProgress The callback when the load progresses
  113648. * @param fileName Defines the name of the file to load
  113649. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  113650. */
  113651. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  113652. meshes: AbstractMesh[];
  113653. particleSystems: IParticleSystem[];
  113654. skeletons: Skeleton[];
  113655. animationGroups: AnimationGroup[];
  113656. }>;
  113657. /**
  113658. * Load into a scene.
  113659. * @param scene The scene to load into
  113660. * @param data The data to import
  113661. * @param rootUrl The root url for scene and resources
  113662. * @param onProgress The callback when the load progresses
  113663. * @param fileName Defines the name of the file to load
  113664. * @returns Nothing
  113665. */
  113666. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  113667. /**
  113668. * Load into an asset container.
  113669. * @param scene The scene to load into
  113670. * @param data The data to import
  113671. * @param rootUrl The root url for scene and resources
  113672. * @param onProgress The callback when the load progresses
  113673. * @param fileName Defines the name of the file to load
  113674. * @returns The loaded asset container
  113675. */
  113676. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  113677. }
  113678. /**
  113679. * Mode that determines how to handle old animation groups before loading new ones.
  113680. */
  113681. export enum SceneLoaderAnimationGroupLoadingMode {
  113682. /**
  113683. * Reset all old animations to initial state then dispose them.
  113684. */
  113685. Clean = 0,
  113686. /**
  113687. * Stop all old animations.
  113688. */
  113689. Stop = 1,
  113690. /**
  113691. * Restart old animations from first frame.
  113692. */
  113693. Sync = 2,
  113694. /**
  113695. * Old animations remains untouched.
  113696. */
  113697. NoSync = 3
  113698. }
  113699. /**
  113700. * Class used to load scene from various file formats using registered plugins
  113701. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  113702. */
  113703. export class SceneLoader {
  113704. /**
  113705. * No logging while loading
  113706. */
  113707. static readonly NO_LOGGING: number;
  113708. /**
  113709. * Minimal logging while loading
  113710. */
  113711. static readonly MINIMAL_LOGGING: number;
  113712. /**
  113713. * Summary logging while loading
  113714. */
  113715. static readonly SUMMARY_LOGGING: number;
  113716. /**
  113717. * Detailled logging while loading
  113718. */
  113719. static readonly DETAILED_LOGGING: number;
  113720. /**
  113721. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  113722. */
  113723. static get ForceFullSceneLoadingForIncremental(): boolean;
  113724. static set ForceFullSceneLoadingForIncremental(value: boolean);
  113725. /**
  113726. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  113727. */
  113728. static get ShowLoadingScreen(): boolean;
  113729. static set ShowLoadingScreen(value: boolean);
  113730. /**
  113731. * Defines the current logging level (while loading the scene)
  113732. * @ignorenaming
  113733. */
  113734. static get loggingLevel(): number;
  113735. static set loggingLevel(value: number);
  113736. /**
  113737. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  113738. */
  113739. static get CleanBoneMatrixWeights(): boolean;
  113740. static set CleanBoneMatrixWeights(value: boolean);
  113741. /**
  113742. * Event raised when a plugin is used to load a scene
  113743. */
  113744. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  113745. private static _registeredPlugins;
  113746. private static _getDefaultPlugin;
  113747. private static _getPluginForExtension;
  113748. private static _getPluginForDirectLoad;
  113749. private static _getPluginForFilename;
  113750. private static _getDirectLoad;
  113751. private static _loadData;
  113752. private static _getFileInfo;
  113753. /**
  113754. * Gets a plugin that can load the given extension
  113755. * @param extension defines the extension to load
  113756. * @returns a plugin or null if none works
  113757. */
  113758. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  113759. /**
  113760. * Gets a boolean indicating that the given extension can be loaded
  113761. * @param extension defines the extension to load
  113762. * @returns true if the extension is supported
  113763. */
  113764. static IsPluginForExtensionAvailable(extension: string): boolean;
  113765. /**
  113766. * Adds a new plugin to the list of registered plugins
  113767. * @param plugin defines the plugin to add
  113768. */
  113769. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  113770. /**
  113771. * Import meshes into a scene
  113772. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113773. * @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)
  113774. * @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)
  113775. * @param scene the instance of BABYLON.Scene to append to
  113776. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  113777. * @param onProgress a callback with a progress event for each file being loaded
  113778. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113779. * @param pluginExtension the extension used to determine the plugin
  113780. * @returns The loaded plugin
  113781. */
  113782. 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>;
  113783. /**
  113784. * Import meshes into a scene
  113785. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113786. * @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)
  113787. * @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)
  113788. * @param scene the instance of BABYLON.Scene to append to
  113789. * @param onProgress a callback with a progress event for each file being loaded
  113790. * @param pluginExtension the extension used to determine the plugin
  113791. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  113792. */
  113793. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  113794. meshes: AbstractMesh[];
  113795. particleSystems: IParticleSystem[];
  113796. skeletons: Skeleton[];
  113797. animationGroups: AnimationGroup[];
  113798. }>;
  113799. /**
  113800. * Load a scene
  113801. * @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)
  113802. * @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)
  113803. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113804. * @param onSuccess a callback with the scene when import succeeds
  113805. * @param onProgress a callback with a progress event for each file being loaded
  113806. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113807. * @param pluginExtension the extension used to determine the plugin
  113808. * @returns The loaded plugin
  113809. */
  113810. 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>;
  113811. /**
  113812. * Load a scene
  113813. * @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)
  113814. * @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)
  113815. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113816. * @param onProgress a callback with a progress event for each file being loaded
  113817. * @param pluginExtension the extension used to determine the plugin
  113818. * @returns The loaded scene
  113819. */
  113820. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113821. /**
  113822. * Append a scene
  113823. * @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)
  113824. * @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)
  113825. * @param scene is the instance of BABYLON.Scene to append to
  113826. * @param onSuccess a callback with the scene when import succeeds
  113827. * @param onProgress a callback with a progress event for each file being loaded
  113828. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113829. * @param pluginExtension the extension used to determine the plugin
  113830. * @returns The loaded plugin
  113831. */
  113832. 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>;
  113833. /**
  113834. * Append a scene
  113835. * @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)
  113836. * @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)
  113837. * @param scene is the instance of BABYLON.Scene to append to
  113838. * @param onProgress a callback with a progress event for each file being loaded
  113839. * @param pluginExtension the extension used to determine the plugin
  113840. * @returns The given scene
  113841. */
  113842. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113843. /**
  113844. * Load a scene into an asset container
  113845. * @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)
  113846. * @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)
  113847. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113848. * @param onSuccess a callback with the scene when import succeeds
  113849. * @param onProgress a callback with a progress event for each file being loaded
  113850. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113851. * @param pluginExtension the extension used to determine the plugin
  113852. * @returns The loaded plugin
  113853. */
  113854. 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>;
  113855. /**
  113856. * Load a scene into an asset container
  113857. * @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)
  113858. * @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)
  113859. * @param scene is the instance of Scene to append to
  113860. * @param onProgress a callback with a progress event for each file being loaded
  113861. * @param pluginExtension the extension used to determine the plugin
  113862. * @returns The loaded asset container
  113863. */
  113864. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  113865. /**
  113866. * Import animations from a file into a scene
  113867. * @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)
  113868. * @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)
  113869. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113870. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113871. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113872. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113873. * @param onSuccess a callback with the scene when import succeeds
  113874. * @param onProgress a callback with a progress event for each file being loaded
  113875. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113876. */
  113877. 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;
  113878. /**
  113879. * Import animations from a file into a scene
  113880. * @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)
  113881. * @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)
  113882. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113883. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113884. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113885. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113886. * @param onSuccess a callback with the scene when import succeeds
  113887. * @param onProgress a callback with a progress event for each file being loaded
  113888. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113889. * @returns the updated scene with imported animations
  113890. */
  113891. 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>;
  113892. }
  113893. }
  113894. declare module BABYLON {
  113895. /**
  113896. * Generic Controller
  113897. */
  113898. export class GenericController extends WebVRController {
  113899. /**
  113900. * Base Url for the controller model.
  113901. */
  113902. static readonly MODEL_BASE_URL: string;
  113903. /**
  113904. * File name for the controller model.
  113905. */
  113906. static readonly MODEL_FILENAME: string;
  113907. /**
  113908. * Creates a new GenericController from a gamepad
  113909. * @param vrGamepad the gamepad that the controller should be created from
  113910. */
  113911. constructor(vrGamepad: any);
  113912. /**
  113913. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113914. * @param scene scene in which to add meshes
  113915. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113916. */
  113917. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113918. /**
  113919. * Called once for each button that changed state since the last frame
  113920. * @param buttonIdx Which button index changed
  113921. * @param state New state of the button
  113922. * @param changes Which properties on the state changed since last frame
  113923. */
  113924. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113925. }
  113926. }
  113927. declare module BABYLON {
  113928. /**
  113929. * Defines the WindowsMotionController object that the state of the windows motion controller
  113930. */
  113931. export class WindowsMotionController extends WebVRController {
  113932. /**
  113933. * The base url used to load the left and right controller models
  113934. */
  113935. static MODEL_BASE_URL: string;
  113936. /**
  113937. * The name of the left controller model file
  113938. */
  113939. static MODEL_LEFT_FILENAME: string;
  113940. /**
  113941. * The name of the right controller model file
  113942. */
  113943. static MODEL_RIGHT_FILENAME: string;
  113944. /**
  113945. * The controller name prefix for this controller type
  113946. */
  113947. static readonly GAMEPAD_ID_PREFIX: string;
  113948. /**
  113949. * The controller id pattern for this controller type
  113950. */
  113951. private static readonly GAMEPAD_ID_PATTERN;
  113952. private _loadedMeshInfo;
  113953. protected readonly _mapping: {
  113954. buttons: string[];
  113955. buttonMeshNames: {
  113956. 'trigger': string;
  113957. 'menu': string;
  113958. 'grip': string;
  113959. 'thumbstick': string;
  113960. 'trackpad': string;
  113961. };
  113962. buttonObservableNames: {
  113963. 'trigger': string;
  113964. 'menu': string;
  113965. 'grip': string;
  113966. 'thumbstick': string;
  113967. 'trackpad': string;
  113968. };
  113969. axisMeshNames: string[];
  113970. pointingPoseMeshName: string;
  113971. };
  113972. /**
  113973. * Fired when the trackpad on this controller is clicked
  113974. */
  113975. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  113976. /**
  113977. * Fired when the trackpad on this controller is modified
  113978. */
  113979. onTrackpadValuesChangedObservable: Observable<StickValues>;
  113980. /**
  113981. * The current x and y values of this controller's trackpad
  113982. */
  113983. trackpad: StickValues;
  113984. /**
  113985. * Creates a new WindowsMotionController from a gamepad
  113986. * @param vrGamepad the gamepad that the controller should be created from
  113987. */
  113988. constructor(vrGamepad: any);
  113989. /**
  113990. * Fired when the trigger on this controller is modified
  113991. */
  113992. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113993. /**
  113994. * Fired when the menu button on this controller is modified
  113995. */
  113996. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113997. /**
  113998. * Fired when the grip button on this controller is modified
  113999. */
  114000. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114001. /**
  114002. * Fired when the thumbstick button on this controller is modified
  114003. */
  114004. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114005. /**
  114006. * Fired when the touchpad button on this controller is modified
  114007. */
  114008. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114009. /**
  114010. * Fired when the touchpad values on this controller are modified
  114011. */
  114012. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  114013. protected _updateTrackpad(): void;
  114014. /**
  114015. * Called once per frame by the engine.
  114016. */
  114017. update(): void;
  114018. /**
  114019. * Called once for each button that changed state since the last frame
  114020. * @param buttonIdx Which button index changed
  114021. * @param state New state of the button
  114022. * @param changes Which properties on the state changed since last frame
  114023. */
  114024. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114025. /**
  114026. * Moves the buttons on the controller mesh based on their current state
  114027. * @param buttonName the name of the button to move
  114028. * @param buttonValue the value of the button which determines the buttons new position
  114029. */
  114030. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  114031. /**
  114032. * Moves the axis on the controller mesh based on its current state
  114033. * @param axis the index of the axis
  114034. * @param axisValue the value of the axis which determines the meshes new position
  114035. * @hidden
  114036. */
  114037. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  114038. /**
  114039. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114040. * @param scene scene in which to add meshes
  114041. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114042. */
  114043. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  114044. /**
  114045. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  114046. * can be transformed by button presses and axes values, based on this._mapping.
  114047. *
  114048. * @param scene scene in which the meshes exist
  114049. * @param meshes list of meshes that make up the controller model to process
  114050. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  114051. */
  114052. private processModel;
  114053. private createMeshInfo;
  114054. /**
  114055. * Gets the ray of the controller in the direction the controller is pointing
  114056. * @param length the length the resulting ray should be
  114057. * @returns a ray in the direction the controller is pointing
  114058. */
  114059. getForwardRay(length?: number): Ray;
  114060. /**
  114061. * Disposes of the controller
  114062. */
  114063. dispose(): void;
  114064. }
  114065. /**
  114066. * This class represents a new windows motion controller in XR.
  114067. */
  114068. export class XRWindowsMotionController extends WindowsMotionController {
  114069. /**
  114070. * Changing the original WIndowsMotionController mapping to fir the new mapping
  114071. */
  114072. protected readonly _mapping: {
  114073. buttons: string[];
  114074. buttonMeshNames: {
  114075. 'trigger': string;
  114076. 'menu': string;
  114077. 'grip': string;
  114078. 'thumbstick': string;
  114079. 'trackpad': string;
  114080. };
  114081. buttonObservableNames: {
  114082. 'trigger': string;
  114083. 'menu': string;
  114084. 'grip': string;
  114085. 'thumbstick': string;
  114086. 'trackpad': string;
  114087. };
  114088. axisMeshNames: string[];
  114089. pointingPoseMeshName: string;
  114090. };
  114091. /**
  114092. * Construct a new XR-Based windows motion controller
  114093. *
  114094. * @param gamepadInfo the gamepad object from the browser
  114095. */
  114096. constructor(gamepadInfo: any);
  114097. /**
  114098. * holds the thumbstick values (X,Y)
  114099. */
  114100. thumbstickValues: StickValues;
  114101. /**
  114102. * Fired when the thumbstick on this controller is clicked
  114103. */
  114104. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  114105. /**
  114106. * Fired when the thumbstick on this controller is modified
  114107. */
  114108. onThumbstickValuesChangedObservable: Observable<StickValues>;
  114109. /**
  114110. * Fired when the touchpad button on this controller is modified
  114111. */
  114112. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  114113. /**
  114114. * Fired when the touchpad values on this controller are modified
  114115. */
  114116. onTrackpadValuesChangedObservable: Observable<StickValues>;
  114117. /**
  114118. * Fired when the thumbstick button on this controller is modified
  114119. * here to prevent breaking changes
  114120. */
  114121. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114122. /**
  114123. * updating the thumbstick(!) and not the trackpad.
  114124. * This is named this way due to the difference between WebVR and XR and to avoid
  114125. * changing the parent class.
  114126. */
  114127. protected _updateTrackpad(): void;
  114128. /**
  114129. * Disposes the class with joy
  114130. */
  114131. dispose(): void;
  114132. }
  114133. }
  114134. declare module BABYLON {
  114135. /**
  114136. * Oculus Touch Controller
  114137. */
  114138. export class OculusTouchController extends WebVRController {
  114139. /**
  114140. * Base Url for the controller model.
  114141. */
  114142. static MODEL_BASE_URL: string;
  114143. /**
  114144. * File name for the left controller model.
  114145. */
  114146. static MODEL_LEFT_FILENAME: string;
  114147. /**
  114148. * File name for the right controller model.
  114149. */
  114150. static MODEL_RIGHT_FILENAME: string;
  114151. /**
  114152. * Base Url for the Quest controller model.
  114153. */
  114154. static QUEST_MODEL_BASE_URL: string;
  114155. /**
  114156. * @hidden
  114157. * If the controllers are running on a device that needs the updated Quest controller models
  114158. */
  114159. static _IsQuest: boolean;
  114160. /**
  114161. * Fired when the secondary trigger on this controller is modified
  114162. */
  114163. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  114164. /**
  114165. * Fired when the thumb rest on this controller is modified
  114166. */
  114167. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  114168. /**
  114169. * Creates a new OculusTouchController from a gamepad
  114170. * @param vrGamepad the gamepad that the controller should be created from
  114171. */
  114172. constructor(vrGamepad: any);
  114173. /**
  114174. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114175. * @param scene scene in which to add meshes
  114176. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114177. */
  114178. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114179. /**
  114180. * Fired when the A button on this controller is modified
  114181. */
  114182. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114183. /**
  114184. * Fired when the B button on this controller is modified
  114185. */
  114186. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114187. /**
  114188. * Fired when the X button on this controller is modified
  114189. */
  114190. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114191. /**
  114192. * Fired when the Y button on this controller is modified
  114193. */
  114194. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114195. /**
  114196. * Called once for each button that changed state since the last frame
  114197. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  114198. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  114199. * 2) secondary trigger (same)
  114200. * 3) A (right) X (left), touch, pressed = value
  114201. * 4) B / Y
  114202. * 5) thumb rest
  114203. * @param buttonIdx Which button index changed
  114204. * @param state New state of the button
  114205. * @param changes Which properties on the state changed since last frame
  114206. */
  114207. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114208. }
  114209. }
  114210. declare module BABYLON {
  114211. /**
  114212. * Vive Controller
  114213. */
  114214. export class ViveController extends WebVRController {
  114215. /**
  114216. * Base Url for the controller model.
  114217. */
  114218. static MODEL_BASE_URL: string;
  114219. /**
  114220. * File name for the controller model.
  114221. */
  114222. static MODEL_FILENAME: string;
  114223. /**
  114224. * Creates a new ViveController from a gamepad
  114225. * @param vrGamepad the gamepad that the controller should be created from
  114226. */
  114227. constructor(vrGamepad: any);
  114228. /**
  114229. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114230. * @param scene scene in which to add meshes
  114231. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114232. */
  114233. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114234. /**
  114235. * Fired when the left button on this controller is modified
  114236. */
  114237. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114238. /**
  114239. * Fired when the right button on this controller is modified
  114240. */
  114241. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114242. /**
  114243. * Fired when the menu button on this controller is modified
  114244. */
  114245. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114246. /**
  114247. * Called once for each button that changed state since the last frame
  114248. * Vive mapping:
  114249. * 0: touchpad
  114250. * 1: trigger
  114251. * 2: left AND right buttons
  114252. * 3: menu button
  114253. * @param buttonIdx Which button index changed
  114254. * @param state New state of the button
  114255. * @param changes Which properties on the state changed since last frame
  114256. */
  114257. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114258. }
  114259. }
  114260. declare module BABYLON {
  114261. /**
  114262. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  114263. */
  114264. export class WebXRControllerModelLoader {
  114265. /**
  114266. * an observable that triggers when a new model (the mesh itself) was initialized.
  114267. * To know when the mesh was loaded use the controller's own modelLoaded() method
  114268. */
  114269. onControllerModelLoaded: Observable<WebXRController>;
  114270. /**
  114271. * Creates the WebXRControllerModelLoader
  114272. * @param input xr input that creates the controllers
  114273. */
  114274. constructor(input: WebXRInput);
  114275. }
  114276. }
  114277. declare module BABYLON {
  114278. /**
  114279. * Handles pointer input automatically for the pointer of XR controllers
  114280. */
  114281. export class WebXRControllerPointerSelection {
  114282. private static _idCounter;
  114283. private _tmpRay;
  114284. /**
  114285. * Creates a WebXRControllerPointerSelection
  114286. * @param input input manager to setup pointer selection
  114287. */
  114288. constructor(input: WebXRInput);
  114289. private _convertNormalToDirectionOfRay;
  114290. private _updatePointerDistance;
  114291. }
  114292. }
  114293. declare module BABYLON {
  114294. /**
  114295. * Enables teleportation
  114296. */
  114297. export class WebXRControllerTeleportation {
  114298. private _teleportationFillColor;
  114299. private _teleportationBorderColor;
  114300. private _tmpRay;
  114301. private _tmpVector;
  114302. /**
  114303. * when set to true (default) teleportation will wait for thumbstick changes.
  114304. * When set to false teleportation will be disabled.
  114305. *
  114306. * If set to false while teleporting results can be unexpected.
  114307. */
  114308. enabled: boolean;
  114309. /**
  114310. * Creates a WebXRControllerTeleportation
  114311. * @param input input manager to add teleportation to
  114312. * @param floorMeshes floormeshes which can be teleported to
  114313. */
  114314. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  114315. }
  114316. }
  114317. declare module BABYLON {
  114318. /**
  114319. * Button which can be used to enter a different mode of XR
  114320. */
  114321. export class WebXREnterExitUIButton {
  114322. /** button element */
  114323. element: HTMLElement;
  114324. /** XR initialization options for the button */
  114325. sessionMode: XRSessionMode;
  114326. /** Reference space type */
  114327. referenceSpaceType: XRReferenceSpaceType;
  114328. /**
  114329. * Creates a WebXREnterExitUIButton
  114330. * @param element button element
  114331. * @param sessionMode XR initialization session mode
  114332. * @param referenceSpaceType the type of reference space to be used
  114333. */
  114334. constructor(
  114335. /** button element */
  114336. element: HTMLElement,
  114337. /** XR initialization options for the button */
  114338. sessionMode: XRSessionMode,
  114339. /** Reference space type */
  114340. referenceSpaceType: XRReferenceSpaceType);
  114341. /**
  114342. * Overwritable function which can be used to update the button's visuals when the state changes
  114343. * @param activeButton the current active button in the UI
  114344. */
  114345. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  114346. }
  114347. /**
  114348. * Options to create the webXR UI
  114349. */
  114350. export class WebXREnterExitUIOptions {
  114351. /**
  114352. * Context to enter xr with
  114353. */
  114354. renderTarget?: Nullable<WebXRRenderTarget>;
  114355. /**
  114356. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  114357. */
  114358. customButtons?: Array<WebXREnterExitUIButton>;
  114359. /**
  114360. * A session mode to use when creating the default button.
  114361. * Default is immersive-vr
  114362. */
  114363. sessionMode?: XRSessionMode;
  114364. /**
  114365. * A reference space type to use when creating the default button.
  114366. * Default is local-floor
  114367. */
  114368. referenceSpaceType?: XRReferenceSpaceType;
  114369. }
  114370. /**
  114371. * UI to allow the user to enter/exit XR mode
  114372. */
  114373. export class WebXREnterExitUI implements IDisposable {
  114374. private scene;
  114375. /** version of the options passed to this UI */
  114376. options: WebXREnterExitUIOptions;
  114377. private _overlay;
  114378. private _buttons;
  114379. private _activeButton;
  114380. /**
  114381. * Fired every time the active button is changed.
  114382. *
  114383. * When xr is entered via a button that launches xr that button will be the callback parameter
  114384. *
  114385. * When exiting xr the callback parameter will be null)
  114386. */
  114387. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  114388. /**
  114389. * Creates UI to allow the user to enter/exit XR mode
  114390. * @param scene the scene to add the ui to
  114391. * @param helper the xr experience helper to enter/exit xr with
  114392. * @param options options to configure the UI
  114393. * @returns the created ui
  114394. */
  114395. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  114396. /**
  114397. *
  114398. * @param scene babylon scene object to use
  114399. * @param options (read-only) version of the options passed to this UI
  114400. */
  114401. private constructor();
  114402. private _updateButtons;
  114403. /**
  114404. * Disposes of the object
  114405. */
  114406. dispose(): void;
  114407. }
  114408. }
  114409. declare module BABYLON {
  114410. /**
  114411. * Options for the default xr helper
  114412. */
  114413. export class WebXRDefaultExperienceOptions {
  114414. /**
  114415. * Floor meshes that should be used for teleporting
  114416. */
  114417. floorMeshes: Array<AbstractMesh>;
  114418. /**
  114419. * Enable or disable default UI to enter XR
  114420. */
  114421. disableDefaultUI?: boolean;
  114422. /**
  114423. * optional configuration for the output canvas
  114424. */
  114425. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  114426. /**
  114427. * optional UI options. This can be used among other to change session mode and reference space type
  114428. */
  114429. uiOptions?: WebXREnterExitUIOptions;
  114430. }
  114431. /**
  114432. * Default experience which provides a similar setup to the previous webVRExperience
  114433. */
  114434. export class WebXRDefaultExperience {
  114435. /**
  114436. * Base experience
  114437. */
  114438. baseExperience: WebXRExperienceHelper;
  114439. /**
  114440. * Input experience extension
  114441. */
  114442. input: WebXRInput;
  114443. /**
  114444. * Loads the controller models
  114445. */
  114446. controllerModelLoader: WebXRControllerModelLoader;
  114447. /**
  114448. * Enables laser pointer and selection
  114449. */
  114450. pointerSelection: WebXRControllerPointerSelection;
  114451. /**
  114452. * Enables teleportation
  114453. */
  114454. teleportation: WebXRControllerTeleportation;
  114455. /**
  114456. * Enables ui for entering/exiting xr
  114457. */
  114458. enterExitUI: WebXREnterExitUI;
  114459. /**
  114460. * Default target xr should render to
  114461. */
  114462. renderTarget: WebXRRenderTarget;
  114463. /**
  114464. * Creates the default xr experience
  114465. * @param scene scene
  114466. * @param options options for basic configuration
  114467. * @returns resulting WebXRDefaultExperience
  114468. */
  114469. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114470. private constructor();
  114471. /**
  114472. * DIsposes of the experience helper
  114473. */
  114474. dispose(): void;
  114475. }
  114476. }
  114477. declare module BABYLON {
  114478. /**
  114479. * Options to modify the vr teleportation behavior.
  114480. */
  114481. export interface VRTeleportationOptions {
  114482. /**
  114483. * The name of the mesh which should be used as the teleportation floor. (default: null)
  114484. */
  114485. floorMeshName?: string;
  114486. /**
  114487. * A list of meshes to be used as the teleportation floor. (default: empty)
  114488. */
  114489. floorMeshes?: Mesh[];
  114490. /**
  114491. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  114492. */
  114493. teleportationMode?: number;
  114494. /**
  114495. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  114496. */
  114497. teleportationTime?: number;
  114498. /**
  114499. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  114500. */
  114501. teleportationSpeed?: number;
  114502. /**
  114503. * The easing function used in the animation or null for Linear. (default CircleEase)
  114504. */
  114505. easingFunction?: EasingFunction;
  114506. }
  114507. /**
  114508. * Options to modify the vr experience helper's behavior.
  114509. */
  114510. export interface VRExperienceHelperOptions extends WebVROptions {
  114511. /**
  114512. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  114513. */
  114514. createDeviceOrientationCamera?: boolean;
  114515. /**
  114516. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  114517. */
  114518. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  114519. /**
  114520. * Uses the main button on the controller to toggle the laser casted. (default: true)
  114521. */
  114522. laserToggle?: boolean;
  114523. /**
  114524. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  114525. */
  114526. floorMeshes?: Mesh[];
  114527. /**
  114528. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  114529. */
  114530. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  114531. /**
  114532. * Defines if WebXR should be used instead of WebVR (if available)
  114533. */
  114534. useXR?: boolean;
  114535. }
  114536. /**
  114537. * Event containing information after VR has been entered
  114538. */
  114539. export class OnAfterEnteringVRObservableEvent {
  114540. /**
  114541. * If entering vr was successful
  114542. */
  114543. success: boolean;
  114544. }
  114545. /**
  114546. * Helps to quickly add VR support to an existing scene.
  114547. * See http://doc.babylonjs.com/how_to/webvr_helper
  114548. */
  114549. export class VRExperienceHelper {
  114550. /** Options to modify the vr experience helper's behavior. */
  114551. webVROptions: VRExperienceHelperOptions;
  114552. private _scene;
  114553. private _position;
  114554. private _btnVR;
  114555. private _btnVRDisplayed;
  114556. private _webVRsupported;
  114557. private _webVRready;
  114558. private _webVRrequesting;
  114559. private _webVRpresenting;
  114560. private _hasEnteredVR;
  114561. private _fullscreenVRpresenting;
  114562. private _inputElement;
  114563. private _webVRCamera;
  114564. private _vrDeviceOrientationCamera;
  114565. private _deviceOrientationCamera;
  114566. private _existingCamera;
  114567. private _onKeyDown;
  114568. private _onVrDisplayPresentChange;
  114569. private _onVRDisplayChanged;
  114570. private _onVRRequestPresentStart;
  114571. private _onVRRequestPresentComplete;
  114572. /**
  114573. * 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)
  114574. */
  114575. enableGazeEvenWhenNoPointerLock: boolean;
  114576. /**
  114577. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  114578. */
  114579. exitVROnDoubleTap: boolean;
  114580. /**
  114581. * Observable raised right before entering VR.
  114582. */
  114583. onEnteringVRObservable: Observable<VRExperienceHelper>;
  114584. /**
  114585. * Observable raised when entering VR has completed.
  114586. */
  114587. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  114588. /**
  114589. * Observable raised when exiting VR.
  114590. */
  114591. onExitingVRObservable: Observable<VRExperienceHelper>;
  114592. /**
  114593. * Observable raised when controller mesh is loaded.
  114594. */
  114595. onControllerMeshLoadedObservable: Observable<WebVRController>;
  114596. /** Return this.onEnteringVRObservable
  114597. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  114598. */
  114599. get onEnteringVR(): Observable<VRExperienceHelper>;
  114600. /** Return this.onExitingVRObservable
  114601. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  114602. */
  114603. get onExitingVR(): Observable<VRExperienceHelper>;
  114604. /** Return this.onControllerMeshLoadedObservable
  114605. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  114606. */
  114607. get onControllerMeshLoaded(): Observable<WebVRController>;
  114608. private _rayLength;
  114609. private _useCustomVRButton;
  114610. private _teleportationRequested;
  114611. private _teleportActive;
  114612. private _floorMeshName;
  114613. private _floorMeshesCollection;
  114614. private _teleportationMode;
  114615. private _teleportationTime;
  114616. private _teleportationSpeed;
  114617. private _teleportationEasing;
  114618. private _rotationAllowed;
  114619. private _teleportBackwardsVector;
  114620. private _teleportationTarget;
  114621. private _isDefaultTeleportationTarget;
  114622. private _postProcessMove;
  114623. private _teleportationFillColor;
  114624. private _teleportationBorderColor;
  114625. private _rotationAngle;
  114626. private _haloCenter;
  114627. private _cameraGazer;
  114628. private _padSensibilityUp;
  114629. private _padSensibilityDown;
  114630. private _leftController;
  114631. private _rightController;
  114632. private _gazeColor;
  114633. private _laserColor;
  114634. private _pickedLaserColor;
  114635. private _pickedGazeColor;
  114636. /**
  114637. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  114638. */
  114639. onNewMeshSelected: Observable<AbstractMesh>;
  114640. /**
  114641. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  114642. * This observable will provide the mesh and the controller used to select the mesh
  114643. */
  114644. onMeshSelectedWithController: Observable<{
  114645. mesh: AbstractMesh;
  114646. controller: WebVRController;
  114647. }>;
  114648. /**
  114649. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  114650. */
  114651. onNewMeshPicked: Observable<PickingInfo>;
  114652. private _circleEase;
  114653. /**
  114654. * Observable raised before camera teleportation
  114655. */
  114656. onBeforeCameraTeleport: Observable<Vector3>;
  114657. /**
  114658. * Observable raised after camera teleportation
  114659. */
  114660. onAfterCameraTeleport: Observable<Vector3>;
  114661. /**
  114662. * Observable raised when current selected mesh gets unselected
  114663. */
  114664. onSelectedMeshUnselected: Observable<AbstractMesh>;
  114665. private _raySelectionPredicate;
  114666. /**
  114667. * To be optionaly changed by user to define custom ray selection
  114668. */
  114669. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  114670. /**
  114671. * To be optionaly changed by user to define custom selection logic (after ray selection)
  114672. */
  114673. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114674. /**
  114675. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  114676. */
  114677. teleportationEnabled: boolean;
  114678. private _defaultHeight;
  114679. private _teleportationInitialized;
  114680. private _interactionsEnabled;
  114681. private _interactionsRequested;
  114682. private _displayGaze;
  114683. private _displayLaserPointer;
  114684. /**
  114685. * The mesh used to display where the user is going to teleport.
  114686. */
  114687. get teleportationTarget(): Mesh;
  114688. /**
  114689. * Sets the mesh to be used to display where the user is going to teleport.
  114690. */
  114691. set teleportationTarget(value: Mesh);
  114692. /**
  114693. * 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
  114694. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  114695. * See http://doc.babylonjs.com/resources/baking_transformations
  114696. */
  114697. get gazeTrackerMesh(): Mesh;
  114698. set gazeTrackerMesh(value: Mesh);
  114699. /**
  114700. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  114701. */
  114702. updateGazeTrackerScale: boolean;
  114703. /**
  114704. * If the gaze trackers color should be updated when selecting meshes
  114705. */
  114706. updateGazeTrackerColor: boolean;
  114707. /**
  114708. * If the controller laser color should be updated when selecting meshes
  114709. */
  114710. updateControllerLaserColor: boolean;
  114711. /**
  114712. * The gaze tracking mesh corresponding to the left controller
  114713. */
  114714. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  114715. /**
  114716. * The gaze tracking mesh corresponding to the right controller
  114717. */
  114718. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  114719. /**
  114720. * If the ray of the gaze should be displayed.
  114721. */
  114722. get displayGaze(): boolean;
  114723. /**
  114724. * Sets if the ray of the gaze should be displayed.
  114725. */
  114726. set displayGaze(value: boolean);
  114727. /**
  114728. * If the ray of the LaserPointer should be displayed.
  114729. */
  114730. get displayLaserPointer(): boolean;
  114731. /**
  114732. * Sets if the ray of the LaserPointer should be displayed.
  114733. */
  114734. set displayLaserPointer(value: boolean);
  114735. /**
  114736. * The deviceOrientationCamera used as the camera when not in VR.
  114737. */
  114738. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  114739. /**
  114740. * Based on the current WebVR support, returns the current VR camera used.
  114741. */
  114742. get currentVRCamera(): Nullable<Camera>;
  114743. /**
  114744. * The webVRCamera which is used when in VR.
  114745. */
  114746. get webVRCamera(): WebVRFreeCamera;
  114747. /**
  114748. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  114749. */
  114750. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  114751. /**
  114752. * The html button that is used to trigger entering into VR.
  114753. */
  114754. get vrButton(): Nullable<HTMLButtonElement>;
  114755. private get _teleportationRequestInitiated();
  114756. /**
  114757. * Defines wether or not Pointer lock should be requested when switching to
  114758. * full screen.
  114759. */
  114760. requestPointerLockOnFullScreen: boolean;
  114761. /**
  114762. * If asking to force XR, this will be populated with the default xr experience
  114763. */
  114764. xr: WebXRDefaultExperience;
  114765. /**
  114766. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  114767. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  114768. */
  114769. xrTestDone: boolean;
  114770. /**
  114771. * Instantiates a VRExperienceHelper.
  114772. * Helps to quickly add VR support to an existing scene.
  114773. * @param scene The scene the VRExperienceHelper belongs to.
  114774. * @param webVROptions Options to modify the vr experience helper's behavior.
  114775. */
  114776. constructor(scene: Scene,
  114777. /** Options to modify the vr experience helper's behavior. */
  114778. webVROptions?: VRExperienceHelperOptions);
  114779. private completeVRInit;
  114780. private _onDefaultMeshLoaded;
  114781. private _onResize;
  114782. private _onFullscreenChange;
  114783. /**
  114784. * Gets a value indicating if we are currently in VR mode.
  114785. */
  114786. get isInVRMode(): boolean;
  114787. private onVrDisplayPresentChange;
  114788. private onVRDisplayChanged;
  114789. private moveButtonToBottomRight;
  114790. private displayVRButton;
  114791. private updateButtonVisibility;
  114792. private _cachedAngularSensibility;
  114793. /**
  114794. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  114795. * Otherwise, will use the fullscreen API.
  114796. */
  114797. enterVR(): void;
  114798. /**
  114799. * Attempt to exit VR, or fullscreen.
  114800. */
  114801. exitVR(): void;
  114802. /**
  114803. * The position of the vr experience helper.
  114804. */
  114805. get position(): Vector3;
  114806. /**
  114807. * Sets the position of the vr experience helper.
  114808. */
  114809. set position(value: Vector3);
  114810. /**
  114811. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  114812. */
  114813. enableInteractions(): void;
  114814. private get _noControllerIsActive();
  114815. private beforeRender;
  114816. private _isTeleportationFloor;
  114817. /**
  114818. * Adds a floor mesh to be used for teleportation.
  114819. * @param floorMesh the mesh to be used for teleportation.
  114820. */
  114821. addFloorMesh(floorMesh: Mesh): void;
  114822. /**
  114823. * Removes a floor mesh from being used for teleportation.
  114824. * @param floorMesh the mesh to be removed.
  114825. */
  114826. removeFloorMesh(floorMesh: Mesh): void;
  114827. /**
  114828. * Enables interactions and teleportation using the VR controllers and gaze.
  114829. * @param vrTeleportationOptions options to modify teleportation behavior.
  114830. */
  114831. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  114832. private _onNewGamepadConnected;
  114833. private _tryEnableInteractionOnController;
  114834. private _onNewGamepadDisconnected;
  114835. private _enableInteractionOnController;
  114836. private _checkTeleportWithRay;
  114837. private _checkRotate;
  114838. private _checkTeleportBackwards;
  114839. private _enableTeleportationOnController;
  114840. private _createTeleportationCircles;
  114841. private _displayTeleportationTarget;
  114842. private _hideTeleportationTarget;
  114843. private _rotateCamera;
  114844. private _moveTeleportationSelectorTo;
  114845. private _workingVector;
  114846. private _workingQuaternion;
  114847. private _workingMatrix;
  114848. /**
  114849. * Time Constant Teleportation Mode
  114850. */
  114851. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  114852. /**
  114853. * Speed Constant Teleportation Mode
  114854. */
  114855. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  114856. /**
  114857. * Teleports the users feet to the desired location
  114858. * @param location The location where the user's feet should be placed
  114859. */
  114860. teleportCamera(location: Vector3): void;
  114861. private _convertNormalToDirectionOfRay;
  114862. private _castRayAndSelectObject;
  114863. private _notifySelectedMeshUnselected;
  114864. /**
  114865. * Permanently set new colors for the laser pointer
  114866. * @param color the new laser color
  114867. * @param pickedColor the new laser color when picked mesh detected
  114868. */
  114869. setLaserColor(color: Color3, pickedColor?: Color3): void;
  114870. /**
  114871. * Permanently set new colors for the gaze pointer
  114872. * @param color the new gaze color
  114873. * @param pickedColor the new gaze color when picked mesh detected
  114874. */
  114875. setGazeColor(color: Color3, pickedColor?: Color3): void;
  114876. /**
  114877. * Sets the color of the laser ray from the vr controllers.
  114878. * @param color new color for the ray.
  114879. */
  114880. changeLaserColor(color: Color3): void;
  114881. /**
  114882. * Sets the color of the ray from the vr headsets gaze.
  114883. * @param color new color for the ray.
  114884. */
  114885. changeGazeColor(color: Color3): void;
  114886. /**
  114887. * Exits VR and disposes of the vr experience helper
  114888. */
  114889. dispose(): void;
  114890. /**
  114891. * Gets the name of the VRExperienceHelper class
  114892. * @returns "VRExperienceHelper"
  114893. */
  114894. getClassName(): string;
  114895. }
  114896. }
  114897. declare module BABYLON {
  114898. /**
  114899. * Options used for hit testing
  114900. */
  114901. export interface IWebXRHitTestOptions {
  114902. /**
  114903. * Only test when user interacted with the scene. Default - hit test every frame
  114904. */
  114905. testOnPointerDownOnly?: boolean;
  114906. /**
  114907. * The node to use to transform the local results to world coordinates
  114908. */
  114909. worldParentNode?: TransformNode;
  114910. }
  114911. /**
  114912. * Interface defining the babylon result of raycasting/hit-test
  114913. */
  114914. export interface IWebXRHitResult {
  114915. /**
  114916. * The native hit test result
  114917. */
  114918. xrHitResult: XRHitResult;
  114919. /**
  114920. * Transformation matrix that can be applied to a node that will put it in the hit point location
  114921. */
  114922. transformationMatrix: Matrix;
  114923. }
  114924. /**
  114925. * The currently-working hit-test module.
  114926. * Hit test (or raycasting) is used to interact with the real world.
  114927. * For further information read here - https://github.com/immersive-web/hit-test
  114928. */
  114929. export class WebXRHitTestLegacy implements IWebXRFeature {
  114930. private _xrSessionManager;
  114931. /**
  114932. * options to use when constructing this feature
  114933. */
  114934. readonly options: IWebXRHitTestOptions;
  114935. /**
  114936. * The module's name
  114937. */
  114938. static readonly Name: string;
  114939. /**
  114940. * The (Babylon) version of this module.
  114941. * This is an integer representing the implementation version.
  114942. * This number does not correspond to the webxr specs version
  114943. */
  114944. static readonly Version: number;
  114945. /**
  114946. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  114947. * @param event the (select) event to use to select with
  114948. * @param referenceSpace the reference space to use for this hit test
  114949. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114950. */
  114951. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  114952. /**
  114953. * execute a hit test with an XR Ray
  114954. *
  114955. * @param xrSession a native xrSession that will execute this hit test
  114956. * @param xrRay the ray (position and direction) to use for raycasting
  114957. * @param referenceSpace native XR reference space to use for the hit-test
  114958. * @param filter filter function that will filter the results
  114959. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114960. */
  114961. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  114962. /**
  114963. * Triggered when new babylon (transformed) hit test results are available
  114964. */
  114965. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  114966. /**
  114967. * Creates a new instance of the (legacy version) hit test feature
  114968. * @param _xrSessionManager an instance of WebXRSessionManager
  114969. * @param options options to use when constructing this feature
  114970. */
  114971. constructor(_xrSessionManager: WebXRSessionManager,
  114972. /**
  114973. * options to use when constructing this feature
  114974. */
  114975. options?: IWebXRHitTestOptions);
  114976. private _onSelectEnabled;
  114977. private _xrFrameObserver;
  114978. private _attached;
  114979. /**
  114980. * Populated with the last native XR Hit Results
  114981. */
  114982. lastNativeXRHitResults: XRHitResult[];
  114983. /**
  114984. * attach this feature
  114985. * Will usually be called by the features manager
  114986. *
  114987. * @returns true if successful.
  114988. */
  114989. attach(): boolean;
  114990. /**
  114991. * detach this feature.
  114992. * Will usually be called by the features manager
  114993. *
  114994. * @returns true if successful.
  114995. */
  114996. detach(): boolean;
  114997. private _onHitTestResults;
  114998. private _onSelect;
  114999. /**
  115000. * Dispose this feature and all of the resources attached
  115001. */
  115002. dispose(): void;
  115003. }
  115004. }
  115005. declare module BABYLON {
  115006. /**
  115007. * Options used in the plane detector module
  115008. */
  115009. export interface IWebXRPlaneDetectorOptions {
  115010. /**
  115011. * The node to use to transform the local results to world coordinates
  115012. */
  115013. worldParentNode?: TransformNode;
  115014. }
  115015. /**
  115016. * A babylon interface for a webxr plane.
  115017. * A Plane is actually a polygon, built from N points in space
  115018. */
  115019. export interface IWebXRPlane {
  115020. /**
  115021. * a babylon-assigned ID for this polygon
  115022. */
  115023. id: number;
  115024. /**
  115025. * the native xr-plane object
  115026. */
  115027. xrPlane: XRPlane;
  115028. /**
  115029. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  115030. */
  115031. polygonDefinition: Array<Vector3>;
  115032. /**
  115033. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  115034. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  115035. */
  115036. transformationMatrix: Matrix;
  115037. }
  115038. /**
  115039. * The plane detector is used to detect planes in the real world when in AR
  115040. * For more information see https://github.com/immersive-web/real-world-geometry/
  115041. */
  115042. export class WebXRPlaneDetector implements IWebXRFeature {
  115043. private _xrSessionManager;
  115044. private _options;
  115045. /**
  115046. * The module's name
  115047. */
  115048. static readonly Name: string;
  115049. /**
  115050. * The (Babylon) version of this module.
  115051. * This is an integer representing the implementation version.
  115052. * This number does not correspond to the webxr specs version
  115053. */
  115054. static readonly Version: number;
  115055. /**
  115056. * Observers registered here will be executed when a new plane was added to the session
  115057. */
  115058. onPlaneAddedObservable: Observable<IWebXRPlane>;
  115059. /**
  115060. * Observers registered here will be executed when a plane is no longer detected in the session
  115061. */
  115062. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  115063. /**
  115064. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  115065. * This can execute N times every frame
  115066. */
  115067. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  115068. private _enabled;
  115069. private _attached;
  115070. private _detectedPlanes;
  115071. private _lastFrameDetected;
  115072. private _observerTracked;
  115073. /**
  115074. * construct a new Plane Detector
  115075. * @param _xrSessionManager an instance of xr Session manager
  115076. * @param _options configuration to use when constructing this feature
  115077. */
  115078. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  115079. /**
  115080. * attach this feature
  115081. * Will usually be called by the features manager
  115082. *
  115083. * @returns true if successful.
  115084. */
  115085. attach(): boolean;
  115086. /**
  115087. * detach this feature.
  115088. * Will usually be called by the features manager
  115089. *
  115090. * @returns true if successful.
  115091. */
  115092. detach(): boolean;
  115093. /**
  115094. * Dispose this feature and all of the resources attached
  115095. */
  115096. dispose(): void;
  115097. private _updatePlaneWithXRPlane;
  115098. /**
  115099. * avoiding using Array.find for global support.
  115100. * @param xrPlane the plane to find in the array
  115101. */
  115102. private findIndexInPlaneArray;
  115103. }
  115104. }
  115105. declare module BABYLON {
  115106. /**
  115107. * Configuration options of the anchor system
  115108. */
  115109. export interface IWebXRAnchorSystemOptions {
  115110. /**
  115111. * a node that will be used to convert local to world coordinates
  115112. */
  115113. worldParentNode?: TransformNode;
  115114. /**
  115115. * should the anchor system use plane detection.
  115116. * If set to true, the plane-detection feature should be set using setPlaneDetector
  115117. */
  115118. usePlaneDetection?: boolean;
  115119. /**
  115120. * Should a new anchor be added every time a select event is triggered
  115121. */
  115122. addAnchorOnSelect?: boolean;
  115123. }
  115124. /**
  115125. * A babylon container for an XR Anchor
  115126. */
  115127. export interface IWebXRAnchor {
  115128. /**
  115129. * A babylon-assigned ID for this anchor
  115130. */
  115131. id: number;
  115132. /**
  115133. * The native anchor object
  115134. */
  115135. xrAnchor: XRAnchor;
  115136. /**
  115137. * Transformation matrix to apply to an object attached to this anchor
  115138. */
  115139. transformationMatrix: Matrix;
  115140. }
  115141. /**
  115142. * An implementation of the anchor system of WebXR.
  115143. * Note that the current documented implementation is not available in any browser. Future implementations
  115144. * will use the frame to create an anchor and not the session or a detected plane
  115145. * For further information see https://github.com/immersive-web/anchors/
  115146. */
  115147. export class WebXRAnchorSystem implements IWebXRFeature {
  115148. private _xrSessionManager;
  115149. private _options;
  115150. /**
  115151. * The module's name
  115152. */
  115153. static readonly Name: string;
  115154. /**
  115155. * The (Babylon) version of this module.
  115156. * This is an integer representing the implementation version.
  115157. * This number does not correspond to the webxr specs version
  115158. */
  115159. static readonly Version: number;
  115160. /**
  115161. * Observers registered here will be executed when a new anchor was added to the session
  115162. */
  115163. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  115164. /**
  115165. * Observers registered here will be executed when an existing anchor updates
  115166. * This can execute N times every frame
  115167. */
  115168. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  115169. /**
  115170. * Observers registered here will be executed when an anchor was removed from the session
  115171. */
  115172. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  115173. private _planeDetector;
  115174. private _hitTestModule;
  115175. private _enabled;
  115176. private _attached;
  115177. private _trackedAnchors;
  115178. private _lastFrameDetected;
  115179. private _observerTracked;
  115180. /**
  115181. * constructs a new anchor system
  115182. * @param _xrSessionManager an instance of WebXRSessionManager
  115183. * @param _options configuration object for this feature
  115184. */
  115185. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  115186. /**
  115187. * set the plane detector to use in order to create anchors from frames
  115188. * @param planeDetector the plane-detector module to use
  115189. * @param enable enable plane-anchors. default is true
  115190. */
  115191. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  115192. /**
  115193. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  115194. * @param hitTestModule the hit-test module to use.
  115195. */
  115196. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  115197. /**
  115198. * attach this feature
  115199. * Will usually be called by the features manager
  115200. *
  115201. * @returns true if successful.
  115202. */
  115203. attach(): boolean;
  115204. /**
  115205. * detach this feature.
  115206. * Will usually be called by the features manager
  115207. *
  115208. * @returns true if successful.
  115209. */
  115210. detach(): boolean;
  115211. /**
  115212. * Dispose this feature and all of the resources attached
  115213. */
  115214. dispose(): void;
  115215. private _onSelect;
  115216. /**
  115217. * Add anchor at a specific XR point.
  115218. *
  115219. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  115220. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  115221. * @returns a promise the fulfills when the anchor was created
  115222. */
  115223. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  115224. private _updateAnchorWithXRFrame;
  115225. /**
  115226. * avoiding using Array.find for global support.
  115227. * @param xrAnchor the plane to find in the array
  115228. */
  115229. private _findIndexInAnchorArray;
  115230. }
  115231. }
  115232. declare module BABYLON {
  115233. /**
  115234. * Options interface for the background remover plugin
  115235. */
  115236. export interface IWebXRBackgroundRemoverOptions {
  115237. /**
  115238. * don't disable the environment helper
  115239. */
  115240. ignoreEnvironmentHelper?: boolean;
  115241. /**
  115242. * flags to configure the removal of the environment helper.
  115243. * If not set, the entire background will be removed. If set, flags should be set as well.
  115244. */
  115245. environmentHelperRemovalFlags?: {
  115246. /**
  115247. * Should the skybox be removed (default false)
  115248. */
  115249. skyBox?: boolean;
  115250. /**
  115251. * Should the ground be removed (default false)
  115252. */
  115253. ground?: boolean;
  115254. };
  115255. /**
  115256. * Further background meshes to disable when entering AR
  115257. */
  115258. backgroundMeshes?: AbstractMesh[];
  115259. }
  115260. /**
  115261. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  115262. */
  115263. export class WebXRBackgroundRemover implements IWebXRFeature {
  115264. private _xrSessionManager;
  115265. /**
  115266. * read-only options to be used in this module
  115267. */
  115268. readonly options: IWebXRBackgroundRemoverOptions;
  115269. /**
  115270. * The module's name
  115271. */
  115272. static readonly Name: string;
  115273. /**
  115274. * The (Babylon) version of this module.
  115275. * This is an integer representing the implementation version.
  115276. * This number does not correspond to the webxr specs version
  115277. */
  115278. static readonly Version: number;
  115279. /**
  115280. * registered observers will be triggered when the background state changes
  115281. */
  115282. onBackgroundStateChangedObservable: Observable<boolean>;
  115283. /**
  115284. * constructs a new background remover module
  115285. * @param _xrSessionManager the session manager for this module
  115286. * @param options read-only options to be used in this module
  115287. */
  115288. constructor(_xrSessionManager: WebXRSessionManager,
  115289. /**
  115290. * read-only options to be used in this module
  115291. */
  115292. options?: IWebXRBackgroundRemoverOptions);
  115293. /**
  115294. * attach this feature
  115295. * Will usually be called by the features manager
  115296. *
  115297. * @returns true if successful.
  115298. */
  115299. attach(): boolean;
  115300. /**
  115301. * detach this feature.
  115302. * Will usually be called by the features manager
  115303. *
  115304. * @returns true if successful.
  115305. */
  115306. detach(): boolean;
  115307. private _setBackgroundState;
  115308. /**
  115309. * Dispose this feature and all of the resources attached
  115310. */
  115311. dispose(): void;
  115312. }
  115313. }
  115314. declare module BABYLON {
  115315. /**
  115316. * Contains an array of blocks representing the octree
  115317. */
  115318. export interface IOctreeContainer<T> {
  115319. /**
  115320. * Blocks within the octree
  115321. */
  115322. blocks: Array<OctreeBlock<T>>;
  115323. }
  115324. /**
  115325. * Class used to store a cell in an octree
  115326. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115327. */
  115328. export class OctreeBlock<T> {
  115329. /**
  115330. * Gets the content of the current block
  115331. */
  115332. entries: T[];
  115333. /**
  115334. * Gets the list of block children
  115335. */
  115336. blocks: Array<OctreeBlock<T>>;
  115337. private _depth;
  115338. private _maxDepth;
  115339. private _capacity;
  115340. private _minPoint;
  115341. private _maxPoint;
  115342. private _boundingVectors;
  115343. private _creationFunc;
  115344. /**
  115345. * Creates a new block
  115346. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  115347. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  115348. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115349. * @param depth defines the current depth of this block in the octree
  115350. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  115351. * @param creationFunc defines a callback to call when an element is added to the block
  115352. */
  115353. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  115354. /**
  115355. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115356. */
  115357. get capacity(): number;
  115358. /**
  115359. * Gets the minimum vector (in world space) of the block's bounding box
  115360. */
  115361. get minPoint(): Vector3;
  115362. /**
  115363. * Gets the maximum vector (in world space) of the block's bounding box
  115364. */
  115365. get maxPoint(): Vector3;
  115366. /**
  115367. * Add a new element to this block
  115368. * @param entry defines the element to add
  115369. */
  115370. addEntry(entry: T): void;
  115371. /**
  115372. * Remove an element from this block
  115373. * @param entry defines the element to remove
  115374. */
  115375. removeEntry(entry: T): void;
  115376. /**
  115377. * Add an array of elements to this block
  115378. * @param entries defines the array of elements to add
  115379. */
  115380. addEntries(entries: T[]): void;
  115381. /**
  115382. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  115383. * @param frustumPlanes defines the frustum planes to test
  115384. * @param selection defines the array to store current content if selection is positive
  115385. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115386. */
  115387. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115388. /**
  115389. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  115390. * @param sphereCenter defines the bounding sphere center
  115391. * @param sphereRadius defines the bounding sphere radius
  115392. * @param selection defines the array to store current content if selection is positive
  115393. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115394. */
  115395. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115396. /**
  115397. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  115398. * @param ray defines the ray to test with
  115399. * @param selection defines the array to store current content if selection is positive
  115400. */
  115401. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  115402. /**
  115403. * Subdivide the content into child blocks (this block will then be empty)
  115404. */
  115405. createInnerBlocks(): void;
  115406. /**
  115407. * @hidden
  115408. */
  115409. 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;
  115410. }
  115411. }
  115412. declare module BABYLON {
  115413. /**
  115414. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  115415. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115416. */
  115417. export class Octree<T> {
  115418. /** 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.) */
  115419. maxDepth: number;
  115420. /**
  115421. * Blocks within the octree containing objects
  115422. */
  115423. blocks: Array<OctreeBlock<T>>;
  115424. /**
  115425. * Content stored in the octree
  115426. */
  115427. dynamicContent: T[];
  115428. private _maxBlockCapacity;
  115429. private _selectionContent;
  115430. private _creationFunc;
  115431. /**
  115432. * Creates a octree
  115433. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115434. * @param creationFunc function to be used to instatiate the octree
  115435. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  115436. * @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.)
  115437. */
  115438. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  115439. /** 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.) */
  115440. maxDepth?: number);
  115441. /**
  115442. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  115443. * @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);
  115444. * @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);
  115445. * @param entries meshes to be added to the octree blocks
  115446. */
  115447. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  115448. /**
  115449. * Adds a mesh to the octree
  115450. * @param entry Mesh to add to the octree
  115451. */
  115452. addMesh(entry: T): void;
  115453. /**
  115454. * Remove an element from the octree
  115455. * @param entry defines the element to remove
  115456. */
  115457. removeMesh(entry: T): void;
  115458. /**
  115459. * Selects an array of meshes within the frustum
  115460. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  115461. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  115462. * @returns array of meshes within the frustum
  115463. */
  115464. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  115465. /**
  115466. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  115467. * @param sphereCenter defines the bounding sphere center
  115468. * @param sphereRadius defines the bounding sphere radius
  115469. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115470. * @returns an array of objects that intersect the sphere
  115471. */
  115472. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  115473. /**
  115474. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  115475. * @param ray defines the ray to test with
  115476. * @returns array of intersected objects
  115477. */
  115478. intersectsRay(ray: Ray): SmartArray<T>;
  115479. /**
  115480. * Adds a mesh into the octree block if it intersects the block
  115481. */
  115482. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  115483. /**
  115484. * Adds a submesh into the octree block if it intersects the block
  115485. */
  115486. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  115487. }
  115488. }
  115489. declare module BABYLON {
  115490. interface Scene {
  115491. /**
  115492. * @hidden
  115493. * Backing Filed
  115494. */
  115495. _selectionOctree: Octree<AbstractMesh>;
  115496. /**
  115497. * Gets the octree used to boost mesh selection (picking)
  115498. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115499. */
  115500. selectionOctree: Octree<AbstractMesh>;
  115501. /**
  115502. * Creates or updates the octree used to boost selection (picking)
  115503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115504. * @param maxCapacity defines the maximum capacity per leaf
  115505. * @param maxDepth defines the maximum depth of the octree
  115506. * @returns an octree of AbstractMesh
  115507. */
  115508. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  115509. }
  115510. interface AbstractMesh {
  115511. /**
  115512. * @hidden
  115513. * Backing Field
  115514. */
  115515. _submeshesOctree: Octree<SubMesh>;
  115516. /**
  115517. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  115518. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  115519. * @param maxCapacity defines the maximum size of each block (64 by default)
  115520. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  115521. * @returns the new octree
  115522. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  115523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115524. */
  115525. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  115526. }
  115527. /**
  115528. * Defines the octree scene component responsible to manage any octrees
  115529. * in a given scene.
  115530. */
  115531. export class OctreeSceneComponent {
  115532. /**
  115533. * The component name help to identify the component in the list of scene components.
  115534. */
  115535. readonly name: string;
  115536. /**
  115537. * The scene the component belongs to.
  115538. */
  115539. scene: Scene;
  115540. /**
  115541. * Indicates if the meshes have been checked to make sure they are isEnabled()
  115542. */
  115543. readonly checksIsEnabled: boolean;
  115544. /**
  115545. * Creates a new instance of the component for the given scene
  115546. * @param scene Defines the scene to register the component in
  115547. */
  115548. constructor(scene: Scene);
  115549. /**
  115550. * Registers the component in a given scene
  115551. */
  115552. register(): void;
  115553. /**
  115554. * Return the list of active meshes
  115555. * @returns the list of active meshes
  115556. */
  115557. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  115558. /**
  115559. * Return the list of active sub meshes
  115560. * @param mesh The mesh to get the candidates sub meshes from
  115561. * @returns the list of active sub meshes
  115562. */
  115563. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  115564. private _tempRay;
  115565. /**
  115566. * Return the list of sub meshes intersecting with a given local ray
  115567. * @param mesh defines the mesh to find the submesh for
  115568. * @param localRay defines the ray in local space
  115569. * @returns the list of intersecting sub meshes
  115570. */
  115571. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  115572. /**
  115573. * Return the list of sub meshes colliding with a collider
  115574. * @param mesh defines the mesh to find the submesh for
  115575. * @param collider defines the collider to evaluate the collision against
  115576. * @returns the list of colliding sub meshes
  115577. */
  115578. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  115579. /**
  115580. * Rebuilds the elements related to this component in case of
  115581. * context lost for instance.
  115582. */
  115583. rebuild(): void;
  115584. /**
  115585. * Disposes the component and the associated ressources.
  115586. */
  115587. dispose(): void;
  115588. }
  115589. }
  115590. declare module BABYLON {
  115591. /**
  115592. * Renders a layer on top of an existing scene
  115593. */
  115594. export class UtilityLayerRenderer implements IDisposable {
  115595. /** the original scene that will be rendered on top of */
  115596. originalScene: Scene;
  115597. private _pointerCaptures;
  115598. private _lastPointerEvents;
  115599. private static _DefaultUtilityLayer;
  115600. private static _DefaultKeepDepthUtilityLayer;
  115601. private _sharedGizmoLight;
  115602. private _renderCamera;
  115603. /**
  115604. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  115605. * @returns the camera that is used when rendering the utility layer
  115606. */
  115607. getRenderCamera(): Nullable<Camera>;
  115608. /**
  115609. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  115610. * @param cam the camera that should be used when rendering the utility layer
  115611. */
  115612. setRenderCamera(cam: Nullable<Camera>): void;
  115613. /**
  115614. * @hidden
  115615. * Light which used by gizmos to get light shading
  115616. */
  115617. _getSharedGizmoLight(): HemisphericLight;
  115618. /**
  115619. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  115620. */
  115621. pickUtilitySceneFirst: boolean;
  115622. /**
  115623. * 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)
  115624. */
  115625. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  115626. /**
  115627. * 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)
  115628. */
  115629. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  115630. /**
  115631. * The scene that is rendered on top of the original scene
  115632. */
  115633. utilityLayerScene: Scene;
  115634. /**
  115635. * If the utility layer should automatically be rendered on top of existing scene
  115636. */
  115637. shouldRender: boolean;
  115638. /**
  115639. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  115640. */
  115641. onlyCheckPointerDownEvents: boolean;
  115642. /**
  115643. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  115644. */
  115645. processAllEvents: boolean;
  115646. /**
  115647. * Observable raised when the pointer move from the utility layer scene to the main scene
  115648. */
  115649. onPointerOutObservable: Observable<number>;
  115650. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  115651. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  115652. private _afterRenderObserver;
  115653. private _sceneDisposeObserver;
  115654. private _originalPointerObserver;
  115655. /**
  115656. * Instantiates a UtilityLayerRenderer
  115657. * @param originalScene the original scene that will be rendered on top of
  115658. * @param handleEvents boolean indicating if the utility layer should handle events
  115659. */
  115660. constructor(
  115661. /** the original scene that will be rendered on top of */
  115662. originalScene: Scene, handleEvents?: boolean);
  115663. private _notifyObservers;
  115664. /**
  115665. * Renders the utility layers scene on top of the original scene
  115666. */
  115667. render(): void;
  115668. /**
  115669. * Disposes of the renderer
  115670. */
  115671. dispose(): void;
  115672. private _updateCamera;
  115673. }
  115674. }
  115675. declare module BABYLON {
  115676. /**
  115677. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  115678. */
  115679. export class Gizmo implements IDisposable {
  115680. /** The utility layer the gizmo will be added to */
  115681. gizmoLayer: UtilityLayerRenderer;
  115682. /**
  115683. * The root mesh of the gizmo
  115684. */
  115685. _rootMesh: Mesh;
  115686. private _attachedMesh;
  115687. /**
  115688. * Ratio for the scale of the gizmo (Default: 1)
  115689. */
  115690. scaleRatio: number;
  115691. /**
  115692. * If a custom mesh has been set (Default: false)
  115693. */
  115694. protected _customMeshSet: boolean;
  115695. /**
  115696. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  115697. * * When set, interactions will be enabled
  115698. */
  115699. get attachedMesh(): Nullable<AbstractMesh>;
  115700. set attachedMesh(value: Nullable<AbstractMesh>);
  115701. /**
  115702. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115703. * @param mesh The mesh to replace the default mesh of the gizmo
  115704. */
  115705. setCustomMesh(mesh: Mesh): void;
  115706. /**
  115707. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  115708. */
  115709. updateGizmoRotationToMatchAttachedMesh: boolean;
  115710. /**
  115711. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  115712. */
  115713. updateGizmoPositionToMatchAttachedMesh: boolean;
  115714. /**
  115715. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  115716. */
  115717. updateScale: boolean;
  115718. protected _interactionsEnabled: boolean;
  115719. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115720. private _beforeRenderObserver;
  115721. private _tempVector;
  115722. /**
  115723. * Creates a gizmo
  115724. * @param gizmoLayer The utility layer the gizmo will be added to
  115725. */
  115726. constructor(
  115727. /** The utility layer the gizmo will be added to */
  115728. gizmoLayer?: UtilityLayerRenderer);
  115729. /**
  115730. * Updates the gizmo to match the attached mesh's position/rotation
  115731. */
  115732. protected _update(): void;
  115733. /**
  115734. * Disposes of the gizmo
  115735. */
  115736. dispose(): void;
  115737. }
  115738. }
  115739. declare module BABYLON {
  115740. /**
  115741. * Single plane drag gizmo
  115742. */
  115743. export class PlaneDragGizmo extends Gizmo {
  115744. /**
  115745. * Drag behavior responsible for the gizmos dragging interactions
  115746. */
  115747. dragBehavior: PointerDragBehavior;
  115748. private _pointerObserver;
  115749. /**
  115750. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115751. */
  115752. snapDistance: number;
  115753. /**
  115754. * Event that fires each time the gizmo snaps to a new location.
  115755. * * snapDistance is the the change in distance
  115756. */
  115757. onSnapObservable: Observable<{
  115758. snapDistance: number;
  115759. }>;
  115760. private _plane;
  115761. private _coloredMaterial;
  115762. private _hoverMaterial;
  115763. private _isEnabled;
  115764. private _parent;
  115765. /** @hidden */
  115766. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  115767. /** @hidden */
  115768. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115769. /**
  115770. * Creates a PlaneDragGizmo
  115771. * @param gizmoLayer The utility layer the gizmo will be added to
  115772. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  115773. * @param color The color of the gizmo
  115774. */
  115775. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115776. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115777. /**
  115778. * If the gizmo is enabled
  115779. */
  115780. set isEnabled(value: boolean);
  115781. get isEnabled(): boolean;
  115782. /**
  115783. * Disposes of the gizmo
  115784. */
  115785. dispose(): void;
  115786. }
  115787. }
  115788. declare module BABYLON {
  115789. /**
  115790. * Gizmo that enables dragging a mesh along 3 axis
  115791. */
  115792. export class PositionGizmo extends Gizmo {
  115793. /**
  115794. * Internal gizmo used for interactions on the x axis
  115795. */
  115796. xGizmo: AxisDragGizmo;
  115797. /**
  115798. * Internal gizmo used for interactions on the y axis
  115799. */
  115800. yGizmo: AxisDragGizmo;
  115801. /**
  115802. * Internal gizmo used for interactions on the z axis
  115803. */
  115804. zGizmo: AxisDragGizmo;
  115805. /**
  115806. * Internal gizmo used for interactions on the yz plane
  115807. */
  115808. xPlaneGizmo: PlaneDragGizmo;
  115809. /**
  115810. * Internal gizmo used for interactions on the xz plane
  115811. */
  115812. yPlaneGizmo: PlaneDragGizmo;
  115813. /**
  115814. * Internal gizmo used for interactions on the xy plane
  115815. */
  115816. zPlaneGizmo: PlaneDragGizmo;
  115817. /**
  115818. * private variables
  115819. */
  115820. private _meshAttached;
  115821. private _updateGizmoRotationToMatchAttachedMesh;
  115822. private _snapDistance;
  115823. private _scaleRatio;
  115824. /** Fires an event when any of it's sub gizmos are dragged */
  115825. onDragStartObservable: Observable<unknown>;
  115826. /** Fires an event when any of it's sub gizmos are released from dragging */
  115827. onDragEndObservable: Observable<unknown>;
  115828. /**
  115829. * If set to true, planar drag is enabled
  115830. */
  115831. private _planarGizmoEnabled;
  115832. get attachedMesh(): Nullable<AbstractMesh>;
  115833. set attachedMesh(mesh: Nullable<AbstractMesh>);
  115834. /**
  115835. * Creates a PositionGizmo
  115836. * @param gizmoLayer The utility layer the gizmo will be added to
  115837. */
  115838. constructor(gizmoLayer?: UtilityLayerRenderer);
  115839. /**
  115840. * If the planar drag gizmo is enabled
  115841. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  115842. */
  115843. set planarGizmoEnabled(value: boolean);
  115844. get planarGizmoEnabled(): boolean;
  115845. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  115846. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  115847. /**
  115848. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115849. */
  115850. set snapDistance(value: number);
  115851. get snapDistance(): number;
  115852. /**
  115853. * Ratio for the scale of the gizmo (Default: 1)
  115854. */
  115855. set scaleRatio(value: number);
  115856. get scaleRatio(): number;
  115857. /**
  115858. * Disposes of the gizmo
  115859. */
  115860. dispose(): void;
  115861. /**
  115862. * CustomMeshes are not supported by this gizmo
  115863. * @param mesh The mesh to replace the default mesh of the gizmo
  115864. */
  115865. setCustomMesh(mesh: Mesh): void;
  115866. }
  115867. }
  115868. declare module BABYLON {
  115869. /**
  115870. * Single axis drag gizmo
  115871. */
  115872. export class AxisDragGizmo extends Gizmo {
  115873. /**
  115874. * Drag behavior responsible for the gizmos dragging interactions
  115875. */
  115876. dragBehavior: PointerDragBehavior;
  115877. private _pointerObserver;
  115878. /**
  115879. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115880. */
  115881. snapDistance: number;
  115882. /**
  115883. * Event that fires each time the gizmo snaps to a new location.
  115884. * * snapDistance is the the change in distance
  115885. */
  115886. onSnapObservable: Observable<{
  115887. snapDistance: number;
  115888. }>;
  115889. private _isEnabled;
  115890. private _parent;
  115891. private _arrow;
  115892. private _coloredMaterial;
  115893. private _hoverMaterial;
  115894. /** @hidden */
  115895. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  115896. /** @hidden */
  115897. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115898. /**
  115899. * Creates an AxisDragGizmo
  115900. * @param gizmoLayer The utility layer the gizmo will be added to
  115901. * @param dragAxis The axis which the gizmo will be able to drag on
  115902. * @param color The color of the gizmo
  115903. */
  115904. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115905. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115906. /**
  115907. * If the gizmo is enabled
  115908. */
  115909. set isEnabled(value: boolean);
  115910. get isEnabled(): boolean;
  115911. /**
  115912. * Disposes of the gizmo
  115913. */
  115914. dispose(): void;
  115915. }
  115916. }
  115917. declare module BABYLON.Debug {
  115918. /**
  115919. * The Axes viewer will show 3 axes in a specific point in space
  115920. */
  115921. export class AxesViewer {
  115922. private _xAxis;
  115923. private _yAxis;
  115924. private _zAxis;
  115925. private _scaleLinesFactor;
  115926. private _instanced;
  115927. /**
  115928. * Gets the hosting scene
  115929. */
  115930. scene: Scene;
  115931. /**
  115932. * Gets or sets a number used to scale line length
  115933. */
  115934. scaleLines: number;
  115935. /** Gets the node hierarchy used to render x-axis */
  115936. get xAxis(): TransformNode;
  115937. /** Gets the node hierarchy used to render y-axis */
  115938. get yAxis(): TransformNode;
  115939. /** Gets the node hierarchy used to render z-axis */
  115940. get zAxis(): TransformNode;
  115941. /**
  115942. * Creates a new AxesViewer
  115943. * @param scene defines the hosting scene
  115944. * @param scaleLines defines a number used to scale line length (1 by default)
  115945. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  115946. * @param xAxis defines the node hierarchy used to render the x-axis
  115947. * @param yAxis defines the node hierarchy used to render the y-axis
  115948. * @param zAxis defines the node hierarchy used to render the z-axis
  115949. */
  115950. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  115951. /**
  115952. * Force the viewer to update
  115953. * @param position defines the position of the viewer
  115954. * @param xaxis defines the x axis of the viewer
  115955. * @param yaxis defines the y axis of the viewer
  115956. * @param zaxis defines the z axis of the viewer
  115957. */
  115958. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  115959. /**
  115960. * Creates an instance of this axes viewer.
  115961. * @returns a new axes viewer with instanced meshes
  115962. */
  115963. createInstance(): AxesViewer;
  115964. /** Releases resources */
  115965. dispose(): void;
  115966. private static _SetRenderingGroupId;
  115967. }
  115968. }
  115969. declare module BABYLON.Debug {
  115970. /**
  115971. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  115972. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  115973. */
  115974. export class BoneAxesViewer extends AxesViewer {
  115975. /**
  115976. * Gets or sets the target mesh where to display the axes viewer
  115977. */
  115978. mesh: Nullable<Mesh>;
  115979. /**
  115980. * Gets or sets the target bone where to display the axes viewer
  115981. */
  115982. bone: Nullable<Bone>;
  115983. /** Gets current position */
  115984. pos: Vector3;
  115985. /** Gets direction of X axis */
  115986. xaxis: Vector3;
  115987. /** Gets direction of Y axis */
  115988. yaxis: Vector3;
  115989. /** Gets direction of Z axis */
  115990. zaxis: Vector3;
  115991. /**
  115992. * Creates a new BoneAxesViewer
  115993. * @param scene defines the hosting scene
  115994. * @param bone defines the target bone
  115995. * @param mesh defines the target mesh
  115996. * @param scaleLines defines a scaling factor for line length (1 by default)
  115997. */
  115998. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  115999. /**
  116000. * Force the viewer to update
  116001. */
  116002. update(): void;
  116003. /** Releases resources */
  116004. dispose(): void;
  116005. }
  116006. }
  116007. declare module BABYLON {
  116008. /**
  116009. * Interface used to define scene explorer extensibility option
  116010. */
  116011. export interface IExplorerExtensibilityOption {
  116012. /**
  116013. * Define the option label
  116014. */
  116015. label: string;
  116016. /**
  116017. * Defines the action to execute on click
  116018. */
  116019. action: (entity: any) => void;
  116020. }
  116021. /**
  116022. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  116023. */
  116024. export interface IExplorerExtensibilityGroup {
  116025. /**
  116026. * Defines a predicate to test if a given type mut be extended
  116027. */
  116028. predicate: (entity: any) => boolean;
  116029. /**
  116030. * Gets the list of options added to a type
  116031. */
  116032. entries: IExplorerExtensibilityOption[];
  116033. }
  116034. /**
  116035. * Interface used to define the options to use to create the Inspector
  116036. */
  116037. export interface IInspectorOptions {
  116038. /**
  116039. * Display in overlay mode (default: false)
  116040. */
  116041. overlay?: boolean;
  116042. /**
  116043. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  116044. */
  116045. globalRoot?: HTMLElement;
  116046. /**
  116047. * Display the Scene explorer
  116048. */
  116049. showExplorer?: boolean;
  116050. /**
  116051. * Display the property inspector
  116052. */
  116053. showInspector?: boolean;
  116054. /**
  116055. * Display in embed mode (both panes on the right)
  116056. */
  116057. embedMode?: boolean;
  116058. /**
  116059. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  116060. */
  116061. handleResize?: boolean;
  116062. /**
  116063. * Allow the panes to popup (default: true)
  116064. */
  116065. enablePopup?: boolean;
  116066. /**
  116067. * Allow the panes to be closed by users (default: true)
  116068. */
  116069. enableClose?: boolean;
  116070. /**
  116071. * Optional list of extensibility entries
  116072. */
  116073. explorerExtensibility?: IExplorerExtensibilityGroup[];
  116074. /**
  116075. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  116076. */
  116077. inspectorURL?: string;
  116078. /**
  116079. * Optional initial tab (default to DebugLayerTab.Properties)
  116080. */
  116081. initialTab?: DebugLayerTab;
  116082. }
  116083. interface Scene {
  116084. /**
  116085. * @hidden
  116086. * Backing field
  116087. */
  116088. _debugLayer: DebugLayer;
  116089. /**
  116090. * Gets the debug layer (aka Inspector) associated with the scene
  116091. * @see http://doc.babylonjs.com/features/playground_debuglayer
  116092. */
  116093. debugLayer: DebugLayer;
  116094. }
  116095. /**
  116096. * Enum of inspector action tab
  116097. */
  116098. export enum DebugLayerTab {
  116099. /**
  116100. * Properties tag (default)
  116101. */
  116102. Properties = 0,
  116103. /**
  116104. * Debug tab
  116105. */
  116106. Debug = 1,
  116107. /**
  116108. * Statistics tab
  116109. */
  116110. Statistics = 2,
  116111. /**
  116112. * Tools tab
  116113. */
  116114. Tools = 3,
  116115. /**
  116116. * Settings tab
  116117. */
  116118. Settings = 4
  116119. }
  116120. /**
  116121. * The debug layer (aka Inspector) is the go to tool in order to better understand
  116122. * what is happening in your scene
  116123. * @see http://doc.babylonjs.com/features/playground_debuglayer
  116124. */
  116125. export class DebugLayer {
  116126. /**
  116127. * Define the url to get the inspector script from.
  116128. * By default it uses the babylonjs CDN.
  116129. * @ignoreNaming
  116130. */
  116131. static InspectorURL: string;
  116132. private _scene;
  116133. private BJSINSPECTOR;
  116134. private _onPropertyChangedObservable?;
  116135. /**
  116136. * Observable triggered when a property is changed through the inspector.
  116137. */
  116138. get onPropertyChangedObservable(): any;
  116139. /**
  116140. * Instantiates a new debug layer.
  116141. * The debug layer (aka Inspector) is the go to tool in order to better understand
  116142. * what is happening in your scene
  116143. * @see http://doc.babylonjs.com/features/playground_debuglayer
  116144. * @param scene Defines the scene to inspect
  116145. */
  116146. constructor(scene: Scene);
  116147. /** Creates the inspector window. */
  116148. private _createInspector;
  116149. /**
  116150. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  116151. * @param entity defines the entity to select
  116152. * @param lineContainerTitle defines the specific block to highlight
  116153. */
  116154. select(entity: any, lineContainerTitle?: string): void;
  116155. /** Get the inspector from bundle or global */
  116156. private _getGlobalInspector;
  116157. /**
  116158. * Get if the inspector is visible or not.
  116159. * @returns true if visible otherwise, false
  116160. */
  116161. isVisible(): boolean;
  116162. /**
  116163. * Hide the inspector and close its window.
  116164. */
  116165. hide(): void;
  116166. /**
  116167. * Launch the debugLayer.
  116168. * @param config Define the configuration of the inspector
  116169. * @return a promise fulfilled when the debug layer is visible
  116170. */
  116171. show(config?: IInspectorOptions): Promise<DebugLayer>;
  116172. }
  116173. }
  116174. declare module BABYLON {
  116175. /**
  116176. * Class containing static functions to help procedurally build meshes
  116177. */
  116178. export class BoxBuilder {
  116179. /**
  116180. * Creates a box mesh
  116181. * * The parameter `size` sets the size (float) of each box side (default 1)
  116182. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  116183. * * 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)
  116184. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116188. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  116189. * @param name defines the name of the mesh
  116190. * @param options defines the options used to create the mesh
  116191. * @param scene defines the hosting scene
  116192. * @returns the box mesh
  116193. */
  116194. static CreateBox(name: string, options: {
  116195. size?: number;
  116196. width?: number;
  116197. height?: number;
  116198. depth?: number;
  116199. faceUV?: Vector4[];
  116200. faceColors?: Color4[];
  116201. sideOrientation?: number;
  116202. frontUVs?: Vector4;
  116203. backUVs?: Vector4;
  116204. wrap?: boolean;
  116205. topBaseAt?: number;
  116206. bottomBaseAt?: number;
  116207. updatable?: boolean;
  116208. }, scene?: Nullable<Scene>): Mesh;
  116209. }
  116210. }
  116211. declare module BABYLON {
  116212. /**
  116213. * Class containing static functions to help procedurally build meshes
  116214. */
  116215. export class SphereBuilder {
  116216. /**
  116217. * Creates a sphere mesh
  116218. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116219. * * 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`)
  116220. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116221. * * 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
  116222. * * 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)
  116223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116226. * @param name defines the name of the mesh
  116227. * @param options defines the options used to create the mesh
  116228. * @param scene defines the hosting scene
  116229. * @returns the sphere mesh
  116230. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116231. */
  116232. static CreateSphere(name: string, options: {
  116233. segments?: number;
  116234. diameter?: number;
  116235. diameterX?: number;
  116236. diameterY?: number;
  116237. diameterZ?: number;
  116238. arc?: number;
  116239. slice?: number;
  116240. sideOrientation?: number;
  116241. frontUVs?: Vector4;
  116242. backUVs?: Vector4;
  116243. updatable?: boolean;
  116244. }, scene?: Nullable<Scene>): Mesh;
  116245. }
  116246. }
  116247. declare module BABYLON.Debug {
  116248. /**
  116249. * Used to show the physics impostor around the specific mesh
  116250. */
  116251. export class PhysicsViewer {
  116252. /** @hidden */
  116253. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  116254. /** @hidden */
  116255. protected _meshes: Array<Nullable<AbstractMesh>>;
  116256. /** @hidden */
  116257. protected _scene: Nullable<Scene>;
  116258. /** @hidden */
  116259. protected _numMeshes: number;
  116260. /** @hidden */
  116261. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  116262. private _renderFunction;
  116263. private _utilityLayer;
  116264. private _debugBoxMesh;
  116265. private _debugSphereMesh;
  116266. private _debugCylinderMesh;
  116267. private _debugMaterial;
  116268. private _debugMeshMeshes;
  116269. /**
  116270. * Creates a new PhysicsViewer
  116271. * @param scene defines the hosting scene
  116272. */
  116273. constructor(scene: Scene);
  116274. /** @hidden */
  116275. protected _updateDebugMeshes(): void;
  116276. /**
  116277. * Renders a specified physic impostor
  116278. * @param impostor defines the impostor to render
  116279. * @param targetMesh defines the mesh represented by the impostor
  116280. * @returns the new debug mesh used to render the impostor
  116281. */
  116282. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  116283. /**
  116284. * Hides a specified physic impostor
  116285. * @param impostor defines the impostor to hide
  116286. */
  116287. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  116288. private _getDebugMaterial;
  116289. private _getDebugBoxMesh;
  116290. private _getDebugSphereMesh;
  116291. private _getDebugCylinderMesh;
  116292. private _getDebugMeshMesh;
  116293. private _getDebugMesh;
  116294. /** Releases all resources */
  116295. dispose(): void;
  116296. }
  116297. }
  116298. declare module BABYLON {
  116299. /**
  116300. * Class containing static functions to help procedurally build meshes
  116301. */
  116302. export class LinesBuilder {
  116303. /**
  116304. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116305. * * 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
  116306. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116307. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116308. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116309. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116310. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116311. * * 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
  116312. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116315. * @param name defines the name of the new line system
  116316. * @param options defines the options used to create the line system
  116317. * @param scene defines the hosting scene
  116318. * @returns a new line system mesh
  116319. */
  116320. static CreateLineSystem(name: string, options: {
  116321. lines: Vector3[][];
  116322. updatable?: boolean;
  116323. instance?: Nullable<LinesMesh>;
  116324. colors?: Nullable<Color4[][]>;
  116325. useVertexAlpha?: boolean;
  116326. }, scene: Nullable<Scene>): LinesMesh;
  116327. /**
  116328. * Creates a line mesh
  116329. * 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
  116330. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116331. * * The parameter `points` is an array successive Vector3
  116332. * * 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
  116333. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116334. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116335. * * When updating an instance, remember that only point positions can change, not the number of points
  116336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116338. * @param name defines the name of the new line system
  116339. * @param options defines the options used to create the line system
  116340. * @param scene defines the hosting scene
  116341. * @returns a new line mesh
  116342. */
  116343. static CreateLines(name: string, options: {
  116344. points: Vector3[];
  116345. updatable?: boolean;
  116346. instance?: Nullable<LinesMesh>;
  116347. colors?: Color4[];
  116348. useVertexAlpha?: boolean;
  116349. }, scene?: Nullable<Scene>): LinesMesh;
  116350. /**
  116351. * Creates a dashed line mesh
  116352. * * 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
  116353. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116354. * * The parameter `points` is an array successive Vector3
  116355. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116356. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116357. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116358. * * 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
  116359. * * When updating an instance, remember that only point positions can change, not the number of points
  116360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116361. * @param name defines the name of the mesh
  116362. * @param options defines the options used to create the mesh
  116363. * @param scene defines the hosting scene
  116364. * @returns the dashed line mesh
  116365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116366. */
  116367. static CreateDashedLines(name: string, options: {
  116368. points: Vector3[];
  116369. dashSize?: number;
  116370. gapSize?: number;
  116371. dashNb?: number;
  116372. updatable?: boolean;
  116373. instance?: LinesMesh;
  116374. }, scene?: Nullable<Scene>): LinesMesh;
  116375. }
  116376. }
  116377. declare module BABYLON {
  116378. /**
  116379. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116380. * in order to better appreciate the issue one might have.
  116381. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116382. */
  116383. export class RayHelper {
  116384. /**
  116385. * Defines the ray we are currently tryin to visualize.
  116386. */
  116387. ray: Nullable<Ray>;
  116388. private _renderPoints;
  116389. private _renderLine;
  116390. private _renderFunction;
  116391. private _scene;
  116392. private _updateToMeshFunction;
  116393. private _attachedToMesh;
  116394. private _meshSpaceDirection;
  116395. private _meshSpaceOrigin;
  116396. /**
  116397. * Helper function to create a colored helper in a scene in one line.
  116398. * @param ray Defines the ray we are currently tryin to visualize
  116399. * @param scene Defines the scene the ray is used in
  116400. * @param color Defines the color we want to see the ray in
  116401. * @returns The newly created ray helper.
  116402. */
  116403. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  116404. /**
  116405. * Instantiate a new ray helper.
  116406. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116407. * in order to better appreciate the issue one might have.
  116408. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116409. * @param ray Defines the ray we are currently tryin to visualize
  116410. */
  116411. constructor(ray: Ray);
  116412. /**
  116413. * Shows the ray we are willing to debug.
  116414. * @param scene Defines the scene the ray needs to be rendered in
  116415. * @param color Defines the color the ray needs to be rendered in
  116416. */
  116417. show(scene: Scene, color?: Color3): void;
  116418. /**
  116419. * Hides the ray we are debugging.
  116420. */
  116421. hide(): void;
  116422. private _render;
  116423. /**
  116424. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  116425. * @param mesh Defines the mesh we want the helper attached to
  116426. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  116427. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  116428. * @param length Defines the length of the ray
  116429. */
  116430. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  116431. /**
  116432. * Detach the ray helper from the mesh it has previously been attached to.
  116433. */
  116434. detachFromMesh(): void;
  116435. private _updateToMesh;
  116436. /**
  116437. * Dispose the helper and release its associated resources.
  116438. */
  116439. dispose(): void;
  116440. }
  116441. }
  116442. declare module BABYLON.Debug {
  116443. /**
  116444. * Class used to render a debug view of a given skeleton
  116445. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  116446. */
  116447. export class SkeletonViewer {
  116448. /** defines the skeleton to render */
  116449. skeleton: Skeleton;
  116450. /** defines the mesh attached to the skeleton */
  116451. mesh: AbstractMesh;
  116452. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116453. autoUpdateBonesMatrices: boolean;
  116454. /** defines the rendering group id to use with the viewer */
  116455. renderingGroupId: number;
  116456. /** Gets or sets the color used to render the skeleton */
  116457. color: Color3;
  116458. private _scene;
  116459. private _debugLines;
  116460. private _debugMesh;
  116461. private _isEnabled;
  116462. private _renderFunction;
  116463. private _utilityLayer;
  116464. /**
  116465. * Returns the mesh used to render the bones
  116466. */
  116467. get debugMesh(): Nullable<LinesMesh>;
  116468. /**
  116469. * Creates a new SkeletonViewer
  116470. * @param skeleton defines the skeleton to render
  116471. * @param mesh defines the mesh attached to the skeleton
  116472. * @param scene defines the hosting scene
  116473. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  116474. * @param renderingGroupId defines the rendering group id to use with the viewer
  116475. */
  116476. constructor(
  116477. /** defines the skeleton to render */
  116478. skeleton: Skeleton,
  116479. /** defines the mesh attached to the skeleton */
  116480. mesh: AbstractMesh, scene: Scene,
  116481. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116482. autoUpdateBonesMatrices?: boolean,
  116483. /** defines the rendering group id to use with the viewer */
  116484. renderingGroupId?: number);
  116485. /** Gets or sets a boolean indicating if the viewer is enabled */
  116486. set isEnabled(value: boolean);
  116487. get isEnabled(): boolean;
  116488. private _getBonePosition;
  116489. private _getLinesForBonesWithLength;
  116490. private _getLinesForBonesNoLength;
  116491. /** Update the viewer to sync with current skeleton state */
  116492. update(): void;
  116493. /** Release associated resources */
  116494. dispose(): void;
  116495. }
  116496. }
  116497. declare module BABYLON {
  116498. /**
  116499. * Options to create the null engine
  116500. */
  116501. export class NullEngineOptions {
  116502. /**
  116503. * Render width (Default: 512)
  116504. */
  116505. renderWidth: number;
  116506. /**
  116507. * Render height (Default: 256)
  116508. */
  116509. renderHeight: number;
  116510. /**
  116511. * Texture size (Default: 512)
  116512. */
  116513. textureSize: number;
  116514. /**
  116515. * If delta time between frames should be constant
  116516. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116517. */
  116518. deterministicLockstep: boolean;
  116519. /**
  116520. * Maximum about of steps between frames (Default: 4)
  116521. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116522. */
  116523. lockstepMaxSteps: number;
  116524. }
  116525. /**
  116526. * The null engine class provides support for headless version of babylon.js.
  116527. * This can be used in server side scenario or for testing purposes
  116528. */
  116529. export class NullEngine extends Engine {
  116530. private _options;
  116531. /**
  116532. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116533. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116534. * @returns true if engine is in deterministic lock step mode
  116535. */
  116536. isDeterministicLockStep(): boolean;
  116537. /**
  116538. * Gets the max steps when engine is running in deterministic lock step
  116539. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116540. * @returns the max steps
  116541. */
  116542. getLockstepMaxSteps(): number;
  116543. /**
  116544. * Gets the current hardware scaling level.
  116545. * By default the hardware scaling level is computed from the window device ratio.
  116546. * 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.
  116547. * @returns a number indicating the current hardware scaling level
  116548. */
  116549. getHardwareScalingLevel(): number;
  116550. constructor(options?: NullEngineOptions);
  116551. /**
  116552. * Creates a vertex buffer
  116553. * @param vertices the data for the vertex buffer
  116554. * @returns the new WebGL static buffer
  116555. */
  116556. createVertexBuffer(vertices: FloatArray): DataBuffer;
  116557. /**
  116558. * Creates a new index buffer
  116559. * @param indices defines the content of the index buffer
  116560. * @param updatable defines if the index buffer must be updatable
  116561. * @returns a new webGL buffer
  116562. */
  116563. createIndexBuffer(indices: IndicesArray): DataBuffer;
  116564. /**
  116565. * Clear the current render buffer or the current render target (if any is set up)
  116566. * @param color defines the color to use
  116567. * @param backBuffer defines if the back buffer must be cleared
  116568. * @param depth defines if the depth buffer must be cleared
  116569. * @param stencil defines if the stencil buffer must be cleared
  116570. */
  116571. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116572. /**
  116573. * Gets the current render width
  116574. * @param useScreen defines if screen size must be used (or the current render target if any)
  116575. * @returns a number defining the current render width
  116576. */
  116577. getRenderWidth(useScreen?: boolean): number;
  116578. /**
  116579. * Gets the current render height
  116580. * @param useScreen defines if screen size must be used (or the current render target if any)
  116581. * @returns a number defining the current render height
  116582. */
  116583. getRenderHeight(useScreen?: boolean): number;
  116584. /**
  116585. * Set the WebGL's viewport
  116586. * @param viewport defines the viewport element to be used
  116587. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116588. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116589. */
  116590. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116591. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  116592. /**
  116593. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116594. * @param pipelineContext defines the pipeline context to use
  116595. * @param uniformsNames defines the list of uniform names
  116596. * @returns an array of webGL uniform locations
  116597. */
  116598. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116599. /**
  116600. * Gets the lsit of active attributes for a given webGL program
  116601. * @param pipelineContext defines the pipeline context to use
  116602. * @param attributesNames defines the list of attribute names to get
  116603. * @returns an array of indices indicating the offset of each attribute
  116604. */
  116605. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116606. /**
  116607. * Binds an effect to the webGL context
  116608. * @param effect defines the effect to bind
  116609. */
  116610. bindSamplers(effect: Effect): void;
  116611. /**
  116612. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116613. * @param effect defines the effect to activate
  116614. */
  116615. enableEffect(effect: Effect): void;
  116616. /**
  116617. * Set various states to the webGL context
  116618. * @param culling defines backface culling state
  116619. * @param zOffset defines the value to apply to zOffset (0 by default)
  116620. * @param force defines if states must be applied even if cache is up to date
  116621. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116622. */
  116623. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116624. /**
  116625. * Set the value of an uniform to an array of int32
  116626. * @param uniform defines the webGL uniform location where to store the value
  116627. * @param array defines the array of int32 to store
  116628. */
  116629. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  116630. /**
  116631. * Set the value of an uniform to an array of int32 (stored as vec2)
  116632. * @param uniform defines the webGL uniform location where to store the value
  116633. * @param array defines the array of int32 to store
  116634. */
  116635. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  116636. /**
  116637. * Set the value of an uniform to an array of int32 (stored as vec3)
  116638. * @param uniform defines the webGL uniform location where to store the value
  116639. * @param array defines the array of int32 to store
  116640. */
  116641. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  116642. /**
  116643. * Set the value of an uniform to an array of int32 (stored as vec4)
  116644. * @param uniform defines the webGL uniform location where to store the value
  116645. * @param array defines the array of int32 to store
  116646. */
  116647. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  116648. /**
  116649. * Set the value of an uniform to an array of float32
  116650. * @param uniform defines the webGL uniform location where to store the value
  116651. * @param array defines the array of float32 to store
  116652. */
  116653. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  116654. /**
  116655. * Set the value of an uniform to an array of float32 (stored as vec2)
  116656. * @param uniform defines the webGL uniform location where to store the value
  116657. * @param array defines the array of float32 to store
  116658. */
  116659. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  116660. /**
  116661. * Set the value of an uniform to an array of float32 (stored as vec3)
  116662. * @param uniform defines the webGL uniform location where to store the value
  116663. * @param array defines the array of float32 to store
  116664. */
  116665. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  116666. /**
  116667. * Set the value of an uniform to an array of float32 (stored as vec4)
  116668. * @param uniform defines the webGL uniform location where to store the value
  116669. * @param array defines the array of float32 to store
  116670. */
  116671. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  116672. /**
  116673. * Set the value of an uniform to an array of number
  116674. * @param uniform defines the webGL uniform location where to store the value
  116675. * @param array defines the array of number to store
  116676. */
  116677. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  116678. /**
  116679. * Set the value of an uniform to an array of number (stored as vec2)
  116680. * @param uniform defines the webGL uniform location where to store the value
  116681. * @param array defines the array of number to store
  116682. */
  116683. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  116684. /**
  116685. * Set the value of an uniform to an array of number (stored as vec3)
  116686. * @param uniform defines the webGL uniform location where to store the value
  116687. * @param array defines the array of number to store
  116688. */
  116689. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  116690. /**
  116691. * Set the value of an uniform to an array of number (stored as vec4)
  116692. * @param uniform defines the webGL uniform location where to store the value
  116693. * @param array defines the array of number to store
  116694. */
  116695. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  116696. /**
  116697. * Set the value of an uniform to an array of float32 (stored as matrices)
  116698. * @param uniform defines the webGL uniform location where to store the value
  116699. * @param matrices defines the array of float32 to store
  116700. */
  116701. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  116702. /**
  116703. * Set the value of an uniform to a matrix (3x3)
  116704. * @param uniform defines the webGL uniform location where to store the value
  116705. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116706. */
  116707. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116708. /**
  116709. * Set the value of an uniform to a matrix (2x2)
  116710. * @param uniform defines the webGL uniform location where to store the value
  116711. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116712. */
  116713. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116714. /**
  116715. * Set the value of an uniform to a number (float)
  116716. * @param uniform defines the webGL uniform location where to store the value
  116717. * @param value defines the float number to store
  116718. */
  116719. setFloat(uniform: WebGLUniformLocation, value: number): void;
  116720. /**
  116721. * Set the value of an uniform to a vec2
  116722. * @param uniform defines the webGL uniform location where to store the value
  116723. * @param x defines the 1st component of the value
  116724. * @param y defines the 2nd component of the value
  116725. */
  116726. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  116727. /**
  116728. * Set the value of an uniform to a vec3
  116729. * @param uniform defines the webGL uniform location where to store the value
  116730. * @param x defines the 1st component of the value
  116731. * @param y defines the 2nd component of the value
  116732. * @param z defines the 3rd component of the value
  116733. */
  116734. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  116735. /**
  116736. * Set the value of an uniform to a boolean
  116737. * @param uniform defines the webGL uniform location where to store the value
  116738. * @param bool defines the boolean to store
  116739. */
  116740. setBool(uniform: WebGLUniformLocation, bool: number): void;
  116741. /**
  116742. * Set the value of an uniform to a vec4
  116743. * @param uniform defines the webGL uniform location where to store the value
  116744. * @param x defines the 1st component of the value
  116745. * @param y defines the 2nd component of the value
  116746. * @param z defines the 3rd component of the value
  116747. * @param w defines the 4th component of the value
  116748. */
  116749. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  116750. /**
  116751. * Sets the current alpha mode
  116752. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  116753. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  116754. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116755. */
  116756. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  116757. /**
  116758. * Bind webGl buffers directly to the webGL context
  116759. * @param vertexBuffers defines the vertex buffer to bind
  116760. * @param indexBuffer defines the index buffer to bind
  116761. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116762. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116763. * @param effect defines the effect associated with the vertex buffer
  116764. */
  116765. bindBuffers(vertexBuffers: {
  116766. [key: string]: VertexBuffer;
  116767. }, indexBuffer: DataBuffer, effect: Effect): void;
  116768. /**
  116769. * Force the entire cache to be cleared
  116770. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116771. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116772. */
  116773. wipeCaches(bruteForce?: boolean): void;
  116774. /**
  116775. * Send a draw order
  116776. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116777. * @param indexStart defines the starting index
  116778. * @param indexCount defines the number of index to draw
  116779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116780. */
  116781. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116782. /**
  116783. * Draw a list of indexed primitives
  116784. * @param fillMode defines the primitive to use
  116785. * @param indexStart defines the starting index
  116786. * @param indexCount defines the number of index to draw
  116787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116788. */
  116789. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116790. /**
  116791. * Draw a list of unindexed primitives
  116792. * @param fillMode defines the primitive to use
  116793. * @param verticesStart defines the index of first vertex to draw
  116794. * @param verticesCount defines the count of vertices to draw
  116795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116796. */
  116797. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116798. /** @hidden */
  116799. _createTexture(): WebGLTexture;
  116800. /** @hidden */
  116801. _releaseTexture(texture: InternalTexture): void;
  116802. /**
  116803. * Usually called from Texture.ts.
  116804. * Passed information to create a WebGLTexture
  116805. * @param urlArg defines a value which contains one of the following:
  116806. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116807. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116808. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116809. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116810. * @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)
  116811. * @param scene needed for loading to the correct scene
  116812. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116813. * @param onLoad optional callback to be called upon successful completion
  116814. * @param onError optional callback to be called upon failure
  116815. * @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
  116816. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116817. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116818. * @param forcedExtension defines the extension to use to pick the right loader
  116819. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  116820. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116821. */
  116822. 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;
  116823. /**
  116824. * Creates a new render target texture
  116825. * @param size defines the size of the texture
  116826. * @param options defines the options used to create the texture
  116827. * @returns a new render target texture stored in an InternalTexture
  116828. */
  116829. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  116830. /**
  116831. * Update the sampling mode of a given texture
  116832. * @param samplingMode defines the required sampling mode
  116833. * @param texture defines the texture to update
  116834. */
  116835. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  116836. /**
  116837. * Binds the frame buffer to the specified texture.
  116838. * @param texture The texture to render to or null for the default canvas
  116839. * @param faceIndex The face of the texture to render to in case of cube texture
  116840. * @param requiredWidth The width of the target to render to
  116841. * @param requiredHeight The height of the target to render to
  116842. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116843. * @param depthStencilTexture The depth stencil texture to use to render
  116844. * @param lodLevel defines le lod level to bind to the frame buffer
  116845. */
  116846. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  116847. /**
  116848. * Unbind the current render target texture from the webGL context
  116849. * @param texture defines the render target texture to unbind
  116850. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116851. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116852. */
  116853. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116854. /**
  116855. * Creates a dynamic vertex buffer
  116856. * @param vertices the data for the dynamic vertex buffer
  116857. * @returns the new WebGL dynamic buffer
  116858. */
  116859. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  116860. /**
  116861. * Update the content of a dynamic texture
  116862. * @param texture defines the texture to update
  116863. * @param canvas defines the canvas containing the source
  116864. * @param invertY defines if data must be stored with Y axis inverted
  116865. * @param premulAlpha defines if alpha is stored as premultiplied
  116866. * @param format defines the format of the data
  116867. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  116868. */
  116869. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  116870. /**
  116871. * Gets a boolean indicating if all created effects are ready
  116872. * @returns true if all effects are ready
  116873. */
  116874. areAllEffectsReady(): boolean;
  116875. /**
  116876. * @hidden
  116877. * Get the current error code of the webGL context
  116878. * @returns the error code
  116879. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116880. */
  116881. getError(): number;
  116882. /** @hidden */
  116883. _getUnpackAlignement(): number;
  116884. /** @hidden */
  116885. _unpackFlipY(value: boolean): void;
  116886. /**
  116887. * Update a dynamic index buffer
  116888. * @param indexBuffer defines the target index buffer
  116889. * @param indices defines the data to update
  116890. * @param offset defines the offset in the target index buffer where update should start
  116891. */
  116892. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  116893. /**
  116894. * Updates a dynamic vertex buffer.
  116895. * @param vertexBuffer the vertex buffer to update
  116896. * @param vertices the data used to update the vertex buffer
  116897. * @param byteOffset the byte offset of the data (optional)
  116898. * @param byteLength the byte length of the data (optional)
  116899. */
  116900. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  116901. /** @hidden */
  116902. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  116903. /** @hidden */
  116904. _bindTexture(channel: number, texture: InternalTexture): void;
  116905. protected _deleteBuffer(buffer: WebGLBuffer): void;
  116906. /**
  116907. * 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
  116908. */
  116909. releaseEffects(): void;
  116910. displayLoadingUI(): void;
  116911. hideLoadingUI(): void;
  116912. /** @hidden */
  116913. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116914. /** @hidden */
  116915. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116916. /** @hidden */
  116917. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116918. /** @hidden */
  116919. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  116920. }
  116921. }
  116922. declare module BABYLON {
  116923. /** @hidden */
  116924. export class _OcclusionDataStorage {
  116925. /** @hidden */
  116926. occlusionInternalRetryCounter: number;
  116927. /** @hidden */
  116928. isOcclusionQueryInProgress: boolean;
  116929. /** @hidden */
  116930. isOccluded: boolean;
  116931. /** @hidden */
  116932. occlusionRetryCount: number;
  116933. /** @hidden */
  116934. occlusionType: number;
  116935. /** @hidden */
  116936. occlusionQueryAlgorithmType: number;
  116937. }
  116938. interface Engine {
  116939. /**
  116940. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  116941. * @return the new query
  116942. */
  116943. createQuery(): WebGLQuery;
  116944. /**
  116945. * Delete and release a webGL query
  116946. * @param query defines the query to delete
  116947. * @return the current engine
  116948. */
  116949. deleteQuery(query: WebGLQuery): Engine;
  116950. /**
  116951. * Check if a given query has resolved and got its value
  116952. * @param query defines the query to check
  116953. * @returns true if the query got its value
  116954. */
  116955. isQueryResultAvailable(query: WebGLQuery): boolean;
  116956. /**
  116957. * Gets the value of a given query
  116958. * @param query defines the query to check
  116959. * @returns the value of the query
  116960. */
  116961. getQueryResult(query: WebGLQuery): number;
  116962. /**
  116963. * Initiates an occlusion query
  116964. * @param algorithmType defines the algorithm to use
  116965. * @param query defines the query to use
  116966. * @returns the current engine
  116967. * @see http://doc.babylonjs.com/features/occlusionquery
  116968. */
  116969. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  116970. /**
  116971. * Ends an occlusion query
  116972. * @see http://doc.babylonjs.com/features/occlusionquery
  116973. * @param algorithmType defines the algorithm to use
  116974. * @returns the current engine
  116975. */
  116976. endOcclusionQuery(algorithmType: number): Engine;
  116977. /**
  116978. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  116979. * Please note that only one query can be issued at a time
  116980. * @returns a time token used to track the time span
  116981. */
  116982. startTimeQuery(): Nullable<_TimeToken>;
  116983. /**
  116984. * Ends a time query
  116985. * @param token defines the token used to measure the time span
  116986. * @returns the time spent (in ns)
  116987. */
  116988. endTimeQuery(token: _TimeToken): int;
  116989. /** @hidden */
  116990. _currentNonTimestampToken: Nullable<_TimeToken>;
  116991. /** @hidden */
  116992. _createTimeQuery(): WebGLQuery;
  116993. /** @hidden */
  116994. _deleteTimeQuery(query: WebGLQuery): void;
  116995. /** @hidden */
  116996. _getGlAlgorithmType(algorithmType: number): number;
  116997. /** @hidden */
  116998. _getTimeQueryResult(query: WebGLQuery): any;
  116999. /** @hidden */
  117000. _getTimeQueryAvailability(query: WebGLQuery): any;
  117001. }
  117002. interface AbstractMesh {
  117003. /**
  117004. * Backing filed
  117005. * @hidden
  117006. */
  117007. __occlusionDataStorage: _OcclusionDataStorage;
  117008. /**
  117009. * Access property
  117010. * @hidden
  117011. */
  117012. _occlusionDataStorage: _OcclusionDataStorage;
  117013. /**
  117014. * 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.
  117015. * The default value is -1 which means don't break the query and wait till the result
  117016. * @see http://doc.babylonjs.com/features/occlusionquery
  117017. */
  117018. occlusionRetryCount: number;
  117019. /**
  117020. * 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:
  117021. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  117022. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  117023. * * 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.
  117024. * @see http://doc.babylonjs.com/features/occlusionquery
  117025. */
  117026. occlusionType: number;
  117027. /**
  117028. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  117029. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  117030. * * 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.
  117031. * @see http://doc.babylonjs.com/features/occlusionquery
  117032. */
  117033. occlusionQueryAlgorithmType: number;
  117034. /**
  117035. * 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
  117036. * @see http://doc.babylonjs.com/features/occlusionquery
  117037. */
  117038. isOccluded: boolean;
  117039. /**
  117040. * Flag to check the progress status of the query
  117041. * @see http://doc.babylonjs.com/features/occlusionquery
  117042. */
  117043. isOcclusionQueryInProgress: boolean;
  117044. }
  117045. }
  117046. declare module BABYLON {
  117047. /** @hidden */
  117048. export var _forceTransformFeedbackToBundle: boolean;
  117049. interface Engine {
  117050. /**
  117051. * Creates a webGL transform feedback object
  117052. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  117053. * @returns the webGL transform feedback object
  117054. */
  117055. createTransformFeedback(): WebGLTransformFeedback;
  117056. /**
  117057. * Delete a webGL transform feedback object
  117058. * @param value defines the webGL transform feedback object to delete
  117059. */
  117060. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  117061. /**
  117062. * Bind a webGL transform feedback object to the webgl context
  117063. * @param value defines the webGL transform feedback object to bind
  117064. */
  117065. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  117066. /**
  117067. * Begins a transform feedback operation
  117068. * @param usePoints defines if points or triangles must be used
  117069. */
  117070. beginTransformFeedback(usePoints: boolean): void;
  117071. /**
  117072. * Ends a transform feedback operation
  117073. */
  117074. endTransformFeedback(): void;
  117075. /**
  117076. * Specify the varyings to use with transform feedback
  117077. * @param program defines the associated webGL program
  117078. * @param value defines the list of strings representing the varying names
  117079. */
  117080. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  117081. /**
  117082. * Bind a webGL buffer for a transform feedback operation
  117083. * @param value defines the webGL buffer to bind
  117084. */
  117085. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  117086. }
  117087. }
  117088. declare module BABYLON {
  117089. /**
  117090. * Creation options of the multi render target texture.
  117091. */
  117092. export interface IMultiRenderTargetOptions {
  117093. /**
  117094. * Define if the texture needs to create mip maps after render.
  117095. */
  117096. generateMipMaps?: boolean;
  117097. /**
  117098. * Define the types of all the draw buffers we want to create
  117099. */
  117100. types?: number[];
  117101. /**
  117102. * Define the sampling modes of all the draw buffers we want to create
  117103. */
  117104. samplingModes?: number[];
  117105. /**
  117106. * Define if a depth buffer is required
  117107. */
  117108. generateDepthBuffer?: boolean;
  117109. /**
  117110. * Define if a stencil buffer is required
  117111. */
  117112. generateStencilBuffer?: boolean;
  117113. /**
  117114. * Define if a depth texture is required instead of a depth buffer
  117115. */
  117116. generateDepthTexture?: boolean;
  117117. /**
  117118. * Define the number of desired draw buffers
  117119. */
  117120. textureCount?: number;
  117121. /**
  117122. * Define if aspect ratio should be adapted to the texture or stay the scene one
  117123. */
  117124. doNotChangeAspectRatio?: boolean;
  117125. /**
  117126. * Define the default type of the buffers we are creating
  117127. */
  117128. defaultType?: number;
  117129. }
  117130. /**
  117131. * A multi render target, like a render target provides the ability to render to a texture.
  117132. * Unlike the render target, it can render to several draw buffers in one draw.
  117133. * This is specially interesting in deferred rendering or for any effects requiring more than
  117134. * just one color from a single pass.
  117135. */
  117136. export class MultiRenderTarget extends RenderTargetTexture {
  117137. private _internalTextures;
  117138. private _textures;
  117139. private _multiRenderTargetOptions;
  117140. /**
  117141. * Get if draw buffers are currently supported by the used hardware and browser.
  117142. */
  117143. get isSupported(): boolean;
  117144. /**
  117145. * Get the list of textures generated by the multi render target.
  117146. */
  117147. get textures(): Texture[];
  117148. /**
  117149. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  117150. */
  117151. get depthTexture(): Texture;
  117152. /**
  117153. * Set the wrapping mode on U of all the textures we are rendering to.
  117154. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  117155. */
  117156. set wrapU(wrap: number);
  117157. /**
  117158. * Set the wrapping mode on V of all the textures we are rendering to.
  117159. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  117160. */
  117161. set wrapV(wrap: number);
  117162. /**
  117163. * Instantiate a new multi render target texture.
  117164. * A multi render target, like a render target provides the ability to render to a texture.
  117165. * Unlike the render target, it can render to several draw buffers in one draw.
  117166. * This is specially interesting in deferred rendering or for any effects requiring more than
  117167. * just one color from a single pass.
  117168. * @param name Define the name of the texture
  117169. * @param size Define the size of the buffers to render to
  117170. * @param count Define the number of target we are rendering into
  117171. * @param scene Define the scene the texture belongs to
  117172. * @param options Define the options used to create the multi render target
  117173. */
  117174. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  117175. /** @hidden */
  117176. _rebuild(): void;
  117177. private _createInternalTextures;
  117178. private _createTextures;
  117179. /**
  117180. * Define the number of samples used if MSAA is enabled.
  117181. */
  117182. get samples(): number;
  117183. set samples(value: number);
  117184. /**
  117185. * Resize all the textures in the multi render target.
  117186. * Be carrefull as it will recreate all the data in the new texture.
  117187. * @param size Define the new size
  117188. */
  117189. resize(size: any): void;
  117190. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  117191. /**
  117192. * Dispose the render targets and their associated resources
  117193. */
  117194. dispose(): void;
  117195. /**
  117196. * Release all the underlying texture used as draw buffers.
  117197. */
  117198. releaseInternalTextures(): void;
  117199. }
  117200. }
  117201. declare module BABYLON {
  117202. interface ThinEngine {
  117203. /**
  117204. * Unbind a list of render target textures from the webGL context
  117205. * This is used only when drawBuffer extension or webGL2 are active
  117206. * @param textures defines the render target textures to unbind
  117207. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  117208. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  117209. */
  117210. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  117211. /**
  117212. * Create a multi render target texture
  117213. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  117214. * @param size defines the size of the texture
  117215. * @param options defines the creation options
  117216. * @returns the cube texture as an InternalTexture
  117217. */
  117218. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  117219. /**
  117220. * Update the sample count for a given multiple render target texture
  117221. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117222. * @param textures defines the textures to update
  117223. * @param samples defines the sample count to set
  117224. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117225. */
  117226. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  117227. }
  117228. }
  117229. declare module BABYLON {
  117230. /**
  117231. * Class used to define an additional view for the engine
  117232. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117233. */
  117234. export class EngineView {
  117235. /** Defines the canvas where to render the view */
  117236. target: HTMLCanvasElement;
  117237. /** Defines an optional camera used to render the view (will use active camera else) */
  117238. camera?: Camera;
  117239. }
  117240. interface Engine {
  117241. /**
  117242. * Gets or sets the HTML element to use for attaching events
  117243. */
  117244. inputElement: Nullable<HTMLElement>;
  117245. /**
  117246. * Gets the current engine view
  117247. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117248. */
  117249. activeView: Nullable<EngineView>;
  117250. /** Gets or sets the list of views */
  117251. views: EngineView[];
  117252. /**
  117253. * Register a new child canvas
  117254. * @param canvas defines the canvas to register
  117255. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  117256. * @returns the associated view
  117257. */
  117258. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  117259. /**
  117260. * Remove a registered child canvas
  117261. * @param canvas defines the canvas to remove
  117262. * @returns the current engine
  117263. */
  117264. unRegisterView(canvas: HTMLCanvasElement): Engine;
  117265. }
  117266. }
  117267. declare module BABYLON {
  117268. /**
  117269. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  117270. */
  117271. export interface CubeMapInfo {
  117272. /**
  117273. * The pixel array for the front face.
  117274. * This is stored in format, left to right, up to down format.
  117275. */
  117276. front: Nullable<ArrayBufferView>;
  117277. /**
  117278. * The pixel array for the back face.
  117279. * This is stored in format, left to right, up to down format.
  117280. */
  117281. back: Nullable<ArrayBufferView>;
  117282. /**
  117283. * The pixel array for the left face.
  117284. * This is stored in format, left to right, up to down format.
  117285. */
  117286. left: Nullable<ArrayBufferView>;
  117287. /**
  117288. * The pixel array for the right face.
  117289. * This is stored in format, left to right, up to down format.
  117290. */
  117291. right: Nullable<ArrayBufferView>;
  117292. /**
  117293. * The pixel array for the up face.
  117294. * This is stored in format, left to right, up to down format.
  117295. */
  117296. up: Nullable<ArrayBufferView>;
  117297. /**
  117298. * The pixel array for the down face.
  117299. * This is stored in format, left to right, up to down format.
  117300. */
  117301. down: Nullable<ArrayBufferView>;
  117302. /**
  117303. * The size of the cubemap stored.
  117304. *
  117305. * Each faces will be size * size pixels.
  117306. */
  117307. size: number;
  117308. /**
  117309. * The format of the texture.
  117310. *
  117311. * RGBA, RGB.
  117312. */
  117313. format: number;
  117314. /**
  117315. * The type of the texture data.
  117316. *
  117317. * UNSIGNED_INT, FLOAT.
  117318. */
  117319. type: number;
  117320. /**
  117321. * Specifies whether the texture is in gamma space.
  117322. */
  117323. gammaSpace: boolean;
  117324. }
  117325. /**
  117326. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  117327. */
  117328. export class PanoramaToCubeMapTools {
  117329. private static FACE_FRONT;
  117330. private static FACE_BACK;
  117331. private static FACE_RIGHT;
  117332. private static FACE_LEFT;
  117333. private static FACE_DOWN;
  117334. private static FACE_UP;
  117335. /**
  117336. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  117337. *
  117338. * @param float32Array The source data.
  117339. * @param inputWidth The width of the input panorama.
  117340. * @param inputHeight The height of the input panorama.
  117341. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  117342. * @return The cubemap data
  117343. */
  117344. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  117345. private static CreateCubemapTexture;
  117346. private static CalcProjectionSpherical;
  117347. }
  117348. }
  117349. declare module BABYLON {
  117350. /**
  117351. * Helper class dealing with the extraction of spherical polynomial dataArray
  117352. * from a cube map.
  117353. */
  117354. export class CubeMapToSphericalPolynomialTools {
  117355. private static FileFaces;
  117356. /**
  117357. * Converts a texture to the according Spherical Polynomial data.
  117358. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117359. *
  117360. * @param texture The texture to extract the information from.
  117361. * @return The Spherical Polynomial data.
  117362. */
  117363. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  117364. /**
  117365. * Converts a cubemap to the according Spherical Polynomial data.
  117366. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117367. *
  117368. * @param cubeInfo The Cube map to extract the information from.
  117369. * @return The Spherical Polynomial data.
  117370. */
  117371. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  117372. }
  117373. }
  117374. declare module BABYLON {
  117375. interface BaseTexture {
  117376. /**
  117377. * Get the polynomial representation of the texture data.
  117378. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  117379. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  117380. */
  117381. sphericalPolynomial: Nullable<SphericalPolynomial>;
  117382. }
  117383. }
  117384. declare module BABYLON {
  117385. /** @hidden */
  117386. export var rgbdEncodePixelShader: {
  117387. name: string;
  117388. shader: string;
  117389. };
  117390. }
  117391. declare module BABYLON {
  117392. /** @hidden */
  117393. export var rgbdDecodePixelShader: {
  117394. name: string;
  117395. shader: string;
  117396. };
  117397. }
  117398. declare module BABYLON {
  117399. /**
  117400. * Raw texture data and descriptor sufficient for WebGL texture upload
  117401. */
  117402. export interface EnvironmentTextureInfo {
  117403. /**
  117404. * Version of the environment map
  117405. */
  117406. version: number;
  117407. /**
  117408. * Width of image
  117409. */
  117410. width: number;
  117411. /**
  117412. * Irradiance information stored in the file.
  117413. */
  117414. irradiance: any;
  117415. /**
  117416. * Specular information stored in the file.
  117417. */
  117418. specular: any;
  117419. }
  117420. /**
  117421. * Defines One Image in the file. It requires only the position in the file
  117422. * as well as the length.
  117423. */
  117424. interface BufferImageData {
  117425. /**
  117426. * Length of the image data.
  117427. */
  117428. length: number;
  117429. /**
  117430. * Position of the data from the null terminator delimiting the end of the JSON.
  117431. */
  117432. position: number;
  117433. }
  117434. /**
  117435. * Defines the specular data enclosed in the file.
  117436. * This corresponds to the version 1 of the data.
  117437. */
  117438. export interface EnvironmentTextureSpecularInfoV1 {
  117439. /**
  117440. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  117441. */
  117442. specularDataPosition?: number;
  117443. /**
  117444. * This contains all the images data needed to reconstruct the cubemap.
  117445. */
  117446. mipmaps: Array<BufferImageData>;
  117447. /**
  117448. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  117449. */
  117450. lodGenerationScale: number;
  117451. }
  117452. /**
  117453. * Sets of helpers addressing the serialization and deserialization of environment texture
  117454. * stored in a BabylonJS env file.
  117455. * Those files are usually stored as .env files.
  117456. */
  117457. export class EnvironmentTextureTools {
  117458. /**
  117459. * Magic number identifying the env file.
  117460. */
  117461. private static _MagicBytes;
  117462. /**
  117463. * Gets the environment info from an env file.
  117464. * @param data The array buffer containing the .env bytes.
  117465. * @returns the environment file info (the json header) if successfully parsed.
  117466. */
  117467. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  117468. /**
  117469. * Creates an environment texture from a loaded cube texture.
  117470. * @param texture defines the cube texture to convert in env file
  117471. * @return a promise containing the environment data if succesfull.
  117472. */
  117473. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  117474. /**
  117475. * Creates a JSON representation of the spherical data.
  117476. * @param texture defines the texture containing the polynomials
  117477. * @return the JSON representation of the spherical info
  117478. */
  117479. private static _CreateEnvTextureIrradiance;
  117480. /**
  117481. * Creates the ArrayBufferViews used for initializing environment texture image data.
  117482. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  117483. * @param info parameters that determine what views will be created for accessing the underlying buffer
  117484. * @return the views described by info providing access to the underlying buffer
  117485. */
  117486. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  117487. /**
  117488. * Uploads the texture info contained in the env file to the GPU.
  117489. * @param texture defines the internal texture to upload to
  117490. * @param arrayBuffer defines the buffer cotaining the data to load
  117491. * @param info defines the texture info retrieved through the GetEnvInfo method
  117492. * @returns a promise
  117493. */
  117494. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  117495. private static _OnImageReadyAsync;
  117496. /**
  117497. * Uploads the levels of image data to the GPU.
  117498. * @param texture defines the internal texture to upload to
  117499. * @param imageData defines the array buffer views of image data [mipmap][face]
  117500. * @returns a promise
  117501. */
  117502. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  117503. /**
  117504. * Uploads spherical polynomials information to the texture.
  117505. * @param texture defines the texture we are trying to upload the information to
  117506. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  117507. */
  117508. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  117509. /** @hidden */
  117510. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117511. }
  117512. }
  117513. declare module BABYLON {
  117514. /**
  117515. * Contains position and normal vectors for a vertex
  117516. */
  117517. export class PositionNormalVertex {
  117518. /** the position of the vertex (defaut: 0,0,0) */
  117519. position: Vector3;
  117520. /** the normal of the vertex (defaut: 0,1,0) */
  117521. normal: Vector3;
  117522. /**
  117523. * Creates a PositionNormalVertex
  117524. * @param position the position of the vertex (defaut: 0,0,0)
  117525. * @param normal the normal of the vertex (defaut: 0,1,0)
  117526. */
  117527. constructor(
  117528. /** the position of the vertex (defaut: 0,0,0) */
  117529. position?: Vector3,
  117530. /** the normal of the vertex (defaut: 0,1,0) */
  117531. normal?: Vector3);
  117532. /**
  117533. * Clones the PositionNormalVertex
  117534. * @returns the cloned PositionNormalVertex
  117535. */
  117536. clone(): PositionNormalVertex;
  117537. }
  117538. /**
  117539. * Contains position, normal and uv vectors for a vertex
  117540. */
  117541. export class PositionNormalTextureVertex {
  117542. /** the position of the vertex (defaut: 0,0,0) */
  117543. position: Vector3;
  117544. /** the normal of the vertex (defaut: 0,1,0) */
  117545. normal: Vector3;
  117546. /** the uv of the vertex (default: 0,0) */
  117547. uv: Vector2;
  117548. /**
  117549. * Creates a PositionNormalTextureVertex
  117550. * @param position the position of the vertex (defaut: 0,0,0)
  117551. * @param normal the normal of the vertex (defaut: 0,1,0)
  117552. * @param uv the uv of the vertex (default: 0,0)
  117553. */
  117554. constructor(
  117555. /** the position of the vertex (defaut: 0,0,0) */
  117556. position?: Vector3,
  117557. /** the normal of the vertex (defaut: 0,1,0) */
  117558. normal?: Vector3,
  117559. /** the uv of the vertex (default: 0,0) */
  117560. uv?: Vector2);
  117561. /**
  117562. * Clones the PositionNormalTextureVertex
  117563. * @returns the cloned PositionNormalTextureVertex
  117564. */
  117565. clone(): PositionNormalTextureVertex;
  117566. }
  117567. }
  117568. declare module BABYLON {
  117569. /** @hidden */
  117570. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  117571. private _genericAttributeLocation;
  117572. private _varyingLocationCount;
  117573. private _varyingLocationMap;
  117574. private _replacements;
  117575. private _textureCount;
  117576. private _uniforms;
  117577. lineProcessor(line: string): string;
  117578. attributeProcessor(attribute: string): string;
  117579. varyingProcessor(varying: string, isFragment: boolean): string;
  117580. uniformProcessor(uniform: string): string;
  117581. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  117582. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  117583. }
  117584. }
  117585. declare module BABYLON {
  117586. /**
  117587. * Container for accessors for natively-stored mesh data buffers.
  117588. */
  117589. class NativeDataBuffer extends DataBuffer {
  117590. /**
  117591. * Accessor value used to identify/retrieve a natively-stored index buffer.
  117592. */
  117593. nativeIndexBuffer?: any;
  117594. /**
  117595. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  117596. */
  117597. nativeVertexBuffer?: any;
  117598. }
  117599. /** @hidden */
  117600. class NativeTexture extends InternalTexture {
  117601. getInternalTexture(): InternalTexture;
  117602. getViewCount(): number;
  117603. }
  117604. /** @hidden */
  117605. export class NativeEngine extends Engine {
  117606. private readonly _native;
  117607. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  117608. private readonly INVALID_HANDLE;
  117609. getHardwareScalingLevel(): number;
  117610. constructor();
  117611. /**
  117612. * Can be used to override the current requestAnimationFrame requester.
  117613. * @hidden
  117614. */
  117615. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  117616. /**
  117617. * Override default engine behavior.
  117618. * @param color
  117619. * @param backBuffer
  117620. * @param depth
  117621. * @param stencil
  117622. */
  117623. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  117624. /**
  117625. * Gets host document
  117626. * @returns the host document object
  117627. */
  117628. getHostDocument(): Nullable<Document>;
  117629. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  117630. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  117631. createVertexBuffer(data: DataArray): NativeDataBuffer;
  117632. recordVertexArrayObject(vertexBuffers: {
  117633. [key: string]: VertexBuffer;
  117634. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  117635. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117636. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117637. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  117638. /**
  117639. * Draw a list of indexed primitives
  117640. * @param fillMode defines the primitive to use
  117641. * @param indexStart defines the starting index
  117642. * @param indexCount defines the number of index to draw
  117643. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117644. */
  117645. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  117646. /**
  117647. * Draw a list of unindexed primitives
  117648. * @param fillMode defines the primitive to use
  117649. * @param verticesStart defines the index of first vertex to draw
  117650. * @param verticesCount defines the count of vertices to draw
  117651. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117652. */
  117653. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  117654. createPipelineContext(): IPipelineContext;
  117655. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  117656. /** @hidden */
  117657. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  117658. /** @hidden */
  117659. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  117660. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117661. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117662. protected _setProgram(program: WebGLProgram): void;
  117663. _releaseEffect(effect: Effect): void;
  117664. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117665. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  117666. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  117667. bindSamplers(effect: Effect): void;
  117668. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  117669. getRenderWidth(useScreen?: boolean): number;
  117670. getRenderHeight(useScreen?: boolean): number;
  117671. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  117672. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117673. /**
  117674. * Set the z offset to apply to current rendering
  117675. * @param value defines the offset to apply
  117676. */
  117677. setZOffset(value: number): void;
  117678. /**
  117679. * Gets the current value of the zOffset
  117680. * @returns the current zOffset state
  117681. */
  117682. getZOffset(): number;
  117683. /**
  117684. * Enable or disable depth buffering
  117685. * @param enable defines the state to set
  117686. */
  117687. setDepthBuffer(enable: boolean): void;
  117688. /**
  117689. * Gets a boolean indicating if depth writing is enabled
  117690. * @returns the current depth writing state
  117691. */
  117692. getDepthWrite(): boolean;
  117693. /**
  117694. * Enable or disable depth writing
  117695. * @param enable defines the state to set
  117696. */
  117697. setDepthWrite(enable: boolean): void;
  117698. /**
  117699. * Enable or disable color writing
  117700. * @param enable defines the state to set
  117701. */
  117702. setColorWrite(enable: boolean): void;
  117703. /**
  117704. * Gets a boolean indicating if color writing is enabled
  117705. * @returns the current color writing state
  117706. */
  117707. getColorWrite(): boolean;
  117708. /**
  117709. * Sets alpha constants used by some alpha blending modes
  117710. * @param r defines the red component
  117711. * @param g defines the green component
  117712. * @param b defines the blue component
  117713. * @param a defines the alpha component
  117714. */
  117715. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  117716. /**
  117717. * Sets the current alpha mode
  117718. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  117719. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  117720. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117721. */
  117722. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  117723. /**
  117724. * Gets the current alpha mode
  117725. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117726. * @returns the current alpha mode
  117727. */
  117728. getAlphaMode(): number;
  117729. setInt(uniform: WebGLUniformLocation, int: number): void;
  117730. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  117731. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  117732. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  117733. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  117734. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  117735. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  117736. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  117737. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  117738. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  117739. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  117740. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  117741. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  117742. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  117743. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117744. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117745. setFloat(uniform: WebGLUniformLocation, value: number): void;
  117746. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  117747. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  117748. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  117749. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  117750. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  117751. wipeCaches(bruteForce?: boolean): void;
  117752. _createTexture(): WebGLTexture;
  117753. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  117754. /**
  117755. * Usually called from BABYLON.Texture.ts.
  117756. * Passed information to create a WebGLTexture
  117757. * @param urlArg defines a value which contains one of the following:
  117758. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  117759. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  117760. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  117761. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  117762. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  117763. * @param scene needed for loading to the correct scene
  117764. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  117765. * @param onLoad optional callback to be called upon successful completion
  117766. * @param onError optional callback to be called upon failure
  117767. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  117768. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  117769. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  117770. * @param forcedExtension defines the extension to use to pick the right loader
  117771. * @returns a InternalTexture for assignment back into BABYLON.Texture
  117772. */
  117773. 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;
  117774. /**
  117775. * Creates a cube texture
  117776. * @param rootUrl defines the url where the files to load is located
  117777. * @param scene defines the current scene
  117778. * @param files defines the list of files to load (1 per face)
  117779. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  117780. * @param onLoad defines an optional callback raised when the texture is loaded
  117781. * @param onError defines an optional callback raised if there is an issue to load the texture
  117782. * @param format defines the format of the data
  117783. * @param forcedExtension defines the extension to use to pick the right loader
  117784. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  117785. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117786. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117787. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  117788. * @returns the cube texture as an InternalTexture
  117789. */
  117790. 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;
  117791. private _getSamplingFilter;
  117792. private static _GetNativeTextureFormat;
  117793. createRenderTargetTexture(size: number | {
  117794. width: number;
  117795. height: number;
  117796. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  117797. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  117798. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  117799. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  117800. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  117801. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  117802. /**
  117803. * Updates a dynamic vertex buffer.
  117804. * @param vertexBuffer the vertex buffer to update
  117805. * @param data the data used to update the vertex buffer
  117806. * @param byteOffset the byte offset of the data (optional)
  117807. * @param byteLength the byte length of the data (optional)
  117808. */
  117809. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  117810. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  117811. private _updateAnisotropicLevel;
  117812. private _getAddressMode;
  117813. /** @hidden */
  117814. _bindTexture(channel: number, texture: InternalTexture): void;
  117815. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  117816. releaseEffects(): void;
  117817. /** @hidden */
  117818. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117819. /** @hidden */
  117820. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117821. /** @hidden */
  117822. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117823. /** @hidden */
  117824. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  117825. }
  117826. }
  117827. declare module BABYLON {
  117828. /**
  117829. * Gather the list of clipboard event types as constants.
  117830. */
  117831. export class ClipboardEventTypes {
  117832. /**
  117833. * The clipboard event is fired when a copy command is active (pressed).
  117834. */
  117835. static readonly COPY: number;
  117836. /**
  117837. * The clipboard event is fired when a cut command is active (pressed).
  117838. */
  117839. static readonly CUT: number;
  117840. /**
  117841. * The clipboard event is fired when a paste command is active (pressed).
  117842. */
  117843. static readonly PASTE: number;
  117844. }
  117845. /**
  117846. * This class is used to store clipboard related info for the onClipboardObservable event.
  117847. */
  117848. export class ClipboardInfo {
  117849. /**
  117850. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117851. */
  117852. type: number;
  117853. /**
  117854. * Defines the related dom event
  117855. */
  117856. event: ClipboardEvent;
  117857. /**
  117858. *Creates an instance of ClipboardInfo.
  117859. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  117860. * @param event Defines the related dom event
  117861. */
  117862. constructor(
  117863. /**
  117864. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117865. */
  117866. type: number,
  117867. /**
  117868. * Defines the related dom event
  117869. */
  117870. event: ClipboardEvent);
  117871. /**
  117872. * Get the clipboard event's type from the keycode.
  117873. * @param keyCode Defines the keyCode for the current keyboard event.
  117874. * @return {number}
  117875. */
  117876. static GetTypeFromCharacter(keyCode: number): number;
  117877. }
  117878. }
  117879. declare module BABYLON {
  117880. /**
  117881. * Google Daydream controller
  117882. */
  117883. export class DaydreamController extends WebVRController {
  117884. /**
  117885. * Base Url for the controller model.
  117886. */
  117887. static MODEL_BASE_URL: string;
  117888. /**
  117889. * File name for the controller model.
  117890. */
  117891. static MODEL_FILENAME: string;
  117892. /**
  117893. * Gamepad Id prefix used to identify Daydream Controller.
  117894. */
  117895. static readonly GAMEPAD_ID_PREFIX: string;
  117896. /**
  117897. * Creates a new DaydreamController from a gamepad
  117898. * @param vrGamepad the gamepad that the controller should be created from
  117899. */
  117900. constructor(vrGamepad: any);
  117901. /**
  117902. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117903. * @param scene scene in which to add meshes
  117904. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117905. */
  117906. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117907. /**
  117908. * Called once for each button that changed state since the last frame
  117909. * @param buttonIdx Which button index changed
  117910. * @param state New state of the button
  117911. * @param changes Which properties on the state changed since last frame
  117912. */
  117913. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117914. }
  117915. }
  117916. declare module BABYLON {
  117917. /**
  117918. * Gear VR Controller
  117919. */
  117920. export class GearVRController extends WebVRController {
  117921. /**
  117922. * Base Url for the controller model.
  117923. */
  117924. static MODEL_BASE_URL: string;
  117925. /**
  117926. * File name for the controller model.
  117927. */
  117928. static MODEL_FILENAME: string;
  117929. /**
  117930. * Gamepad Id prefix used to identify this controller.
  117931. */
  117932. static readonly GAMEPAD_ID_PREFIX: string;
  117933. private readonly _buttonIndexToObservableNameMap;
  117934. /**
  117935. * Creates a new GearVRController from a gamepad
  117936. * @param vrGamepad the gamepad that the controller should be created from
  117937. */
  117938. constructor(vrGamepad: any);
  117939. /**
  117940. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117941. * @param scene scene in which to add meshes
  117942. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117943. */
  117944. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117945. /**
  117946. * Called once for each button that changed state since the last frame
  117947. * @param buttonIdx Which button index changed
  117948. * @param state New state of the button
  117949. * @param changes Which properties on the state changed since last frame
  117950. */
  117951. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117952. }
  117953. }
  117954. declare module BABYLON {
  117955. /**
  117956. * Class containing static functions to help procedurally build meshes
  117957. */
  117958. export class PolyhedronBuilder {
  117959. /**
  117960. * Creates a polyhedron mesh
  117961. * * 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
  117962. * * The parameter `size` (positive float, default 1) sets the polygon size
  117963. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  117964. * * 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`
  117965. * * 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
  117966. * * 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)`)
  117967. * * 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
  117968. * * 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
  117969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117972. * @param name defines the name of the mesh
  117973. * @param options defines the options used to create the mesh
  117974. * @param scene defines the hosting scene
  117975. * @returns the polyhedron mesh
  117976. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  117977. */
  117978. static CreatePolyhedron(name: string, options: {
  117979. type?: number;
  117980. size?: number;
  117981. sizeX?: number;
  117982. sizeY?: number;
  117983. sizeZ?: number;
  117984. custom?: any;
  117985. faceUV?: Vector4[];
  117986. faceColors?: Color4[];
  117987. flat?: boolean;
  117988. updatable?: boolean;
  117989. sideOrientation?: number;
  117990. frontUVs?: Vector4;
  117991. backUVs?: Vector4;
  117992. }, scene?: Nullable<Scene>): Mesh;
  117993. }
  117994. }
  117995. declare module BABYLON {
  117996. /**
  117997. * Gizmo that enables scaling a mesh along 3 axis
  117998. */
  117999. export class ScaleGizmo extends Gizmo {
  118000. /**
  118001. * Internal gizmo used for interactions on the x axis
  118002. */
  118003. xGizmo: AxisScaleGizmo;
  118004. /**
  118005. * Internal gizmo used for interactions on the y axis
  118006. */
  118007. yGizmo: AxisScaleGizmo;
  118008. /**
  118009. * Internal gizmo used for interactions on the z axis
  118010. */
  118011. zGizmo: AxisScaleGizmo;
  118012. /**
  118013. * Internal gizmo used to scale all axis equally
  118014. */
  118015. uniformScaleGizmo: AxisScaleGizmo;
  118016. private _meshAttached;
  118017. private _updateGizmoRotationToMatchAttachedMesh;
  118018. private _snapDistance;
  118019. private _scaleRatio;
  118020. private _uniformScalingMesh;
  118021. private _octahedron;
  118022. private _sensitivity;
  118023. /** Fires an event when any of it's sub gizmos are dragged */
  118024. onDragStartObservable: Observable<unknown>;
  118025. /** Fires an event when any of it's sub gizmos are released from dragging */
  118026. onDragEndObservable: Observable<unknown>;
  118027. get attachedMesh(): Nullable<AbstractMesh>;
  118028. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118029. /**
  118030. * Creates a ScaleGizmo
  118031. * @param gizmoLayer The utility layer the gizmo will be added to
  118032. */
  118033. constructor(gizmoLayer?: UtilityLayerRenderer);
  118034. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118035. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118036. /**
  118037. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118038. */
  118039. set snapDistance(value: number);
  118040. get snapDistance(): number;
  118041. /**
  118042. * Ratio for the scale of the gizmo (Default: 1)
  118043. */
  118044. set scaleRatio(value: number);
  118045. get scaleRatio(): number;
  118046. /**
  118047. * Sensitivity factor for dragging (Default: 1)
  118048. */
  118049. set sensitivity(value: number);
  118050. get sensitivity(): number;
  118051. /**
  118052. * Disposes of the gizmo
  118053. */
  118054. dispose(): void;
  118055. }
  118056. }
  118057. declare module BABYLON {
  118058. /**
  118059. * Single axis scale gizmo
  118060. */
  118061. export class AxisScaleGizmo extends Gizmo {
  118062. /**
  118063. * Drag behavior responsible for the gizmos dragging interactions
  118064. */
  118065. dragBehavior: PointerDragBehavior;
  118066. private _pointerObserver;
  118067. /**
  118068. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118069. */
  118070. snapDistance: number;
  118071. /**
  118072. * Event that fires each time the gizmo snaps to a new location.
  118073. * * snapDistance is the the change in distance
  118074. */
  118075. onSnapObservable: Observable<{
  118076. snapDistance: number;
  118077. }>;
  118078. /**
  118079. * If the scaling operation should be done on all axis (default: false)
  118080. */
  118081. uniformScaling: boolean;
  118082. /**
  118083. * Custom sensitivity value for the drag strength
  118084. */
  118085. sensitivity: number;
  118086. private _isEnabled;
  118087. private _parent;
  118088. private _arrow;
  118089. private _coloredMaterial;
  118090. private _hoverMaterial;
  118091. /**
  118092. * Creates an AxisScaleGizmo
  118093. * @param gizmoLayer The utility layer the gizmo will be added to
  118094. * @param dragAxis The axis which the gizmo will be able to scale on
  118095. * @param color The color of the gizmo
  118096. */
  118097. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  118098. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118099. /**
  118100. * If the gizmo is enabled
  118101. */
  118102. set isEnabled(value: boolean);
  118103. get isEnabled(): boolean;
  118104. /**
  118105. * Disposes of the gizmo
  118106. */
  118107. dispose(): void;
  118108. /**
  118109. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118110. * @param mesh The mesh to replace the default mesh of the gizmo
  118111. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  118112. */
  118113. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  118114. }
  118115. }
  118116. declare module BABYLON {
  118117. /**
  118118. * Bounding box gizmo
  118119. */
  118120. export class BoundingBoxGizmo extends Gizmo {
  118121. private _lineBoundingBox;
  118122. private _rotateSpheresParent;
  118123. private _scaleBoxesParent;
  118124. private _boundingDimensions;
  118125. private _renderObserver;
  118126. private _pointerObserver;
  118127. private _scaleDragSpeed;
  118128. private _tmpQuaternion;
  118129. private _tmpVector;
  118130. private _tmpRotationMatrix;
  118131. /**
  118132. * 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)
  118133. */
  118134. ignoreChildren: boolean;
  118135. /**
  118136. * 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)
  118137. */
  118138. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  118139. /**
  118140. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  118141. */
  118142. rotationSphereSize: number;
  118143. /**
  118144. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  118145. */
  118146. scaleBoxSize: number;
  118147. /**
  118148. * 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)
  118149. */
  118150. fixedDragMeshScreenSize: boolean;
  118151. /**
  118152. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  118153. */
  118154. fixedDragMeshScreenSizeDistanceFactor: number;
  118155. /**
  118156. * Fired when a rotation sphere or scale box is dragged
  118157. */
  118158. onDragStartObservable: Observable<{}>;
  118159. /**
  118160. * Fired when a scale box is dragged
  118161. */
  118162. onScaleBoxDragObservable: Observable<{}>;
  118163. /**
  118164. * Fired when a scale box drag is ended
  118165. */
  118166. onScaleBoxDragEndObservable: Observable<{}>;
  118167. /**
  118168. * Fired when a rotation sphere is dragged
  118169. */
  118170. onRotationSphereDragObservable: Observable<{}>;
  118171. /**
  118172. * Fired when a rotation sphere drag is ended
  118173. */
  118174. onRotationSphereDragEndObservable: Observable<{}>;
  118175. /**
  118176. * 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)
  118177. */
  118178. scalePivot: Nullable<Vector3>;
  118179. /**
  118180. * Mesh used as a pivot to rotate the attached mesh
  118181. */
  118182. private _anchorMesh;
  118183. private _existingMeshScale;
  118184. private _dragMesh;
  118185. private pointerDragBehavior;
  118186. private coloredMaterial;
  118187. private hoverColoredMaterial;
  118188. /**
  118189. * Sets the color of the bounding box gizmo
  118190. * @param color the color to set
  118191. */
  118192. setColor(color: Color3): void;
  118193. /**
  118194. * Creates an BoundingBoxGizmo
  118195. * @param gizmoLayer The utility layer the gizmo will be added to
  118196. * @param color The color of the gizmo
  118197. */
  118198. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  118199. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118200. private _selectNode;
  118201. /**
  118202. * Updates the bounding box information for the Gizmo
  118203. */
  118204. updateBoundingBox(): void;
  118205. private _updateRotationSpheres;
  118206. private _updateScaleBoxes;
  118207. /**
  118208. * Enables rotation on the specified axis and disables rotation on the others
  118209. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  118210. */
  118211. setEnabledRotationAxis(axis: string): void;
  118212. /**
  118213. * Enables/disables scaling
  118214. * @param enable if scaling should be enabled
  118215. */
  118216. setEnabledScaling(enable: boolean): void;
  118217. private _updateDummy;
  118218. /**
  118219. * Enables a pointer drag behavior on the bounding box of the gizmo
  118220. */
  118221. enableDragBehavior(): void;
  118222. /**
  118223. * Disposes of the gizmo
  118224. */
  118225. dispose(): void;
  118226. /**
  118227. * 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)
  118228. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  118229. * @returns the bounding box mesh with the passed in mesh as a child
  118230. */
  118231. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  118232. /**
  118233. * CustomMeshes are not supported by this gizmo
  118234. * @param mesh The mesh to replace the default mesh of the gizmo
  118235. */
  118236. setCustomMesh(mesh: Mesh): void;
  118237. }
  118238. }
  118239. declare module BABYLON {
  118240. /**
  118241. * Single plane rotation gizmo
  118242. */
  118243. export class PlaneRotationGizmo extends Gizmo {
  118244. /**
  118245. * Drag behavior responsible for the gizmos dragging interactions
  118246. */
  118247. dragBehavior: PointerDragBehavior;
  118248. private _pointerObserver;
  118249. /**
  118250. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  118251. */
  118252. snapDistance: number;
  118253. /**
  118254. * Event that fires each time the gizmo snaps to a new location.
  118255. * * snapDistance is the the change in distance
  118256. */
  118257. onSnapObservable: Observable<{
  118258. snapDistance: number;
  118259. }>;
  118260. private _isEnabled;
  118261. private _parent;
  118262. /**
  118263. * Creates a PlaneRotationGizmo
  118264. * @param gizmoLayer The utility layer the gizmo will be added to
  118265. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  118266. * @param color The color of the gizmo
  118267. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118268. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118269. */
  118270. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  118271. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118272. /**
  118273. * If the gizmo is enabled
  118274. */
  118275. set isEnabled(value: boolean);
  118276. get isEnabled(): boolean;
  118277. /**
  118278. * Disposes of the gizmo
  118279. */
  118280. dispose(): void;
  118281. }
  118282. }
  118283. declare module BABYLON {
  118284. /**
  118285. * Gizmo that enables rotating a mesh along 3 axis
  118286. */
  118287. export class RotationGizmo extends Gizmo {
  118288. /**
  118289. * Internal gizmo used for interactions on the x axis
  118290. */
  118291. xGizmo: PlaneRotationGizmo;
  118292. /**
  118293. * Internal gizmo used for interactions on the y axis
  118294. */
  118295. yGizmo: PlaneRotationGizmo;
  118296. /**
  118297. * Internal gizmo used for interactions on the z axis
  118298. */
  118299. zGizmo: PlaneRotationGizmo;
  118300. /** Fires an event when any of it's sub gizmos are dragged */
  118301. onDragStartObservable: Observable<unknown>;
  118302. /** Fires an event when any of it's sub gizmos are released from dragging */
  118303. onDragEndObservable: Observable<unknown>;
  118304. private _meshAttached;
  118305. get attachedMesh(): Nullable<AbstractMesh>;
  118306. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118307. /**
  118308. * Creates a RotationGizmo
  118309. * @param gizmoLayer The utility layer the gizmo will be added to
  118310. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118311. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118312. */
  118313. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  118314. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118315. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118316. /**
  118317. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118318. */
  118319. set snapDistance(value: number);
  118320. get snapDistance(): number;
  118321. /**
  118322. * Ratio for the scale of the gizmo (Default: 1)
  118323. */
  118324. set scaleRatio(value: number);
  118325. get scaleRatio(): number;
  118326. /**
  118327. * Disposes of the gizmo
  118328. */
  118329. dispose(): void;
  118330. /**
  118331. * CustomMeshes are not supported by this gizmo
  118332. * @param mesh The mesh to replace the default mesh of the gizmo
  118333. */
  118334. setCustomMesh(mesh: Mesh): void;
  118335. }
  118336. }
  118337. declare module BABYLON {
  118338. /**
  118339. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  118340. */
  118341. export class GizmoManager implements IDisposable {
  118342. private scene;
  118343. /**
  118344. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  118345. */
  118346. gizmos: {
  118347. positionGizmo: Nullable<PositionGizmo>;
  118348. rotationGizmo: Nullable<RotationGizmo>;
  118349. scaleGizmo: Nullable<ScaleGizmo>;
  118350. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  118351. };
  118352. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  118353. clearGizmoOnEmptyPointerEvent: boolean;
  118354. /** Fires an event when the manager is attached to a mesh */
  118355. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  118356. private _gizmosEnabled;
  118357. private _pointerObserver;
  118358. private _attachedMesh;
  118359. private _boundingBoxColor;
  118360. private _defaultUtilityLayer;
  118361. private _defaultKeepDepthUtilityLayer;
  118362. /**
  118363. * When bounding box gizmo is enabled, this can be used to track drag/end events
  118364. */
  118365. boundingBoxDragBehavior: SixDofDragBehavior;
  118366. /**
  118367. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  118368. */
  118369. attachableMeshes: Nullable<Array<AbstractMesh>>;
  118370. /**
  118371. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  118372. */
  118373. usePointerToAttachGizmos: boolean;
  118374. /**
  118375. * Utility layer that the bounding box gizmo belongs to
  118376. */
  118377. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  118378. /**
  118379. * Utility layer that all gizmos besides bounding box belong to
  118380. */
  118381. get utilityLayer(): UtilityLayerRenderer;
  118382. /**
  118383. * Instatiates a gizmo manager
  118384. * @param scene the scene to overlay the gizmos on top of
  118385. */
  118386. constructor(scene: Scene);
  118387. /**
  118388. * Attaches a set of gizmos to the specified mesh
  118389. * @param mesh The mesh the gizmo's should be attached to
  118390. */
  118391. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118392. /**
  118393. * If the position gizmo is enabled
  118394. */
  118395. set positionGizmoEnabled(value: boolean);
  118396. get positionGizmoEnabled(): boolean;
  118397. /**
  118398. * If the rotation gizmo is enabled
  118399. */
  118400. set rotationGizmoEnabled(value: boolean);
  118401. get rotationGizmoEnabled(): boolean;
  118402. /**
  118403. * If the scale gizmo is enabled
  118404. */
  118405. set scaleGizmoEnabled(value: boolean);
  118406. get scaleGizmoEnabled(): boolean;
  118407. /**
  118408. * If the boundingBox gizmo is enabled
  118409. */
  118410. set boundingBoxGizmoEnabled(value: boolean);
  118411. get boundingBoxGizmoEnabled(): boolean;
  118412. /**
  118413. * Disposes of the gizmo manager
  118414. */
  118415. dispose(): void;
  118416. }
  118417. }
  118418. declare module BABYLON {
  118419. /**
  118420. * A directional light is defined by a direction (what a surprise!).
  118421. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  118422. * 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.
  118423. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118424. */
  118425. export class DirectionalLight extends ShadowLight {
  118426. private _shadowFrustumSize;
  118427. /**
  118428. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  118429. */
  118430. get shadowFrustumSize(): number;
  118431. /**
  118432. * Specifies a fix frustum size for the shadow generation.
  118433. */
  118434. set shadowFrustumSize(value: number);
  118435. private _shadowOrthoScale;
  118436. /**
  118437. * Gets the shadow projection scale against the optimal computed one.
  118438. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118439. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118440. */
  118441. get shadowOrthoScale(): number;
  118442. /**
  118443. * Sets the shadow projection scale against the optimal computed one.
  118444. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118445. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118446. */
  118447. set shadowOrthoScale(value: number);
  118448. /**
  118449. * Automatically compute the projection matrix to best fit (including all the casters)
  118450. * on each frame.
  118451. */
  118452. autoUpdateExtends: boolean;
  118453. /**
  118454. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  118455. * on each frame. autoUpdateExtends must be set to true for this to work
  118456. */
  118457. autoCalcShadowZBounds: boolean;
  118458. private _orthoLeft;
  118459. private _orthoRight;
  118460. private _orthoTop;
  118461. private _orthoBottom;
  118462. /**
  118463. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  118464. * The directional light is emitted from everywhere in the given direction.
  118465. * It can cast shadows.
  118466. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118467. * @param name The friendly name of the light
  118468. * @param direction The direction of the light
  118469. * @param scene The scene the light belongs to
  118470. */
  118471. constructor(name: string, direction: Vector3, scene: Scene);
  118472. /**
  118473. * Returns the string "DirectionalLight".
  118474. * @return The class name
  118475. */
  118476. getClassName(): string;
  118477. /**
  118478. * Returns the integer 1.
  118479. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118480. */
  118481. getTypeID(): number;
  118482. /**
  118483. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  118484. * Returns the DirectionalLight Shadow projection matrix.
  118485. */
  118486. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118487. /**
  118488. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  118489. * Returns the DirectionalLight Shadow projection matrix.
  118490. */
  118491. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  118492. /**
  118493. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  118494. * Returns the DirectionalLight Shadow projection matrix.
  118495. */
  118496. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118497. protected _buildUniformLayout(): void;
  118498. /**
  118499. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  118500. * @param effect The effect to update
  118501. * @param lightIndex The index of the light in the effect to update
  118502. * @returns The directional light
  118503. */
  118504. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  118505. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  118506. /**
  118507. * Gets the minZ used for shadow according to both the scene and the light.
  118508. *
  118509. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118510. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118511. * @param activeCamera The camera we are returning the min for
  118512. * @returns the depth min z
  118513. */
  118514. getDepthMinZ(activeCamera: Camera): number;
  118515. /**
  118516. * Gets the maxZ used for shadow according to both the scene and the light.
  118517. *
  118518. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118519. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118520. * @param activeCamera The camera we are returning the max for
  118521. * @returns the depth max z
  118522. */
  118523. getDepthMaxZ(activeCamera: Camera): number;
  118524. /**
  118525. * Prepares the list of defines specific to the light type.
  118526. * @param defines the list of defines
  118527. * @param lightIndex defines the index of the light for the effect
  118528. */
  118529. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118530. }
  118531. }
  118532. declare module BABYLON {
  118533. /**
  118534. * Class containing static functions to help procedurally build meshes
  118535. */
  118536. export class HemisphereBuilder {
  118537. /**
  118538. * Creates a hemisphere mesh
  118539. * @param name defines the name of the mesh
  118540. * @param options defines the options used to create the mesh
  118541. * @param scene defines the hosting scene
  118542. * @returns the hemisphere mesh
  118543. */
  118544. static CreateHemisphere(name: string, options: {
  118545. segments?: number;
  118546. diameter?: number;
  118547. sideOrientation?: number;
  118548. }, scene: any): Mesh;
  118549. }
  118550. }
  118551. declare module BABYLON {
  118552. /**
  118553. * A spot light is defined by a position, a direction, an angle, and an exponent.
  118554. * These values define a cone of light starting from the position, emitting toward the direction.
  118555. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  118556. * and the exponent defines the speed of the decay of the light with distance (reach).
  118557. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118558. */
  118559. export class SpotLight extends ShadowLight {
  118560. private _angle;
  118561. private _innerAngle;
  118562. private _cosHalfAngle;
  118563. private _lightAngleScale;
  118564. private _lightAngleOffset;
  118565. /**
  118566. * Gets the cone angle of the spot light in Radians.
  118567. */
  118568. get angle(): number;
  118569. /**
  118570. * Sets the cone angle of the spot light in Radians.
  118571. */
  118572. set angle(value: number);
  118573. /**
  118574. * Only used in gltf falloff mode, this defines the angle where
  118575. * the directional falloff will start before cutting at angle which could be seen
  118576. * as outer angle.
  118577. */
  118578. get innerAngle(): number;
  118579. /**
  118580. * Only used in gltf falloff mode, this defines the angle where
  118581. * the directional falloff will start before cutting at angle which could be seen
  118582. * as outer angle.
  118583. */
  118584. set innerAngle(value: number);
  118585. private _shadowAngleScale;
  118586. /**
  118587. * Allows scaling the angle of the light for shadow generation only.
  118588. */
  118589. get shadowAngleScale(): number;
  118590. /**
  118591. * Allows scaling the angle of the light for shadow generation only.
  118592. */
  118593. set shadowAngleScale(value: number);
  118594. /**
  118595. * The light decay speed with the distance from the emission spot.
  118596. */
  118597. exponent: number;
  118598. private _projectionTextureMatrix;
  118599. /**
  118600. * Allows reading the projecton texture
  118601. */
  118602. get projectionTextureMatrix(): Matrix;
  118603. protected _projectionTextureLightNear: number;
  118604. /**
  118605. * Gets the near clip of the Spotlight for texture projection.
  118606. */
  118607. get projectionTextureLightNear(): number;
  118608. /**
  118609. * Sets the near clip of the Spotlight for texture projection.
  118610. */
  118611. set projectionTextureLightNear(value: number);
  118612. protected _projectionTextureLightFar: number;
  118613. /**
  118614. * Gets the far clip of the Spotlight for texture projection.
  118615. */
  118616. get projectionTextureLightFar(): number;
  118617. /**
  118618. * Sets the far clip of the Spotlight for texture projection.
  118619. */
  118620. set projectionTextureLightFar(value: number);
  118621. protected _projectionTextureUpDirection: Vector3;
  118622. /**
  118623. * Gets the Up vector of the Spotlight for texture projection.
  118624. */
  118625. get projectionTextureUpDirection(): Vector3;
  118626. /**
  118627. * Sets the Up vector of the Spotlight for texture projection.
  118628. */
  118629. set projectionTextureUpDirection(value: Vector3);
  118630. private _projectionTexture;
  118631. /**
  118632. * Gets the projection texture of the light.
  118633. */
  118634. get projectionTexture(): Nullable<BaseTexture>;
  118635. /**
  118636. * Sets the projection texture of the light.
  118637. */
  118638. set projectionTexture(value: Nullable<BaseTexture>);
  118639. private _projectionTextureViewLightDirty;
  118640. private _projectionTextureProjectionLightDirty;
  118641. private _projectionTextureDirty;
  118642. private _projectionTextureViewTargetVector;
  118643. private _projectionTextureViewLightMatrix;
  118644. private _projectionTextureProjectionLightMatrix;
  118645. private _projectionTextureScalingMatrix;
  118646. /**
  118647. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  118648. * It can cast shadows.
  118649. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118650. * @param name The light friendly name
  118651. * @param position The position of the spot light in the scene
  118652. * @param direction The direction of the light in the scene
  118653. * @param angle The cone angle of the light in Radians
  118654. * @param exponent The light decay speed with the distance from the emission spot
  118655. * @param scene The scene the lights belongs to
  118656. */
  118657. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  118658. /**
  118659. * Returns the string "SpotLight".
  118660. * @returns the class name
  118661. */
  118662. getClassName(): string;
  118663. /**
  118664. * Returns the integer 2.
  118665. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118666. */
  118667. getTypeID(): number;
  118668. /**
  118669. * Overrides the direction setter to recompute the projection texture view light Matrix.
  118670. */
  118671. protected _setDirection(value: Vector3): void;
  118672. /**
  118673. * Overrides the position setter to recompute the projection texture view light Matrix.
  118674. */
  118675. protected _setPosition(value: Vector3): void;
  118676. /**
  118677. * 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.
  118678. * Returns the SpotLight.
  118679. */
  118680. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118681. protected _computeProjectionTextureViewLightMatrix(): void;
  118682. protected _computeProjectionTextureProjectionLightMatrix(): void;
  118683. /**
  118684. * Main function for light texture projection matrix computing.
  118685. */
  118686. protected _computeProjectionTextureMatrix(): void;
  118687. protected _buildUniformLayout(): void;
  118688. private _computeAngleValues;
  118689. /**
  118690. * Sets the passed Effect "effect" with the Light textures.
  118691. * @param effect The effect to update
  118692. * @param lightIndex The index of the light in the effect to update
  118693. * @returns The light
  118694. */
  118695. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  118696. /**
  118697. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  118698. * @param effect The effect to update
  118699. * @param lightIndex The index of the light in the effect to update
  118700. * @returns The spot light
  118701. */
  118702. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  118703. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118704. /**
  118705. * Disposes the light and the associated resources.
  118706. */
  118707. dispose(): void;
  118708. /**
  118709. * Prepares the list of defines specific to the light type.
  118710. * @param defines the list of defines
  118711. * @param lightIndex defines the index of the light for the effect
  118712. */
  118713. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118714. }
  118715. }
  118716. declare module BABYLON {
  118717. /**
  118718. * Gizmo that enables viewing a light
  118719. */
  118720. export class LightGizmo extends Gizmo {
  118721. private _lightMesh;
  118722. private _material;
  118723. private _cachedPosition;
  118724. private _cachedForward;
  118725. private _attachedMeshParent;
  118726. /**
  118727. * Creates a LightGizmo
  118728. * @param gizmoLayer The utility layer the gizmo will be added to
  118729. */
  118730. constructor(gizmoLayer?: UtilityLayerRenderer);
  118731. private _light;
  118732. /**
  118733. * The light that the gizmo is attached to
  118734. */
  118735. set light(light: Nullable<Light>);
  118736. get light(): Nullable<Light>;
  118737. /**
  118738. * Gets the material used to render the light gizmo
  118739. */
  118740. get material(): StandardMaterial;
  118741. /**
  118742. * @hidden
  118743. * Updates the gizmo to match the attached mesh's position/rotation
  118744. */
  118745. protected _update(): void;
  118746. private static _Scale;
  118747. /**
  118748. * Creates the lines for a light mesh
  118749. */
  118750. private static _CreateLightLines;
  118751. /**
  118752. * Disposes of the light gizmo
  118753. */
  118754. dispose(): void;
  118755. private static _CreateHemisphericLightMesh;
  118756. private static _CreatePointLightMesh;
  118757. private static _CreateSpotLightMesh;
  118758. private static _CreateDirectionalLightMesh;
  118759. }
  118760. }
  118761. declare module BABYLON {
  118762. /** @hidden */
  118763. export var backgroundFragmentDeclaration: {
  118764. name: string;
  118765. shader: string;
  118766. };
  118767. }
  118768. declare module BABYLON {
  118769. /** @hidden */
  118770. export var backgroundUboDeclaration: {
  118771. name: string;
  118772. shader: string;
  118773. };
  118774. }
  118775. declare module BABYLON {
  118776. /** @hidden */
  118777. export var backgroundPixelShader: {
  118778. name: string;
  118779. shader: string;
  118780. };
  118781. }
  118782. declare module BABYLON {
  118783. /** @hidden */
  118784. export var backgroundVertexDeclaration: {
  118785. name: string;
  118786. shader: string;
  118787. };
  118788. }
  118789. declare module BABYLON {
  118790. /** @hidden */
  118791. export var backgroundVertexShader: {
  118792. name: string;
  118793. shader: string;
  118794. };
  118795. }
  118796. declare module BABYLON {
  118797. /**
  118798. * Background material used to create an efficient environement around your scene.
  118799. */
  118800. export class BackgroundMaterial extends PushMaterial {
  118801. /**
  118802. * Standard reflectance value at parallel view angle.
  118803. */
  118804. static StandardReflectance0: number;
  118805. /**
  118806. * Standard reflectance value at grazing angle.
  118807. */
  118808. static StandardReflectance90: number;
  118809. protected _primaryColor: Color3;
  118810. /**
  118811. * Key light Color (multiply against the environement texture)
  118812. */
  118813. primaryColor: Color3;
  118814. protected __perceptualColor: Nullable<Color3>;
  118815. /**
  118816. * Experimental Internal Use Only.
  118817. *
  118818. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  118819. * This acts as a helper to set the primary color to a more "human friendly" value.
  118820. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  118821. * output color as close as possible from the chosen value.
  118822. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  118823. * part of lighting setup.)
  118824. */
  118825. get _perceptualColor(): Nullable<Color3>;
  118826. set _perceptualColor(value: Nullable<Color3>);
  118827. protected _primaryColorShadowLevel: float;
  118828. /**
  118829. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  118830. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  118831. */
  118832. get primaryColorShadowLevel(): float;
  118833. set primaryColorShadowLevel(value: float);
  118834. protected _primaryColorHighlightLevel: float;
  118835. /**
  118836. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  118837. * The primary color is used at the level chosen to define what the white area would look.
  118838. */
  118839. get primaryColorHighlightLevel(): float;
  118840. set primaryColorHighlightLevel(value: float);
  118841. protected _reflectionTexture: Nullable<BaseTexture>;
  118842. /**
  118843. * Reflection Texture used in the material.
  118844. * Should be author in a specific way for the best result (refer to the documentation).
  118845. */
  118846. reflectionTexture: Nullable<BaseTexture>;
  118847. protected _reflectionBlur: float;
  118848. /**
  118849. * Reflection Texture level of blur.
  118850. *
  118851. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  118852. * texture twice.
  118853. */
  118854. reflectionBlur: float;
  118855. protected _diffuseTexture: Nullable<BaseTexture>;
  118856. /**
  118857. * Diffuse Texture used in the material.
  118858. * Should be author in a specific way for the best result (refer to the documentation).
  118859. */
  118860. diffuseTexture: Nullable<BaseTexture>;
  118861. protected _shadowLights: Nullable<IShadowLight[]>;
  118862. /**
  118863. * Specify the list of lights casting shadow on the material.
  118864. * All scene shadow lights will be included if null.
  118865. */
  118866. shadowLights: Nullable<IShadowLight[]>;
  118867. protected _shadowLevel: float;
  118868. /**
  118869. * Helps adjusting the shadow to a softer level if required.
  118870. * 0 means black shadows and 1 means no shadows.
  118871. */
  118872. shadowLevel: float;
  118873. protected _sceneCenter: Vector3;
  118874. /**
  118875. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  118876. * It is usually zero but might be interesting to modify according to your setup.
  118877. */
  118878. sceneCenter: Vector3;
  118879. protected _opacityFresnel: boolean;
  118880. /**
  118881. * This helps specifying that the material is falling off to the sky box at grazing angle.
  118882. * This helps ensuring a nice transition when the camera goes under the ground.
  118883. */
  118884. opacityFresnel: boolean;
  118885. protected _reflectionFresnel: boolean;
  118886. /**
  118887. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  118888. * This helps adding a mirror texture on the ground.
  118889. */
  118890. reflectionFresnel: boolean;
  118891. protected _reflectionFalloffDistance: number;
  118892. /**
  118893. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  118894. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  118895. */
  118896. reflectionFalloffDistance: number;
  118897. protected _reflectionAmount: number;
  118898. /**
  118899. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  118900. */
  118901. reflectionAmount: number;
  118902. protected _reflectionReflectance0: number;
  118903. /**
  118904. * This specifies the weight of the reflection at grazing angle.
  118905. */
  118906. reflectionReflectance0: number;
  118907. protected _reflectionReflectance90: number;
  118908. /**
  118909. * This specifies the weight of the reflection at a perpendicular point of view.
  118910. */
  118911. reflectionReflectance90: number;
  118912. /**
  118913. * Sets the reflection reflectance fresnel values according to the default standard
  118914. * empirically know to work well :-)
  118915. */
  118916. set reflectionStandardFresnelWeight(value: number);
  118917. protected _useRGBColor: boolean;
  118918. /**
  118919. * Helps to directly use the maps channels instead of their level.
  118920. */
  118921. useRGBColor: boolean;
  118922. protected _enableNoise: boolean;
  118923. /**
  118924. * This helps reducing the banding effect that could occur on the background.
  118925. */
  118926. enableNoise: boolean;
  118927. /**
  118928. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118929. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  118930. * Recommended to be keep at 1.0 except for special cases.
  118931. */
  118932. get fovMultiplier(): number;
  118933. set fovMultiplier(value: number);
  118934. private _fovMultiplier;
  118935. /**
  118936. * Enable the FOV adjustment feature controlled by fovMultiplier.
  118937. */
  118938. useEquirectangularFOV: boolean;
  118939. private _maxSimultaneousLights;
  118940. /**
  118941. * Number of Simultaneous lights allowed on the material.
  118942. */
  118943. maxSimultaneousLights: int;
  118944. /**
  118945. * Default configuration related to image processing available in the Background Material.
  118946. */
  118947. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118948. /**
  118949. * Keep track of the image processing observer to allow dispose and replace.
  118950. */
  118951. private _imageProcessingObserver;
  118952. /**
  118953. * Attaches a new image processing configuration to the PBR Material.
  118954. * @param configuration (if null the scene configuration will be use)
  118955. */
  118956. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118957. /**
  118958. * Gets the image processing configuration used either in this material.
  118959. */
  118960. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  118961. /**
  118962. * Sets the Default image processing configuration used either in the this material.
  118963. *
  118964. * If sets to null, the scene one is in use.
  118965. */
  118966. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  118967. /**
  118968. * Gets wether the color curves effect is enabled.
  118969. */
  118970. get cameraColorCurvesEnabled(): boolean;
  118971. /**
  118972. * Sets wether the color curves effect is enabled.
  118973. */
  118974. set cameraColorCurvesEnabled(value: boolean);
  118975. /**
  118976. * Gets wether the color grading effect is enabled.
  118977. */
  118978. get cameraColorGradingEnabled(): boolean;
  118979. /**
  118980. * Gets wether the color grading effect is enabled.
  118981. */
  118982. set cameraColorGradingEnabled(value: boolean);
  118983. /**
  118984. * Gets wether tonemapping is enabled or not.
  118985. */
  118986. get cameraToneMappingEnabled(): boolean;
  118987. /**
  118988. * Sets wether tonemapping is enabled or not
  118989. */
  118990. set cameraToneMappingEnabled(value: boolean);
  118991. /**
  118992. * The camera exposure used on this material.
  118993. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118994. * This corresponds to a photographic exposure.
  118995. */
  118996. get cameraExposure(): float;
  118997. /**
  118998. * The camera exposure used on this material.
  118999. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  119000. * This corresponds to a photographic exposure.
  119001. */
  119002. set cameraExposure(value: float);
  119003. /**
  119004. * Gets The camera contrast used on this material.
  119005. */
  119006. get cameraContrast(): float;
  119007. /**
  119008. * Sets The camera contrast used on this material.
  119009. */
  119010. set cameraContrast(value: float);
  119011. /**
  119012. * Gets the Color Grading 2D Lookup Texture.
  119013. */
  119014. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  119015. /**
  119016. * Sets the Color Grading 2D Lookup Texture.
  119017. */
  119018. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  119019. /**
  119020. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  119021. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  119022. * 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;
  119023. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  119024. */
  119025. get cameraColorCurves(): Nullable<ColorCurves>;
  119026. /**
  119027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  119028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  119029. * 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;
  119030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  119031. */
  119032. set cameraColorCurves(value: Nullable<ColorCurves>);
  119033. /**
  119034. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  119035. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  119036. */
  119037. switchToBGR: boolean;
  119038. private _renderTargets;
  119039. private _reflectionControls;
  119040. private _white;
  119041. private _primaryShadowColor;
  119042. private _primaryHighlightColor;
  119043. /**
  119044. * Instantiates a Background Material in the given scene
  119045. * @param name The friendly name of the material
  119046. * @param scene The scene to add the material to
  119047. */
  119048. constructor(name: string, scene: Scene);
  119049. /**
  119050. * Gets a boolean indicating that current material needs to register RTT
  119051. */
  119052. get hasRenderTargetTextures(): boolean;
  119053. /**
  119054. * The entire material has been created in order to prevent overdraw.
  119055. * @returns false
  119056. */
  119057. needAlphaTesting(): boolean;
  119058. /**
  119059. * The entire material has been created in order to prevent overdraw.
  119060. * @returns true if blending is enable
  119061. */
  119062. needAlphaBlending(): boolean;
  119063. /**
  119064. * Checks wether the material is ready to be rendered for a given mesh.
  119065. * @param mesh The mesh to render
  119066. * @param subMesh The submesh to check against
  119067. * @param useInstances Specify wether or not the material is used with instances
  119068. * @returns true if all the dependencies are ready (Textures, Effects...)
  119069. */
  119070. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119071. /**
  119072. * Compute the primary color according to the chosen perceptual color.
  119073. */
  119074. private _computePrimaryColorFromPerceptualColor;
  119075. /**
  119076. * Compute the highlights and shadow colors according to their chosen levels.
  119077. */
  119078. private _computePrimaryColors;
  119079. /**
  119080. * Build the uniform buffer used in the material.
  119081. */
  119082. buildUniformLayout(): void;
  119083. /**
  119084. * Unbind the material.
  119085. */
  119086. unbind(): void;
  119087. /**
  119088. * Bind only the world matrix to the material.
  119089. * @param world The world matrix to bind.
  119090. */
  119091. bindOnlyWorldMatrix(world: Matrix): void;
  119092. /**
  119093. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  119094. * @param world The world matrix to bind.
  119095. * @param subMesh The submesh to bind for.
  119096. */
  119097. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119098. /**
  119099. * Checks to see if a texture is used in the material.
  119100. * @param texture - Base texture to use.
  119101. * @returns - Boolean specifying if a texture is used in the material.
  119102. */
  119103. hasTexture(texture: BaseTexture): boolean;
  119104. /**
  119105. * Dispose the material.
  119106. * @param forceDisposeEffect Force disposal of the associated effect.
  119107. * @param forceDisposeTextures Force disposal of the associated textures.
  119108. */
  119109. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  119110. /**
  119111. * Clones the material.
  119112. * @param name The cloned name.
  119113. * @returns The cloned material.
  119114. */
  119115. clone(name: string): BackgroundMaterial;
  119116. /**
  119117. * Serializes the current material to its JSON representation.
  119118. * @returns The JSON representation.
  119119. */
  119120. serialize(): any;
  119121. /**
  119122. * Gets the class name of the material
  119123. * @returns "BackgroundMaterial"
  119124. */
  119125. getClassName(): string;
  119126. /**
  119127. * Parse a JSON input to create back a background material.
  119128. * @param source The JSON data to parse
  119129. * @param scene The scene to create the parsed material in
  119130. * @param rootUrl The root url of the assets the material depends upon
  119131. * @returns the instantiated BackgroundMaterial.
  119132. */
  119133. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  119134. }
  119135. }
  119136. declare module BABYLON {
  119137. /**
  119138. * Represents the different options available during the creation of
  119139. * a Environment helper.
  119140. *
  119141. * This can control the default ground, skybox and image processing setup of your scene.
  119142. */
  119143. export interface IEnvironmentHelperOptions {
  119144. /**
  119145. * Specifies wether or not to create a ground.
  119146. * True by default.
  119147. */
  119148. createGround: boolean;
  119149. /**
  119150. * Specifies the ground size.
  119151. * 15 by default.
  119152. */
  119153. groundSize: number;
  119154. /**
  119155. * The texture used on the ground for the main color.
  119156. * Comes from the BabylonJS CDN by default.
  119157. *
  119158. * Remarks: Can be either a texture or a url.
  119159. */
  119160. groundTexture: string | BaseTexture;
  119161. /**
  119162. * The color mixed in the ground texture by default.
  119163. * BabylonJS clearColor by default.
  119164. */
  119165. groundColor: Color3;
  119166. /**
  119167. * Specifies the ground opacity.
  119168. * 1 by default.
  119169. */
  119170. groundOpacity: number;
  119171. /**
  119172. * Enables the ground to receive shadows.
  119173. * True by default.
  119174. */
  119175. enableGroundShadow: boolean;
  119176. /**
  119177. * Helps preventing the shadow to be fully black on the ground.
  119178. * 0.5 by default.
  119179. */
  119180. groundShadowLevel: number;
  119181. /**
  119182. * Creates a mirror texture attach to the ground.
  119183. * false by default.
  119184. */
  119185. enableGroundMirror: boolean;
  119186. /**
  119187. * Specifies the ground mirror size ratio.
  119188. * 0.3 by default as the default kernel is 64.
  119189. */
  119190. groundMirrorSizeRatio: number;
  119191. /**
  119192. * Specifies the ground mirror blur kernel size.
  119193. * 64 by default.
  119194. */
  119195. groundMirrorBlurKernel: number;
  119196. /**
  119197. * Specifies the ground mirror visibility amount.
  119198. * 1 by default
  119199. */
  119200. groundMirrorAmount: number;
  119201. /**
  119202. * Specifies the ground mirror reflectance weight.
  119203. * This uses the standard weight of the background material to setup the fresnel effect
  119204. * of the mirror.
  119205. * 1 by default.
  119206. */
  119207. groundMirrorFresnelWeight: number;
  119208. /**
  119209. * Specifies the ground mirror Falloff distance.
  119210. * This can helps reducing the size of the reflection.
  119211. * 0 by Default.
  119212. */
  119213. groundMirrorFallOffDistance: number;
  119214. /**
  119215. * Specifies the ground mirror texture type.
  119216. * Unsigned Int by Default.
  119217. */
  119218. groundMirrorTextureType: number;
  119219. /**
  119220. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  119221. * the shown objects.
  119222. */
  119223. groundYBias: number;
  119224. /**
  119225. * Specifies wether or not to create a skybox.
  119226. * True by default.
  119227. */
  119228. createSkybox: boolean;
  119229. /**
  119230. * Specifies the skybox size.
  119231. * 20 by default.
  119232. */
  119233. skyboxSize: number;
  119234. /**
  119235. * The texture used on the skybox for the main color.
  119236. * Comes from the BabylonJS CDN by default.
  119237. *
  119238. * Remarks: Can be either a texture or a url.
  119239. */
  119240. skyboxTexture: string | BaseTexture;
  119241. /**
  119242. * The color mixed in the skybox texture by default.
  119243. * BabylonJS clearColor by default.
  119244. */
  119245. skyboxColor: Color3;
  119246. /**
  119247. * The background rotation around the Y axis of the scene.
  119248. * This helps aligning the key lights of your scene with the background.
  119249. * 0 by default.
  119250. */
  119251. backgroundYRotation: number;
  119252. /**
  119253. * Compute automatically the size of the elements to best fit with the scene.
  119254. */
  119255. sizeAuto: boolean;
  119256. /**
  119257. * Default position of the rootMesh if autoSize is not true.
  119258. */
  119259. rootPosition: Vector3;
  119260. /**
  119261. * Sets up the image processing in the scene.
  119262. * true by default.
  119263. */
  119264. setupImageProcessing: boolean;
  119265. /**
  119266. * The texture used as your environment texture in the scene.
  119267. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  119268. *
  119269. * Remarks: Can be either a texture or a url.
  119270. */
  119271. environmentTexture: string | BaseTexture;
  119272. /**
  119273. * The value of the exposure to apply to the scene.
  119274. * 0.6 by default if setupImageProcessing is true.
  119275. */
  119276. cameraExposure: number;
  119277. /**
  119278. * The value of the contrast to apply to the scene.
  119279. * 1.6 by default if setupImageProcessing is true.
  119280. */
  119281. cameraContrast: number;
  119282. /**
  119283. * Specifies wether or not tonemapping should be enabled in the scene.
  119284. * true by default if setupImageProcessing is true.
  119285. */
  119286. toneMappingEnabled: boolean;
  119287. }
  119288. /**
  119289. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  119290. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  119291. * It also helps with the default setup of your imageProcessing configuration.
  119292. */
  119293. export class EnvironmentHelper {
  119294. /**
  119295. * Default ground texture URL.
  119296. */
  119297. private static _groundTextureCDNUrl;
  119298. /**
  119299. * Default skybox texture URL.
  119300. */
  119301. private static _skyboxTextureCDNUrl;
  119302. /**
  119303. * Default environment texture URL.
  119304. */
  119305. private static _environmentTextureCDNUrl;
  119306. /**
  119307. * Creates the default options for the helper.
  119308. */
  119309. private static _getDefaultOptions;
  119310. private _rootMesh;
  119311. /**
  119312. * Gets the root mesh created by the helper.
  119313. */
  119314. get rootMesh(): Mesh;
  119315. private _skybox;
  119316. /**
  119317. * Gets the skybox created by the helper.
  119318. */
  119319. get skybox(): Nullable<Mesh>;
  119320. private _skyboxTexture;
  119321. /**
  119322. * Gets the skybox texture created by the helper.
  119323. */
  119324. get skyboxTexture(): Nullable<BaseTexture>;
  119325. private _skyboxMaterial;
  119326. /**
  119327. * Gets the skybox material created by the helper.
  119328. */
  119329. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  119330. private _ground;
  119331. /**
  119332. * Gets the ground mesh created by the helper.
  119333. */
  119334. get ground(): Nullable<Mesh>;
  119335. private _groundTexture;
  119336. /**
  119337. * Gets the ground texture created by the helper.
  119338. */
  119339. get groundTexture(): Nullable<BaseTexture>;
  119340. private _groundMirror;
  119341. /**
  119342. * Gets the ground mirror created by the helper.
  119343. */
  119344. get groundMirror(): Nullable<MirrorTexture>;
  119345. /**
  119346. * Gets the ground mirror render list to helps pushing the meshes
  119347. * you wish in the ground reflection.
  119348. */
  119349. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  119350. private _groundMaterial;
  119351. /**
  119352. * Gets the ground material created by the helper.
  119353. */
  119354. get groundMaterial(): Nullable<BackgroundMaterial>;
  119355. /**
  119356. * Stores the creation options.
  119357. */
  119358. private readonly _scene;
  119359. private _options;
  119360. /**
  119361. * This observable will be notified with any error during the creation of the environment,
  119362. * mainly texture creation errors.
  119363. */
  119364. onErrorObservable: Observable<{
  119365. message?: string;
  119366. exception?: any;
  119367. }>;
  119368. /**
  119369. * constructor
  119370. * @param options Defines the options we want to customize the helper
  119371. * @param scene The scene to add the material to
  119372. */
  119373. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  119374. /**
  119375. * Updates the background according to the new options
  119376. * @param options
  119377. */
  119378. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  119379. /**
  119380. * Sets the primary color of all the available elements.
  119381. * @param color the main color to affect to the ground and the background
  119382. */
  119383. setMainColor(color: Color3): void;
  119384. /**
  119385. * Setup the image processing according to the specified options.
  119386. */
  119387. private _setupImageProcessing;
  119388. /**
  119389. * Setup the environment texture according to the specified options.
  119390. */
  119391. private _setupEnvironmentTexture;
  119392. /**
  119393. * Setup the background according to the specified options.
  119394. */
  119395. private _setupBackground;
  119396. /**
  119397. * Get the scene sizes according to the setup.
  119398. */
  119399. private _getSceneSize;
  119400. /**
  119401. * Setup the ground according to the specified options.
  119402. */
  119403. private _setupGround;
  119404. /**
  119405. * Setup the ground material according to the specified options.
  119406. */
  119407. private _setupGroundMaterial;
  119408. /**
  119409. * Setup the ground diffuse texture according to the specified options.
  119410. */
  119411. private _setupGroundDiffuseTexture;
  119412. /**
  119413. * Setup the ground mirror texture according to the specified options.
  119414. */
  119415. private _setupGroundMirrorTexture;
  119416. /**
  119417. * Setup the ground to receive the mirror texture.
  119418. */
  119419. private _setupMirrorInGroundMaterial;
  119420. /**
  119421. * Setup the skybox according to the specified options.
  119422. */
  119423. private _setupSkybox;
  119424. /**
  119425. * Setup the skybox material according to the specified options.
  119426. */
  119427. private _setupSkyboxMaterial;
  119428. /**
  119429. * Setup the skybox reflection texture according to the specified options.
  119430. */
  119431. private _setupSkyboxReflectionTexture;
  119432. private _errorHandler;
  119433. /**
  119434. * Dispose all the elements created by the Helper.
  119435. */
  119436. dispose(): void;
  119437. }
  119438. }
  119439. declare module BABYLON {
  119440. /**
  119441. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  119442. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  119443. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  119444. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  119445. */
  119446. export class PhotoDome extends TransformNode {
  119447. /**
  119448. * Define the image as a Monoscopic panoramic 360 image.
  119449. */
  119450. static readonly MODE_MONOSCOPIC: number;
  119451. /**
  119452. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119453. */
  119454. static readonly MODE_TOPBOTTOM: number;
  119455. /**
  119456. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119457. */
  119458. static readonly MODE_SIDEBYSIDE: number;
  119459. private _useDirectMapping;
  119460. /**
  119461. * The texture being displayed on the sphere
  119462. */
  119463. protected _photoTexture: Texture;
  119464. /**
  119465. * Gets or sets the texture being displayed on the sphere
  119466. */
  119467. get photoTexture(): Texture;
  119468. set photoTexture(value: Texture);
  119469. /**
  119470. * Observable raised when an error occured while loading the 360 image
  119471. */
  119472. onLoadErrorObservable: Observable<string>;
  119473. /**
  119474. * The skybox material
  119475. */
  119476. protected _material: BackgroundMaterial;
  119477. /**
  119478. * The surface used for the skybox
  119479. */
  119480. protected _mesh: Mesh;
  119481. /**
  119482. * Gets the mesh used for the skybox.
  119483. */
  119484. get mesh(): Mesh;
  119485. /**
  119486. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119487. * Also see the options.resolution property.
  119488. */
  119489. get fovMultiplier(): number;
  119490. set fovMultiplier(value: number);
  119491. private _imageMode;
  119492. /**
  119493. * Gets or set the current video mode for the video. It can be:
  119494. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  119495. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119496. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119497. */
  119498. get imageMode(): number;
  119499. set imageMode(value: number);
  119500. /**
  119501. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  119502. * @param name Element's name, child elements will append suffixes for their own names.
  119503. * @param urlsOfPhoto defines the url of the photo to display
  119504. * @param options defines an object containing optional or exposed sub element properties
  119505. * @param onError defines a callback called when an error occured while loading the texture
  119506. */
  119507. constructor(name: string, urlOfPhoto: string, options: {
  119508. resolution?: number;
  119509. size?: number;
  119510. useDirectMapping?: boolean;
  119511. faceForward?: boolean;
  119512. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  119513. private _onBeforeCameraRenderObserver;
  119514. private _changeImageMode;
  119515. /**
  119516. * Releases resources associated with this node.
  119517. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119518. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119519. */
  119520. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119521. }
  119522. }
  119523. declare module BABYLON {
  119524. /**
  119525. * Class used to host RGBD texture specific utilities
  119526. */
  119527. export class RGBDTextureTools {
  119528. /**
  119529. * Expand the RGBD Texture from RGBD to Half Float if possible.
  119530. * @param texture the texture to expand.
  119531. */
  119532. static ExpandRGBDTexture(texture: Texture): void;
  119533. }
  119534. }
  119535. declare module BABYLON {
  119536. /**
  119537. * Class used to host texture specific utilities
  119538. */
  119539. export class BRDFTextureTools {
  119540. /**
  119541. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  119542. * @param scene defines the hosting scene
  119543. * @returns the environment BRDF texture
  119544. */
  119545. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  119546. private static _environmentBRDFBase64Texture;
  119547. }
  119548. }
  119549. declare module BABYLON {
  119550. /**
  119551. * @hidden
  119552. */
  119553. export interface IMaterialClearCoatDefines {
  119554. CLEARCOAT: boolean;
  119555. CLEARCOAT_DEFAULTIOR: boolean;
  119556. CLEARCOAT_TEXTURE: boolean;
  119557. CLEARCOAT_TEXTUREDIRECTUV: number;
  119558. CLEARCOAT_BUMP: boolean;
  119559. CLEARCOAT_BUMPDIRECTUV: number;
  119560. CLEARCOAT_TINT: boolean;
  119561. CLEARCOAT_TINT_TEXTURE: boolean;
  119562. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  119563. /** @hidden */
  119564. _areTexturesDirty: boolean;
  119565. }
  119566. /**
  119567. * Define the code related to the clear coat parameters of the pbr material.
  119568. */
  119569. export class PBRClearCoatConfiguration {
  119570. /**
  119571. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119572. * The default fits with a polyurethane material.
  119573. */
  119574. private static readonly _DefaultIndexOfRefraction;
  119575. private _isEnabled;
  119576. /**
  119577. * Defines if the clear coat is enabled in the material.
  119578. */
  119579. isEnabled: boolean;
  119580. /**
  119581. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  119582. */
  119583. intensity: number;
  119584. /**
  119585. * Defines the clear coat layer roughness.
  119586. */
  119587. roughness: number;
  119588. private _indexOfRefraction;
  119589. /**
  119590. * Defines the index of refraction of the clear coat.
  119591. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119592. * The default fits with a polyurethane material.
  119593. * Changing the default value is more performance intensive.
  119594. */
  119595. indexOfRefraction: number;
  119596. private _texture;
  119597. /**
  119598. * Stores the clear coat values in a texture.
  119599. */
  119600. texture: Nullable<BaseTexture>;
  119601. private _bumpTexture;
  119602. /**
  119603. * Define the clear coat specific bump texture.
  119604. */
  119605. bumpTexture: Nullable<BaseTexture>;
  119606. private _isTintEnabled;
  119607. /**
  119608. * Defines if the clear coat tint is enabled in the material.
  119609. */
  119610. isTintEnabled: boolean;
  119611. /**
  119612. * Defines the clear coat tint of the material.
  119613. * This is only use if tint is enabled
  119614. */
  119615. tintColor: Color3;
  119616. /**
  119617. * Defines the distance at which the tint color should be found in the
  119618. * clear coat media.
  119619. * This is only use if tint is enabled
  119620. */
  119621. tintColorAtDistance: number;
  119622. /**
  119623. * Defines the clear coat layer thickness.
  119624. * This is only use if tint is enabled
  119625. */
  119626. tintThickness: number;
  119627. private _tintTexture;
  119628. /**
  119629. * Stores the clear tint values in a texture.
  119630. * rgb is tint
  119631. * a is a thickness factor
  119632. */
  119633. tintTexture: Nullable<BaseTexture>;
  119634. /** @hidden */
  119635. private _internalMarkAllSubMeshesAsTexturesDirty;
  119636. /** @hidden */
  119637. _markAllSubMeshesAsTexturesDirty(): void;
  119638. /**
  119639. * Instantiate a new istance of clear coat configuration.
  119640. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119641. */
  119642. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119643. /**
  119644. * Gets wehter the submesh is ready to be used or not.
  119645. * @param defines the list of "defines" to update.
  119646. * @param scene defines the scene the material belongs to.
  119647. * @param engine defines the engine the material belongs to.
  119648. * @param disableBumpMap defines wether the material disables bump or not.
  119649. * @returns - boolean indicating that the submesh is ready or not.
  119650. */
  119651. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  119652. /**
  119653. * Checks to see if a texture is used in the material.
  119654. * @param defines the list of "defines" to update.
  119655. * @param scene defines the scene to the material belongs to.
  119656. */
  119657. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  119658. /**
  119659. * Binds the material data.
  119660. * @param uniformBuffer defines the Uniform buffer to fill in.
  119661. * @param scene defines the scene the material belongs to.
  119662. * @param engine defines the engine the material belongs to.
  119663. * @param disableBumpMap defines wether the material disables bump or not.
  119664. * @param isFrozen defines wether the material is frozen or not.
  119665. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  119666. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  119667. */
  119668. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  119669. /**
  119670. * Checks to see if a texture is used in the material.
  119671. * @param texture - Base texture to use.
  119672. * @returns - Boolean specifying if a texture is used in the material.
  119673. */
  119674. hasTexture(texture: BaseTexture): boolean;
  119675. /**
  119676. * Returns an array of the actively used textures.
  119677. * @param activeTextures Array of BaseTextures
  119678. */
  119679. getActiveTextures(activeTextures: BaseTexture[]): void;
  119680. /**
  119681. * Returns the animatable textures.
  119682. * @param animatables Array of animatable textures.
  119683. */
  119684. getAnimatables(animatables: IAnimatable[]): void;
  119685. /**
  119686. * Disposes the resources of the material.
  119687. * @param forceDisposeTextures - Forces the disposal of all textures.
  119688. */
  119689. dispose(forceDisposeTextures?: boolean): void;
  119690. /**
  119691. * Get the current class name of the texture useful for serialization or dynamic coding.
  119692. * @returns "PBRClearCoatConfiguration"
  119693. */
  119694. getClassName(): string;
  119695. /**
  119696. * Add fallbacks to the effect fallbacks list.
  119697. * @param defines defines the Base texture to use.
  119698. * @param fallbacks defines the current fallback list.
  119699. * @param currentRank defines the current fallback rank.
  119700. * @returns the new fallback rank.
  119701. */
  119702. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119703. /**
  119704. * Add the required uniforms to the current list.
  119705. * @param uniforms defines the current uniform list.
  119706. */
  119707. static AddUniforms(uniforms: string[]): void;
  119708. /**
  119709. * Add the required samplers to the current list.
  119710. * @param samplers defines the current sampler list.
  119711. */
  119712. static AddSamplers(samplers: string[]): void;
  119713. /**
  119714. * Add the required uniforms to the current buffer.
  119715. * @param uniformBuffer defines the current uniform buffer.
  119716. */
  119717. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119718. /**
  119719. * Makes a duplicate of the current configuration into another one.
  119720. * @param clearCoatConfiguration define the config where to copy the info
  119721. */
  119722. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  119723. /**
  119724. * Serializes this clear coat configuration.
  119725. * @returns - An object with the serialized config.
  119726. */
  119727. serialize(): any;
  119728. /**
  119729. * Parses a anisotropy Configuration from a serialized object.
  119730. * @param source - Serialized object.
  119731. * @param scene Defines the scene we are parsing for
  119732. * @param rootUrl Defines the rootUrl to load from
  119733. */
  119734. parse(source: any, scene: Scene, rootUrl: string): void;
  119735. }
  119736. }
  119737. declare module BABYLON {
  119738. /**
  119739. * @hidden
  119740. */
  119741. export interface IMaterialAnisotropicDefines {
  119742. ANISOTROPIC: boolean;
  119743. ANISOTROPIC_TEXTURE: boolean;
  119744. ANISOTROPIC_TEXTUREDIRECTUV: number;
  119745. MAINUV1: boolean;
  119746. _areTexturesDirty: boolean;
  119747. _needUVs: boolean;
  119748. }
  119749. /**
  119750. * Define the code related to the anisotropic parameters of the pbr material.
  119751. */
  119752. export class PBRAnisotropicConfiguration {
  119753. private _isEnabled;
  119754. /**
  119755. * Defines if the anisotropy is enabled in the material.
  119756. */
  119757. isEnabled: boolean;
  119758. /**
  119759. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  119760. */
  119761. intensity: number;
  119762. /**
  119763. * Defines if the effect is along the tangents, bitangents or in between.
  119764. * By default, the effect is "strectching" the highlights along the tangents.
  119765. */
  119766. direction: Vector2;
  119767. private _texture;
  119768. /**
  119769. * Stores the anisotropy values in a texture.
  119770. * rg is direction (like normal from -1 to 1)
  119771. * b is a intensity
  119772. */
  119773. texture: Nullable<BaseTexture>;
  119774. /** @hidden */
  119775. private _internalMarkAllSubMeshesAsTexturesDirty;
  119776. /** @hidden */
  119777. _markAllSubMeshesAsTexturesDirty(): void;
  119778. /**
  119779. * Instantiate a new istance of anisotropy configuration.
  119780. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119781. */
  119782. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119783. /**
  119784. * Specifies that the submesh is ready to be used.
  119785. * @param defines the list of "defines" to update.
  119786. * @param scene defines the scene the material belongs to.
  119787. * @returns - boolean indicating that the submesh is ready or not.
  119788. */
  119789. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  119790. /**
  119791. * Checks to see if a texture is used in the material.
  119792. * @param defines the list of "defines" to update.
  119793. * @param mesh the mesh we are preparing the defines for.
  119794. * @param scene defines the scene the material belongs to.
  119795. */
  119796. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  119797. /**
  119798. * Binds the material data.
  119799. * @param uniformBuffer defines the Uniform buffer to fill in.
  119800. * @param scene defines the scene the material belongs to.
  119801. * @param isFrozen defines wether the material is frozen or not.
  119802. */
  119803. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119804. /**
  119805. * Checks to see if a texture is used in the material.
  119806. * @param texture - Base texture to use.
  119807. * @returns - Boolean specifying if a texture is used in the material.
  119808. */
  119809. hasTexture(texture: BaseTexture): boolean;
  119810. /**
  119811. * Returns an array of the actively used textures.
  119812. * @param activeTextures Array of BaseTextures
  119813. */
  119814. getActiveTextures(activeTextures: BaseTexture[]): void;
  119815. /**
  119816. * Returns the animatable textures.
  119817. * @param animatables Array of animatable textures.
  119818. */
  119819. getAnimatables(animatables: IAnimatable[]): void;
  119820. /**
  119821. * Disposes the resources of the material.
  119822. * @param forceDisposeTextures - Forces the disposal of all textures.
  119823. */
  119824. dispose(forceDisposeTextures?: boolean): void;
  119825. /**
  119826. * Get the current class name of the texture useful for serialization or dynamic coding.
  119827. * @returns "PBRAnisotropicConfiguration"
  119828. */
  119829. getClassName(): string;
  119830. /**
  119831. * Add fallbacks to the effect fallbacks list.
  119832. * @param defines defines the Base texture to use.
  119833. * @param fallbacks defines the current fallback list.
  119834. * @param currentRank defines the current fallback rank.
  119835. * @returns the new fallback rank.
  119836. */
  119837. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119838. /**
  119839. * Add the required uniforms to the current list.
  119840. * @param uniforms defines the current uniform list.
  119841. */
  119842. static AddUniforms(uniforms: string[]): void;
  119843. /**
  119844. * Add the required uniforms to the current buffer.
  119845. * @param uniformBuffer defines the current uniform buffer.
  119846. */
  119847. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119848. /**
  119849. * Add the required samplers to the current list.
  119850. * @param samplers defines the current sampler list.
  119851. */
  119852. static AddSamplers(samplers: string[]): void;
  119853. /**
  119854. * Makes a duplicate of the current configuration into another one.
  119855. * @param anisotropicConfiguration define the config where to copy the info
  119856. */
  119857. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  119858. /**
  119859. * Serializes this anisotropy configuration.
  119860. * @returns - An object with the serialized config.
  119861. */
  119862. serialize(): any;
  119863. /**
  119864. * Parses a anisotropy Configuration from a serialized object.
  119865. * @param source - Serialized object.
  119866. * @param scene Defines the scene we are parsing for
  119867. * @param rootUrl Defines the rootUrl to load from
  119868. */
  119869. parse(source: any, scene: Scene, rootUrl: string): void;
  119870. }
  119871. }
  119872. declare module BABYLON {
  119873. /**
  119874. * @hidden
  119875. */
  119876. export interface IMaterialBRDFDefines {
  119877. BRDF_V_HEIGHT_CORRELATED: boolean;
  119878. MS_BRDF_ENERGY_CONSERVATION: boolean;
  119879. SPHERICAL_HARMONICS: boolean;
  119880. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  119881. /** @hidden */
  119882. _areMiscDirty: boolean;
  119883. }
  119884. /**
  119885. * Define the code related to the BRDF parameters of the pbr material.
  119886. */
  119887. export class PBRBRDFConfiguration {
  119888. /**
  119889. * Default value used for the energy conservation.
  119890. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119891. */
  119892. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  119893. /**
  119894. * Default value used for the Smith Visibility Height Correlated mode.
  119895. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119896. */
  119897. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  119898. /**
  119899. * Default value used for the IBL diffuse part.
  119900. * This can help switching back to the polynomials mode globally which is a tiny bit
  119901. * less GPU intensive at the drawback of a lower quality.
  119902. */
  119903. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  119904. /**
  119905. * Default value used for activating energy conservation for the specular workflow.
  119906. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119907. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119908. */
  119909. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  119910. private _useEnergyConservation;
  119911. /**
  119912. * Defines if the material uses energy conservation.
  119913. */
  119914. useEnergyConservation: boolean;
  119915. private _useSmithVisibilityHeightCorrelated;
  119916. /**
  119917. * LEGACY Mode set to false
  119918. * Defines if the material uses height smith correlated visibility term.
  119919. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  119920. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  119921. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  119922. * Not relying on height correlated will also disable energy conservation.
  119923. */
  119924. useSmithVisibilityHeightCorrelated: boolean;
  119925. private _useSphericalHarmonics;
  119926. /**
  119927. * LEGACY Mode set to false
  119928. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  119929. * diffuse part of the IBL.
  119930. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  119931. * to the ground truth.
  119932. */
  119933. useSphericalHarmonics: boolean;
  119934. private _useSpecularGlossinessInputEnergyConservation;
  119935. /**
  119936. * Defines if the material uses energy conservation, when the specular workflow is active.
  119937. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119938. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119939. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  119940. */
  119941. useSpecularGlossinessInputEnergyConservation: boolean;
  119942. /** @hidden */
  119943. private _internalMarkAllSubMeshesAsMiscDirty;
  119944. /** @hidden */
  119945. _markAllSubMeshesAsMiscDirty(): void;
  119946. /**
  119947. * Instantiate a new istance of clear coat configuration.
  119948. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  119949. */
  119950. constructor(markAllSubMeshesAsMiscDirty: () => void);
  119951. /**
  119952. * Checks to see if a texture is used in the material.
  119953. * @param defines the list of "defines" to update.
  119954. */
  119955. prepareDefines(defines: IMaterialBRDFDefines): void;
  119956. /**
  119957. * Get the current class name of the texture useful for serialization or dynamic coding.
  119958. * @returns "PBRClearCoatConfiguration"
  119959. */
  119960. getClassName(): string;
  119961. /**
  119962. * Makes a duplicate of the current configuration into another one.
  119963. * @param brdfConfiguration define the config where to copy the info
  119964. */
  119965. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  119966. /**
  119967. * Serializes this BRDF configuration.
  119968. * @returns - An object with the serialized config.
  119969. */
  119970. serialize(): any;
  119971. /**
  119972. * Parses a anisotropy Configuration from a serialized object.
  119973. * @param source - Serialized object.
  119974. * @param scene Defines the scene we are parsing for
  119975. * @param rootUrl Defines the rootUrl to load from
  119976. */
  119977. parse(source: any, scene: Scene, rootUrl: string): void;
  119978. }
  119979. }
  119980. declare module BABYLON {
  119981. /**
  119982. * @hidden
  119983. */
  119984. export interface IMaterialSheenDefines {
  119985. SHEEN: boolean;
  119986. SHEEN_TEXTURE: boolean;
  119987. SHEEN_TEXTUREDIRECTUV: number;
  119988. SHEEN_LINKWITHALBEDO: boolean;
  119989. /** @hidden */
  119990. _areTexturesDirty: boolean;
  119991. }
  119992. /**
  119993. * Define the code related to the Sheen parameters of the pbr material.
  119994. */
  119995. export class PBRSheenConfiguration {
  119996. private _isEnabled;
  119997. /**
  119998. * Defines if the material uses sheen.
  119999. */
  120000. isEnabled: boolean;
  120001. private _linkSheenWithAlbedo;
  120002. /**
  120003. * Defines if the sheen is linked to the sheen color.
  120004. */
  120005. linkSheenWithAlbedo: boolean;
  120006. /**
  120007. * Defines the sheen intensity.
  120008. */
  120009. intensity: number;
  120010. /**
  120011. * Defines the sheen color.
  120012. */
  120013. color: Color3;
  120014. private _texture;
  120015. /**
  120016. * Stores the sheen tint values in a texture.
  120017. * rgb is tint
  120018. * a is a intensity
  120019. */
  120020. texture: Nullable<BaseTexture>;
  120021. /** @hidden */
  120022. private _internalMarkAllSubMeshesAsTexturesDirty;
  120023. /** @hidden */
  120024. _markAllSubMeshesAsTexturesDirty(): void;
  120025. /**
  120026. * Instantiate a new istance of clear coat configuration.
  120027. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  120028. */
  120029. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  120030. /**
  120031. * Specifies that the submesh is ready to be used.
  120032. * @param defines the list of "defines" to update.
  120033. * @param scene defines the scene the material belongs to.
  120034. * @returns - boolean indicating that the submesh is ready or not.
  120035. */
  120036. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  120037. /**
  120038. * Checks to see if a texture is used in the material.
  120039. * @param defines the list of "defines" to update.
  120040. * @param scene defines the scene the material belongs to.
  120041. */
  120042. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  120043. /**
  120044. * Binds the material data.
  120045. * @param uniformBuffer defines the Uniform buffer to fill in.
  120046. * @param scene defines the scene the material belongs to.
  120047. * @param isFrozen defines wether the material is frozen or not.
  120048. */
  120049. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  120050. /**
  120051. * Checks to see if a texture is used in the material.
  120052. * @param texture - Base texture to use.
  120053. * @returns - Boolean specifying if a texture is used in the material.
  120054. */
  120055. hasTexture(texture: BaseTexture): boolean;
  120056. /**
  120057. * Returns an array of the actively used textures.
  120058. * @param activeTextures Array of BaseTextures
  120059. */
  120060. getActiveTextures(activeTextures: BaseTexture[]): void;
  120061. /**
  120062. * Returns the animatable textures.
  120063. * @param animatables Array of animatable textures.
  120064. */
  120065. getAnimatables(animatables: IAnimatable[]): void;
  120066. /**
  120067. * Disposes the resources of the material.
  120068. * @param forceDisposeTextures - Forces the disposal of all textures.
  120069. */
  120070. dispose(forceDisposeTextures?: boolean): void;
  120071. /**
  120072. * Get the current class name of the texture useful for serialization or dynamic coding.
  120073. * @returns "PBRSheenConfiguration"
  120074. */
  120075. getClassName(): string;
  120076. /**
  120077. * Add fallbacks to the effect fallbacks list.
  120078. * @param defines defines the Base texture to use.
  120079. * @param fallbacks defines the current fallback list.
  120080. * @param currentRank defines the current fallback rank.
  120081. * @returns the new fallback rank.
  120082. */
  120083. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  120084. /**
  120085. * Add the required uniforms to the current list.
  120086. * @param uniforms defines the current uniform list.
  120087. */
  120088. static AddUniforms(uniforms: string[]): void;
  120089. /**
  120090. * Add the required uniforms to the current buffer.
  120091. * @param uniformBuffer defines the current uniform buffer.
  120092. */
  120093. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  120094. /**
  120095. * Add the required samplers to the current list.
  120096. * @param samplers defines the current sampler list.
  120097. */
  120098. static AddSamplers(samplers: string[]): void;
  120099. /**
  120100. * Makes a duplicate of the current configuration into another one.
  120101. * @param sheenConfiguration define the config where to copy the info
  120102. */
  120103. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  120104. /**
  120105. * Serializes this BRDF configuration.
  120106. * @returns - An object with the serialized config.
  120107. */
  120108. serialize(): any;
  120109. /**
  120110. * Parses a anisotropy Configuration from a serialized object.
  120111. * @param source - Serialized object.
  120112. * @param scene Defines the scene we are parsing for
  120113. * @param rootUrl Defines the rootUrl to load from
  120114. */
  120115. parse(source: any, scene: Scene, rootUrl: string): void;
  120116. }
  120117. }
  120118. declare module BABYLON {
  120119. /**
  120120. * @hidden
  120121. */
  120122. export interface IMaterialSubSurfaceDefines {
  120123. SUBSURFACE: boolean;
  120124. SS_REFRACTION: boolean;
  120125. SS_TRANSLUCENCY: boolean;
  120126. SS_SCATERRING: boolean;
  120127. SS_THICKNESSANDMASK_TEXTURE: boolean;
  120128. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  120129. SS_REFRACTIONMAP_3D: boolean;
  120130. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  120131. SS_LODINREFRACTIONALPHA: boolean;
  120132. SS_GAMMAREFRACTION: boolean;
  120133. SS_RGBDREFRACTION: boolean;
  120134. SS_LINEARSPECULARREFRACTION: boolean;
  120135. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  120136. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  120137. /** @hidden */
  120138. _areTexturesDirty: boolean;
  120139. }
  120140. /**
  120141. * Define the code related to the sub surface parameters of the pbr material.
  120142. */
  120143. export class PBRSubSurfaceConfiguration {
  120144. private _isRefractionEnabled;
  120145. /**
  120146. * Defines if the refraction is enabled in the material.
  120147. */
  120148. isRefractionEnabled: boolean;
  120149. private _isTranslucencyEnabled;
  120150. /**
  120151. * Defines if the translucency is enabled in the material.
  120152. */
  120153. isTranslucencyEnabled: boolean;
  120154. private _isScatteringEnabled;
  120155. /**
  120156. * Defines the refraction intensity of the material.
  120157. * The refraction when enabled replaces the Diffuse part of the material.
  120158. * The intensity helps transitionning between diffuse and refraction.
  120159. */
  120160. refractionIntensity: number;
  120161. /**
  120162. * Defines the translucency intensity of the material.
  120163. * When translucency has been enabled, this defines how much of the "translucency"
  120164. * is addded to the diffuse part of the material.
  120165. */
  120166. translucencyIntensity: number;
  120167. /**
  120168. * Defines the scattering intensity of the material.
  120169. * When scattering has been enabled, this defines how much of the "scattered light"
  120170. * is addded to the diffuse part of the material.
  120171. */
  120172. scatteringIntensity: number;
  120173. private _thicknessTexture;
  120174. /**
  120175. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  120176. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  120177. * 0 would mean minimumThickness
  120178. * 1 would mean maximumThickness
  120179. * The other channels might be use as a mask to vary the different effects intensity.
  120180. */
  120181. thicknessTexture: Nullable<BaseTexture>;
  120182. private _refractionTexture;
  120183. /**
  120184. * Defines the texture to use for refraction.
  120185. */
  120186. refractionTexture: Nullable<BaseTexture>;
  120187. private _indexOfRefraction;
  120188. /**
  120189. * Defines the index of refraction used in the material.
  120190. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  120191. */
  120192. indexOfRefraction: number;
  120193. private _invertRefractionY;
  120194. /**
  120195. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  120196. */
  120197. invertRefractionY: boolean;
  120198. private _linkRefractionWithTransparency;
  120199. /**
  120200. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  120201. * Materials half opaque for instance using refraction could benefit from this control.
  120202. */
  120203. linkRefractionWithTransparency: boolean;
  120204. /**
  120205. * Defines the minimum thickness stored in the thickness map.
  120206. * If no thickness map is defined, this value will be used to simulate thickness.
  120207. */
  120208. minimumThickness: number;
  120209. /**
  120210. * Defines the maximum thickness stored in the thickness map.
  120211. */
  120212. maximumThickness: number;
  120213. /**
  120214. * Defines the volume tint of the material.
  120215. * This is used for both translucency and scattering.
  120216. */
  120217. tintColor: Color3;
  120218. /**
  120219. * Defines the distance at which the tint color should be found in the media.
  120220. * This is used for refraction only.
  120221. */
  120222. tintColorAtDistance: number;
  120223. /**
  120224. * Defines how far each channel transmit through the media.
  120225. * It is defined as a color to simplify it selection.
  120226. */
  120227. diffusionDistance: Color3;
  120228. private _useMaskFromThicknessTexture;
  120229. /**
  120230. * Stores the intensity of the different subsurface effects in the thickness texture.
  120231. * * the green channel is the translucency intensity.
  120232. * * the blue channel is the scattering intensity.
  120233. * * the alpha channel is the refraction intensity.
  120234. */
  120235. useMaskFromThicknessTexture: boolean;
  120236. /** @hidden */
  120237. private _internalMarkAllSubMeshesAsTexturesDirty;
  120238. /** @hidden */
  120239. _markAllSubMeshesAsTexturesDirty(): void;
  120240. /**
  120241. * Instantiate a new istance of sub surface configuration.
  120242. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  120243. */
  120244. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  120245. /**
  120246. * Gets wehter the submesh is ready to be used or not.
  120247. * @param defines the list of "defines" to update.
  120248. * @param scene defines the scene the material belongs to.
  120249. * @returns - boolean indicating that the submesh is ready or not.
  120250. */
  120251. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  120252. /**
  120253. * Checks to see if a texture is used in the material.
  120254. * @param defines the list of "defines" to update.
  120255. * @param scene defines the scene to the material belongs to.
  120256. */
  120257. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  120258. /**
  120259. * Binds the material data.
  120260. * @param uniformBuffer defines the Uniform buffer to fill in.
  120261. * @param scene defines the scene the material belongs to.
  120262. * @param engine defines the engine the material belongs to.
  120263. * @param isFrozen defines wether the material is frozen or not.
  120264. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  120265. */
  120266. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  120267. /**
  120268. * Unbinds the material from the mesh.
  120269. * @param activeEffect defines the effect that should be unbound from.
  120270. * @returns true if unbound, otherwise false
  120271. */
  120272. unbind(activeEffect: Effect): boolean;
  120273. /**
  120274. * Returns the texture used for refraction or null if none is used.
  120275. * @param scene defines the scene the material belongs to.
  120276. * @returns - Refraction texture if present. If no refraction texture and refraction
  120277. * is linked with transparency, returns environment texture. Otherwise, returns null.
  120278. */
  120279. private _getRefractionTexture;
  120280. /**
  120281. * Returns true if alpha blending should be disabled.
  120282. */
  120283. get disableAlphaBlending(): boolean;
  120284. /**
  120285. * Fills the list of render target textures.
  120286. * @param renderTargets the list of render targets to update
  120287. */
  120288. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  120289. /**
  120290. * Checks to see if a texture is used in the material.
  120291. * @param texture - Base texture to use.
  120292. * @returns - Boolean specifying if a texture is used in the material.
  120293. */
  120294. hasTexture(texture: BaseTexture): boolean;
  120295. /**
  120296. * Gets a boolean indicating that current material needs to register RTT
  120297. * @returns true if this uses a render target otherwise false.
  120298. */
  120299. hasRenderTargetTextures(): boolean;
  120300. /**
  120301. * Returns an array of the actively used textures.
  120302. * @param activeTextures Array of BaseTextures
  120303. */
  120304. getActiveTextures(activeTextures: BaseTexture[]): void;
  120305. /**
  120306. * Returns the animatable textures.
  120307. * @param animatables Array of animatable textures.
  120308. */
  120309. getAnimatables(animatables: IAnimatable[]): void;
  120310. /**
  120311. * Disposes the resources of the material.
  120312. * @param forceDisposeTextures - Forces the disposal of all textures.
  120313. */
  120314. dispose(forceDisposeTextures?: boolean): void;
  120315. /**
  120316. * Get the current class name of the texture useful for serialization or dynamic coding.
  120317. * @returns "PBRSubSurfaceConfiguration"
  120318. */
  120319. getClassName(): string;
  120320. /**
  120321. * Add fallbacks to the effect fallbacks list.
  120322. * @param defines defines the Base texture to use.
  120323. * @param fallbacks defines the current fallback list.
  120324. * @param currentRank defines the current fallback rank.
  120325. * @returns the new fallback rank.
  120326. */
  120327. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  120328. /**
  120329. * Add the required uniforms to the current list.
  120330. * @param uniforms defines the current uniform list.
  120331. */
  120332. static AddUniforms(uniforms: string[]): void;
  120333. /**
  120334. * Add the required samplers to the current list.
  120335. * @param samplers defines the current sampler list.
  120336. */
  120337. static AddSamplers(samplers: string[]): void;
  120338. /**
  120339. * Add the required uniforms to the current buffer.
  120340. * @param uniformBuffer defines the current uniform buffer.
  120341. */
  120342. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  120343. /**
  120344. * Makes a duplicate of the current configuration into another one.
  120345. * @param configuration define the config where to copy the info
  120346. */
  120347. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  120348. /**
  120349. * Serializes this Sub Surface configuration.
  120350. * @returns - An object with the serialized config.
  120351. */
  120352. serialize(): any;
  120353. /**
  120354. * Parses a anisotropy Configuration from a serialized object.
  120355. * @param source - Serialized object.
  120356. * @param scene Defines the scene we are parsing for
  120357. * @param rootUrl Defines the rootUrl to load from
  120358. */
  120359. parse(source: any, scene: Scene, rootUrl: string): void;
  120360. }
  120361. }
  120362. declare module BABYLON {
  120363. /** @hidden */
  120364. export var pbrFragmentDeclaration: {
  120365. name: string;
  120366. shader: string;
  120367. };
  120368. }
  120369. declare module BABYLON {
  120370. /** @hidden */
  120371. export var pbrUboDeclaration: {
  120372. name: string;
  120373. shader: string;
  120374. };
  120375. }
  120376. declare module BABYLON {
  120377. /** @hidden */
  120378. export var pbrFragmentExtraDeclaration: {
  120379. name: string;
  120380. shader: string;
  120381. };
  120382. }
  120383. declare module BABYLON {
  120384. /** @hidden */
  120385. export var pbrFragmentSamplersDeclaration: {
  120386. name: string;
  120387. shader: string;
  120388. };
  120389. }
  120390. declare module BABYLON {
  120391. /** @hidden */
  120392. export var pbrHelperFunctions: {
  120393. name: string;
  120394. shader: string;
  120395. };
  120396. }
  120397. declare module BABYLON {
  120398. /** @hidden */
  120399. export var harmonicsFunctions: {
  120400. name: string;
  120401. shader: string;
  120402. };
  120403. }
  120404. declare module BABYLON {
  120405. /** @hidden */
  120406. export var pbrDirectLightingSetupFunctions: {
  120407. name: string;
  120408. shader: string;
  120409. };
  120410. }
  120411. declare module BABYLON {
  120412. /** @hidden */
  120413. export var pbrDirectLightingFalloffFunctions: {
  120414. name: string;
  120415. shader: string;
  120416. };
  120417. }
  120418. declare module BABYLON {
  120419. /** @hidden */
  120420. export var pbrBRDFFunctions: {
  120421. name: string;
  120422. shader: string;
  120423. };
  120424. }
  120425. declare module BABYLON {
  120426. /** @hidden */
  120427. export var pbrDirectLightingFunctions: {
  120428. name: string;
  120429. shader: string;
  120430. };
  120431. }
  120432. declare module BABYLON {
  120433. /** @hidden */
  120434. export var pbrIBLFunctions: {
  120435. name: string;
  120436. shader: string;
  120437. };
  120438. }
  120439. declare module BABYLON {
  120440. /** @hidden */
  120441. export var pbrDebug: {
  120442. name: string;
  120443. shader: string;
  120444. };
  120445. }
  120446. declare module BABYLON {
  120447. /** @hidden */
  120448. export var pbrPixelShader: {
  120449. name: string;
  120450. shader: string;
  120451. };
  120452. }
  120453. declare module BABYLON {
  120454. /** @hidden */
  120455. export var pbrVertexDeclaration: {
  120456. name: string;
  120457. shader: string;
  120458. };
  120459. }
  120460. declare module BABYLON {
  120461. /** @hidden */
  120462. export var pbrVertexShader: {
  120463. name: string;
  120464. shader: string;
  120465. };
  120466. }
  120467. declare module BABYLON {
  120468. /**
  120469. * Manages the defines for the PBR Material.
  120470. * @hidden
  120471. */
  120472. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  120473. PBR: boolean;
  120474. MAINUV1: boolean;
  120475. MAINUV2: boolean;
  120476. UV1: boolean;
  120477. UV2: boolean;
  120478. ALBEDO: boolean;
  120479. ALBEDODIRECTUV: number;
  120480. VERTEXCOLOR: boolean;
  120481. AMBIENT: boolean;
  120482. AMBIENTDIRECTUV: number;
  120483. AMBIENTINGRAYSCALE: boolean;
  120484. OPACITY: boolean;
  120485. VERTEXALPHA: boolean;
  120486. OPACITYDIRECTUV: number;
  120487. OPACITYRGB: boolean;
  120488. ALPHATEST: boolean;
  120489. DEPTHPREPASS: boolean;
  120490. ALPHABLEND: boolean;
  120491. ALPHAFROMALBEDO: boolean;
  120492. ALPHATESTVALUE: string;
  120493. SPECULAROVERALPHA: boolean;
  120494. RADIANCEOVERALPHA: boolean;
  120495. ALPHAFRESNEL: boolean;
  120496. LINEARALPHAFRESNEL: boolean;
  120497. PREMULTIPLYALPHA: boolean;
  120498. EMISSIVE: boolean;
  120499. EMISSIVEDIRECTUV: number;
  120500. REFLECTIVITY: boolean;
  120501. REFLECTIVITYDIRECTUV: number;
  120502. SPECULARTERM: boolean;
  120503. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  120504. MICROSURFACEAUTOMATIC: boolean;
  120505. LODBASEDMICROSFURACE: boolean;
  120506. MICROSURFACEMAP: boolean;
  120507. MICROSURFACEMAPDIRECTUV: number;
  120508. METALLICWORKFLOW: boolean;
  120509. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  120510. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  120511. METALLNESSSTOREINMETALMAPBLUE: boolean;
  120512. AOSTOREINMETALMAPRED: boolean;
  120513. METALLICF0FACTORFROMMETALLICMAP: boolean;
  120514. ENVIRONMENTBRDF: boolean;
  120515. ENVIRONMENTBRDF_RGBD: boolean;
  120516. NORMAL: boolean;
  120517. TANGENT: boolean;
  120518. BUMP: boolean;
  120519. BUMPDIRECTUV: number;
  120520. OBJECTSPACE_NORMALMAP: boolean;
  120521. PARALLAX: boolean;
  120522. PARALLAXOCCLUSION: boolean;
  120523. NORMALXYSCALE: boolean;
  120524. LIGHTMAP: boolean;
  120525. LIGHTMAPDIRECTUV: number;
  120526. USELIGHTMAPASSHADOWMAP: boolean;
  120527. GAMMALIGHTMAP: boolean;
  120528. RGBDLIGHTMAP: boolean;
  120529. REFLECTION: boolean;
  120530. REFLECTIONMAP_3D: boolean;
  120531. REFLECTIONMAP_SPHERICAL: boolean;
  120532. REFLECTIONMAP_PLANAR: boolean;
  120533. REFLECTIONMAP_CUBIC: boolean;
  120534. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  120535. REFLECTIONMAP_PROJECTION: boolean;
  120536. REFLECTIONMAP_SKYBOX: boolean;
  120537. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  120538. REFLECTIONMAP_EXPLICIT: boolean;
  120539. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  120540. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  120541. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  120542. INVERTCUBICMAP: boolean;
  120543. USESPHERICALFROMREFLECTIONMAP: boolean;
  120544. USEIRRADIANCEMAP: boolean;
  120545. SPHERICAL_HARMONICS: boolean;
  120546. USESPHERICALINVERTEX: boolean;
  120547. REFLECTIONMAP_OPPOSITEZ: boolean;
  120548. LODINREFLECTIONALPHA: boolean;
  120549. GAMMAREFLECTION: boolean;
  120550. RGBDREFLECTION: boolean;
  120551. LINEARSPECULARREFLECTION: boolean;
  120552. RADIANCEOCCLUSION: boolean;
  120553. HORIZONOCCLUSION: boolean;
  120554. INSTANCES: boolean;
  120555. NUM_BONE_INFLUENCERS: number;
  120556. BonesPerMesh: number;
  120557. BONETEXTURE: boolean;
  120558. NONUNIFORMSCALING: boolean;
  120559. MORPHTARGETS: boolean;
  120560. MORPHTARGETS_NORMAL: boolean;
  120561. MORPHTARGETS_TANGENT: boolean;
  120562. MORPHTARGETS_UV: boolean;
  120563. NUM_MORPH_INFLUENCERS: number;
  120564. IMAGEPROCESSING: boolean;
  120565. VIGNETTE: boolean;
  120566. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120567. VIGNETTEBLENDMODEOPAQUE: boolean;
  120568. TONEMAPPING: boolean;
  120569. TONEMAPPING_ACES: boolean;
  120570. CONTRAST: boolean;
  120571. COLORCURVES: boolean;
  120572. COLORGRADING: boolean;
  120573. COLORGRADING3D: boolean;
  120574. SAMPLER3DGREENDEPTH: boolean;
  120575. SAMPLER3DBGRMAP: boolean;
  120576. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120577. EXPOSURE: boolean;
  120578. MULTIVIEW: boolean;
  120579. USEPHYSICALLIGHTFALLOFF: boolean;
  120580. USEGLTFLIGHTFALLOFF: boolean;
  120581. TWOSIDEDLIGHTING: boolean;
  120582. SHADOWFLOAT: boolean;
  120583. CLIPPLANE: boolean;
  120584. CLIPPLANE2: boolean;
  120585. CLIPPLANE3: boolean;
  120586. CLIPPLANE4: boolean;
  120587. CLIPPLANE5: boolean;
  120588. CLIPPLANE6: boolean;
  120589. POINTSIZE: boolean;
  120590. FOG: boolean;
  120591. LOGARITHMICDEPTH: boolean;
  120592. FORCENORMALFORWARD: boolean;
  120593. SPECULARAA: boolean;
  120594. CLEARCOAT: boolean;
  120595. CLEARCOAT_DEFAULTIOR: boolean;
  120596. CLEARCOAT_TEXTURE: boolean;
  120597. CLEARCOAT_TEXTUREDIRECTUV: number;
  120598. CLEARCOAT_BUMP: boolean;
  120599. CLEARCOAT_BUMPDIRECTUV: number;
  120600. CLEARCOAT_TINT: boolean;
  120601. CLEARCOAT_TINT_TEXTURE: boolean;
  120602. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  120603. ANISOTROPIC: boolean;
  120604. ANISOTROPIC_TEXTURE: boolean;
  120605. ANISOTROPIC_TEXTUREDIRECTUV: number;
  120606. BRDF_V_HEIGHT_CORRELATED: boolean;
  120607. MS_BRDF_ENERGY_CONSERVATION: boolean;
  120608. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  120609. SHEEN: boolean;
  120610. SHEEN_TEXTURE: boolean;
  120611. SHEEN_TEXTUREDIRECTUV: number;
  120612. SHEEN_LINKWITHALBEDO: boolean;
  120613. SUBSURFACE: boolean;
  120614. SS_REFRACTION: boolean;
  120615. SS_TRANSLUCENCY: boolean;
  120616. SS_SCATERRING: boolean;
  120617. SS_THICKNESSANDMASK_TEXTURE: boolean;
  120618. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  120619. SS_REFRACTIONMAP_3D: boolean;
  120620. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  120621. SS_LODINREFRACTIONALPHA: boolean;
  120622. SS_GAMMAREFRACTION: boolean;
  120623. SS_RGBDREFRACTION: boolean;
  120624. SS_LINEARSPECULARREFRACTION: boolean;
  120625. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  120626. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  120627. UNLIT: boolean;
  120628. DEBUGMODE: number;
  120629. /**
  120630. * Initializes the PBR Material defines.
  120631. */
  120632. constructor();
  120633. /**
  120634. * Resets the PBR Material defines.
  120635. */
  120636. reset(): void;
  120637. }
  120638. /**
  120639. * The Physically based material base class of BJS.
  120640. *
  120641. * This offers the main features of a standard PBR material.
  120642. * For more information, please refer to the documentation :
  120643. * https://doc.babylonjs.com/how_to/physically_based_rendering
  120644. */
  120645. export abstract class PBRBaseMaterial extends PushMaterial {
  120646. /**
  120647. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  120648. */
  120649. static readonly PBRMATERIAL_OPAQUE: number;
  120650. /**
  120651. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  120652. */
  120653. static readonly PBRMATERIAL_ALPHATEST: number;
  120654. /**
  120655. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120656. */
  120657. static readonly PBRMATERIAL_ALPHABLEND: number;
  120658. /**
  120659. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120660. * They are also discarded below the alpha cutoff threshold to improve performances.
  120661. */
  120662. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  120663. /**
  120664. * Defines the default value of how much AO map is occluding the analytical lights
  120665. * (point spot...).
  120666. */
  120667. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  120668. /**
  120669. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  120670. */
  120671. static readonly LIGHTFALLOFF_PHYSICAL: number;
  120672. /**
  120673. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  120674. * to enhance interoperability with other engines.
  120675. */
  120676. static readonly LIGHTFALLOFF_GLTF: number;
  120677. /**
  120678. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  120679. * to enhance interoperability with other materials.
  120680. */
  120681. static readonly LIGHTFALLOFF_STANDARD: number;
  120682. /**
  120683. * Intensity of the direct lights e.g. the four lights available in your scene.
  120684. * This impacts both the direct diffuse and specular highlights.
  120685. */
  120686. protected _directIntensity: number;
  120687. /**
  120688. * Intensity of the emissive part of the material.
  120689. * This helps controlling the emissive effect without modifying the emissive color.
  120690. */
  120691. protected _emissiveIntensity: number;
  120692. /**
  120693. * Intensity of the environment e.g. how much the environment will light the object
  120694. * either through harmonics for rough material or through the refelction for shiny ones.
  120695. */
  120696. protected _environmentIntensity: number;
  120697. /**
  120698. * This is a special control allowing the reduction of the specular highlights coming from the
  120699. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  120700. */
  120701. protected _specularIntensity: number;
  120702. /**
  120703. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  120704. */
  120705. private _lightingInfos;
  120706. /**
  120707. * Debug Control allowing disabling the bump map on this material.
  120708. */
  120709. protected _disableBumpMap: boolean;
  120710. /**
  120711. * AKA Diffuse Texture in standard nomenclature.
  120712. */
  120713. protected _albedoTexture: Nullable<BaseTexture>;
  120714. /**
  120715. * AKA Occlusion Texture in other nomenclature.
  120716. */
  120717. protected _ambientTexture: Nullable<BaseTexture>;
  120718. /**
  120719. * AKA Occlusion Texture Intensity in other nomenclature.
  120720. */
  120721. protected _ambientTextureStrength: number;
  120722. /**
  120723. * Defines how much the AO map is occluding the analytical lights (point spot...).
  120724. * 1 means it completely occludes it
  120725. * 0 mean it has no impact
  120726. */
  120727. protected _ambientTextureImpactOnAnalyticalLights: number;
  120728. /**
  120729. * Stores the alpha values in a texture.
  120730. */
  120731. protected _opacityTexture: Nullable<BaseTexture>;
  120732. /**
  120733. * Stores the reflection values in a texture.
  120734. */
  120735. protected _reflectionTexture: Nullable<BaseTexture>;
  120736. /**
  120737. * Stores the emissive values in a texture.
  120738. */
  120739. protected _emissiveTexture: Nullable<BaseTexture>;
  120740. /**
  120741. * AKA Specular texture in other nomenclature.
  120742. */
  120743. protected _reflectivityTexture: Nullable<BaseTexture>;
  120744. /**
  120745. * Used to switch from specular/glossiness to metallic/roughness workflow.
  120746. */
  120747. protected _metallicTexture: Nullable<BaseTexture>;
  120748. /**
  120749. * Specifies the metallic scalar of the metallic/roughness workflow.
  120750. * Can also be used to scale the metalness values of the metallic texture.
  120751. */
  120752. protected _metallic: Nullable<number>;
  120753. /**
  120754. * Specifies the roughness scalar of the metallic/roughness workflow.
  120755. * Can also be used to scale the roughness values of the metallic texture.
  120756. */
  120757. protected _roughness: Nullable<number>;
  120758. /**
  120759. * Specifies the an F0 factor to help configuring the material F0.
  120760. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  120761. * to 0.5 the previously hard coded value stays the same.
  120762. * Can also be used to scale the F0 values of the metallic texture.
  120763. */
  120764. protected _metallicF0Factor: number;
  120765. /**
  120766. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  120767. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  120768. * your expectation as it multiplies with the texture data.
  120769. */
  120770. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  120771. /**
  120772. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  120773. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  120774. */
  120775. protected _microSurfaceTexture: Nullable<BaseTexture>;
  120776. /**
  120777. * Stores surface normal data used to displace a mesh in a texture.
  120778. */
  120779. protected _bumpTexture: Nullable<BaseTexture>;
  120780. /**
  120781. * Stores the pre-calculated light information of a mesh in a texture.
  120782. */
  120783. protected _lightmapTexture: Nullable<BaseTexture>;
  120784. /**
  120785. * The color of a material in ambient lighting.
  120786. */
  120787. protected _ambientColor: Color3;
  120788. /**
  120789. * AKA Diffuse Color in other nomenclature.
  120790. */
  120791. protected _albedoColor: Color3;
  120792. /**
  120793. * AKA Specular Color in other nomenclature.
  120794. */
  120795. protected _reflectivityColor: Color3;
  120796. /**
  120797. * The color applied when light is reflected from a material.
  120798. */
  120799. protected _reflectionColor: Color3;
  120800. /**
  120801. * The color applied when light is emitted from a material.
  120802. */
  120803. protected _emissiveColor: Color3;
  120804. /**
  120805. * AKA Glossiness in other nomenclature.
  120806. */
  120807. protected _microSurface: number;
  120808. /**
  120809. * Specifies that the material will use the light map as a show map.
  120810. */
  120811. protected _useLightmapAsShadowmap: boolean;
  120812. /**
  120813. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  120814. * makes the reflect vector face the model (under horizon).
  120815. */
  120816. protected _useHorizonOcclusion: boolean;
  120817. /**
  120818. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  120819. * too much the area relying on ambient texture to define their ambient occlusion.
  120820. */
  120821. protected _useRadianceOcclusion: boolean;
  120822. /**
  120823. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  120824. */
  120825. protected _useAlphaFromAlbedoTexture: boolean;
  120826. /**
  120827. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  120828. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  120829. */
  120830. protected _useSpecularOverAlpha: boolean;
  120831. /**
  120832. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  120833. */
  120834. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  120835. /**
  120836. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  120837. */
  120838. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  120839. /**
  120840. * Specifies if the metallic texture contains the roughness information in its green channel.
  120841. */
  120842. protected _useRoughnessFromMetallicTextureGreen: boolean;
  120843. /**
  120844. * Specifies if the metallic texture contains the metallness information in its blue channel.
  120845. */
  120846. protected _useMetallnessFromMetallicTextureBlue: boolean;
  120847. /**
  120848. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  120849. */
  120850. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  120851. /**
  120852. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  120853. */
  120854. protected _useAmbientInGrayScale: boolean;
  120855. /**
  120856. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  120857. * The material will try to infer what glossiness each pixel should be.
  120858. */
  120859. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  120860. /**
  120861. * Defines the falloff type used in this material.
  120862. * It by default is Physical.
  120863. */
  120864. protected _lightFalloff: number;
  120865. /**
  120866. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  120867. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  120868. */
  120869. protected _useRadianceOverAlpha: boolean;
  120870. /**
  120871. * Allows using an object space normal map (instead of tangent space).
  120872. */
  120873. protected _useObjectSpaceNormalMap: boolean;
  120874. /**
  120875. * Allows using the bump map in parallax mode.
  120876. */
  120877. protected _useParallax: boolean;
  120878. /**
  120879. * Allows using the bump map in parallax occlusion mode.
  120880. */
  120881. protected _useParallaxOcclusion: boolean;
  120882. /**
  120883. * Controls the scale bias of the parallax mode.
  120884. */
  120885. protected _parallaxScaleBias: number;
  120886. /**
  120887. * If sets to true, disables all the lights affecting the material.
  120888. */
  120889. protected _disableLighting: boolean;
  120890. /**
  120891. * Number of Simultaneous lights allowed on the material.
  120892. */
  120893. protected _maxSimultaneousLights: number;
  120894. /**
  120895. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  120896. */
  120897. protected _invertNormalMapX: boolean;
  120898. /**
  120899. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  120900. */
  120901. protected _invertNormalMapY: boolean;
  120902. /**
  120903. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120904. */
  120905. protected _twoSidedLighting: boolean;
  120906. /**
  120907. * Defines the alpha limits in alpha test mode.
  120908. */
  120909. protected _alphaCutOff: number;
  120910. /**
  120911. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  120912. */
  120913. protected _forceAlphaTest: boolean;
  120914. /**
  120915. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120916. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  120917. */
  120918. protected _useAlphaFresnel: boolean;
  120919. /**
  120920. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120921. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  120922. */
  120923. protected _useLinearAlphaFresnel: boolean;
  120924. /**
  120925. * The transparency mode of the material.
  120926. */
  120927. protected _transparencyMode: Nullable<number>;
  120928. /**
  120929. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  120930. * from cos thetav and roughness:
  120931. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  120932. */
  120933. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  120934. /**
  120935. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  120936. */
  120937. protected _forceIrradianceInFragment: boolean;
  120938. /**
  120939. * Force normal to face away from face.
  120940. */
  120941. protected _forceNormalForward: boolean;
  120942. /**
  120943. * Enables specular anti aliasing in the PBR shader.
  120944. * It will both interacts on the Geometry for analytical and IBL lighting.
  120945. * It also prefilter the roughness map based on the bump values.
  120946. */
  120947. protected _enableSpecularAntiAliasing: boolean;
  120948. /**
  120949. * Default configuration related to image processing available in the PBR Material.
  120950. */
  120951. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120952. /**
  120953. * Keep track of the image processing observer to allow dispose and replace.
  120954. */
  120955. private _imageProcessingObserver;
  120956. /**
  120957. * Attaches a new image processing configuration to the PBR Material.
  120958. * @param configuration
  120959. */
  120960. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120961. /**
  120962. * Stores the available render targets.
  120963. */
  120964. private _renderTargets;
  120965. /**
  120966. * Sets the global ambient color for the material used in lighting calculations.
  120967. */
  120968. private _globalAmbientColor;
  120969. /**
  120970. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  120971. */
  120972. private _useLogarithmicDepth;
  120973. /**
  120974. * If set to true, no lighting calculations will be applied.
  120975. */
  120976. private _unlit;
  120977. private _debugMode;
  120978. /**
  120979. * @hidden
  120980. * This is reserved for the inspector.
  120981. * Defines the material debug mode.
  120982. * It helps seeing only some components of the material while troubleshooting.
  120983. */
  120984. debugMode: number;
  120985. /**
  120986. * @hidden
  120987. * This is reserved for the inspector.
  120988. * Specify from where on screen the debug mode should start.
  120989. * The value goes from -1 (full screen) to 1 (not visible)
  120990. * It helps with side by side comparison against the final render
  120991. * This defaults to -1
  120992. */
  120993. private debugLimit;
  120994. /**
  120995. * @hidden
  120996. * This is reserved for the inspector.
  120997. * As the default viewing range might not be enough (if the ambient is really small for instance)
  120998. * You can use the factor to better multiply the final value.
  120999. */
  121000. private debugFactor;
  121001. /**
  121002. * Defines the clear coat layer parameters for the material.
  121003. */
  121004. readonly clearCoat: PBRClearCoatConfiguration;
  121005. /**
  121006. * Defines the anisotropic parameters for the material.
  121007. */
  121008. readonly anisotropy: PBRAnisotropicConfiguration;
  121009. /**
  121010. * Defines the BRDF parameters for the material.
  121011. */
  121012. readonly brdf: PBRBRDFConfiguration;
  121013. /**
  121014. * Defines the Sheen parameters for the material.
  121015. */
  121016. readonly sheen: PBRSheenConfiguration;
  121017. /**
  121018. * Defines the SubSurface parameters for the material.
  121019. */
  121020. readonly subSurface: PBRSubSurfaceConfiguration;
  121021. /**
  121022. * Custom callback helping to override the default shader used in the material.
  121023. */
  121024. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  121025. protected _rebuildInParallel: boolean;
  121026. /**
  121027. * Instantiates a new PBRMaterial instance.
  121028. *
  121029. * @param name The material name
  121030. * @param scene The scene the material will be use in.
  121031. */
  121032. constructor(name: string, scene: Scene);
  121033. /**
  121034. * Gets a boolean indicating that current material needs to register RTT
  121035. */
  121036. get hasRenderTargetTextures(): boolean;
  121037. /**
  121038. * Gets the name of the material class.
  121039. */
  121040. getClassName(): string;
  121041. /**
  121042. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  121043. */
  121044. get useLogarithmicDepth(): boolean;
  121045. /**
  121046. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  121047. */
  121048. set useLogarithmicDepth(value: boolean);
  121049. /**
  121050. * Gets the current transparency mode.
  121051. */
  121052. get transparencyMode(): Nullable<number>;
  121053. /**
  121054. * Sets the transparency mode of the material.
  121055. *
  121056. * | Value | Type | Description |
  121057. * | ----- | ----------------------------------- | ----------- |
  121058. * | 0 | OPAQUE | |
  121059. * | 1 | ALPHATEST | |
  121060. * | 2 | ALPHABLEND | |
  121061. * | 3 | ALPHATESTANDBLEND | |
  121062. *
  121063. */
  121064. set transparencyMode(value: Nullable<number>);
  121065. /**
  121066. * Returns true if alpha blending should be disabled.
  121067. */
  121068. private get _disableAlphaBlending();
  121069. /**
  121070. * Specifies whether or not this material should be rendered in alpha blend mode.
  121071. */
  121072. needAlphaBlending(): boolean;
  121073. /**
  121074. * Specifies if the mesh will require alpha blending.
  121075. * @param mesh - BJS mesh.
  121076. */
  121077. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  121078. /**
  121079. * Specifies whether or not this material should be rendered in alpha test mode.
  121080. */
  121081. needAlphaTesting(): boolean;
  121082. /**
  121083. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  121084. */
  121085. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  121086. /**
  121087. * Gets the texture used for the alpha test.
  121088. */
  121089. getAlphaTestTexture(): Nullable<BaseTexture>;
  121090. /**
  121091. * Specifies that the submesh is ready to be used.
  121092. * @param mesh - BJS mesh.
  121093. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  121094. * @param useInstances - Specifies that instances should be used.
  121095. * @returns - boolean indicating that the submesh is ready or not.
  121096. */
  121097. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121098. /**
  121099. * Specifies if the material uses metallic roughness workflow.
  121100. * @returns boolean specifiying if the material uses metallic roughness workflow.
  121101. */
  121102. isMetallicWorkflow(): boolean;
  121103. private _prepareEffect;
  121104. private _prepareDefines;
  121105. /**
  121106. * Force shader compilation
  121107. */
  121108. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  121109. /**
  121110. * Initializes the uniform buffer layout for the shader.
  121111. */
  121112. buildUniformLayout(): void;
  121113. /**
  121114. * Unbinds the material from the mesh
  121115. */
  121116. unbind(): void;
  121117. /**
  121118. * Binds the submesh data.
  121119. * @param world - The world matrix.
  121120. * @param mesh - The BJS mesh.
  121121. * @param subMesh - A submesh of the BJS mesh.
  121122. */
  121123. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121124. /**
  121125. * Returns the animatable textures.
  121126. * @returns - Array of animatable textures.
  121127. */
  121128. getAnimatables(): IAnimatable[];
  121129. /**
  121130. * Returns the texture used for reflections.
  121131. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  121132. */
  121133. private _getReflectionTexture;
  121134. /**
  121135. * Returns an array of the actively used textures.
  121136. * @returns - Array of BaseTextures
  121137. */
  121138. getActiveTextures(): BaseTexture[];
  121139. /**
  121140. * Checks to see if a texture is used in the material.
  121141. * @param texture - Base texture to use.
  121142. * @returns - Boolean specifying if a texture is used in the material.
  121143. */
  121144. hasTexture(texture: BaseTexture): boolean;
  121145. /**
  121146. * Disposes the resources of the material.
  121147. * @param forceDisposeEffect - Forces the disposal of effects.
  121148. * @param forceDisposeTextures - Forces the disposal of all textures.
  121149. */
  121150. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  121151. }
  121152. }
  121153. declare module BABYLON {
  121154. /**
  121155. * The Physically based material of BJS.
  121156. *
  121157. * This offers the main features of a standard PBR material.
  121158. * For more information, please refer to the documentation :
  121159. * https://doc.babylonjs.com/how_to/physically_based_rendering
  121160. */
  121161. export class PBRMaterial extends PBRBaseMaterial {
  121162. /**
  121163. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  121164. */
  121165. static readonly PBRMATERIAL_OPAQUE: number;
  121166. /**
  121167. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  121168. */
  121169. static readonly PBRMATERIAL_ALPHATEST: number;
  121170. /**
  121171. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  121172. */
  121173. static readonly PBRMATERIAL_ALPHABLEND: number;
  121174. /**
  121175. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  121176. * They are also discarded below the alpha cutoff threshold to improve performances.
  121177. */
  121178. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  121179. /**
  121180. * Defines the default value of how much AO map is occluding the analytical lights
  121181. * (point spot...).
  121182. */
  121183. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  121184. /**
  121185. * Intensity of the direct lights e.g. the four lights available in your scene.
  121186. * This impacts both the direct diffuse and specular highlights.
  121187. */
  121188. directIntensity: number;
  121189. /**
  121190. * Intensity of the emissive part of the material.
  121191. * This helps controlling the emissive effect without modifying the emissive color.
  121192. */
  121193. emissiveIntensity: number;
  121194. /**
  121195. * Intensity of the environment e.g. how much the environment will light the object
  121196. * either through harmonics for rough material or through the refelction for shiny ones.
  121197. */
  121198. environmentIntensity: number;
  121199. /**
  121200. * This is a special control allowing the reduction of the specular highlights coming from the
  121201. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  121202. */
  121203. specularIntensity: number;
  121204. /**
  121205. * Debug Control allowing disabling the bump map on this material.
  121206. */
  121207. disableBumpMap: boolean;
  121208. /**
  121209. * AKA Diffuse Texture in standard nomenclature.
  121210. */
  121211. albedoTexture: BaseTexture;
  121212. /**
  121213. * AKA Occlusion Texture in other nomenclature.
  121214. */
  121215. ambientTexture: BaseTexture;
  121216. /**
  121217. * AKA Occlusion Texture Intensity in other nomenclature.
  121218. */
  121219. ambientTextureStrength: number;
  121220. /**
  121221. * Defines how much the AO map is occluding the analytical lights (point spot...).
  121222. * 1 means it completely occludes it
  121223. * 0 mean it has no impact
  121224. */
  121225. ambientTextureImpactOnAnalyticalLights: number;
  121226. /**
  121227. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  121228. */
  121229. opacityTexture: BaseTexture;
  121230. /**
  121231. * Stores the reflection values in a texture.
  121232. */
  121233. reflectionTexture: Nullable<BaseTexture>;
  121234. /**
  121235. * Stores the emissive values in a texture.
  121236. */
  121237. emissiveTexture: BaseTexture;
  121238. /**
  121239. * AKA Specular texture in other nomenclature.
  121240. */
  121241. reflectivityTexture: BaseTexture;
  121242. /**
  121243. * Used to switch from specular/glossiness to metallic/roughness workflow.
  121244. */
  121245. metallicTexture: BaseTexture;
  121246. /**
  121247. * Specifies the metallic scalar of the metallic/roughness workflow.
  121248. * Can also be used to scale the metalness values of the metallic texture.
  121249. */
  121250. metallic: Nullable<number>;
  121251. /**
  121252. * Specifies the roughness scalar of the metallic/roughness workflow.
  121253. * Can also be used to scale the roughness values of the metallic texture.
  121254. */
  121255. roughness: Nullable<number>;
  121256. /**
  121257. * Specifies the an F0 factor to help configuring the material F0.
  121258. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  121259. * to 0.5 the previously hard coded value stays the same.
  121260. * Can also be used to scale the F0 values of the metallic texture.
  121261. */
  121262. metallicF0Factor: number;
  121263. /**
  121264. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  121265. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  121266. * your expectation as it multiplies with the texture data.
  121267. */
  121268. useMetallicF0FactorFromMetallicTexture: boolean;
  121269. /**
  121270. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  121271. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  121272. */
  121273. microSurfaceTexture: BaseTexture;
  121274. /**
  121275. * Stores surface normal data used to displace a mesh in a texture.
  121276. */
  121277. bumpTexture: BaseTexture;
  121278. /**
  121279. * Stores the pre-calculated light information of a mesh in a texture.
  121280. */
  121281. lightmapTexture: BaseTexture;
  121282. /**
  121283. * Stores the refracted light information in a texture.
  121284. */
  121285. get refractionTexture(): Nullable<BaseTexture>;
  121286. set refractionTexture(value: Nullable<BaseTexture>);
  121287. /**
  121288. * The color of a material in ambient lighting.
  121289. */
  121290. ambientColor: Color3;
  121291. /**
  121292. * AKA Diffuse Color in other nomenclature.
  121293. */
  121294. albedoColor: Color3;
  121295. /**
  121296. * AKA Specular Color in other nomenclature.
  121297. */
  121298. reflectivityColor: Color3;
  121299. /**
  121300. * The color reflected from the material.
  121301. */
  121302. reflectionColor: Color3;
  121303. /**
  121304. * The color emitted from the material.
  121305. */
  121306. emissiveColor: Color3;
  121307. /**
  121308. * AKA Glossiness in other nomenclature.
  121309. */
  121310. microSurface: number;
  121311. /**
  121312. * source material index of refraction (IOR)' / 'destination material IOR.
  121313. */
  121314. get indexOfRefraction(): number;
  121315. set indexOfRefraction(value: number);
  121316. /**
  121317. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  121318. */
  121319. get invertRefractionY(): boolean;
  121320. set invertRefractionY(value: boolean);
  121321. /**
  121322. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  121323. * Materials half opaque for instance using refraction could benefit from this control.
  121324. */
  121325. get linkRefractionWithTransparency(): boolean;
  121326. set linkRefractionWithTransparency(value: boolean);
  121327. /**
  121328. * If true, the light map contains occlusion information instead of lighting info.
  121329. */
  121330. useLightmapAsShadowmap: boolean;
  121331. /**
  121332. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  121333. */
  121334. useAlphaFromAlbedoTexture: boolean;
  121335. /**
  121336. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  121337. */
  121338. forceAlphaTest: boolean;
  121339. /**
  121340. * Defines the alpha limits in alpha test mode.
  121341. */
  121342. alphaCutOff: number;
  121343. /**
  121344. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  121345. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  121346. */
  121347. useSpecularOverAlpha: boolean;
  121348. /**
  121349. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  121350. */
  121351. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  121352. /**
  121353. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  121354. */
  121355. useRoughnessFromMetallicTextureAlpha: boolean;
  121356. /**
  121357. * Specifies if the metallic texture contains the roughness information in its green channel.
  121358. */
  121359. useRoughnessFromMetallicTextureGreen: boolean;
  121360. /**
  121361. * Specifies if the metallic texture contains the metallness information in its blue channel.
  121362. */
  121363. useMetallnessFromMetallicTextureBlue: boolean;
  121364. /**
  121365. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  121366. */
  121367. useAmbientOcclusionFromMetallicTextureRed: boolean;
  121368. /**
  121369. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  121370. */
  121371. useAmbientInGrayScale: boolean;
  121372. /**
  121373. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  121374. * The material will try to infer what glossiness each pixel should be.
  121375. */
  121376. useAutoMicroSurfaceFromReflectivityMap: boolean;
  121377. /**
  121378. * BJS is using an harcoded light falloff based on a manually sets up range.
  121379. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121380. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121381. */
  121382. get usePhysicalLightFalloff(): boolean;
  121383. /**
  121384. * BJS is using an harcoded light falloff based on a manually sets up range.
  121385. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121386. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121387. */
  121388. set usePhysicalLightFalloff(value: boolean);
  121389. /**
  121390. * In order to support the falloff compatibility with gltf, a special mode has been added
  121391. * to reproduce the gltf light falloff.
  121392. */
  121393. get useGLTFLightFalloff(): boolean;
  121394. /**
  121395. * In order to support the falloff compatibility with gltf, a special mode has been added
  121396. * to reproduce the gltf light falloff.
  121397. */
  121398. set useGLTFLightFalloff(value: boolean);
  121399. /**
  121400. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  121401. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  121402. */
  121403. useRadianceOverAlpha: boolean;
  121404. /**
  121405. * Allows using an object space normal map (instead of tangent space).
  121406. */
  121407. useObjectSpaceNormalMap: boolean;
  121408. /**
  121409. * Allows using the bump map in parallax mode.
  121410. */
  121411. useParallax: boolean;
  121412. /**
  121413. * Allows using the bump map in parallax occlusion mode.
  121414. */
  121415. useParallaxOcclusion: boolean;
  121416. /**
  121417. * Controls the scale bias of the parallax mode.
  121418. */
  121419. parallaxScaleBias: number;
  121420. /**
  121421. * If sets to true, disables all the lights affecting the material.
  121422. */
  121423. disableLighting: boolean;
  121424. /**
  121425. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  121426. */
  121427. forceIrradianceInFragment: boolean;
  121428. /**
  121429. * Number of Simultaneous lights allowed on the material.
  121430. */
  121431. maxSimultaneousLights: number;
  121432. /**
  121433. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121434. */
  121435. invertNormalMapX: boolean;
  121436. /**
  121437. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121438. */
  121439. invertNormalMapY: boolean;
  121440. /**
  121441. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121442. */
  121443. twoSidedLighting: boolean;
  121444. /**
  121445. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121446. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  121447. */
  121448. useAlphaFresnel: boolean;
  121449. /**
  121450. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121451. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  121452. */
  121453. useLinearAlphaFresnel: boolean;
  121454. /**
  121455. * Let user defines the brdf lookup texture used for IBL.
  121456. * A default 8bit version is embedded but you could point at :
  121457. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  121458. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  121459. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  121460. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  121461. */
  121462. environmentBRDFTexture: Nullable<BaseTexture>;
  121463. /**
  121464. * Force normal to face away from face.
  121465. */
  121466. forceNormalForward: boolean;
  121467. /**
  121468. * Enables specular anti aliasing in the PBR shader.
  121469. * It will both interacts on the Geometry for analytical and IBL lighting.
  121470. * It also prefilter the roughness map based on the bump values.
  121471. */
  121472. enableSpecularAntiAliasing: boolean;
  121473. /**
  121474. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  121475. * makes the reflect vector face the model (under horizon).
  121476. */
  121477. useHorizonOcclusion: boolean;
  121478. /**
  121479. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  121480. * too much the area relying on ambient texture to define their ambient occlusion.
  121481. */
  121482. useRadianceOcclusion: boolean;
  121483. /**
  121484. * If set to true, no lighting calculations will be applied.
  121485. */
  121486. unlit: boolean;
  121487. /**
  121488. * Gets the image processing configuration used either in this material.
  121489. */
  121490. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  121491. /**
  121492. * Sets the Default image processing configuration used either in the this material.
  121493. *
  121494. * If sets to null, the scene one is in use.
  121495. */
  121496. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  121497. /**
  121498. * Gets wether the color curves effect is enabled.
  121499. */
  121500. get cameraColorCurvesEnabled(): boolean;
  121501. /**
  121502. * Sets wether the color curves effect is enabled.
  121503. */
  121504. set cameraColorCurvesEnabled(value: boolean);
  121505. /**
  121506. * Gets wether the color grading effect is enabled.
  121507. */
  121508. get cameraColorGradingEnabled(): boolean;
  121509. /**
  121510. * Gets wether the color grading effect is enabled.
  121511. */
  121512. set cameraColorGradingEnabled(value: boolean);
  121513. /**
  121514. * Gets wether tonemapping is enabled or not.
  121515. */
  121516. get cameraToneMappingEnabled(): boolean;
  121517. /**
  121518. * Sets wether tonemapping is enabled or not
  121519. */
  121520. set cameraToneMappingEnabled(value: boolean);
  121521. /**
  121522. * The camera exposure used on this material.
  121523. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121524. * This corresponds to a photographic exposure.
  121525. */
  121526. get cameraExposure(): number;
  121527. /**
  121528. * The camera exposure used on this material.
  121529. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121530. * This corresponds to a photographic exposure.
  121531. */
  121532. set cameraExposure(value: number);
  121533. /**
  121534. * Gets The camera contrast used on this material.
  121535. */
  121536. get cameraContrast(): number;
  121537. /**
  121538. * Sets The camera contrast used on this material.
  121539. */
  121540. set cameraContrast(value: number);
  121541. /**
  121542. * Gets the Color Grading 2D Lookup Texture.
  121543. */
  121544. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  121545. /**
  121546. * Sets the Color Grading 2D Lookup Texture.
  121547. */
  121548. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  121549. /**
  121550. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121551. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121552. * 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;
  121553. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121554. */
  121555. get cameraColorCurves(): Nullable<ColorCurves>;
  121556. /**
  121557. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121558. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121559. * 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;
  121560. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121561. */
  121562. set cameraColorCurves(value: Nullable<ColorCurves>);
  121563. /**
  121564. * Instantiates a new PBRMaterial instance.
  121565. *
  121566. * @param name The material name
  121567. * @param scene The scene the material will be use in.
  121568. */
  121569. constructor(name: string, scene: Scene);
  121570. /**
  121571. * Returns the name of this material class.
  121572. */
  121573. getClassName(): string;
  121574. /**
  121575. * Makes a duplicate of the current material.
  121576. * @param name - name to use for the new material.
  121577. */
  121578. clone(name: string): PBRMaterial;
  121579. /**
  121580. * Serializes this PBR Material.
  121581. * @returns - An object with the serialized material.
  121582. */
  121583. serialize(): any;
  121584. /**
  121585. * Parses a PBR Material from a serialized object.
  121586. * @param source - Serialized object.
  121587. * @param scene - BJS scene instance.
  121588. * @param rootUrl - url for the scene object
  121589. * @returns - PBRMaterial
  121590. */
  121591. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  121592. }
  121593. }
  121594. declare module BABYLON {
  121595. /**
  121596. * Direct draw surface info
  121597. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  121598. */
  121599. export interface DDSInfo {
  121600. /**
  121601. * Width of the texture
  121602. */
  121603. width: number;
  121604. /**
  121605. * Width of the texture
  121606. */
  121607. height: number;
  121608. /**
  121609. * Number of Mipmaps for the texture
  121610. * @see https://en.wikipedia.org/wiki/Mipmap
  121611. */
  121612. mipmapCount: number;
  121613. /**
  121614. * If the textures format is a known fourCC format
  121615. * @see https://www.fourcc.org/
  121616. */
  121617. isFourCC: boolean;
  121618. /**
  121619. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  121620. */
  121621. isRGB: boolean;
  121622. /**
  121623. * If the texture is a lumincance format
  121624. */
  121625. isLuminance: boolean;
  121626. /**
  121627. * If this is a cube texture
  121628. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  121629. */
  121630. isCube: boolean;
  121631. /**
  121632. * If the texture is a compressed format eg. FOURCC_DXT1
  121633. */
  121634. isCompressed: boolean;
  121635. /**
  121636. * The dxgiFormat of the texture
  121637. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  121638. */
  121639. dxgiFormat: number;
  121640. /**
  121641. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  121642. */
  121643. textureType: number;
  121644. /**
  121645. * Sphericle polynomial created for the dds texture
  121646. */
  121647. sphericalPolynomial?: SphericalPolynomial;
  121648. }
  121649. /**
  121650. * Class used to provide DDS decompression tools
  121651. */
  121652. export class DDSTools {
  121653. /**
  121654. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  121655. */
  121656. static StoreLODInAlphaChannel: boolean;
  121657. /**
  121658. * Gets DDS information from an array buffer
  121659. * @param arrayBuffer defines the array buffer to read data from
  121660. * @returns the DDS information
  121661. */
  121662. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  121663. private static _FloatView;
  121664. private static _Int32View;
  121665. private static _ToHalfFloat;
  121666. private static _FromHalfFloat;
  121667. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  121668. private static _GetHalfFloatRGBAArrayBuffer;
  121669. private static _GetFloatRGBAArrayBuffer;
  121670. private static _GetFloatAsUIntRGBAArrayBuffer;
  121671. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  121672. private static _GetRGBAArrayBuffer;
  121673. private static _ExtractLongWordOrder;
  121674. private static _GetRGBArrayBuffer;
  121675. private static _GetLuminanceArrayBuffer;
  121676. /**
  121677. * Uploads DDS Levels to a Babylon Texture
  121678. * @hidden
  121679. */
  121680. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  121681. }
  121682. interface ThinEngine {
  121683. /**
  121684. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  121685. * @param rootUrl defines the url where the file to load is located
  121686. * @param scene defines the current scene
  121687. * @param lodScale defines scale to apply to the mip map selection
  121688. * @param lodOffset defines offset to apply to the mip map selection
  121689. * @param onLoad defines an optional callback raised when the texture is loaded
  121690. * @param onError defines an optional callback raised if there is an issue to load the texture
  121691. * @param format defines the format of the data
  121692. * @param forcedExtension defines the extension to use to pick the right loader
  121693. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  121694. * @returns the cube texture as an InternalTexture
  121695. */
  121696. 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;
  121697. }
  121698. }
  121699. declare module BABYLON {
  121700. /**
  121701. * Implementation of the DDS Texture Loader.
  121702. * @hidden
  121703. */
  121704. export class _DDSTextureLoader implements IInternalTextureLoader {
  121705. /**
  121706. * Defines wether the loader supports cascade loading the different faces.
  121707. */
  121708. readonly supportCascades: boolean;
  121709. /**
  121710. * This returns if the loader support the current file information.
  121711. * @param extension defines the file extension of the file being loaded
  121712. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121713. * @param fallback defines the fallback internal texture if any
  121714. * @param isBase64 defines whether the texture is encoded as a base64
  121715. * @param isBuffer defines whether the texture data are stored as a buffer
  121716. * @returns true if the loader can load the specified file
  121717. */
  121718. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121719. /**
  121720. * Transform the url before loading if required.
  121721. * @param rootUrl the url of the texture
  121722. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121723. * @returns the transformed texture
  121724. */
  121725. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121726. /**
  121727. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121728. * @param rootUrl the url of the texture
  121729. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121730. * @returns the fallback texture
  121731. */
  121732. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121733. /**
  121734. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121735. * @param data contains the texture data
  121736. * @param texture defines the BabylonJS internal texture
  121737. * @param createPolynomials will be true if polynomials have been requested
  121738. * @param onLoad defines the callback to trigger once the texture is ready
  121739. * @param onError defines the callback to trigger in case of error
  121740. */
  121741. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121742. /**
  121743. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121744. * @param data contains the texture data
  121745. * @param texture defines the BabylonJS internal texture
  121746. * @param callback defines the method to call once ready to upload
  121747. */
  121748. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121749. }
  121750. }
  121751. declare module BABYLON {
  121752. /**
  121753. * Implementation of the ENV Texture Loader.
  121754. * @hidden
  121755. */
  121756. export class _ENVTextureLoader implements IInternalTextureLoader {
  121757. /**
  121758. * Defines wether the loader supports cascade loading the different faces.
  121759. */
  121760. readonly supportCascades: boolean;
  121761. /**
  121762. * This returns if the loader support the current file information.
  121763. * @param extension defines the file extension of the file being loaded
  121764. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121765. * @param fallback defines the fallback internal texture if any
  121766. * @param isBase64 defines whether the texture is encoded as a base64
  121767. * @param isBuffer defines whether the texture data are stored as a buffer
  121768. * @returns true if the loader can load the specified file
  121769. */
  121770. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121771. /**
  121772. * Transform the url before loading if required.
  121773. * @param rootUrl the url of the texture
  121774. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121775. * @returns the transformed texture
  121776. */
  121777. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121778. /**
  121779. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121780. * @param rootUrl the url of the texture
  121781. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121782. * @returns the fallback texture
  121783. */
  121784. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121785. /**
  121786. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121787. * @param data contains the texture data
  121788. * @param texture defines the BabylonJS internal texture
  121789. * @param createPolynomials will be true if polynomials have been requested
  121790. * @param onLoad defines the callback to trigger once the texture is ready
  121791. * @param onError defines the callback to trigger in case of error
  121792. */
  121793. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121794. /**
  121795. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121796. * @param data contains the texture data
  121797. * @param texture defines the BabylonJS internal texture
  121798. * @param callback defines the method to call once ready to upload
  121799. */
  121800. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121801. }
  121802. }
  121803. declare module BABYLON {
  121804. /**
  121805. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121806. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121807. */
  121808. export class KhronosTextureContainer {
  121809. /** contents of the KTX container file */
  121810. arrayBuffer: any;
  121811. private static HEADER_LEN;
  121812. private static COMPRESSED_2D;
  121813. private static COMPRESSED_3D;
  121814. private static TEX_2D;
  121815. private static TEX_3D;
  121816. /**
  121817. * Gets the openGL type
  121818. */
  121819. glType: number;
  121820. /**
  121821. * Gets the openGL type size
  121822. */
  121823. glTypeSize: number;
  121824. /**
  121825. * Gets the openGL format
  121826. */
  121827. glFormat: number;
  121828. /**
  121829. * Gets the openGL internal format
  121830. */
  121831. glInternalFormat: number;
  121832. /**
  121833. * Gets the base internal format
  121834. */
  121835. glBaseInternalFormat: number;
  121836. /**
  121837. * Gets image width in pixel
  121838. */
  121839. pixelWidth: number;
  121840. /**
  121841. * Gets image height in pixel
  121842. */
  121843. pixelHeight: number;
  121844. /**
  121845. * Gets image depth in pixels
  121846. */
  121847. pixelDepth: number;
  121848. /**
  121849. * Gets the number of array elements
  121850. */
  121851. numberOfArrayElements: number;
  121852. /**
  121853. * Gets the number of faces
  121854. */
  121855. numberOfFaces: number;
  121856. /**
  121857. * Gets the number of mipmap levels
  121858. */
  121859. numberOfMipmapLevels: number;
  121860. /**
  121861. * Gets the bytes of key value data
  121862. */
  121863. bytesOfKeyValueData: number;
  121864. /**
  121865. * Gets the load type
  121866. */
  121867. loadType: number;
  121868. /**
  121869. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  121870. */
  121871. isInvalid: boolean;
  121872. /**
  121873. * Creates a new KhronosTextureContainer
  121874. * @param arrayBuffer contents of the KTX container file
  121875. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  121876. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  121877. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  121878. */
  121879. constructor(
  121880. /** contents of the KTX container file */
  121881. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  121882. /**
  121883. * Uploads KTX content to a Babylon Texture.
  121884. * It is assumed that the texture has already been created & is currently bound
  121885. * @hidden
  121886. */
  121887. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  121888. private _upload2DCompressedLevels;
  121889. }
  121890. }
  121891. declare module BABYLON {
  121892. /**
  121893. * Implementation of the KTX Texture Loader.
  121894. * @hidden
  121895. */
  121896. export class _KTXTextureLoader implements IInternalTextureLoader {
  121897. /**
  121898. * Defines wether the loader supports cascade loading the different faces.
  121899. */
  121900. readonly supportCascades: boolean;
  121901. /**
  121902. * This returns if the loader support the current file information.
  121903. * @param extension defines the file extension of the file being loaded
  121904. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121905. * @param fallback defines the fallback internal texture if any
  121906. * @param isBase64 defines whether the texture is encoded as a base64
  121907. * @param isBuffer defines whether the texture data are stored as a buffer
  121908. * @returns true if the loader can load the specified file
  121909. */
  121910. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121911. /**
  121912. * Transform the url before loading if required.
  121913. * @param rootUrl the url of the texture
  121914. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121915. * @returns the transformed texture
  121916. */
  121917. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121918. /**
  121919. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121920. * @param rootUrl the url of the texture
  121921. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121922. * @returns the fallback texture
  121923. */
  121924. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121925. /**
  121926. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121927. * @param data contains the texture data
  121928. * @param texture defines the BabylonJS internal texture
  121929. * @param createPolynomials will be true if polynomials have been requested
  121930. * @param onLoad defines the callback to trigger once the texture is ready
  121931. * @param onError defines the callback to trigger in case of error
  121932. */
  121933. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121934. /**
  121935. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121936. * @param data contains the texture data
  121937. * @param texture defines the BabylonJS internal texture
  121938. * @param callback defines the method to call once ready to upload
  121939. */
  121940. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  121941. }
  121942. }
  121943. declare module BABYLON {
  121944. /** @hidden */
  121945. export var _forceSceneHelpersToBundle: boolean;
  121946. interface Scene {
  121947. /**
  121948. * Creates a default light for the scene.
  121949. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  121950. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  121951. */
  121952. createDefaultLight(replace?: boolean): void;
  121953. /**
  121954. * Creates a default camera for the scene.
  121955. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  121956. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121957. * @param replace has default false, when true replaces the active camera in the scene
  121958. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  121959. */
  121960. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121961. /**
  121962. * Creates a default camera and a default light.
  121963. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  121964. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121965. * @param replace has the default false, when true replaces the active camera/light in the scene
  121966. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  121967. */
  121968. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121969. /**
  121970. * Creates a new sky box
  121971. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  121972. * @param environmentTexture defines the texture to use as environment texture
  121973. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  121974. * @param scale defines the overall scale of the skybox
  121975. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  121976. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  121977. * @returns a new mesh holding the sky box
  121978. */
  121979. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  121980. /**
  121981. * Creates a new environment
  121982. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  121983. * @param options defines the options you can use to configure the environment
  121984. * @returns the new EnvironmentHelper
  121985. */
  121986. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  121987. /**
  121988. * Creates a new VREXperienceHelper
  121989. * @see http://doc.babylonjs.com/how_to/webvr_helper
  121990. * @param webVROptions defines the options used to create the new VREXperienceHelper
  121991. * @returns a new VREXperienceHelper
  121992. */
  121993. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  121994. /**
  121995. * Creates a new WebXRDefaultExperience
  121996. * @see http://doc.babylonjs.com/how_to/webxr
  121997. * @param options experience options
  121998. * @returns a promise for a new WebXRDefaultExperience
  121999. */
  122000. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  122001. }
  122002. }
  122003. declare module BABYLON {
  122004. /**
  122005. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  122006. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  122007. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  122008. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122009. */
  122010. export class VideoDome extends TransformNode {
  122011. /**
  122012. * Define the video source as a Monoscopic panoramic 360 video.
  122013. */
  122014. static readonly MODE_MONOSCOPIC: number;
  122015. /**
  122016. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  122017. */
  122018. static readonly MODE_TOPBOTTOM: number;
  122019. /**
  122020. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  122021. */
  122022. static readonly MODE_SIDEBYSIDE: number;
  122023. private _halfDome;
  122024. private _useDirectMapping;
  122025. /**
  122026. * The video texture being displayed on the sphere
  122027. */
  122028. protected _videoTexture: VideoTexture;
  122029. /**
  122030. * Gets the video texture being displayed on the sphere
  122031. */
  122032. get videoTexture(): VideoTexture;
  122033. /**
  122034. * The skybox material
  122035. */
  122036. protected _material: BackgroundMaterial;
  122037. /**
  122038. * The surface used for the skybox
  122039. */
  122040. protected _mesh: Mesh;
  122041. /**
  122042. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  122043. */
  122044. private _halfDomeMask;
  122045. /**
  122046. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122047. * Also see the options.resolution property.
  122048. */
  122049. get fovMultiplier(): number;
  122050. set fovMultiplier(value: number);
  122051. private _videoMode;
  122052. /**
  122053. * Gets or set the current video mode for the video. It can be:
  122054. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  122055. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  122056. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  122057. */
  122058. get videoMode(): number;
  122059. set videoMode(value: number);
  122060. /**
  122061. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  122062. *
  122063. */
  122064. get halfDome(): boolean;
  122065. /**
  122066. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  122067. */
  122068. set halfDome(enabled: boolean);
  122069. /**
  122070. * Oberserver used in Stereoscopic VR Mode.
  122071. */
  122072. private _onBeforeCameraRenderObserver;
  122073. /**
  122074. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  122075. * @param name Element's name, child elements will append suffixes for their own names.
  122076. * @param urlsOrVideo defines the url(s) or the video element to use
  122077. * @param options An object containing optional or exposed sub element properties
  122078. */
  122079. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  122080. resolution?: number;
  122081. clickToPlay?: boolean;
  122082. autoPlay?: boolean;
  122083. loop?: boolean;
  122084. size?: number;
  122085. poster?: string;
  122086. faceForward?: boolean;
  122087. useDirectMapping?: boolean;
  122088. halfDomeMode?: boolean;
  122089. }, scene: Scene);
  122090. private _changeVideoMode;
  122091. /**
  122092. * Releases resources associated with this node.
  122093. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122094. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122095. */
  122096. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122097. }
  122098. }
  122099. declare module BABYLON {
  122100. /**
  122101. * This class can be used to get instrumentation data from a Babylon engine
  122102. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122103. */
  122104. export class EngineInstrumentation implements IDisposable {
  122105. /**
  122106. * Define the instrumented engine.
  122107. */
  122108. engine: Engine;
  122109. private _captureGPUFrameTime;
  122110. private _gpuFrameTimeToken;
  122111. private _gpuFrameTime;
  122112. private _captureShaderCompilationTime;
  122113. private _shaderCompilationTime;
  122114. private _onBeginFrameObserver;
  122115. private _onEndFrameObserver;
  122116. private _onBeforeShaderCompilationObserver;
  122117. private _onAfterShaderCompilationObserver;
  122118. /**
  122119. * Gets the perf counter used for GPU frame time
  122120. */
  122121. get gpuFrameTimeCounter(): PerfCounter;
  122122. /**
  122123. * Gets the GPU frame time capture status
  122124. */
  122125. get captureGPUFrameTime(): boolean;
  122126. /**
  122127. * Enable or disable the GPU frame time capture
  122128. */
  122129. set captureGPUFrameTime(value: boolean);
  122130. /**
  122131. * Gets the perf counter used for shader compilation time
  122132. */
  122133. get shaderCompilationTimeCounter(): PerfCounter;
  122134. /**
  122135. * Gets the shader compilation time capture status
  122136. */
  122137. get captureShaderCompilationTime(): boolean;
  122138. /**
  122139. * Enable or disable the shader compilation time capture
  122140. */
  122141. set captureShaderCompilationTime(value: boolean);
  122142. /**
  122143. * Instantiates a new engine instrumentation.
  122144. * This class can be used to get instrumentation data from a Babylon engine
  122145. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122146. * @param engine Defines the engine to instrument
  122147. */
  122148. constructor(
  122149. /**
  122150. * Define the instrumented engine.
  122151. */
  122152. engine: Engine);
  122153. /**
  122154. * Dispose and release associated resources.
  122155. */
  122156. dispose(): void;
  122157. }
  122158. }
  122159. declare module BABYLON {
  122160. /**
  122161. * This class can be used to get instrumentation data from a Babylon engine
  122162. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  122163. */
  122164. export class SceneInstrumentation implements IDisposable {
  122165. /**
  122166. * Defines the scene to instrument
  122167. */
  122168. scene: Scene;
  122169. private _captureActiveMeshesEvaluationTime;
  122170. private _activeMeshesEvaluationTime;
  122171. private _captureRenderTargetsRenderTime;
  122172. private _renderTargetsRenderTime;
  122173. private _captureFrameTime;
  122174. private _frameTime;
  122175. private _captureRenderTime;
  122176. private _renderTime;
  122177. private _captureInterFrameTime;
  122178. private _interFrameTime;
  122179. private _captureParticlesRenderTime;
  122180. private _particlesRenderTime;
  122181. private _captureSpritesRenderTime;
  122182. private _spritesRenderTime;
  122183. private _capturePhysicsTime;
  122184. private _physicsTime;
  122185. private _captureAnimationsTime;
  122186. private _animationsTime;
  122187. private _captureCameraRenderTime;
  122188. private _cameraRenderTime;
  122189. private _onBeforeActiveMeshesEvaluationObserver;
  122190. private _onAfterActiveMeshesEvaluationObserver;
  122191. private _onBeforeRenderTargetsRenderObserver;
  122192. private _onAfterRenderTargetsRenderObserver;
  122193. private _onAfterRenderObserver;
  122194. private _onBeforeDrawPhaseObserver;
  122195. private _onAfterDrawPhaseObserver;
  122196. private _onBeforeAnimationsObserver;
  122197. private _onBeforeParticlesRenderingObserver;
  122198. private _onAfterParticlesRenderingObserver;
  122199. private _onBeforeSpritesRenderingObserver;
  122200. private _onAfterSpritesRenderingObserver;
  122201. private _onBeforePhysicsObserver;
  122202. private _onAfterPhysicsObserver;
  122203. private _onAfterAnimationsObserver;
  122204. private _onBeforeCameraRenderObserver;
  122205. private _onAfterCameraRenderObserver;
  122206. /**
  122207. * Gets the perf counter used for active meshes evaluation time
  122208. */
  122209. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  122210. /**
  122211. * Gets the active meshes evaluation time capture status
  122212. */
  122213. get captureActiveMeshesEvaluationTime(): boolean;
  122214. /**
  122215. * Enable or disable the active meshes evaluation time capture
  122216. */
  122217. set captureActiveMeshesEvaluationTime(value: boolean);
  122218. /**
  122219. * Gets the perf counter used for render targets render time
  122220. */
  122221. get renderTargetsRenderTimeCounter(): PerfCounter;
  122222. /**
  122223. * Gets the render targets render time capture status
  122224. */
  122225. get captureRenderTargetsRenderTime(): boolean;
  122226. /**
  122227. * Enable or disable the render targets render time capture
  122228. */
  122229. set captureRenderTargetsRenderTime(value: boolean);
  122230. /**
  122231. * Gets the perf counter used for particles render time
  122232. */
  122233. get particlesRenderTimeCounter(): PerfCounter;
  122234. /**
  122235. * Gets the particles render time capture status
  122236. */
  122237. get captureParticlesRenderTime(): boolean;
  122238. /**
  122239. * Enable or disable the particles render time capture
  122240. */
  122241. set captureParticlesRenderTime(value: boolean);
  122242. /**
  122243. * Gets the perf counter used for sprites render time
  122244. */
  122245. get spritesRenderTimeCounter(): PerfCounter;
  122246. /**
  122247. * Gets the sprites render time capture status
  122248. */
  122249. get captureSpritesRenderTime(): boolean;
  122250. /**
  122251. * Enable or disable the sprites render time capture
  122252. */
  122253. set captureSpritesRenderTime(value: boolean);
  122254. /**
  122255. * Gets the perf counter used for physics time
  122256. */
  122257. get physicsTimeCounter(): PerfCounter;
  122258. /**
  122259. * Gets the physics time capture status
  122260. */
  122261. get capturePhysicsTime(): boolean;
  122262. /**
  122263. * Enable or disable the physics time capture
  122264. */
  122265. set capturePhysicsTime(value: boolean);
  122266. /**
  122267. * Gets the perf counter used for animations time
  122268. */
  122269. get animationsTimeCounter(): PerfCounter;
  122270. /**
  122271. * Gets the animations time capture status
  122272. */
  122273. get captureAnimationsTime(): boolean;
  122274. /**
  122275. * Enable or disable the animations time capture
  122276. */
  122277. set captureAnimationsTime(value: boolean);
  122278. /**
  122279. * Gets the perf counter used for frame time capture
  122280. */
  122281. get frameTimeCounter(): PerfCounter;
  122282. /**
  122283. * Gets the frame time capture status
  122284. */
  122285. get captureFrameTime(): boolean;
  122286. /**
  122287. * Enable or disable the frame time capture
  122288. */
  122289. set captureFrameTime(value: boolean);
  122290. /**
  122291. * Gets the perf counter used for inter-frames time capture
  122292. */
  122293. get interFrameTimeCounter(): PerfCounter;
  122294. /**
  122295. * Gets the inter-frames time capture status
  122296. */
  122297. get captureInterFrameTime(): boolean;
  122298. /**
  122299. * Enable or disable the inter-frames time capture
  122300. */
  122301. set captureInterFrameTime(value: boolean);
  122302. /**
  122303. * Gets the perf counter used for render time capture
  122304. */
  122305. get renderTimeCounter(): PerfCounter;
  122306. /**
  122307. * Gets the render time capture status
  122308. */
  122309. get captureRenderTime(): boolean;
  122310. /**
  122311. * Enable or disable the render time capture
  122312. */
  122313. set captureRenderTime(value: boolean);
  122314. /**
  122315. * Gets the perf counter used for camera render time capture
  122316. */
  122317. get cameraRenderTimeCounter(): PerfCounter;
  122318. /**
  122319. * Gets the camera render time capture status
  122320. */
  122321. get captureCameraRenderTime(): boolean;
  122322. /**
  122323. * Enable or disable the camera render time capture
  122324. */
  122325. set captureCameraRenderTime(value: boolean);
  122326. /**
  122327. * Gets the perf counter used for draw calls
  122328. */
  122329. get drawCallsCounter(): PerfCounter;
  122330. /**
  122331. * Instantiates a new scene instrumentation.
  122332. * This class can be used to get instrumentation data from a Babylon engine
  122333. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  122334. * @param scene Defines the scene to instrument
  122335. */
  122336. constructor(
  122337. /**
  122338. * Defines the scene to instrument
  122339. */
  122340. scene: Scene);
  122341. /**
  122342. * Dispose and release associated resources.
  122343. */
  122344. dispose(): void;
  122345. }
  122346. }
  122347. declare module BABYLON {
  122348. /** @hidden */
  122349. export var glowMapGenerationPixelShader: {
  122350. name: string;
  122351. shader: string;
  122352. };
  122353. }
  122354. declare module BABYLON {
  122355. /** @hidden */
  122356. export var glowMapGenerationVertexShader: {
  122357. name: string;
  122358. shader: string;
  122359. };
  122360. }
  122361. declare module BABYLON {
  122362. /**
  122363. * Effect layer options. This helps customizing the behaviour
  122364. * of the effect layer.
  122365. */
  122366. export interface IEffectLayerOptions {
  122367. /**
  122368. * Multiplication factor apply to the canvas size to compute the render target size
  122369. * used to generated the objects (the smaller the faster).
  122370. */
  122371. mainTextureRatio: number;
  122372. /**
  122373. * Enforces a fixed size texture to ensure effect stability across devices.
  122374. */
  122375. mainTextureFixedSize?: number;
  122376. /**
  122377. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  122378. */
  122379. alphaBlendingMode: number;
  122380. /**
  122381. * The camera attached to the layer.
  122382. */
  122383. camera: Nullable<Camera>;
  122384. /**
  122385. * The rendering group to draw the layer in.
  122386. */
  122387. renderingGroupId: number;
  122388. }
  122389. /**
  122390. * The effect layer Helps adding post process effect blended with the main pass.
  122391. *
  122392. * This can be for instance use to generate glow or higlight effects on the scene.
  122393. *
  122394. * The effect layer class can not be used directly and is intented to inherited from to be
  122395. * customized per effects.
  122396. */
  122397. export abstract class EffectLayer {
  122398. private _vertexBuffers;
  122399. private _indexBuffer;
  122400. private _cachedDefines;
  122401. private _effectLayerMapGenerationEffect;
  122402. private _effectLayerOptions;
  122403. private _mergeEffect;
  122404. protected _scene: Scene;
  122405. protected _engine: Engine;
  122406. protected _maxSize: number;
  122407. protected _mainTextureDesiredSize: ISize;
  122408. protected _mainTexture: RenderTargetTexture;
  122409. protected _shouldRender: boolean;
  122410. protected _postProcesses: PostProcess[];
  122411. protected _textures: BaseTexture[];
  122412. protected _emissiveTextureAndColor: {
  122413. texture: Nullable<BaseTexture>;
  122414. color: Color4;
  122415. };
  122416. /**
  122417. * The name of the layer
  122418. */
  122419. name: string;
  122420. /**
  122421. * The clear color of the texture used to generate the glow map.
  122422. */
  122423. neutralColor: Color4;
  122424. /**
  122425. * Specifies wether the highlight layer is enabled or not.
  122426. */
  122427. isEnabled: boolean;
  122428. /**
  122429. * Gets the camera attached to the layer.
  122430. */
  122431. get camera(): Nullable<Camera>;
  122432. /**
  122433. * Gets the rendering group id the layer should render in.
  122434. */
  122435. get renderingGroupId(): number;
  122436. set renderingGroupId(renderingGroupId: number);
  122437. /**
  122438. * An event triggered when the effect layer has been disposed.
  122439. */
  122440. onDisposeObservable: Observable<EffectLayer>;
  122441. /**
  122442. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  122443. */
  122444. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  122445. /**
  122446. * An event triggered when the generated texture is being merged in the scene.
  122447. */
  122448. onBeforeComposeObservable: Observable<EffectLayer>;
  122449. /**
  122450. * An event triggered when the mesh is rendered into the effect render target.
  122451. */
  122452. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  122453. /**
  122454. * An event triggered after the mesh has been rendered into the effect render target.
  122455. */
  122456. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  122457. /**
  122458. * An event triggered when the generated texture has been merged in the scene.
  122459. */
  122460. onAfterComposeObservable: Observable<EffectLayer>;
  122461. /**
  122462. * An event triggered when the efffect layer changes its size.
  122463. */
  122464. onSizeChangedObservable: Observable<EffectLayer>;
  122465. /** @hidden */
  122466. static _SceneComponentInitialization: (scene: Scene) => void;
  122467. /**
  122468. * Instantiates a new effect Layer and references it in the scene.
  122469. * @param name The name of the layer
  122470. * @param scene The scene to use the layer in
  122471. */
  122472. constructor(
  122473. /** The Friendly of the effect in the scene */
  122474. name: string, scene: Scene);
  122475. /**
  122476. * Get the effect name of the layer.
  122477. * @return The effect name
  122478. */
  122479. abstract getEffectName(): string;
  122480. /**
  122481. * Checks for the readiness of the element composing the layer.
  122482. * @param subMesh the mesh to check for
  122483. * @param useInstances specify wether or not to use instances to render the mesh
  122484. * @return true if ready otherwise, false
  122485. */
  122486. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122487. /**
  122488. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122489. * @returns true if the effect requires stencil during the main canvas render pass.
  122490. */
  122491. abstract needStencil(): boolean;
  122492. /**
  122493. * Create the merge effect. This is the shader use to blit the information back
  122494. * to the main canvas at the end of the scene rendering.
  122495. * @returns The effect containing the shader used to merge the effect on the main canvas
  122496. */
  122497. protected abstract _createMergeEffect(): Effect;
  122498. /**
  122499. * Creates the render target textures and post processes used in the effect layer.
  122500. */
  122501. protected abstract _createTextureAndPostProcesses(): void;
  122502. /**
  122503. * Implementation specific of rendering the generating effect on the main canvas.
  122504. * @param effect The effect used to render through
  122505. */
  122506. protected abstract _internalRender(effect: Effect): void;
  122507. /**
  122508. * Sets the required values for both the emissive texture and and the main color.
  122509. */
  122510. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122511. /**
  122512. * Free any resources and references associated to a mesh.
  122513. * Internal use
  122514. * @param mesh The mesh to free.
  122515. */
  122516. abstract _disposeMesh(mesh: Mesh): void;
  122517. /**
  122518. * Serializes this layer (Glow or Highlight for example)
  122519. * @returns a serialized layer object
  122520. */
  122521. abstract serialize?(): any;
  122522. /**
  122523. * Initializes the effect layer with the required options.
  122524. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  122525. */
  122526. protected _init(options: Partial<IEffectLayerOptions>): void;
  122527. /**
  122528. * Generates the index buffer of the full screen quad blending to the main canvas.
  122529. */
  122530. private _generateIndexBuffer;
  122531. /**
  122532. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  122533. */
  122534. private _generateVertexBuffer;
  122535. /**
  122536. * Sets the main texture desired size which is the closest power of two
  122537. * of the engine canvas size.
  122538. */
  122539. private _setMainTextureSize;
  122540. /**
  122541. * Creates the main texture for the effect layer.
  122542. */
  122543. protected _createMainTexture(): void;
  122544. /**
  122545. * Adds specific effects defines.
  122546. * @param defines The defines to add specifics to.
  122547. */
  122548. protected _addCustomEffectDefines(defines: string[]): void;
  122549. /**
  122550. * Checks for the readiness of the element composing the layer.
  122551. * @param subMesh the mesh to check for
  122552. * @param useInstances specify wether or not to use instances to render the mesh
  122553. * @param emissiveTexture the associated emissive texture used to generate the glow
  122554. * @return true if ready otherwise, false
  122555. */
  122556. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  122557. /**
  122558. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  122559. */
  122560. render(): void;
  122561. /**
  122562. * Determine if a given mesh will be used in the current effect.
  122563. * @param mesh mesh to test
  122564. * @returns true if the mesh will be used
  122565. */
  122566. hasMesh(mesh: AbstractMesh): boolean;
  122567. /**
  122568. * Returns true if the layer contains information to display, otherwise false.
  122569. * @returns true if the glow layer should be rendered
  122570. */
  122571. shouldRender(): boolean;
  122572. /**
  122573. * Returns true if the mesh should render, otherwise false.
  122574. * @param mesh The mesh to render
  122575. * @returns true if it should render otherwise false
  122576. */
  122577. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  122578. /**
  122579. * Returns true if the mesh can be rendered, otherwise false.
  122580. * @param mesh The mesh to render
  122581. * @param material The material used on the mesh
  122582. * @returns true if it can be rendered otherwise false
  122583. */
  122584. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122585. /**
  122586. * Returns true if the mesh should render, otherwise false.
  122587. * @param mesh The mesh to render
  122588. * @returns true if it should render otherwise false
  122589. */
  122590. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  122591. /**
  122592. * Renders the submesh passed in parameter to the generation map.
  122593. */
  122594. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  122595. /**
  122596. * Defines wether the current material of the mesh should be use to render the effect.
  122597. * @param mesh defines the current mesh to render
  122598. */
  122599. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122600. /**
  122601. * Rebuild the required buffers.
  122602. * @hidden Internal use only.
  122603. */
  122604. _rebuild(): void;
  122605. /**
  122606. * Dispose only the render target textures and post process.
  122607. */
  122608. private _disposeTextureAndPostProcesses;
  122609. /**
  122610. * Dispose the highlight layer and free resources.
  122611. */
  122612. dispose(): void;
  122613. /**
  122614. * Gets the class name of the effect layer
  122615. * @returns the string with the class name of the effect layer
  122616. */
  122617. getClassName(): string;
  122618. /**
  122619. * Creates an effect layer from parsed effect layer data
  122620. * @param parsedEffectLayer defines effect layer data
  122621. * @param scene defines the current scene
  122622. * @param rootUrl defines the root URL containing the effect layer information
  122623. * @returns a parsed effect Layer
  122624. */
  122625. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  122626. }
  122627. }
  122628. declare module BABYLON {
  122629. interface AbstractScene {
  122630. /**
  122631. * The list of effect layers (highlights/glow) added to the scene
  122632. * @see http://doc.babylonjs.com/how_to/highlight_layer
  122633. * @see http://doc.babylonjs.com/how_to/glow_layer
  122634. */
  122635. effectLayers: Array<EffectLayer>;
  122636. /**
  122637. * Removes the given effect layer from this scene.
  122638. * @param toRemove defines the effect layer to remove
  122639. * @returns the index of the removed effect layer
  122640. */
  122641. removeEffectLayer(toRemove: EffectLayer): number;
  122642. /**
  122643. * Adds the given effect layer to this scene
  122644. * @param newEffectLayer defines the effect layer to add
  122645. */
  122646. addEffectLayer(newEffectLayer: EffectLayer): void;
  122647. }
  122648. /**
  122649. * Defines the layer scene component responsible to manage any effect layers
  122650. * in a given scene.
  122651. */
  122652. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  122653. /**
  122654. * The component name helpfull to identify the component in the list of scene components.
  122655. */
  122656. readonly name: string;
  122657. /**
  122658. * The scene the component belongs to.
  122659. */
  122660. scene: Scene;
  122661. private _engine;
  122662. private _renderEffects;
  122663. private _needStencil;
  122664. private _previousStencilState;
  122665. /**
  122666. * Creates a new instance of the component for the given scene
  122667. * @param scene Defines the scene to register the component in
  122668. */
  122669. constructor(scene: Scene);
  122670. /**
  122671. * Registers the component in a given scene
  122672. */
  122673. register(): void;
  122674. /**
  122675. * Rebuilds the elements related to this component in case of
  122676. * context lost for instance.
  122677. */
  122678. rebuild(): void;
  122679. /**
  122680. * Serializes the component data to the specified json object
  122681. * @param serializationObject The object to serialize to
  122682. */
  122683. serialize(serializationObject: any): void;
  122684. /**
  122685. * Adds all the elements from the container to the scene
  122686. * @param container the container holding the elements
  122687. */
  122688. addFromContainer(container: AbstractScene): void;
  122689. /**
  122690. * Removes all the elements in the container from the scene
  122691. * @param container contains the elements to remove
  122692. * @param dispose if the removed element should be disposed (default: false)
  122693. */
  122694. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122695. /**
  122696. * Disposes the component and the associated ressources.
  122697. */
  122698. dispose(): void;
  122699. private _isReadyForMesh;
  122700. private _renderMainTexture;
  122701. private _setStencil;
  122702. private _setStencilBack;
  122703. private _draw;
  122704. private _drawCamera;
  122705. private _drawRenderingGroup;
  122706. }
  122707. }
  122708. declare module BABYLON {
  122709. /** @hidden */
  122710. export var glowMapMergePixelShader: {
  122711. name: string;
  122712. shader: string;
  122713. };
  122714. }
  122715. declare module BABYLON {
  122716. /** @hidden */
  122717. export var glowMapMergeVertexShader: {
  122718. name: string;
  122719. shader: string;
  122720. };
  122721. }
  122722. declare module BABYLON {
  122723. interface AbstractScene {
  122724. /**
  122725. * Return a the first highlight layer of the scene with a given name.
  122726. * @param name The name of the highlight layer to look for.
  122727. * @return The highlight layer if found otherwise null.
  122728. */
  122729. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  122730. }
  122731. /**
  122732. * Glow layer options. This helps customizing the behaviour
  122733. * of the glow layer.
  122734. */
  122735. export interface IGlowLayerOptions {
  122736. /**
  122737. * Multiplication factor apply to the canvas size to compute the render target size
  122738. * used to generated the glowing objects (the smaller the faster).
  122739. */
  122740. mainTextureRatio: number;
  122741. /**
  122742. * Enforces a fixed size texture to ensure resize independant blur.
  122743. */
  122744. mainTextureFixedSize?: number;
  122745. /**
  122746. * How big is the kernel of the blur texture.
  122747. */
  122748. blurKernelSize: number;
  122749. /**
  122750. * The camera attached to the layer.
  122751. */
  122752. camera: Nullable<Camera>;
  122753. /**
  122754. * Enable MSAA by chosing the number of samples.
  122755. */
  122756. mainTextureSamples?: number;
  122757. /**
  122758. * The rendering group to draw the layer in.
  122759. */
  122760. renderingGroupId: number;
  122761. }
  122762. /**
  122763. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  122764. *
  122765. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  122766. *
  122767. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  122768. */
  122769. export class GlowLayer extends EffectLayer {
  122770. /**
  122771. * Effect Name of the layer.
  122772. */
  122773. static readonly EffectName: string;
  122774. /**
  122775. * The default blur kernel size used for the glow.
  122776. */
  122777. static DefaultBlurKernelSize: number;
  122778. /**
  122779. * The default texture size ratio used for the glow.
  122780. */
  122781. static DefaultTextureRatio: number;
  122782. /**
  122783. * Sets the kernel size of the blur.
  122784. */
  122785. set blurKernelSize(value: number);
  122786. /**
  122787. * Gets the kernel size of the blur.
  122788. */
  122789. get blurKernelSize(): number;
  122790. /**
  122791. * Sets the glow intensity.
  122792. */
  122793. set intensity(value: number);
  122794. /**
  122795. * Gets the glow intensity.
  122796. */
  122797. get intensity(): number;
  122798. private _options;
  122799. private _intensity;
  122800. private _horizontalBlurPostprocess1;
  122801. private _verticalBlurPostprocess1;
  122802. private _horizontalBlurPostprocess2;
  122803. private _verticalBlurPostprocess2;
  122804. private _blurTexture1;
  122805. private _blurTexture2;
  122806. private _postProcesses1;
  122807. private _postProcesses2;
  122808. private _includedOnlyMeshes;
  122809. private _excludedMeshes;
  122810. private _meshesUsingTheirOwnMaterials;
  122811. /**
  122812. * Callback used to let the user override the color selection on a per mesh basis
  122813. */
  122814. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  122815. /**
  122816. * Callback used to let the user override the texture selection on a per mesh basis
  122817. */
  122818. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  122819. /**
  122820. * Instantiates a new glow Layer and references it to the scene.
  122821. * @param name The name of the layer
  122822. * @param scene The scene to use the layer in
  122823. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  122824. */
  122825. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  122826. /**
  122827. * Get the effect name of the layer.
  122828. * @return The effect name
  122829. */
  122830. getEffectName(): string;
  122831. /**
  122832. * Create the merge effect. This is the shader use to blit the information back
  122833. * to the main canvas at the end of the scene rendering.
  122834. */
  122835. protected _createMergeEffect(): Effect;
  122836. /**
  122837. * Creates the render target textures and post processes used in the glow layer.
  122838. */
  122839. protected _createTextureAndPostProcesses(): void;
  122840. /**
  122841. * Checks for the readiness of the element composing the layer.
  122842. * @param subMesh the mesh to check for
  122843. * @param useInstances specify wether or not to use instances to render the mesh
  122844. * @param emissiveTexture the associated emissive texture used to generate the glow
  122845. * @return true if ready otherwise, false
  122846. */
  122847. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122848. /**
  122849. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122850. */
  122851. needStencil(): boolean;
  122852. /**
  122853. * Returns true if the mesh can be rendered, otherwise false.
  122854. * @param mesh The mesh to render
  122855. * @param material The material used on the mesh
  122856. * @returns true if it can be rendered otherwise false
  122857. */
  122858. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122859. /**
  122860. * Implementation specific of rendering the generating effect on the main canvas.
  122861. * @param effect The effect used to render through
  122862. */
  122863. protected _internalRender(effect: Effect): void;
  122864. /**
  122865. * Sets the required values for both the emissive texture and and the main color.
  122866. */
  122867. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122868. /**
  122869. * Returns true if the mesh should render, otherwise false.
  122870. * @param mesh The mesh to render
  122871. * @returns true if it should render otherwise false
  122872. */
  122873. protected _shouldRenderMesh(mesh: Mesh): boolean;
  122874. /**
  122875. * Adds specific effects defines.
  122876. * @param defines The defines to add specifics to.
  122877. */
  122878. protected _addCustomEffectDefines(defines: string[]): void;
  122879. /**
  122880. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  122881. * @param mesh The mesh to exclude from the glow layer
  122882. */
  122883. addExcludedMesh(mesh: Mesh): void;
  122884. /**
  122885. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  122886. * @param mesh The mesh to remove
  122887. */
  122888. removeExcludedMesh(mesh: Mesh): void;
  122889. /**
  122890. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  122891. * @param mesh The mesh to include in the glow layer
  122892. */
  122893. addIncludedOnlyMesh(mesh: Mesh): void;
  122894. /**
  122895. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  122896. * @param mesh The mesh to remove
  122897. */
  122898. removeIncludedOnlyMesh(mesh: Mesh): void;
  122899. /**
  122900. * Determine if a given mesh will be used in the glow layer
  122901. * @param mesh The mesh to test
  122902. * @returns true if the mesh will be highlighted by the current glow layer
  122903. */
  122904. hasMesh(mesh: AbstractMesh): boolean;
  122905. /**
  122906. * Defines wether the current material of the mesh should be use to render the effect.
  122907. * @param mesh defines the current mesh to render
  122908. */
  122909. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122910. /**
  122911. * Add a mesh to be rendered through its own material and not with emissive only.
  122912. * @param mesh The mesh for which we need to use its material
  122913. */
  122914. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  122915. /**
  122916. * Remove a mesh from being rendered through its own material and not with emissive only.
  122917. * @param mesh The mesh for which we need to not use its material
  122918. */
  122919. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  122920. /**
  122921. * Free any resources and references associated to a mesh.
  122922. * Internal use
  122923. * @param mesh The mesh to free.
  122924. * @hidden
  122925. */
  122926. _disposeMesh(mesh: Mesh): void;
  122927. /**
  122928. * Gets the class name of the effect layer
  122929. * @returns the string with the class name of the effect layer
  122930. */
  122931. getClassName(): string;
  122932. /**
  122933. * Serializes this glow layer
  122934. * @returns a serialized glow layer object
  122935. */
  122936. serialize(): any;
  122937. /**
  122938. * Creates a Glow Layer from parsed glow layer data
  122939. * @param parsedGlowLayer defines glow layer data
  122940. * @param scene defines the current scene
  122941. * @param rootUrl defines the root URL containing the glow layer information
  122942. * @returns a parsed Glow Layer
  122943. */
  122944. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  122945. }
  122946. }
  122947. declare module BABYLON {
  122948. /** @hidden */
  122949. export var glowBlurPostProcessPixelShader: {
  122950. name: string;
  122951. shader: string;
  122952. };
  122953. }
  122954. declare module BABYLON {
  122955. interface AbstractScene {
  122956. /**
  122957. * Return a the first highlight layer of the scene with a given name.
  122958. * @param name The name of the highlight layer to look for.
  122959. * @return The highlight layer if found otherwise null.
  122960. */
  122961. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  122962. }
  122963. /**
  122964. * Highlight layer options. This helps customizing the behaviour
  122965. * of the highlight layer.
  122966. */
  122967. export interface IHighlightLayerOptions {
  122968. /**
  122969. * Multiplication factor apply to the canvas size to compute the render target size
  122970. * used to generated the glowing objects (the smaller the faster).
  122971. */
  122972. mainTextureRatio: number;
  122973. /**
  122974. * Enforces a fixed size texture to ensure resize independant blur.
  122975. */
  122976. mainTextureFixedSize?: number;
  122977. /**
  122978. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  122979. * of the picture to blur (the smaller the faster).
  122980. */
  122981. blurTextureSizeRatio: number;
  122982. /**
  122983. * How big in texel of the blur texture is the vertical blur.
  122984. */
  122985. blurVerticalSize: number;
  122986. /**
  122987. * How big in texel of the blur texture is the horizontal blur.
  122988. */
  122989. blurHorizontalSize: number;
  122990. /**
  122991. * Alpha blending mode used to apply the blur. Default is combine.
  122992. */
  122993. alphaBlendingMode: number;
  122994. /**
  122995. * The camera attached to the layer.
  122996. */
  122997. camera: Nullable<Camera>;
  122998. /**
  122999. * Should we display highlight as a solid stroke?
  123000. */
  123001. isStroke?: boolean;
  123002. /**
  123003. * The rendering group to draw the layer in.
  123004. */
  123005. renderingGroupId: number;
  123006. }
  123007. /**
  123008. * The highlight layer Helps adding a glow effect around a mesh.
  123009. *
  123010. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  123011. * glowy meshes to your scene.
  123012. *
  123013. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  123014. */
  123015. export class HighlightLayer extends EffectLayer {
  123016. name: string;
  123017. /**
  123018. * Effect Name of the highlight layer.
  123019. */
  123020. static readonly EffectName: string;
  123021. /**
  123022. * The neutral color used during the preparation of the glow effect.
  123023. * This is black by default as the blend operation is a blend operation.
  123024. */
  123025. static NeutralColor: Color4;
  123026. /**
  123027. * Stencil value used for glowing meshes.
  123028. */
  123029. static GlowingMeshStencilReference: number;
  123030. /**
  123031. * Stencil value used for the other meshes in the scene.
  123032. */
  123033. static NormalMeshStencilReference: number;
  123034. /**
  123035. * Specifies whether or not the inner glow is ACTIVE in the layer.
  123036. */
  123037. innerGlow: boolean;
  123038. /**
  123039. * Specifies whether or not the outer glow is ACTIVE in the layer.
  123040. */
  123041. outerGlow: boolean;
  123042. /**
  123043. * Specifies the horizontal size of the blur.
  123044. */
  123045. set blurHorizontalSize(value: number);
  123046. /**
  123047. * Specifies the vertical size of the blur.
  123048. */
  123049. set blurVerticalSize(value: number);
  123050. /**
  123051. * Gets the horizontal size of the blur.
  123052. */
  123053. get blurHorizontalSize(): number;
  123054. /**
  123055. * Gets the vertical size of the blur.
  123056. */
  123057. get blurVerticalSize(): number;
  123058. /**
  123059. * An event triggered when the highlight layer is being blurred.
  123060. */
  123061. onBeforeBlurObservable: Observable<HighlightLayer>;
  123062. /**
  123063. * An event triggered when the highlight layer has been blurred.
  123064. */
  123065. onAfterBlurObservable: Observable<HighlightLayer>;
  123066. private _instanceGlowingMeshStencilReference;
  123067. private _options;
  123068. private _downSamplePostprocess;
  123069. private _horizontalBlurPostprocess;
  123070. private _verticalBlurPostprocess;
  123071. private _blurTexture;
  123072. private _meshes;
  123073. private _excludedMeshes;
  123074. /**
  123075. * Instantiates a new highlight Layer and references it to the scene..
  123076. * @param name The name of the layer
  123077. * @param scene The scene to use the layer in
  123078. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  123079. */
  123080. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  123081. /**
  123082. * Get the effect name of the layer.
  123083. * @return The effect name
  123084. */
  123085. getEffectName(): string;
  123086. /**
  123087. * Create the merge effect. This is the shader use to blit the information back
  123088. * to the main canvas at the end of the scene rendering.
  123089. */
  123090. protected _createMergeEffect(): Effect;
  123091. /**
  123092. * Creates the render target textures and post processes used in the highlight layer.
  123093. */
  123094. protected _createTextureAndPostProcesses(): void;
  123095. /**
  123096. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  123097. */
  123098. needStencil(): boolean;
  123099. /**
  123100. * Checks for the readiness of the element composing the layer.
  123101. * @param subMesh the mesh to check for
  123102. * @param useInstances specify wether or not to use instances to render the mesh
  123103. * @param emissiveTexture the associated emissive texture used to generate the glow
  123104. * @return true if ready otherwise, false
  123105. */
  123106. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123107. /**
  123108. * Implementation specific of rendering the generating effect on the main canvas.
  123109. * @param effect The effect used to render through
  123110. */
  123111. protected _internalRender(effect: Effect): void;
  123112. /**
  123113. * Returns true if the layer contains information to display, otherwise false.
  123114. */
  123115. shouldRender(): boolean;
  123116. /**
  123117. * Returns true if the mesh should render, otherwise false.
  123118. * @param mesh The mesh to render
  123119. * @returns true if it should render otherwise false
  123120. */
  123121. protected _shouldRenderMesh(mesh: Mesh): boolean;
  123122. /**
  123123. * Sets the required values for both the emissive texture and and the main color.
  123124. */
  123125. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  123126. /**
  123127. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  123128. * @param mesh The mesh to exclude from the highlight layer
  123129. */
  123130. addExcludedMesh(mesh: Mesh): void;
  123131. /**
  123132. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  123133. * @param mesh The mesh to highlight
  123134. */
  123135. removeExcludedMesh(mesh: Mesh): void;
  123136. /**
  123137. * Determine if a given mesh will be highlighted by the current HighlightLayer
  123138. * @param mesh mesh to test
  123139. * @returns true if the mesh will be highlighted by the current HighlightLayer
  123140. */
  123141. hasMesh(mesh: AbstractMesh): boolean;
  123142. /**
  123143. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  123144. * @param mesh The mesh to highlight
  123145. * @param color The color of the highlight
  123146. * @param glowEmissiveOnly Extract the glow from the emissive texture
  123147. */
  123148. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  123149. /**
  123150. * Remove a mesh from the highlight layer in order to make it stop glowing.
  123151. * @param mesh The mesh to highlight
  123152. */
  123153. removeMesh(mesh: Mesh): void;
  123154. /**
  123155. * Force the stencil to the normal expected value for none glowing parts
  123156. */
  123157. private _defaultStencilReference;
  123158. /**
  123159. * Free any resources and references associated to a mesh.
  123160. * Internal use
  123161. * @param mesh The mesh to free.
  123162. * @hidden
  123163. */
  123164. _disposeMesh(mesh: Mesh): void;
  123165. /**
  123166. * Dispose the highlight layer and free resources.
  123167. */
  123168. dispose(): void;
  123169. /**
  123170. * Gets the class name of the effect layer
  123171. * @returns the string with the class name of the effect layer
  123172. */
  123173. getClassName(): string;
  123174. /**
  123175. * Serializes this Highlight layer
  123176. * @returns a serialized Highlight layer object
  123177. */
  123178. serialize(): any;
  123179. /**
  123180. * Creates a Highlight layer from parsed Highlight layer data
  123181. * @param parsedHightlightLayer defines the Highlight layer data
  123182. * @param scene defines the current scene
  123183. * @param rootUrl defines the root URL containing the Highlight layer information
  123184. * @returns a parsed Highlight layer
  123185. */
  123186. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  123187. }
  123188. }
  123189. declare module BABYLON {
  123190. interface AbstractScene {
  123191. /**
  123192. * The list of layers (background and foreground) of the scene
  123193. */
  123194. layers: Array<Layer>;
  123195. }
  123196. /**
  123197. * Defines the layer scene component responsible to manage any layers
  123198. * in a given scene.
  123199. */
  123200. export class LayerSceneComponent implements ISceneComponent {
  123201. /**
  123202. * The component name helpfull to identify the component in the list of scene components.
  123203. */
  123204. readonly name: string;
  123205. /**
  123206. * The scene the component belongs to.
  123207. */
  123208. scene: Scene;
  123209. private _engine;
  123210. /**
  123211. * Creates a new instance of the component for the given scene
  123212. * @param scene Defines the scene to register the component in
  123213. */
  123214. constructor(scene: Scene);
  123215. /**
  123216. * Registers the component in a given scene
  123217. */
  123218. register(): void;
  123219. /**
  123220. * Rebuilds the elements related to this component in case of
  123221. * context lost for instance.
  123222. */
  123223. rebuild(): void;
  123224. /**
  123225. * Disposes the component and the associated ressources.
  123226. */
  123227. dispose(): void;
  123228. private _draw;
  123229. private _drawCameraPredicate;
  123230. private _drawCameraBackground;
  123231. private _drawCameraForeground;
  123232. private _drawRenderTargetPredicate;
  123233. private _drawRenderTargetBackground;
  123234. private _drawRenderTargetForeground;
  123235. /**
  123236. * Adds all the elements from the container to the scene
  123237. * @param container the container holding the elements
  123238. */
  123239. addFromContainer(container: AbstractScene): void;
  123240. /**
  123241. * Removes all the elements in the container from the scene
  123242. * @param container contains the elements to remove
  123243. * @param dispose if the removed element should be disposed (default: false)
  123244. */
  123245. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123246. }
  123247. }
  123248. declare module BABYLON {
  123249. /** @hidden */
  123250. export var layerPixelShader: {
  123251. name: string;
  123252. shader: string;
  123253. };
  123254. }
  123255. declare module BABYLON {
  123256. /** @hidden */
  123257. export var layerVertexShader: {
  123258. name: string;
  123259. shader: string;
  123260. };
  123261. }
  123262. declare module BABYLON {
  123263. /**
  123264. * This represents a full screen 2d layer.
  123265. * This can be useful to display a picture in the background of your scene for instance.
  123266. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123267. */
  123268. export class Layer {
  123269. /**
  123270. * Define the name of the layer.
  123271. */
  123272. name: string;
  123273. /**
  123274. * Define the texture the layer should display.
  123275. */
  123276. texture: Nullable<Texture>;
  123277. /**
  123278. * Is the layer in background or foreground.
  123279. */
  123280. isBackground: boolean;
  123281. /**
  123282. * Define the color of the layer (instead of texture).
  123283. */
  123284. color: Color4;
  123285. /**
  123286. * Define the scale of the layer in order to zoom in out of the texture.
  123287. */
  123288. scale: Vector2;
  123289. /**
  123290. * Define an offset for the layer in order to shift the texture.
  123291. */
  123292. offset: Vector2;
  123293. /**
  123294. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  123295. */
  123296. alphaBlendingMode: number;
  123297. /**
  123298. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  123299. * Alpha test will not mix with the background color in case of transparency.
  123300. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  123301. */
  123302. alphaTest: boolean;
  123303. /**
  123304. * Define a mask to restrict the layer to only some of the scene cameras.
  123305. */
  123306. layerMask: number;
  123307. /**
  123308. * Define the list of render target the layer is visible into.
  123309. */
  123310. renderTargetTextures: RenderTargetTexture[];
  123311. /**
  123312. * Define if the layer is only used in renderTarget or if it also
  123313. * renders in the main frame buffer of the canvas.
  123314. */
  123315. renderOnlyInRenderTargetTextures: boolean;
  123316. private _scene;
  123317. private _vertexBuffers;
  123318. private _indexBuffer;
  123319. private _effect;
  123320. private _previousDefines;
  123321. /**
  123322. * An event triggered when the layer is disposed.
  123323. */
  123324. onDisposeObservable: Observable<Layer>;
  123325. private _onDisposeObserver;
  123326. /**
  123327. * Back compatibility with callback before the onDisposeObservable existed.
  123328. * The set callback will be triggered when the layer has been disposed.
  123329. */
  123330. set onDispose(callback: () => void);
  123331. /**
  123332. * An event triggered before rendering the scene
  123333. */
  123334. onBeforeRenderObservable: Observable<Layer>;
  123335. private _onBeforeRenderObserver;
  123336. /**
  123337. * Back compatibility with callback before the onBeforeRenderObservable existed.
  123338. * The set callback will be triggered just before rendering the layer.
  123339. */
  123340. set onBeforeRender(callback: () => void);
  123341. /**
  123342. * An event triggered after rendering the scene
  123343. */
  123344. onAfterRenderObservable: Observable<Layer>;
  123345. private _onAfterRenderObserver;
  123346. /**
  123347. * Back compatibility with callback before the onAfterRenderObservable existed.
  123348. * The set callback will be triggered just after rendering the layer.
  123349. */
  123350. set onAfterRender(callback: () => void);
  123351. /**
  123352. * Instantiates a new layer.
  123353. * This represents a full screen 2d layer.
  123354. * This can be useful to display a picture in the background of your scene for instance.
  123355. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123356. * @param name Define the name of the layer in the scene
  123357. * @param imgUrl Define the url of the texture to display in the layer
  123358. * @param scene Define the scene the layer belongs to
  123359. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  123360. * @param color Defines a color for the layer
  123361. */
  123362. constructor(
  123363. /**
  123364. * Define the name of the layer.
  123365. */
  123366. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  123367. private _createIndexBuffer;
  123368. /** @hidden */
  123369. _rebuild(): void;
  123370. /**
  123371. * Renders the layer in the scene.
  123372. */
  123373. render(): void;
  123374. /**
  123375. * Disposes and releases the associated ressources.
  123376. */
  123377. dispose(): void;
  123378. }
  123379. }
  123380. declare module BABYLON {
  123381. /** @hidden */
  123382. export var lensFlarePixelShader: {
  123383. name: string;
  123384. shader: string;
  123385. };
  123386. }
  123387. declare module BABYLON {
  123388. /** @hidden */
  123389. export var lensFlareVertexShader: {
  123390. name: string;
  123391. shader: string;
  123392. };
  123393. }
  123394. declare module BABYLON {
  123395. /**
  123396. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123397. * It is usually composed of several `lensFlare`.
  123398. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123399. */
  123400. export class LensFlareSystem {
  123401. /**
  123402. * Define the name of the lens flare system
  123403. */
  123404. name: string;
  123405. /**
  123406. * List of lens flares used in this system.
  123407. */
  123408. lensFlares: LensFlare[];
  123409. /**
  123410. * Define a limit from the border the lens flare can be visible.
  123411. */
  123412. borderLimit: number;
  123413. /**
  123414. * Define a viewport border we do not want to see the lens flare in.
  123415. */
  123416. viewportBorder: number;
  123417. /**
  123418. * Define a predicate which could limit the list of meshes able to occlude the effect.
  123419. */
  123420. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  123421. /**
  123422. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  123423. */
  123424. layerMask: number;
  123425. /**
  123426. * Define the id of the lens flare system in the scene.
  123427. * (equal to name by default)
  123428. */
  123429. id: string;
  123430. private _scene;
  123431. private _emitter;
  123432. private _vertexBuffers;
  123433. private _indexBuffer;
  123434. private _effect;
  123435. private _positionX;
  123436. private _positionY;
  123437. private _isEnabled;
  123438. /** @hidden */
  123439. static _SceneComponentInitialization: (scene: Scene) => void;
  123440. /**
  123441. * Instantiates a lens flare system.
  123442. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123443. * It is usually composed of several `lensFlare`.
  123444. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123445. * @param name Define the name of the lens flare system in the scene
  123446. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  123447. * @param scene Define the scene the lens flare system belongs to
  123448. */
  123449. constructor(
  123450. /**
  123451. * Define the name of the lens flare system
  123452. */
  123453. name: string, emitter: any, scene: Scene);
  123454. /**
  123455. * Define if the lens flare system is enabled.
  123456. */
  123457. get isEnabled(): boolean;
  123458. set isEnabled(value: boolean);
  123459. /**
  123460. * Get the scene the effects belongs to.
  123461. * @returns the scene holding the lens flare system
  123462. */
  123463. getScene(): Scene;
  123464. /**
  123465. * Get the emitter of the lens flare system.
  123466. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123467. * @returns the emitter of the lens flare system
  123468. */
  123469. getEmitter(): any;
  123470. /**
  123471. * Set the emitter of the lens flare system.
  123472. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123473. * @param newEmitter Define the new emitter of the system
  123474. */
  123475. setEmitter(newEmitter: any): void;
  123476. /**
  123477. * Get the lens flare system emitter position.
  123478. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  123479. * @returns the position
  123480. */
  123481. getEmitterPosition(): Vector3;
  123482. /**
  123483. * @hidden
  123484. */
  123485. computeEffectivePosition(globalViewport: Viewport): boolean;
  123486. /** @hidden */
  123487. _isVisible(): boolean;
  123488. /**
  123489. * @hidden
  123490. */
  123491. render(): boolean;
  123492. /**
  123493. * Dispose and release the lens flare with its associated resources.
  123494. */
  123495. dispose(): void;
  123496. /**
  123497. * Parse a lens flare system from a JSON repressentation
  123498. * @param parsedLensFlareSystem Define the JSON to parse
  123499. * @param scene Define the scene the parsed system should be instantiated in
  123500. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  123501. * @returns the parsed system
  123502. */
  123503. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  123504. /**
  123505. * Serialize the current Lens Flare System into a JSON representation.
  123506. * @returns the serialized JSON
  123507. */
  123508. serialize(): any;
  123509. }
  123510. }
  123511. declare module BABYLON {
  123512. /**
  123513. * This represents one of the lens effect in a `lensFlareSystem`.
  123514. * It controls one of the indiviual texture used in the effect.
  123515. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123516. */
  123517. export class LensFlare {
  123518. /**
  123519. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123520. */
  123521. size: number;
  123522. /**
  123523. * 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.
  123524. */
  123525. position: number;
  123526. /**
  123527. * Define the lens color.
  123528. */
  123529. color: Color3;
  123530. /**
  123531. * Define the lens texture.
  123532. */
  123533. texture: Nullable<Texture>;
  123534. /**
  123535. * Define the alpha mode to render this particular lens.
  123536. */
  123537. alphaMode: number;
  123538. private _system;
  123539. /**
  123540. * Creates a new Lens Flare.
  123541. * This represents one of the lens effect in a `lensFlareSystem`.
  123542. * It controls one of the indiviual texture used in the effect.
  123543. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123544. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  123545. * @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.
  123546. * @param color Define the lens color
  123547. * @param imgUrl Define the lens texture url
  123548. * @param system Define the `lensFlareSystem` this flare is part of
  123549. * @returns The newly created Lens Flare
  123550. */
  123551. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  123552. /**
  123553. * Instantiates a new Lens Flare.
  123554. * This represents one of the lens effect in a `lensFlareSystem`.
  123555. * It controls one of the indiviual texture used in the effect.
  123556. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123557. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  123558. * @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.
  123559. * @param color Define the lens color
  123560. * @param imgUrl Define the lens texture url
  123561. * @param system Define the `lensFlareSystem` this flare is part of
  123562. */
  123563. constructor(
  123564. /**
  123565. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123566. */
  123567. size: number,
  123568. /**
  123569. * 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.
  123570. */
  123571. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  123572. /**
  123573. * Dispose and release the lens flare with its associated resources.
  123574. */
  123575. dispose(): void;
  123576. }
  123577. }
  123578. declare module BABYLON {
  123579. interface AbstractScene {
  123580. /**
  123581. * The list of lens flare system added to the scene
  123582. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123583. */
  123584. lensFlareSystems: Array<LensFlareSystem>;
  123585. /**
  123586. * Removes the given lens flare system from this scene.
  123587. * @param toRemove The lens flare system to remove
  123588. * @returns The index of the removed lens flare system
  123589. */
  123590. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  123591. /**
  123592. * Adds the given lens flare system to this scene
  123593. * @param newLensFlareSystem The lens flare system to add
  123594. */
  123595. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  123596. /**
  123597. * Gets a lens flare system using its name
  123598. * @param name defines the name to look for
  123599. * @returns the lens flare system or null if not found
  123600. */
  123601. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  123602. /**
  123603. * Gets a lens flare system using its id
  123604. * @param id defines the id to look for
  123605. * @returns the lens flare system or null if not found
  123606. */
  123607. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  123608. }
  123609. /**
  123610. * Defines the lens flare scene component responsible to manage any lens flares
  123611. * in a given scene.
  123612. */
  123613. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  123614. /**
  123615. * The component name helpfull to identify the component in the list of scene components.
  123616. */
  123617. readonly name: string;
  123618. /**
  123619. * The scene the component belongs to.
  123620. */
  123621. scene: Scene;
  123622. /**
  123623. * Creates a new instance of the component for the given scene
  123624. * @param scene Defines the scene to register the component in
  123625. */
  123626. constructor(scene: Scene);
  123627. /**
  123628. * Registers the component in a given scene
  123629. */
  123630. register(): void;
  123631. /**
  123632. * Rebuilds the elements related to this component in case of
  123633. * context lost for instance.
  123634. */
  123635. rebuild(): void;
  123636. /**
  123637. * Adds all the elements from the container to the scene
  123638. * @param container the container holding the elements
  123639. */
  123640. addFromContainer(container: AbstractScene): void;
  123641. /**
  123642. * Removes all the elements in the container from the scene
  123643. * @param container contains the elements to remove
  123644. * @param dispose if the removed element should be disposed (default: false)
  123645. */
  123646. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123647. /**
  123648. * Serializes the component data to the specified json object
  123649. * @param serializationObject The object to serialize to
  123650. */
  123651. serialize(serializationObject: any): void;
  123652. /**
  123653. * Disposes the component and the associated ressources.
  123654. */
  123655. dispose(): void;
  123656. private _draw;
  123657. }
  123658. }
  123659. declare module BABYLON {
  123660. /**
  123661. * Defines the shadow generator component responsible to manage any shadow generators
  123662. * in a given scene.
  123663. */
  123664. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  123665. /**
  123666. * The component name helpfull to identify the component in the list of scene components.
  123667. */
  123668. readonly name: string;
  123669. /**
  123670. * The scene the component belongs to.
  123671. */
  123672. scene: Scene;
  123673. /**
  123674. * Creates a new instance of the component for the given scene
  123675. * @param scene Defines the scene to register the component in
  123676. */
  123677. constructor(scene: Scene);
  123678. /**
  123679. * Registers the component in a given scene
  123680. */
  123681. register(): void;
  123682. /**
  123683. * Rebuilds the elements related to this component in case of
  123684. * context lost for instance.
  123685. */
  123686. rebuild(): void;
  123687. /**
  123688. * Serializes the component data to the specified json object
  123689. * @param serializationObject The object to serialize to
  123690. */
  123691. serialize(serializationObject: any): void;
  123692. /**
  123693. * Adds all the elements from the container to the scene
  123694. * @param container the container holding the elements
  123695. */
  123696. addFromContainer(container: AbstractScene): void;
  123697. /**
  123698. * Removes all the elements in the container from the scene
  123699. * @param container contains the elements to remove
  123700. * @param dispose if the removed element should be disposed (default: false)
  123701. */
  123702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123703. /**
  123704. * Rebuilds the elements related to this component in case of
  123705. * context lost for instance.
  123706. */
  123707. dispose(): void;
  123708. private _gatherRenderTargets;
  123709. }
  123710. }
  123711. declare module BABYLON {
  123712. /**
  123713. * A point light is a light defined by an unique point in world space.
  123714. * The light is emitted in every direction from this point.
  123715. * A good example of a point light is a standard light bulb.
  123716. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123717. */
  123718. export class PointLight extends ShadowLight {
  123719. private _shadowAngle;
  123720. /**
  123721. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123722. * This specifies what angle the shadow will use to be created.
  123723. *
  123724. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123725. */
  123726. get shadowAngle(): number;
  123727. /**
  123728. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123729. * This specifies what angle the shadow will use to be created.
  123730. *
  123731. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123732. */
  123733. set shadowAngle(value: number);
  123734. /**
  123735. * Gets the direction if it has been set.
  123736. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123737. */
  123738. get direction(): Vector3;
  123739. /**
  123740. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123741. */
  123742. set direction(value: Vector3);
  123743. /**
  123744. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  123745. * A PointLight emits the light in every direction.
  123746. * It can cast shadows.
  123747. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  123748. * ```javascript
  123749. * var pointLight = new PointLight("pl", camera.position, scene);
  123750. * ```
  123751. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123752. * @param name The light friendly name
  123753. * @param position The position of the point light in the scene
  123754. * @param scene The scene the lights belongs to
  123755. */
  123756. constructor(name: string, position: Vector3, scene: Scene);
  123757. /**
  123758. * Returns the string "PointLight"
  123759. * @returns the class name
  123760. */
  123761. getClassName(): string;
  123762. /**
  123763. * Returns the integer 0.
  123764. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123765. */
  123766. getTypeID(): number;
  123767. /**
  123768. * Specifies wether or not the shadowmap should be a cube texture.
  123769. * @returns true if the shadowmap needs to be a cube texture.
  123770. */
  123771. needCube(): boolean;
  123772. /**
  123773. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  123774. * @param faceIndex The index of the face we are computed the direction to generate shadow
  123775. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  123776. */
  123777. getShadowDirection(faceIndex?: number): Vector3;
  123778. /**
  123779. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  123780. * - fov = PI / 2
  123781. * - aspect ratio : 1.0
  123782. * - z-near and far equal to the active camera minZ and maxZ.
  123783. * Returns the PointLight.
  123784. */
  123785. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123786. protected _buildUniformLayout(): void;
  123787. /**
  123788. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  123789. * @param effect The effect to update
  123790. * @param lightIndex The index of the light in the effect to update
  123791. * @returns The point light
  123792. */
  123793. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  123794. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123795. /**
  123796. * Prepares the list of defines specific to the light type.
  123797. * @param defines the list of defines
  123798. * @param lightIndex defines the index of the light for the effect
  123799. */
  123800. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123801. }
  123802. }
  123803. declare module BABYLON {
  123804. /**
  123805. * Header information of HDR texture files.
  123806. */
  123807. export interface HDRInfo {
  123808. /**
  123809. * The height of the texture in pixels.
  123810. */
  123811. height: number;
  123812. /**
  123813. * The width of the texture in pixels.
  123814. */
  123815. width: number;
  123816. /**
  123817. * The index of the beginning of the data in the binary file.
  123818. */
  123819. dataPosition: number;
  123820. }
  123821. /**
  123822. * This groups tools to convert HDR texture to native colors array.
  123823. */
  123824. export class HDRTools {
  123825. private static Ldexp;
  123826. private static Rgbe2float;
  123827. private static readStringLine;
  123828. /**
  123829. * Reads header information from an RGBE texture stored in a native array.
  123830. * More information on this format are available here:
  123831. * https://en.wikipedia.org/wiki/RGBE_image_format
  123832. *
  123833. * @param uint8array The binary file stored in native array.
  123834. * @return The header information.
  123835. */
  123836. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  123837. /**
  123838. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  123839. * This RGBE texture needs to store the information as a panorama.
  123840. *
  123841. * More information on this format are available here:
  123842. * https://en.wikipedia.org/wiki/RGBE_image_format
  123843. *
  123844. * @param buffer The binary file stored in an array buffer.
  123845. * @param size The expected size of the extracted cubemap.
  123846. * @return The Cube Map information.
  123847. */
  123848. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  123849. /**
  123850. * Returns the pixels data extracted from an RGBE texture.
  123851. * This pixels will be stored left to right up to down in the R G B order in one array.
  123852. *
  123853. * More information on this format are available here:
  123854. * https://en.wikipedia.org/wiki/RGBE_image_format
  123855. *
  123856. * @param uint8array The binary file stored in an array buffer.
  123857. * @param hdrInfo The header information of the file.
  123858. * @return The pixels data in RGB right to left up to down order.
  123859. */
  123860. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  123861. private static RGBE_ReadPixels_RLE;
  123862. }
  123863. }
  123864. declare module BABYLON {
  123865. /**
  123866. * This represents a texture coming from an HDR input.
  123867. *
  123868. * The only supported format is currently panorama picture stored in RGBE format.
  123869. * Example of such files can be found on HDRLib: http://hdrlib.com/
  123870. */
  123871. export class HDRCubeTexture extends BaseTexture {
  123872. private static _facesMapping;
  123873. private _generateHarmonics;
  123874. private _noMipmap;
  123875. private _textureMatrix;
  123876. private _size;
  123877. private _onLoad;
  123878. private _onError;
  123879. /**
  123880. * The texture URL.
  123881. */
  123882. url: string;
  123883. /**
  123884. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  123885. */
  123886. coordinatesMode: number;
  123887. protected _isBlocking: boolean;
  123888. /**
  123889. * Sets wether or not the texture is blocking during loading.
  123890. */
  123891. set isBlocking(value: boolean);
  123892. /**
  123893. * Gets wether or not the texture is blocking during loading.
  123894. */
  123895. get isBlocking(): boolean;
  123896. protected _rotationY: number;
  123897. /**
  123898. * Sets texture matrix rotation angle around Y axis in radians.
  123899. */
  123900. set rotationY(value: number);
  123901. /**
  123902. * Gets texture matrix rotation angle around Y axis radians.
  123903. */
  123904. get rotationY(): number;
  123905. /**
  123906. * Gets or sets the center of the bounding box associated with the cube texture
  123907. * It must define where the camera used to render the texture was set
  123908. */
  123909. boundingBoxPosition: Vector3;
  123910. private _boundingBoxSize;
  123911. /**
  123912. * Gets or sets the size of the bounding box associated with the cube texture
  123913. * When defined, the cubemap will switch to local mode
  123914. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  123915. * @example https://www.babylonjs-playground.com/#RNASML
  123916. */
  123917. set boundingBoxSize(value: Vector3);
  123918. get boundingBoxSize(): Vector3;
  123919. /**
  123920. * Instantiates an HDRTexture from the following parameters.
  123921. *
  123922. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  123923. * @param scene The scene the texture will be used in
  123924. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  123925. * @param noMipmap Forces to not generate the mipmap if true
  123926. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  123927. * @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)
  123928. * @param reserved Reserved flag for internal use.
  123929. */
  123930. 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>);
  123931. /**
  123932. * Get the current class name of the texture useful for serialization or dynamic coding.
  123933. * @returns "HDRCubeTexture"
  123934. */
  123935. getClassName(): string;
  123936. /**
  123937. * Occurs when the file is raw .hdr file.
  123938. */
  123939. private loadTexture;
  123940. clone(): HDRCubeTexture;
  123941. delayLoad(): void;
  123942. /**
  123943. * Get the texture reflection matrix used to rotate/transform the reflection.
  123944. * @returns the reflection matrix
  123945. */
  123946. getReflectionTextureMatrix(): Matrix;
  123947. /**
  123948. * Set the texture reflection matrix used to rotate/transform the reflection.
  123949. * @param value Define the reflection matrix to set
  123950. */
  123951. setReflectionTextureMatrix(value: Matrix): void;
  123952. /**
  123953. * Parses a JSON representation of an HDR Texture in order to create the texture
  123954. * @param parsedTexture Define the JSON representation
  123955. * @param scene Define the scene the texture should be created in
  123956. * @param rootUrl Define the root url in case we need to load relative dependencies
  123957. * @returns the newly created texture after parsing
  123958. */
  123959. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  123960. serialize(): any;
  123961. }
  123962. }
  123963. declare module BABYLON {
  123964. /**
  123965. * Class used to control physics engine
  123966. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123967. */
  123968. export class PhysicsEngine implements IPhysicsEngine {
  123969. private _physicsPlugin;
  123970. /**
  123971. * Global value used to control the smallest number supported by the simulation
  123972. */
  123973. static Epsilon: number;
  123974. private _impostors;
  123975. private _joints;
  123976. private _subTimeStep;
  123977. /**
  123978. * Gets the gravity vector used by the simulation
  123979. */
  123980. gravity: Vector3;
  123981. /**
  123982. * Factory used to create the default physics plugin.
  123983. * @returns The default physics plugin
  123984. */
  123985. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  123986. /**
  123987. * Creates a new Physics Engine
  123988. * @param gravity defines the gravity vector used by the simulation
  123989. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  123990. */
  123991. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  123992. /**
  123993. * Sets the gravity vector used by the simulation
  123994. * @param gravity defines the gravity vector to use
  123995. */
  123996. setGravity(gravity: Vector3): void;
  123997. /**
  123998. * Set the time step of the physics engine.
  123999. * Default is 1/60.
  124000. * To slow it down, enter 1/600 for example.
  124001. * To speed it up, 1/30
  124002. * @param newTimeStep defines the new timestep to apply to this world.
  124003. */
  124004. setTimeStep(newTimeStep?: number): void;
  124005. /**
  124006. * Get the time step of the physics engine.
  124007. * @returns the current time step
  124008. */
  124009. getTimeStep(): number;
  124010. /**
  124011. * Set the sub time step of the physics engine.
  124012. * Default is 0 meaning there is no sub steps
  124013. * To increase physics resolution precision, set a small value (like 1 ms)
  124014. * @param subTimeStep defines the new sub timestep used for physics resolution.
  124015. */
  124016. setSubTimeStep(subTimeStep?: number): void;
  124017. /**
  124018. * Get the sub time step of the physics engine.
  124019. * @returns the current sub time step
  124020. */
  124021. getSubTimeStep(): number;
  124022. /**
  124023. * Release all resources
  124024. */
  124025. dispose(): void;
  124026. /**
  124027. * Gets the name of the current physics plugin
  124028. * @returns the name of the plugin
  124029. */
  124030. getPhysicsPluginName(): string;
  124031. /**
  124032. * Adding a new impostor for the impostor tracking.
  124033. * This will be done by the impostor itself.
  124034. * @param impostor the impostor to add
  124035. */
  124036. addImpostor(impostor: PhysicsImpostor): void;
  124037. /**
  124038. * Remove an impostor from the engine.
  124039. * This impostor and its mesh will not longer be updated by the physics engine.
  124040. * @param impostor the impostor to remove
  124041. */
  124042. removeImpostor(impostor: PhysicsImpostor): void;
  124043. /**
  124044. * Add a joint to the physics engine
  124045. * @param mainImpostor defines the main impostor to which the joint is added.
  124046. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  124047. * @param joint defines the joint that will connect both impostors.
  124048. */
  124049. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  124050. /**
  124051. * Removes a joint from the simulation
  124052. * @param mainImpostor defines the impostor used with the joint
  124053. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  124054. * @param joint defines the joint to remove
  124055. */
  124056. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  124057. /**
  124058. * Called by the scene. No need to call it.
  124059. * @param delta defines the timespam between frames
  124060. */
  124061. _step(delta: number): void;
  124062. /**
  124063. * Gets the current plugin used to run the simulation
  124064. * @returns current plugin
  124065. */
  124066. getPhysicsPlugin(): IPhysicsEnginePlugin;
  124067. /**
  124068. * Gets the list of physic impostors
  124069. * @returns an array of PhysicsImpostor
  124070. */
  124071. getImpostors(): Array<PhysicsImpostor>;
  124072. /**
  124073. * Gets the impostor for a physics enabled object
  124074. * @param object defines the object impersonated by the impostor
  124075. * @returns the PhysicsImpostor or null if not found
  124076. */
  124077. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  124078. /**
  124079. * Gets the impostor for a physics body object
  124080. * @param body defines physics body used by the impostor
  124081. * @returns the PhysicsImpostor or null if not found
  124082. */
  124083. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  124084. /**
  124085. * Does a raycast in the physics world
  124086. * @param from when should the ray start?
  124087. * @param to when should the ray end?
  124088. * @returns PhysicsRaycastResult
  124089. */
  124090. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124091. }
  124092. }
  124093. declare module BABYLON {
  124094. /** @hidden */
  124095. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  124096. private _useDeltaForWorldStep;
  124097. world: any;
  124098. name: string;
  124099. private _physicsMaterials;
  124100. private _fixedTimeStep;
  124101. private _cannonRaycastResult;
  124102. private _raycastResult;
  124103. private _physicsBodysToRemoveAfterStep;
  124104. BJSCANNON: any;
  124105. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  124106. setGravity(gravity: Vector3): void;
  124107. setTimeStep(timeStep: number): void;
  124108. getTimeStep(): number;
  124109. executeStep(delta: number): void;
  124110. private _removeMarkedPhysicsBodiesFromWorld;
  124111. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124112. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124113. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124114. private _processChildMeshes;
  124115. removePhysicsBody(impostor: PhysicsImpostor): void;
  124116. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124117. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124118. private _addMaterial;
  124119. private _checkWithEpsilon;
  124120. private _createShape;
  124121. private _createHeightmap;
  124122. private _minus90X;
  124123. private _plus90X;
  124124. private _tmpPosition;
  124125. private _tmpDeltaPosition;
  124126. private _tmpUnityRotation;
  124127. private _updatePhysicsBodyTransformation;
  124128. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124129. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124130. isSupported(): boolean;
  124131. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124132. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124133. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124134. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124135. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124136. getBodyMass(impostor: PhysicsImpostor): number;
  124137. getBodyFriction(impostor: PhysicsImpostor): number;
  124138. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124139. getBodyRestitution(impostor: PhysicsImpostor): number;
  124140. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124141. sleepBody(impostor: PhysicsImpostor): void;
  124142. wakeUpBody(impostor: PhysicsImpostor): void;
  124143. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  124144. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  124145. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  124146. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124147. getRadius(impostor: PhysicsImpostor): number;
  124148. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124149. dispose(): void;
  124150. private _extendNamespace;
  124151. /**
  124152. * Does a raycast in the physics world
  124153. * @param from when should the ray start?
  124154. * @param to when should the ray end?
  124155. * @returns PhysicsRaycastResult
  124156. */
  124157. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124158. }
  124159. }
  124160. declare module BABYLON {
  124161. /** @hidden */
  124162. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  124163. world: any;
  124164. name: string;
  124165. BJSOIMO: any;
  124166. private _raycastResult;
  124167. constructor(iterations?: number, oimoInjection?: any);
  124168. setGravity(gravity: Vector3): void;
  124169. setTimeStep(timeStep: number): void;
  124170. getTimeStep(): number;
  124171. private _tmpImpostorsArray;
  124172. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  124173. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124174. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124175. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124176. private _tmpPositionVector;
  124177. removePhysicsBody(impostor: PhysicsImpostor): void;
  124178. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124179. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124180. isSupported(): boolean;
  124181. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124182. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124183. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124184. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124185. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124186. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124187. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124188. getBodyMass(impostor: PhysicsImpostor): number;
  124189. getBodyFriction(impostor: PhysicsImpostor): number;
  124190. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124191. getBodyRestitution(impostor: PhysicsImpostor): number;
  124192. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124193. sleepBody(impostor: PhysicsImpostor): void;
  124194. wakeUpBody(impostor: PhysicsImpostor): void;
  124195. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124196. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  124197. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  124198. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124199. getRadius(impostor: PhysicsImpostor): number;
  124200. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124201. dispose(): void;
  124202. /**
  124203. * Does a raycast in the physics world
  124204. * @param from when should the ray start?
  124205. * @param to when should the ray end?
  124206. * @returns PhysicsRaycastResult
  124207. */
  124208. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124209. }
  124210. }
  124211. declare module BABYLON {
  124212. /**
  124213. * Class containing static functions to help procedurally build meshes
  124214. */
  124215. export class RibbonBuilder {
  124216. /**
  124217. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124218. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124219. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124220. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124221. * * 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
  124222. * * 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
  124223. * * 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
  124224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124226. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124227. * * 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
  124228. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124229. * * 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
  124230. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124232. * @param name defines the name of the mesh
  124233. * @param options defines the options used to create the mesh
  124234. * @param scene defines the hosting scene
  124235. * @returns the ribbon mesh
  124236. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124237. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124238. */
  124239. static CreateRibbon(name: string, options: {
  124240. pathArray: Vector3[][];
  124241. closeArray?: boolean;
  124242. closePath?: boolean;
  124243. offset?: number;
  124244. updatable?: boolean;
  124245. sideOrientation?: number;
  124246. frontUVs?: Vector4;
  124247. backUVs?: Vector4;
  124248. instance?: Mesh;
  124249. invertUV?: boolean;
  124250. uvs?: Vector2[];
  124251. colors?: Color4[];
  124252. }, scene?: Nullable<Scene>): Mesh;
  124253. }
  124254. }
  124255. declare module BABYLON {
  124256. /**
  124257. * Class containing static functions to help procedurally build meshes
  124258. */
  124259. export class ShapeBuilder {
  124260. /**
  124261. * 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.
  124262. * * 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.
  124263. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124264. * * 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.
  124265. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124266. * * 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
  124267. * * 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
  124268. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124271. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124273. * @param name defines the name of the mesh
  124274. * @param options defines the options used to create the mesh
  124275. * @param scene defines the hosting scene
  124276. * @returns the extruded shape mesh
  124277. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124279. */
  124280. static ExtrudeShape(name: string, options: {
  124281. shape: Vector3[];
  124282. path: Vector3[];
  124283. scale?: number;
  124284. rotation?: number;
  124285. cap?: number;
  124286. updatable?: boolean;
  124287. sideOrientation?: number;
  124288. frontUVs?: Vector4;
  124289. backUVs?: Vector4;
  124290. instance?: Mesh;
  124291. invertUV?: boolean;
  124292. }, scene?: Nullable<Scene>): Mesh;
  124293. /**
  124294. * Creates an custom extruded shape mesh.
  124295. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124296. * * 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.
  124297. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124298. * * 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
  124299. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124300. * * 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
  124301. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124302. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124303. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124304. * * 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
  124305. * * 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
  124306. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124309. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124311. * @param name defines the name of the mesh
  124312. * @param options defines the options used to create the mesh
  124313. * @param scene defines the hosting scene
  124314. * @returns the custom extruded shape mesh
  124315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124316. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124318. */
  124319. static ExtrudeShapeCustom(name: string, options: {
  124320. shape: Vector3[];
  124321. path: Vector3[];
  124322. scaleFunction?: any;
  124323. rotationFunction?: any;
  124324. ribbonCloseArray?: boolean;
  124325. ribbonClosePath?: boolean;
  124326. cap?: number;
  124327. updatable?: boolean;
  124328. sideOrientation?: number;
  124329. frontUVs?: Vector4;
  124330. backUVs?: Vector4;
  124331. instance?: Mesh;
  124332. invertUV?: boolean;
  124333. }, scene?: Nullable<Scene>): Mesh;
  124334. private static _ExtrudeShapeGeneric;
  124335. }
  124336. }
  124337. declare module BABYLON {
  124338. /**
  124339. * AmmoJS Physics plugin
  124340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  124341. * @see https://github.com/kripken/ammo.js/
  124342. */
  124343. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  124344. private _useDeltaForWorldStep;
  124345. /**
  124346. * Reference to the Ammo library
  124347. */
  124348. bjsAMMO: any;
  124349. /**
  124350. * Created ammoJS world which physics bodies are added to
  124351. */
  124352. world: any;
  124353. /**
  124354. * Name of the plugin
  124355. */
  124356. name: string;
  124357. private _timeStep;
  124358. private _fixedTimeStep;
  124359. private _maxSteps;
  124360. private _tmpQuaternion;
  124361. private _tmpAmmoTransform;
  124362. private _tmpAmmoQuaternion;
  124363. private _tmpAmmoConcreteContactResultCallback;
  124364. private _collisionConfiguration;
  124365. private _dispatcher;
  124366. private _overlappingPairCache;
  124367. private _solver;
  124368. private _softBodySolver;
  124369. private _tmpAmmoVectorA;
  124370. private _tmpAmmoVectorB;
  124371. private _tmpAmmoVectorC;
  124372. private _tmpAmmoVectorD;
  124373. private _tmpContactCallbackResult;
  124374. private _tmpAmmoVectorRCA;
  124375. private _tmpAmmoVectorRCB;
  124376. private _raycastResult;
  124377. private static readonly DISABLE_COLLISION_FLAG;
  124378. private static readonly KINEMATIC_FLAG;
  124379. private static readonly DISABLE_DEACTIVATION_FLAG;
  124380. /**
  124381. * Initializes the ammoJS plugin
  124382. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  124383. * @param ammoInjection can be used to inject your own ammo reference
  124384. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  124385. */
  124386. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  124387. /**
  124388. * Sets the gravity of the physics world (m/(s^2))
  124389. * @param gravity Gravity to set
  124390. */
  124391. setGravity(gravity: Vector3): void;
  124392. /**
  124393. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  124394. * @param timeStep timestep to use in seconds
  124395. */
  124396. setTimeStep(timeStep: number): void;
  124397. /**
  124398. * 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)
  124399. * @param fixedTimeStep fixedTimeStep to use in seconds
  124400. */
  124401. setFixedTimeStep(fixedTimeStep: number): void;
  124402. /**
  124403. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  124404. * @param maxSteps the maximum number of steps by the physics engine per frame
  124405. */
  124406. setMaxSteps(maxSteps: number): void;
  124407. /**
  124408. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  124409. * @returns the current timestep in seconds
  124410. */
  124411. getTimeStep(): number;
  124412. /**
  124413. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  124414. */
  124415. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  124416. private _isImpostorInContact;
  124417. private _isImpostorPairInContact;
  124418. private _stepSimulation;
  124419. /**
  124420. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  124421. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  124422. * After the step the babylon meshes are set to the position of the physics imposters
  124423. * @param delta amount of time to step forward
  124424. * @param impostors array of imposters to update before/after the step
  124425. */
  124426. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  124427. /**
  124428. * Update babylon mesh to match physics world object
  124429. * @param impostor imposter to match
  124430. */
  124431. private _afterSoftStep;
  124432. /**
  124433. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124434. * @param impostor imposter to match
  124435. */
  124436. private _ropeStep;
  124437. /**
  124438. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124439. * @param impostor imposter to match
  124440. */
  124441. private _softbodyOrClothStep;
  124442. private _tmpVector;
  124443. private _tmpMatrix;
  124444. /**
  124445. * Applies an impulse on the imposter
  124446. * @param impostor imposter to apply impulse to
  124447. * @param force amount of force to be applied to the imposter
  124448. * @param contactPoint the location to apply the impulse on the imposter
  124449. */
  124450. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124451. /**
  124452. * Applies a force on the imposter
  124453. * @param impostor imposter to apply force
  124454. * @param force amount of force to be applied to the imposter
  124455. * @param contactPoint the location to apply the force on the imposter
  124456. */
  124457. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124458. /**
  124459. * Creates a physics body using the plugin
  124460. * @param impostor the imposter to create the physics body on
  124461. */
  124462. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124463. /**
  124464. * Removes the physics body from the imposter and disposes of the body's memory
  124465. * @param impostor imposter to remove the physics body from
  124466. */
  124467. removePhysicsBody(impostor: PhysicsImpostor): void;
  124468. /**
  124469. * Generates a joint
  124470. * @param impostorJoint the imposter joint to create the joint with
  124471. */
  124472. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124473. /**
  124474. * Removes a joint
  124475. * @param impostorJoint the imposter joint to remove the joint from
  124476. */
  124477. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124478. private _addMeshVerts;
  124479. /**
  124480. * Initialise the soft body vertices to match its object's (mesh) vertices
  124481. * Softbody vertices (nodes) are in world space and to match this
  124482. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  124483. * @param impostor to create the softbody for
  124484. */
  124485. private _softVertexData;
  124486. /**
  124487. * Create an impostor's soft body
  124488. * @param impostor to create the softbody for
  124489. */
  124490. private _createSoftbody;
  124491. /**
  124492. * Create cloth for an impostor
  124493. * @param impostor to create the softbody for
  124494. */
  124495. private _createCloth;
  124496. /**
  124497. * Create rope for an impostor
  124498. * @param impostor to create the softbody for
  124499. */
  124500. private _createRope;
  124501. /**
  124502. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  124503. * @param impostor to create the custom physics shape for
  124504. */
  124505. private _createCustom;
  124506. private _addHullVerts;
  124507. private _createShape;
  124508. /**
  124509. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  124510. * @param impostor imposter containing the physics body and babylon object
  124511. */
  124512. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124513. /**
  124514. * Sets the babylon object's position/rotation from the physics body's position/rotation
  124515. * @param impostor imposter containing the physics body and babylon object
  124516. * @param newPosition new position
  124517. * @param newRotation new rotation
  124518. */
  124519. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124520. /**
  124521. * If this plugin is supported
  124522. * @returns true if its supported
  124523. */
  124524. isSupported(): boolean;
  124525. /**
  124526. * Sets the linear velocity of the physics body
  124527. * @param impostor imposter to set the velocity on
  124528. * @param velocity velocity to set
  124529. */
  124530. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124531. /**
  124532. * Sets the angular velocity of the physics body
  124533. * @param impostor imposter to set the velocity on
  124534. * @param velocity velocity to set
  124535. */
  124536. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124537. /**
  124538. * gets the linear velocity
  124539. * @param impostor imposter to get linear velocity from
  124540. * @returns linear velocity
  124541. */
  124542. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124543. /**
  124544. * gets the angular velocity
  124545. * @param impostor imposter to get angular velocity from
  124546. * @returns angular velocity
  124547. */
  124548. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124549. /**
  124550. * Sets the mass of physics body
  124551. * @param impostor imposter to set the mass on
  124552. * @param mass mass to set
  124553. */
  124554. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124555. /**
  124556. * Gets the mass of the physics body
  124557. * @param impostor imposter to get the mass from
  124558. * @returns mass
  124559. */
  124560. getBodyMass(impostor: PhysicsImpostor): number;
  124561. /**
  124562. * Gets friction of the impostor
  124563. * @param impostor impostor to get friction from
  124564. * @returns friction value
  124565. */
  124566. getBodyFriction(impostor: PhysicsImpostor): number;
  124567. /**
  124568. * Sets friction of the impostor
  124569. * @param impostor impostor to set friction on
  124570. * @param friction friction value
  124571. */
  124572. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124573. /**
  124574. * Gets restitution of the impostor
  124575. * @param impostor impostor to get restitution from
  124576. * @returns restitution value
  124577. */
  124578. getBodyRestitution(impostor: PhysicsImpostor): number;
  124579. /**
  124580. * Sets resitution of the impostor
  124581. * @param impostor impostor to set resitution on
  124582. * @param restitution resitution value
  124583. */
  124584. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124585. /**
  124586. * Gets pressure inside the impostor
  124587. * @param impostor impostor to get pressure from
  124588. * @returns pressure value
  124589. */
  124590. getBodyPressure(impostor: PhysicsImpostor): number;
  124591. /**
  124592. * Sets pressure inside a soft body impostor
  124593. * Cloth and rope must remain 0 pressure
  124594. * @param impostor impostor to set pressure on
  124595. * @param pressure pressure value
  124596. */
  124597. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  124598. /**
  124599. * Gets stiffness of the impostor
  124600. * @param impostor impostor to get stiffness from
  124601. * @returns pressure value
  124602. */
  124603. getBodyStiffness(impostor: PhysicsImpostor): number;
  124604. /**
  124605. * Sets stiffness of the impostor
  124606. * @param impostor impostor to set stiffness on
  124607. * @param stiffness stiffness value from 0 to 1
  124608. */
  124609. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  124610. /**
  124611. * Gets velocityIterations of the impostor
  124612. * @param impostor impostor to get velocity iterations from
  124613. * @returns velocityIterations value
  124614. */
  124615. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  124616. /**
  124617. * Sets velocityIterations of the impostor
  124618. * @param impostor impostor to set velocity iterations on
  124619. * @param velocityIterations velocityIterations value
  124620. */
  124621. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  124622. /**
  124623. * Gets positionIterations of the impostor
  124624. * @param impostor impostor to get position iterations from
  124625. * @returns positionIterations value
  124626. */
  124627. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  124628. /**
  124629. * Sets positionIterations of the impostor
  124630. * @param impostor impostor to set position on
  124631. * @param positionIterations positionIterations value
  124632. */
  124633. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  124634. /**
  124635. * Append an anchor to a cloth object
  124636. * @param impostor is the cloth impostor to add anchor to
  124637. * @param otherImpostor is the rigid impostor to anchor to
  124638. * @param width ratio across width from 0 to 1
  124639. * @param height ratio up height from 0 to 1
  124640. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  124641. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124642. */
  124643. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124644. /**
  124645. * Append an hook to a rope object
  124646. * @param impostor is the rope impostor to add hook to
  124647. * @param otherImpostor is the rigid impostor to hook to
  124648. * @param length ratio along the rope from 0 to 1
  124649. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  124650. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124651. */
  124652. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124653. /**
  124654. * Sleeps the physics body and stops it from being active
  124655. * @param impostor impostor to sleep
  124656. */
  124657. sleepBody(impostor: PhysicsImpostor): void;
  124658. /**
  124659. * Activates the physics body
  124660. * @param impostor impostor to activate
  124661. */
  124662. wakeUpBody(impostor: PhysicsImpostor): void;
  124663. /**
  124664. * Updates the distance parameters of the joint
  124665. * @param joint joint to update
  124666. * @param maxDistance maximum distance of the joint
  124667. * @param minDistance minimum distance of the joint
  124668. */
  124669. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124670. /**
  124671. * Sets a motor on the joint
  124672. * @param joint joint to set motor on
  124673. * @param speed speed of the motor
  124674. * @param maxForce maximum force of the motor
  124675. * @param motorIndex index of the motor
  124676. */
  124677. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  124678. /**
  124679. * Sets the motors limit
  124680. * @param joint joint to set limit on
  124681. * @param upperLimit upper limit
  124682. * @param lowerLimit lower limit
  124683. */
  124684. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  124685. /**
  124686. * Syncs the position and rotation of a mesh with the impostor
  124687. * @param mesh mesh to sync
  124688. * @param impostor impostor to update the mesh with
  124689. */
  124690. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124691. /**
  124692. * Gets the radius of the impostor
  124693. * @param impostor impostor to get radius from
  124694. * @returns the radius
  124695. */
  124696. getRadius(impostor: PhysicsImpostor): number;
  124697. /**
  124698. * Gets the box size of the impostor
  124699. * @param impostor impostor to get box size from
  124700. * @param result the resulting box size
  124701. */
  124702. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124703. /**
  124704. * Disposes of the impostor
  124705. */
  124706. dispose(): void;
  124707. /**
  124708. * Does a raycast in the physics world
  124709. * @param from when should the ray start?
  124710. * @param to when should the ray end?
  124711. * @returns PhysicsRaycastResult
  124712. */
  124713. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124714. }
  124715. }
  124716. declare module BABYLON {
  124717. interface AbstractScene {
  124718. /**
  124719. * The list of reflection probes added to the scene
  124720. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124721. */
  124722. reflectionProbes: Array<ReflectionProbe>;
  124723. /**
  124724. * Removes the given reflection probe from this scene.
  124725. * @param toRemove The reflection probe to remove
  124726. * @returns The index of the removed reflection probe
  124727. */
  124728. removeReflectionProbe(toRemove: ReflectionProbe): number;
  124729. /**
  124730. * Adds the given reflection probe to this scene.
  124731. * @param newReflectionProbe The reflection probe to add
  124732. */
  124733. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  124734. }
  124735. /**
  124736. * Class used to generate realtime reflection / refraction cube textures
  124737. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124738. */
  124739. export class ReflectionProbe {
  124740. /** defines the name of the probe */
  124741. name: string;
  124742. private _scene;
  124743. private _renderTargetTexture;
  124744. private _projectionMatrix;
  124745. private _viewMatrix;
  124746. private _target;
  124747. private _add;
  124748. private _attachedMesh;
  124749. private _invertYAxis;
  124750. /** Gets or sets probe position (center of the cube map) */
  124751. position: Vector3;
  124752. /**
  124753. * Creates a new reflection probe
  124754. * @param name defines the name of the probe
  124755. * @param size defines the texture resolution (for each face)
  124756. * @param scene defines the hosting scene
  124757. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  124758. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  124759. */
  124760. constructor(
  124761. /** defines the name of the probe */
  124762. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  124763. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  124764. get samples(): number;
  124765. set samples(value: number);
  124766. /** Gets or sets the refresh rate to use (on every frame by default) */
  124767. get refreshRate(): number;
  124768. set refreshRate(value: number);
  124769. /**
  124770. * Gets the hosting scene
  124771. * @returns a Scene
  124772. */
  124773. getScene(): Scene;
  124774. /** Gets the internal CubeTexture used to render to */
  124775. get cubeTexture(): RenderTargetTexture;
  124776. /** Gets the list of meshes to render */
  124777. get renderList(): Nullable<AbstractMesh[]>;
  124778. /**
  124779. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  124780. * @param mesh defines the mesh to attach to
  124781. */
  124782. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  124783. /**
  124784. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  124785. * @param renderingGroupId The rendering group id corresponding to its index
  124786. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124787. */
  124788. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  124789. /**
  124790. * Clean all associated resources
  124791. */
  124792. dispose(): void;
  124793. /**
  124794. * Converts the reflection probe information to a readable string for debug purpose.
  124795. * @param fullDetails Supports for multiple levels of logging within scene loading
  124796. * @returns the human readable reflection probe info
  124797. */
  124798. toString(fullDetails?: boolean): string;
  124799. /**
  124800. * Get the class name of the relfection probe.
  124801. * @returns "ReflectionProbe"
  124802. */
  124803. getClassName(): string;
  124804. /**
  124805. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  124806. * @returns The JSON representation of the texture
  124807. */
  124808. serialize(): any;
  124809. /**
  124810. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  124811. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  124812. * @param scene Define the scene the parsed reflection probe should be instantiated in
  124813. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  124814. * @returns The parsed reflection probe if successful
  124815. */
  124816. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  124817. }
  124818. }
  124819. declare module BABYLON {
  124820. /** @hidden */
  124821. export var _BabylonLoaderRegistered: boolean;
  124822. /**
  124823. * Helps setting up some configuration for the babylon file loader.
  124824. */
  124825. export class BabylonFileLoaderConfiguration {
  124826. /**
  124827. * The loader does not allow injecting custom physix engine into the plugins.
  124828. * Unfortunately in ES6, we need to manually inject them into the plugin.
  124829. * So you could set this variable to your engine import to make it work.
  124830. */
  124831. static LoaderInjectedPhysicsEngine: any;
  124832. }
  124833. }
  124834. declare module BABYLON {
  124835. /**
  124836. * The Physically based simple base material of BJS.
  124837. *
  124838. * This enables better naming and convention enforcements on top of the pbrMaterial.
  124839. * It is used as the base class for both the specGloss and metalRough conventions.
  124840. */
  124841. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  124842. /**
  124843. * Number of Simultaneous lights allowed on the material.
  124844. */
  124845. maxSimultaneousLights: number;
  124846. /**
  124847. * If sets to true, disables all the lights affecting the material.
  124848. */
  124849. disableLighting: boolean;
  124850. /**
  124851. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  124852. */
  124853. environmentTexture: BaseTexture;
  124854. /**
  124855. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124856. */
  124857. invertNormalMapX: boolean;
  124858. /**
  124859. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124860. */
  124861. invertNormalMapY: boolean;
  124862. /**
  124863. * Normal map used in the model.
  124864. */
  124865. normalTexture: BaseTexture;
  124866. /**
  124867. * Emissivie color used to self-illuminate the model.
  124868. */
  124869. emissiveColor: Color3;
  124870. /**
  124871. * Emissivie texture used to self-illuminate the model.
  124872. */
  124873. emissiveTexture: BaseTexture;
  124874. /**
  124875. * Occlusion Channel Strenght.
  124876. */
  124877. occlusionStrength: number;
  124878. /**
  124879. * Occlusion Texture of the material (adding extra occlusion effects).
  124880. */
  124881. occlusionTexture: BaseTexture;
  124882. /**
  124883. * Defines the alpha limits in alpha test mode.
  124884. */
  124885. alphaCutOff: number;
  124886. /**
  124887. * Gets the current double sided mode.
  124888. */
  124889. get doubleSided(): boolean;
  124890. /**
  124891. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124892. */
  124893. set doubleSided(value: boolean);
  124894. /**
  124895. * Stores the pre-calculated light information of a mesh in a texture.
  124896. */
  124897. lightmapTexture: BaseTexture;
  124898. /**
  124899. * If true, the light map contains occlusion information instead of lighting info.
  124900. */
  124901. useLightmapAsShadowmap: boolean;
  124902. /**
  124903. * Instantiates a new PBRMaterial instance.
  124904. *
  124905. * @param name The material name
  124906. * @param scene The scene the material will be use in.
  124907. */
  124908. constructor(name: string, scene: Scene);
  124909. getClassName(): string;
  124910. }
  124911. }
  124912. declare module BABYLON {
  124913. /**
  124914. * The PBR material of BJS following the metal roughness convention.
  124915. *
  124916. * This fits to the PBR convention in the GLTF definition:
  124917. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  124918. */
  124919. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  124920. /**
  124921. * The base color has two different interpretations depending on the value of metalness.
  124922. * When the material is a metal, the base color is the specific measured reflectance value
  124923. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  124924. * of the material.
  124925. */
  124926. baseColor: Color3;
  124927. /**
  124928. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  124929. * well as opacity information in the alpha channel.
  124930. */
  124931. baseTexture: BaseTexture;
  124932. /**
  124933. * Specifies the metallic scalar value of the material.
  124934. * Can also be used to scale the metalness values of the metallic texture.
  124935. */
  124936. metallic: number;
  124937. /**
  124938. * Specifies the roughness scalar value of the material.
  124939. * Can also be used to scale the roughness values of the metallic texture.
  124940. */
  124941. roughness: number;
  124942. /**
  124943. * Texture containing both the metallic value in the B channel and the
  124944. * roughness value in the G channel to keep better precision.
  124945. */
  124946. metallicRoughnessTexture: BaseTexture;
  124947. /**
  124948. * Instantiates a new PBRMetalRoughnessMaterial instance.
  124949. *
  124950. * @param name The material name
  124951. * @param scene The scene the material will be use in.
  124952. */
  124953. constructor(name: string, scene: Scene);
  124954. /**
  124955. * Return the currrent class name of the material.
  124956. */
  124957. getClassName(): string;
  124958. /**
  124959. * Makes a duplicate of the current material.
  124960. * @param name - name to use for the new material.
  124961. */
  124962. clone(name: string): PBRMetallicRoughnessMaterial;
  124963. /**
  124964. * Serialize the material to a parsable JSON object.
  124965. */
  124966. serialize(): any;
  124967. /**
  124968. * Parses a JSON object correponding to the serialize function.
  124969. */
  124970. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  124971. }
  124972. }
  124973. declare module BABYLON {
  124974. /**
  124975. * The PBR material of BJS following the specular glossiness convention.
  124976. *
  124977. * This fits to the PBR convention in the GLTF definition:
  124978. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  124979. */
  124980. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  124981. /**
  124982. * Specifies the diffuse color of the material.
  124983. */
  124984. diffuseColor: Color3;
  124985. /**
  124986. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  124987. * channel.
  124988. */
  124989. diffuseTexture: BaseTexture;
  124990. /**
  124991. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  124992. */
  124993. specularColor: Color3;
  124994. /**
  124995. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  124996. */
  124997. glossiness: number;
  124998. /**
  124999. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  125000. */
  125001. specularGlossinessTexture: BaseTexture;
  125002. /**
  125003. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  125004. *
  125005. * @param name The material name
  125006. * @param scene The scene the material will be use in.
  125007. */
  125008. constructor(name: string, scene: Scene);
  125009. /**
  125010. * Return the currrent class name of the material.
  125011. */
  125012. getClassName(): string;
  125013. /**
  125014. * Makes a duplicate of the current material.
  125015. * @param name - name to use for the new material.
  125016. */
  125017. clone(name: string): PBRSpecularGlossinessMaterial;
  125018. /**
  125019. * Serialize the material to a parsable JSON object.
  125020. */
  125021. serialize(): any;
  125022. /**
  125023. * Parses a JSON object correponding to the serialize function.
  125024. */
  125025. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  125026. }
  125027. }
  125028. declare module BABYLON {
  125029. /**
  125030. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  125031. * It can help converting any input color in a desired output one. This can then be used to create effects
  125032. * from sepia, black and white to sixties or futuristic rendering...
  125033. *
  125034. * The only supported format is currently 3dl.
  125035. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  125036. */
  125037. export class ColorGradingTexture extends BaseTexture {
  125038. /**
  125039. * The current texture matrix. (will always be identity in color grading texture)
  125040. */
  125041. private _textureMatrix;
  125042. /**
  125043. * The texture URL.
  125044. */
  125045. url: string;
  125046. /**
  125047. * Empty line regex stored for GC.
  125048. */
  125049. private static _noneEmptyLineRegex;
  125050. private _engine;
  125051. /**
  125052. * Instantiates a ColorGradingTexture from the following parameters.
  125053. *
  125054. * @param url The location of the color gradind data (currently only supporting 3dl)
  125055. * @param scene The scene the texture will be used in
  125056. */
  125057. constructor(url: string, scene: Scene);
  125058. /**
  125059. * Returns the texture matrix used in most of the material.
  125060. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  125061. */
  125062. getTextureMatrix(): Matrix;
  125063. /**
  125064. * Occurs when the file being loaded is a .3dl LUT file.
  125065. */
  125066. private load3dlTexture;
  125067. /**
  125068. * Starts the loading process of the texture.
  125069. */
  125070. private loadTexture;
  125071. /**
  125072. * Clones the color gradind texture.
  125073. */
  125074. clone(): ColorGradingTexture;
  125075. /**
  125076. * Called during delayed load for textures.
  125077. */
  125078. delayLoad(): void;
  125079. /**
  125080. * Parses a color grading texture serialized by Babylon.
  125081. * @param parsedTexture The texture information being parsedTexture
  125082. * @param scene The scene to load the texture in
  125083. * @param rootUrl The root url of the data assets to load
  125084. * @return A color gradind texture
  125085. */
  125086. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  125087. /**
  125088. * Serializes the LUT texture to json format.
  125089. */
  125090. serialize(): any;
  125091. }
  125092. }
  125093. declare module BABYLON {
  125094. /**
  125095. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  125096. */
  125097. export class EquiRectangularCubeTexture extends BaseTexture {
  125098. /** The six faces of the cube. */
  125099. private static _FacesMapping;
  125100. private _noMipmap;
  125101. private _onLoad;
  125102. private _onError;
  125103. /** The size of the cubemap. */
  125104. private _size;
  125105. /** The buffer of the image. */
  125106. private _buffer;
  125107. /** The width of the input image. */
  125108. private _width;
  125109. /** The height of the input image. */
  125110. private _height;
  125111. /** The URL to the image. */
  125112. url: string;
  125113. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  125114. coordinatesMode: number;
  125115. /**
  125116. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  125117. * @param url The location of the image
  125118. * @param scene The scene the texture will be used in
  125119. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  125120. * @param noMipmap Forces to not generate the mipmap if true
  125121. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  125122. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  125123. * @param onLoad — defines a callback called when texture is loaded
  125124. * @param onError — defines a callback called if there is an error
  125125. */
  125126. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  125127. /**
  125128. * Load the image data, by putting the image on a canvas and extracting its buffer.
  125129. */
  125130. private loadImage;
  125131. /**
  125132. * Convert the image buffer into a cubemap and create a CubeTexture.
  125133. */
  125134. private loadTexture;
  125135. /**
  125136. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  125137. * @param buffer The ArrayBuffer that should be converted.
  125138. * @returns The buffer as Float32Array.
  125139. */
  125140. private getFloat32ArrayFromArrayBuffer;
  125141. /**
  125142. * Get the current class name of the texture useful for serialization or dynamic coding.
  125143. * @returns "EquiRectangularCubeTexture"
  125144. */
  125145. getClassName(): string;
  125146. /**
  125147. * Create a clone of the current EquiRectangularCubeTexture and return it.
  125148. * @returns A clone of the current EquiRectangularCubeTexture.
  125149. */
  125150. clone(): EquiRectangularCubeTexture;
  125151. }
  125152. }
  125153. declare module BABYLON {
  125154. /**
  125155. * Based on jsTGALoader - Javascript loader for TGA file
  125156. * By Vincent Thibault
  125157. * @see http://blog.robrowser.com/javascript-tga-loader.html
  125158. */
  125159. export class TGATools {
  125160. private static _TYPE_INDEXED;
  125161. private static _TYPE_RGB;
  125162. private static _TYPE_GREY;
  125163. private static _TYPE_RLE_INDEXED;
  125164. private static _TYPE_RLE_RGB;
  125165. private static _TYPE_RLE_GREY;
  125166. private static _ORIGIN_MASK;
  125167. private static _ORIGIN_SHIFT;
  125168. private static _ORIGIN_BL;
  125169. private static _ORIGIN_BR;
  125170. private static _ORIGIN_UL;
  125171. private static _ORIGIN_UR;
  125172. /**
  125173. * Gets the header of a TGA file
  125174. * @param data defines the TGA data
  125175. * @returns the header
  125176. */
  125177. static GetTGAHeader(data: Uint8Array): any;
  125178. /**
  125179. * Uploads TGA content to a Babylon Texture
  125180. * @hidden
  125181. */
  125182. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  125183. /** @hidden */
  125184. 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;
  125185. /** @hidden */
  125186. 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;
  125187. /** @hidden */
  125188. 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;
  125189. /** @hidden */
  125190. 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;
  125191. /** @hidden */
  125192. 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;
  125193. /** @hidden */
  125194. 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;
  125195. }
  125196. }
  125197. declare module BABYLON {
  125198. /**
  125199. * Implementation of the TGA Texture Loader.
  125200. * @hidden
  125201. */
  125202. export class _TGATextureLoader implements IInternalTextureLoader {
  125203. /**
  125204. * Defines wether the loader supports cascade loading the different faces.
  125205. */
  125206. readonly supportCascades: boolean;
  125207. /**
  125208. * This returns if the loader support the current file information.
  125209. * @param extension defines the file extension of the file being loaded
  125210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125211. * @param fallback defines the fallback internal texture if any
  125212. * @param isBase64 defines whether the texture is encoded as a base64
  125213. * @param isBuffer defines whether the texture data are stored as a buffer
  125214. * @returns true if the loader can load the specified file
  125215. */
  125216. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125217. /**
  125218. * Transform the url before loading if required.
  125219. * @param rootUrl the url of the texture
  125220. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125221. * @returns the transformed texture
  125222. */
  125223. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125224. /**
  125225. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125226. * @param rootUrl the url of the texture
  125227. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125228. * @returns the fallback texture
  125229. */
  125230. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125231. /**
  125232. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125233. * @param data contains the texture data
  125234. * @param texture defines the BabylonJS internal texture
  125235. * @param createPolynomials will be true if polynomials have been requested
  125236. * @param onLoad defines the callback to trigger once the texture is ready
  125237. * @param onError defines the callback to trigger in case of error
  125238. */
  125239. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125240. /**
  125241. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125242. * @param data contains the texture data
  125243. * @param texture defines the BabylonJS internal texture
  125244. * @param callback defines the method to call once ready to upload
  125245. */
  125246. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125247. }
  125248. }
  125249. declare module BABYLON {
  125250. /**
  125251. * Info about the .basis files
  125252. */
  125253. class BasisFileInfo {
  125254. /**
  125255. * If the file has alpha
  125256. */
  125257. hasAlpha: boolean;
  125258. /**
  125259. * Info about each image of the basis file
  125260. */
  125261. images: Array<{
  125262. levels: Array<{
  125263. width: number;
  125264. height: number;
  125265. transcodedPixels: ArrayBufferView;
  125266. }>;
  125267. }>;
  125268. }
  125269. /**
  125270. * Result of transcoding a basis file
  125271. */
  125272. class TranscodeResult {
  125273. /**
  125274. * Info about the .basis file
  125275. */
  125276. fileInfo: BasisFileInfo;
  125277. /**
  125278. * Format to use when loading the file
  125279. */
  125280. format: number;
  125281. }
  125282. /**
  125283. * Configuration options for the Basis transcoder
  125284. */
  125285. export class BasisTranscodeConfiguration {
  125286. /**
  125287. * Supported compression formats used to determine the supported output format of the transcoder
  125288. */
  125289. supportedCompressionFormats?: {
  125290. /**
  125291. * etc1 compression format
  125292. */
  125293. etc1?: boolean;
  125294. /**
  125295. * s3tc compression format
  125296. */
  125297. s3tc?: boolean;
  125298. /**
  125299. * pvrtc compression format
  125300. */
  125301. pvrtc?: boolean;
  125302. /**
  125303. * etc2 compression format
  125304. */
  125305. etc2?: boolean;
  125306. };
  125307. /**
  125308. * If mipmap levels should be loaded for transcoded images (Default: true)
  125309. */
  125310. loadMipmapLevels?: boolean;
  125311. /**
  125312. * Index of a single image to load (Default: all images)
  125313. */
  125314. loadSingleImage?: number;
  125315. }
  125316. /**
  125317. * Used to load .Basis files
  125318. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  125319. */
  125320. export class BasisTools {
  125321. private static _IgnoreSupportedFormats;
  125322. /**
  125323. * URL to use when loading the basis transcoder
  125324. */
  125325. static JSModuleURL: string;
  125326. /**
  125327. * URL to use when loading the wasm module for the transcoder
  125328. */
  125329. static WasmModuleURL: string;
  125330. /**
  125331. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  125332. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  125333. * @returns internal format corresponding to the Basis format
  125334. */
  125335. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  125336. private static _WorkerPromise;
  125337. private static _Worker;
  125338. private static _actionId;
  125339. private static _CreateWorkerAsync;
  125340. /**
  125341. * Transcodes a loaded image file to compressed pixel data
  125342. * @param imageData image data to transcode
  125343. * @param config configuration options for the transcoding
  125344. * @returns a promise resulting in the transcoded image
  125345. */
  125346. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  125347. /**
  125348. * Loads a texture from the transcode result
  125349. * @param texture texture load to
  125350. * @param transcodeResult the result of transcoding the basis file to load from
  125351. */
  125352. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  125353. }
  125354. }
  125355. declare module BABYLON {
  125356. /**
  125357. * Loader for .basis file format
  125358. */
  125359. export class _BasisTextureLoader implements IInternalTextureLoader {
  125360. /**
  125361. * Defines whether the loader supports cascade loading the different faces.
  125362. */
  125363. readonly supportCascades: boolean;
  125364. /**
  125365. * This returns if the loader support the current file information.
  125366. * @param extension defines the file extension of the file being loaded
  125367. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125368. * @param fallback defines the fallback internal texture if any
  125369. * @param isBase64 defines whether the texture is encoded as a base64
  125370. * @param isBuffer defines whether the texture data are stored as a buffer
  125371. * @returns true if the loader can load the specified file
  125372. */
  125373. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125374. /**
  125375. * Transform the url before loading if required.
  125376. * @param rootUrl the url of the texture
  125377. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125378. * @returns the transformed texture
  125379. */
  125380. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125381. /**
  125382. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125383. * @param rootUrl the url of the texture
  125384. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125385. * @returns the fallback texture
  125386. */
  125387. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125388. /**
  125389. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  125390. * @param data contains the texture data
  125391. * @param texture defines the BabylonJS internal texture
  125392. * @param createPolynomials will be true if polynomials have been requested
  125393. * @param onLoad defines the callback to trigger once the texture is ready
  125394. * @param onError defines the callback to trigger in case of error
  125395. */
  125396. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125397. /**
  125398. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125399. * @param data contains the texture data
  125400. * @param texture defines the BabylonJS internal texture
  125401. * @param callback defines the method to call once ready to upload
  125402. */
  125403. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125404. }
  125405. }
  125406. declare module BABYLON {
  125407. /**
  125408. * 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.
  125409. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125410. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125411. */
  125412. export class CustomProceduralTexture extends ProceduralTexture {
  125413. private _animate;
  125414. private _time;
  125415. private _config;
  125416. private _texturePath;
  125417. /**
  125418. * Instantiates a new Custom Procedural Texture.
  125419. * 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.
  125420. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125421. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125422. * @param name Define the name of the texture
  125423. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  125424. * @param size Define the size of the texture to create
  125425. * @param scene Define the scene the texture belongs to
  125426. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  125427. * @param generateMipMaps Define if the texture should creates mip maps or not
  125428. */
  125429. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125430. private _loadJson;
  125431. /**
  125432. * Is the texture ready to be used ? (rendered at least once)
  125433. * @returns true if ready, otherwise, false.
  125434. */
  125435. isReady(): boolean;
  125436. /**
  125437. * Render the texture to its associated render target.
  125438. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  125439. */
  125440. render(useCameraPostProcess?: boolean): void;
  125441. /**
  125442. * Update the list of dependant textures samplers in the shader.
  125443. */
  125444. updateTextures(): void;
  125445. /**
  125446. * Update the uniform values of the procedural texture in the shader.
  125447. */
  125448. updateShaderUniforms(): void;
  125449. /**
  125450. * Define if the texture animates or not.
  125451. */
  125452. get animate(): boolean;
  125453. set animate(value: boolean);
  125454. }
  125455. }
  125456. declare module BABYLON {
  125457. /** @hidden */
  125458. export var noisePixelShader: {
  125459. name: string;
  125460. shader: string;
  125461. };
  125462. }
  125463. declare module BABYLON {
  125464. /**
  125465. * Class used to generate noise procedural textures
  125466. */
  125467. export class NoiseProceduralTexture extends ProceduralTexture {
  125468. private _time;
  125469. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  125470. brightness: number;
  125471. /** Defines the number of octaves to process */
  125472. octaves: number;
  125473. /** Defines the level of persistence (0.8 by default) */
  125474. persistence: number;
  125475. /** Gets or sets animation speed factor (default is 1) */
  125476. animationSpeedFactor: number;
  125477. /**
  125478. * Creates a new NoiseProceduralTexture
  125479. * @param name defines the name fo the texture
  125480. * @param size defines the size of the texture (default is 256)
  125481. * @param scene defines the hosting scene
  125482. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  125483. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  125484. */
  125485. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125486. private _updateShaderUniforms;
  125487. protected _getDefines(): string;
  125488. /** Generate the current state of the procedural texture */
  125489. render(useCameraPostProcess?: boolean): void;
  125490. /**
  125491. * Serializes this noise procedural texture
  125492. * @returns a serialized noise procedural texture object
  125493. */
  125494. serialize(): any;
  125495. /**
  125496. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  125497. * @param parsedTexture defines parsed texture data
  125498. * @param scene defines the current scene
  125499. * @param rootUrl defines the root URL containing noise procedural texture information
  125500. * @returns a parsed NoiseProceduralTexture
  125501. */
  125502. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  125503. }
  125504. }
  125505. declare module BABYLON {
  125506. /**
  125507. * Raw cube texture where the raw buffers are passed in
  125508. */
  125509. export class RawCubeTexture extends CubeTexture {
  125510. /**
  125511. * Creates a cube texture where the raw buffers are passed in.
  125512. * @param scene defines the scene the texture is attached to
  125513. * @param data defines the array of data to use to create each face
  125514. * @param size defines the size of the textures
  125515. * @param format defines the format of the data
  125516. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  125517. * @param generateMipMaps defines if the engine should generate the mip levels
  125518. * @param invertY defines if data must be stored with Y axis inverted
  125519. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  125520. * @param compression defines the compression used (null by default)
  125521. */
  125522. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  125523. /**
  125524. * Updates the raw cube texture.
  125525. * @param data defines the data to store
  125526. * @param format defines the data format
  125527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125528. * @param invertY defines if data must be stored with Y axis inverted
  125529. * @param compression defines the compression used (null by default)
  125530. * @param level defines which level of the texture to update
  125531. */
  125532. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  125533. /**
  125534. * Updates a raw cube texture with RGBD encoded data.
  125535. * @param data defines the array of data [mipmap][face] to use to create each face
  125536. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  125537. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  125538. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  125539. * @returns a promsie that resolves when the operation is complete
  125540. */
  125541. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  125542. /**
  125543. * Clones the raw cube texture.
  125544. * @return a new cube texture
  125545. */
  125546. clone(): CubeTexture;
  125547. /** @hidden */
  125548. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  125549. }
  125550. }
  125551. declare module BABYLON {
  125552. /**
  125553. * Class used to store 3D textures containing user data
  125554. */
  125555. export class RawTexture3D extends Texture {
  125556. /** Gets or sets the texture format to use */
  125557. format: number;
  125558. private _engine;
  125559. /**
  125560. * Create a new RawTexture3D
  125561. * @param data defines the data of the texture
  125562. * @param width defines the width of the texture
  125563. * @param height defines the height of the texture
  125564. * @param depth defines the depth of the texture
  125565. * @param format defines the texture format to use
  125566. * @param scene defines the hosting scene
  125567. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125568. * @param invertY defines if texture must be stored with Y axis inverted
  125569. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125570. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125571. */
  125572. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125573. /** Gets or sets the texture format to use */
  125574. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125575. /**
  125576. * Update the texture with new data
  125577. * @param data defines the data to store in the texture
  125578. */
  125579. update(data: ArrayBufferView): void;
  125580. }
  125581. }
  125582. declare module BABYLON {
  125583. /**
  125584. * Class used to store 2D array textures containing user data
  125585. */
  125586. export class RawTexture2DArray extends Texture {
  125587. /** Gets or sets the texture format to use */
  125588. format: number;
  125589. private _engine;
  125590. /**
  125591. * Create a new RawTexture2DArray
  125592. * @param data defines the data of the texture
  125593. * @param width defines the width of the texture
  125594. * @param height defines the height of the texture
  125595. * @param depth defines the number of layers of the texture
  125596. * @param format defines the texture format to use
  125597. * @param scene defines the hosting scene
  125598. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125599. * @param invertY defines if texture must be stored with Y axis inverted
  125600. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125601. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125602. */
  125603. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125604. /** Gets or sets the texture format to use */
  125605. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125606. /**
  125607. * Update the texture with new data
  125608. * @param data defines the data to store in the texture
  125609. */
  125610. update(data: ArrayBufferView): void;
  125611. }
  125612. }
  125613. declare module BABYLON {
  125614. /**
  125615. * Creates a refraction texture used by refraction channel of the standard material.
  125616. * It is like a mirror but to see through a material.
  125617. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125618. */
  125619. export class RefractionTexture extends RenderTargetTexture {
  125620. /**
  125621. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  125622. * 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.
  125623. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125624. */
  125625. refractionPlane: Plane;
  125626. /**
  125627. * Define how deep under the surface we should see.
  125628. */
  125629. depth: number;
  125630. /**
  125631. * Creates a refraction texture used by refraction channel of the standard material.
  125632. * It is like a mirror but to see through a material.
  125633. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125634. * @param name Define the texture name
  125635. * @param size Define the size of the underlying texture
  125636. * @param scene Define the scene the refraction belongs to
  125637. * @param generateMipMaps Define if we need to generate mips level for the refraction
  125638. */
  125639. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  125640. /**
  125641. * Clone the refraction texture.
  125642. * @returns the cloned texture
  125643. */
  125644. clone(): RefractionTexture;
  125645. /**
  125646. * Serialize the texture to a JSON representation you could use in Parse later on
  125647. * @returns the serialized JSON representation
  125648. */
  125649. serialize(): any;
  125650. }
  125651. }
  125652. declare module BABYLON {
  125653. /**
  125654. * Defines the options related to the creation of an HtmlElementTexture
  125655. */
  125656. export interface IHtmlElementTextureOptions {
  125657. /**
  125658. * Defines wether mip maps should be created or not.
  125659. */
  125660. generateMipMaps?: boolean;
  125661. /**
  125662. * Defines the sampling mode of the texture.
  125663. */
  125664. samplingMode?: number;
  125665. /**
  125666. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  125667. */
  125668. engine: Nullable<ThinEngine>;
  125669. /**
  125670. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  125671. */
  125672. scene: Nullable<Scene>;
  125673. }
  125674. /**
  125675. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  125676. * To be as efficient as possible depending on your constraints nothing aside the first upload
  125677. * is automatically managed.
  125678. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  125679. * in your application.
  125680. *
  125681. * As the update is not automatic, you need to call them manually.
  125682. */
  125683. export class HtmlElementTexture extends BaseTexture {
  125684. /**
  125685. * The texture URL.
  125686. */
  125687. element: HTMLVideoElement | HTMLCanvasElement;
  125688. private static readonly DefaultOptions;
  125689. private _textureMatrix;
  125690. private _engine;
  125691. private _isVideo;
  125692. private _generateMipMaps;
  125693. private _samplingMode;
  125694. /**
  125695. * Instantiates a HtmlElementTexture from the following parameters.
  125696. *
  125697. * @param name Defines the name of the texture
  125698. * @param element Defines the video or canvas the texture is filled with
  125699. * @param options Defines the other none mandatory texture creation options
  125700. */
  125701. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  125702. private _createInternalTexture;
  125703. /**
  125704. * Returns the texture matrix used in most of the material.
  125705. */
  125706. getTextureMatrix(): Matrix;
  125707. /**
  125708. * Updates the content of the texture.
  125709. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  125710. */
  125711. update(invertY?: Nullable<boolean>): void;
  125712. }
  125713. }
  125714. declare module BABYLON {
  125715. /**
  125716. * Enum used to define the target of a block
  125717. */
  125718. export enum NodeMaterialBlockTargets {
  125719. /** Vertex shader */
  125720. Vertex = 1,
  125721. /** Fragment shader */
  125722. Fragment = 2,
  125723. /** Neutral */
  125724. Neutral = 4,
  125725. /** Vertex and Fragment */
  125726. VertexAndFragment = 3
  125727. }
  125728. }
  125729. declare module BABYLON {
  125730. /**
  125731. * Defines the kind of connection point for node based material
  125732. */
  125733. export enum NodeMaterialBlockConnectionPointTypes {
  125734. /** Float */
  125735. Float = 1,
  125736. /** Int */
  125737. Int = 2,
  125738. /** Vector2 */
  125739. Vector2 = 4,
  125740. /** Vector3 */
  125741. Vector3 = 8,
  125742. /** Vector4 */
  125743. Vector4 = 16,
  125744. /** Color3 */
  125745. Color3 = 32,
  125746. /** Color4 */
  125747. Color4 = 64,
  125748. /** Matrix */
  125749. Matrix = 128,
  125750. /** Detect type based on connection */
  125751. AutoDetect = 1024,
  125752. /** Output type that will be defined by input type */
  125753. BasedOnInput = 2048
  125754. }
  125755. }
  125756. declare module BABYLON {
  125757. /**
  125758. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  125759. */
  125760. export enum NodeMaterialBlockConnectionPointMode {
  125761. /** Value is an uniform */
  125762. Uniform = 0,
  125763. /** Value is a mesh attribute */
  125764. Attribute = 1,
  125765. /** Value is a varying between vertex and fragment shaders */
  125766. Varying = 2,
  125767. /** Mode is undefined */
  125768. Undefined = 3
  125769. }
  125770. }
  125771. declare module BABYLON {
  125772. /**
  125773. * Enum used to define system values e.g. values automatically provided by the system
  125774. */
  125775. export enum NodeMaterialSystemValues {
  125776. /** World */
  125777. World = 1,
  125778. /** View */
  125779. View = 2,
  125780. /** Projection */
  125781. Projection = 3,
  125782. /** ViewProjection */
  125783. ViewProjection = 4,
  125784. /** WorldView */
  125785. WorldView = 5,
  125786. /** WorldViewProjection */
  125787. WorldViewProjection = 6,
  125788. /** CameraPosition */
  125789. CameraPosition = 7,
  125790. /** Fog Color */
  125791. FogColor = 8,
  125792. /** Delta time */
  125793. DeltaTime = 9
  125794. }
  125795. }
  125796. declare module BABYLON {
  125797. /**
  125798. * Root class for all node material optimizers
  125799. */
  125800. export class NodeMaterialOptimizer {
  125801. /**
  125802. * Function used to optimize a NodeMaterial graph
  125803. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  125804. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  125805. */
  125806. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  125807. }
  125808. }
  125809. declare module BABYLON {
  125810. /**
  125811. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  125812. */
  125813. export class TransformBlock extends NodeMaterialBlock {
  125814. /**
  125815. * Defines the value to use to complement W value to transform it to a Vector4
  125816. */
  125817. complementW: number;
  125818. /**
  125819. * Defines the value to use to complement z value to transform it to a Vector4
  125820. */
  125821. complementZ: number;
  125822. /**
  125823. * Creates a new TransformBlock
  125824. * @param name defines the block name
  125825. */
  125826. constructor(name: string);
  125827. /**
  125828. * Gets the current class name
  125829. * @returns the class name
  125830. */
  125831. getClassName(): string;
  125832. /**
  125833. * Gets the vector input
  125834. */
  125835. get vector(): NodeMaterialConnectionPoint;
  125836. /**
  125837. * Gets the output component
  125838. */
  125839. get output(): NodeMaterialConnectionPoint;
  125840. /**
  125841. * Gets the matrix transform input
  125842. */
  125843. get transform(): NodeMaterialConnectionPoint;
  125844. protected _buildBlock(state: NodeMaterialBuildState): this;
  125845. serialize(): any;
  125846. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125847. protected _dumpPropertiesCode(): string;
  125848. }
  125849. }
  125850. declare module BABYLON {
  125851. /**
  125852. * Block used to output the vertex position
  125853. */
  125854. export class VertexOutputBlock extends NodeMaterialBlock {
  125855. /**
  125856. * Creates a new VertexOutputBlock
  125857. * @param name defines the block name
  125858. */
  125859. constructor(name: string);
  125860. /**
  125861. * Gets the current class name
  125862. * @returns the class name
  125863. */
  125864. getClassName(): string;
  125865. /**
  125866. * Gets the vector input component
  125867. */
  125868. get vector(): NodeMaterialConnectionPoint;
  125869. protected _buildBlock(state: NodeMaterialBuildState): this;
  125870. }
  125871. }
  125872. declare module BABYLON {
  125873. /**
  125874. * Block used to output the final color
  125875. */
  125876. export class FragmentOutputBlock extends NodeMaterialBlock {
  125877. /**
  125878. * Create a new FragmentOutputBlock
  125879. * @param name defines the block name
  125880. */
  125881. constructor(name: string);
  125882. /**
  125883. * Gets the current class name
  125884. * @returns the class name
  125885. */
  125886. getClassName(): string;
  125887. /**
  125888. * Gets the rgba input component
  125889. */
  125890. get rgba(): NodeMaterialConnectionPoint;
  125891. /**
  125892. * Gets the rgb input component
  125893. */
  125894. get rgb(): NodeMaterialConnectionPoint;
  125895. /**
  125896. * Gets the a input component
  125897. */
  125898. get a(): NodeMaterialConnectionPoint;
  125899. protected _buildBlock(state: NodeMaterialBuildState): this;
  125900. }
  125901. }
  125902. declare module BABYLON {
  125903. /**
  125904. * Block used to read a reflection texture from a sampler
  125905. */
  125906. export class ReflectionTextureBlock extends NodeMaterialBlock {
  125907. private _define3DName;
  125908. private _defineCubicName;
  125909. private _defineExplicitName;
  125910. private _defineProjectionName;
  125911. private _defineLocalCubicName;
  125912. private _defineSphericalName;
  125913. private _definePlanarName;
  125914. private _defineEquirectangularName;
  125915. private _defineMirroredEquirectangularFixedName;
  125916. private _defineEquirectangularFixedName;
  125917. private _defineSkyboxName;
  125918. private _cubeSamplerName;
  125919. private _2DSamplerName;
  125920. private _positionUVWName;
  125921. private _directionWName;
  125922. private _reflectionCoordsName;
  125923. private _reflection2DCoordsName;
  125924. private _reflectionColorName;
  125925. private _reflectionMatrixName;
  125926. /**
  125927. * Gets or sets the texture associated with the node
  125928. */
  125929. texture: Nullable<BaseTexture>;
  125930. /**
  125931. * Create a new TextureBlock
  125932. * @param name defines the block name
  125933. */
  125934. constructor(name: string);
  125935. /**
  125936. * Gets the current class name
  125937. * @returns the class name
  125938. */
  125939. getClassName(): string;
  125940. /**
  125941. * Gets the world position input component
  125942. */
  125943. get position(): NodeMaterialConnectionPoint;
  125944. /**
  125945. * Gets the world position input component
  125946. */
  125947. get worldPosition(): NodeMaterialConnectionPoint;
  125948. /**
  125949. * Gets the world normal input component
  125950. */
  125951. get worldNormal(): NodeMaterialConnectionPoint;
  125952. /**
  125953. * Gets the world input component
  125954. */
  125955. get world(): NodeMaterialConnectionPoint;
  125956. /**
  125957. * Gets the camera (or eye) position component
  125958. */
  125959. get cameraPosition(): NodeMaterialConnectionPoint;
  125960. /**
  125961. * Gets the view input component
  125962. */
  125963. get view(): NodeMaterialConnectionPoint;
  125964. /**
  125965. * Gets the rgb output component
  125966. */
  125967. get rgb(): NodeMaterialConnectionPoint;
  125968. /**
  125969. * Gets the r output component
  125970. */
  125971. get r(): NodeMaterialConnectionPoint;
  125972. /**
  125973. * Gets the g output component
  125974. */
  125975. get g(): NodeMaterialConnectionPoint;
  125976. /**
  125977. * Gets the b output component
  125978. */
  125979. get b(): NodeMaterialConnectionPoint;
  125980. autoConfigure(material: NodeMaterial): void;
  125981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125982. isReady(): boolean;
  125983. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125984. private _injectVertexCode;
  125985. private _writeOutput;
  125986. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125987. protected _dumpPropertiesCode(): string;
  125988. serialize(): any;
  125989. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125990. }
  125991. }
  125992. declare module BABYLON {
  125993. /**
  125994. * Interface used to configure the node material editor
  125995. */
  125996. export interface INodeMaterialEditorOptions {
  125997. /** Define the URl to load node editor script */
  125998. editorURL?: string;
  125999. }
  126000. /** @hidden */
  126001. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  126002. /** BONES */
  126003. NUM_BONE_INFLUENCERS: number;
  126004. BonesPerMesh: number;
  126005. BONETEXTURE: boolean;
  126006. /** MORPH TARGETS */
  126007. MORPHTARGETS: boolean;
  126008. MORPHTARGETS_NORMAL: boolean;
  126009. MORPHTARGETS_TANGENT: boolean;
  126010. MORPHTARGETS_UV: boolean;
  126011. NUM_MORPH_INFLUENCERS: number;
  126012. /** IMAGE PROCESSING */
  126013. IMAGEPROCESSING: boolean;
  126014. VIGNETTE: boolean;
  126015. VIGNETTEBLENDMODEMULTIPLY: boolean;
  126016. VIGNETTEBLENDMODEOPAQUE: boolean;
  126017. TONEMAPPING: boolean;
  126018. TONEMAPPING_ACES: boolean;
  126019. CONTRAST: boolean;
  126020. EXPOSURE: boolean;
  126021. COLORCURVES: boolean;
  126022. COLORGRADING: boolean;
  126023. COLORGRADING3D: boolean;
  126024. SAMPLER3DGREENDEPTH: boolean;
  126025. SAMPLER3DBGRMAP: boolean;
  126026. IMAGEPROCESSINGPOSTPROCESS: boolean;
  126027. /** MISC. */
  126028. BUMPDIRECTUV: number;
  126029. constructor();
  126030. setValue(name: string, value: boolean): void;
  126031. }
  126032. /**
  126033. * Class used to configure NodeMaterial
  126034. */
  126035. export interface INodeMaterialOptions {
  126036. /**
  126037. * Defines if blocks should emit comments
  126038. */
  126039. emitComments: boolean;
  126040. }
  126041. /**
  126042. * Class used to create a node based material built by assembling shader blocks
  126043. */
  126044. export class NodeMaterial extends PushMaterial {
  126045. private static _BuildIdGenerator;
  126046. private _options;
  126047. private _vertexCompilationState;
  126048. private _fragmentCompilationState;
  126049. private _sharedData;
  126050. private _buildId;
  126051. private _buildWasSuccessful;
  126052. private _cachedWorldViewMatrix;
  126053. private _cachedWorldViewProjectionMatrix;
  126054. private _optimizers;
  126055. private _animationFrame;
  126056. /** Define the URl to load node editor script */
  126057. static EditorURL: string;
  126058. private BJSNODEMATERIALEDITOR;
  126059. /** Get the inspector from bundle or global */
  126060. private _getGlobalNodeMaterialEditor;
  126061. /**
  126062. * Gets or sets data used by visual editor
  126063. * @see https://nme.babylonjs.com
  126064. */
  126065. editorData: any;
  126066. /**
  126067. * 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)
  126068. */
  126069. ignoreAlpha: boolean;
  126070. /**
  126071. * Defines the maximum number of lights that can be used in the material
  126072. */
  126073. maxSimultaneousLights: number;
  126074. /**
  126075. * Observable raised when the material is built
  126076. */
  126077. onBuildObservable: Observable<NodeMaterial>;
  126078. /**
  126079. * Gets or sets the root nodes of the material vertex shader
  126080. */
  126081. _vertexOutputNodes: NodeMaterialBlock[];
  126082. /**
  126083. * Gets or sets the root nodes of the material fragment (pixel) shader
  126084. */
  126085. _fragmentOutputNodes: NodeMaterialBlock[];
  126086. /** Gets or sets options to control the node material overall behavior */
  126087. get options(): INodeMaterialOptions;
  126088. set options(options: INodeMaterialOptions);
  126089. /**
  126090. * Default configuration related to image processing available in the standard Material.
  126091. */
  126092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126093. /**
  126094. * Gets the image processing configuration used either in this material.
  126095. */
  126096. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  126097. /**
  126098. * Sets the Default image processing configuration used either in the this material.
  126099. *
  126100. * If sets to null, the scene one is in use.
  126101. */
  126102. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  126103. /**
  126104. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  126105. */
  126106. attachedBlocks: NodeMaterialBlock[];
  126107. /**
  126108. * Create a new node based material
  126109. * @param name defines the material name
  126110. * @param scene defines the hosting scene
  126111. * @param options defines creation option
  126112. */
  126113. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  126114. /**
  126115. * Gets the current class name of the material e.g. "NodeMaterial"
  126116. * @returns the class name
  126117. */
  126118. getClassName(): string;
  126119. /**
  126120. * Keep track of the image processing observer to allow dispose and replace.
  126121. */
  126122. private _imageProcessingObserver;
  126123. /**
  126124. * Attaches a new image processing configuration to the Standard Material.
  126125. * @param configuration
  126126. */
  126127. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126128. /**
  126129. * Get a block by its name
  126130. * @param name defines the name of the block to retrieve
  126131. * @returns the required block or null if not found
  126132. */
  126133. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  126134. /**
  126135. * Get a block by its name
  126136. * @param predicate defines the predicate used to find the good candidate
  126137. * @returns the required block or null if not found
  126138. */
  126139. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  126140. /**
  126141. * Get an input block by its name
  126142. * @param predicate defines the predicate used to find the good candidate
  126143. * @returns the required input block or null if not found
  126144. */
  126145. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  126146. /**
  126147. * Gets the list of input blocks attached to this material
  126148. * @returns an array of InputBlocks
  126149. */
  126150. getInputBlocks(): InputBlock[];
  126151. /**
  126152. * Adds a new optimizer to the list of optimizers
  126153. * @param optimizer defines the optimizers to add
  126154. * @returns the current material
  126155. */
  126156. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  126157. /**
  126158. * Remove an optimizer from the list of optimizers
  126159. * @param optimizer defines the optimizers to remove
  126160. * @returns the current material
  126161. */
  126162. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  126163. /**
  126164. * Add a new block to the list of output nodes
  126165. * @param node defines the node to add
  126166. * @returns the current material
  126167. */
  126168. addOutputNode(node: NodeMaterialBlock): this;
  126169. /**
  126170. * Remove a block from the list of root nodes
  126171. * @param node defines the node to remove
  126172. * @returns the current material
  126173. */
  126174. removeOutputNode(node: NodeMaterialBlock): this;
  126175. private _addVertexOutputNode;
  126176. private _removeVertexOutputNode;
  126177. private _addFragmentOutputNode;
  126178. private _removeFragmentOutputNode;
  126179. /**
  126180. * Specifies if the material will require alpha blending
  126181. * @returns a boolean specifying if alpha blending is needed
  126182. */
  126183. needAlphaBlending(): boolean;
  126184. /**
  126185. * Specifies if this material should be rendered in alpha test mode
  126186. * @returns a boolean specifying if an alpha test is needed.
  126187. */
  126188. needAlphaTesting(): boolean;
  126189. private _initializeBlock;
  126190. private _resetDualBlocks;
  126191. /**
  126192. * Remove a block from the current node material
  126193. * @param block defines the block to remove
  126194. */
  126195. removeBlock(block: NodeMaterialBlock): void;
  126196. /**
  126197. * Build the material and generates the inner effect
  126198. * @param verbose defines if the build should log activity
  126199. */
  126200. build(verbose?: boolean): void;
  126201. /**
  126202. * Runs an otpimization phase to try to improve the shader code
  126203. */
  126204. optimize(): void;
  126205. private _prepareDefinesForAttributes;
  126206. /**
  126207. * Get if the submesh is ready to be used and all its information available.
  126208. * Child classes can use it to update shaders
  126209. * @param mesh defines the mesh to check
  126210. * @param subMesh defines which submesh to check
  126211. * @param useInstances specifies that instances should be used
  126212. * @returns a boolean indicating that the submesh is ready or not
  126213. */
  126214. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126215. /**
  126216. * Get a string representing the shaders built by the current node graph
  126217. */
  126218. get compiledShaders(): string;
  126219. /**
  126220. * Binds the world matrix to the material
  126221. * @param world defines the world transformation matrix
  126222. */
  126223. bindOnlyWorldMatrix(world: Matrix): void;
  126224. /**
  126225. * Binds the submesh to this material by preparing the effect and shader to draw
  126226. * @param world defines the world transformation matrix
  126227. * @param mesh defines the mesh containing the submesh
  126228. * @param subMesh defines the submesh to bind the material to
  126229. */
  126230. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126231. /**
  126232. * Gets the active textures from the material
  126233. * @returns an array of textures
  126234. */
  126235. getActiveTextures(): BaseTexture[];
  126236. /**
  126237. * Gets the list of texture blocks
  126238. * @returns an array of texture blocks
  126239. */
  126240. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  126241. /**
  126242. * Specifies if the material uses a texture
  126243. * @param texture defines the texture to check against the material
  126244. * @returns a boolean specifying if the material uses the texture
  126245. */
  126246. hasTexture(texture: BaseTexture): boolean;
  126247. /**
  126248. * Disposes the material
  126249. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  126250. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  126251. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  126252. */
  126253. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  126254. /** Creates the node editor window. */
  126255. private _createNodeEditor;
  126256. /**
  126257. * Launch the node material editor
  126258. * @param config Define the configuration of the editor
  126259. * @return a promise fulfilled when the node editor is visible
  126260. */
  126261. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  126262. /**
  126263. * Clear the current material
  126264. */
  126265. clear(): void;
  126266. /**
  126267. * Clear the current material and set it to a default state
  126268. */
  126269. setToDefault(): void;
  126270. /**
  126271. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  126272. * @param url defines the url to load from
  126273. * @returns a promise that will fullfil when the material is fully loaded
  126274. */
  126275. loadAsync(url: string): Promise<void>;
  126276. private _gatherBlocks;
  126277. /**
  126278. * Generate a string containing the code declaration required to create an equivalent of this material
  126279. * @returns a string
  126280. */
  126281. generateCode(): string;
  126282. /**
  126283. * Serializes this material in a JSON representation
  126284. * @returns the serialized material object
  126285. */
  126286. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  126287. private _restoreConnections;
  126288. /**
  126289. * Clear the current graph and load a new one from a serialization object
  126290. * @param source defines the JSON representation of the material
  126291. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126292. */
  126293. loadFromSerialization(source: any, rootUrl?: string): void;
  126294. /**
  126295. * Creates a node material from parsed material data
  126296. * @param source defines the JSON representation of the material
  126297. * @param scene defines the hosting scene
  126298. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126299. * @returns a new node material
  126300. */
  126301. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  126302. /**
  126303. * Creates a new node material set to default basic configuration
  126304. * @param name defines the name of the material
  126305. * @param scene defines the hosting scene
  126306. * @returns a new NodeMaterial
  126307. */
  126308. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  126309. }
  126310. }
  126311. declare module BABYLON {
  126312. /**
  126313. * Block used to read a texture from a sampler
  126314. */
  126315. export class TextureBlock extends NodeMaterialBlock {
  126316. private _defineName;
  126317. private _linearDefineName;
  126318. private _tempTextureRead;
  126319. private _samplerName;
  126320. private _transformedUVName;
  126321. private _textureTransformName;
  126322. private _textureInfoName;
  126323. private _mainUVName;
  126324. private _mainUVDefineName;
  126325. /**
  126326. * Gets or sets the texture associated with the node
  126327. */
  126328. texture: Nullable<Texture>;
  126329. /**
  126330. * Create a new TextureBlock
  126331. * @param name defines the block name
  126332. */
  126333. constructor(name: string);
  126334. /**
  126335. * Gets the current class name
  126336. * @returns the class name
  126337. */
  126338. getClassName(): string;
  126339. /**
  126340. * Gets the uv input component
  126341. */
  126342. get uv(): NodeMaterialConnectionPoint;
  126343. /**
  126344. * Gets the rgba output component
  126345. */
  126346. get rgba(): NodeMaterialConnectionPoint;
  126347. /**
  126348. * Gets the rgb output component
  126349. */
  126350. get rgb(): NodeMaterialConnectionPoint;
  126351. /**
  126352. * Gets the r output component
  126353. */
  126354. get r(): NodeMaterialConnectionPoint;
  126355. /**
  126356. * Gets the g output component
  126357. */
  126358. get g(): NodeMaterialConnectionPoint;
  126359. /**
  126360. * Gets the b output component
  126361. */
  126362. get b(): NodeMaterialConnectionPoint;
  126363. /**
  126364. * Gets the a output component
  126365. */
  126366. get a(): NodeMaterialConnectionPoint;
  126367. get target(): NodeMaterialBlockTargets;
  126368. autoConfigure(material: NodeMaterial): void;
  126369. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126370. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126371. private _getTextureBase;
  126372. isReady(): boolean;
  126373. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126374. private get _isMixed();
  126375. private _injectVertexCode;
  126376. private _writeTextureRead;
  126377. private _writeOutput;
  126378. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126379. protected _dumpPropertiesCode(): string;
  126380. serialize(): any;
  126381. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126382. }
  126383. }
  126384. declare module BABYLON {
  126385. /**
  126386. * Class used to store shared data between 2 NodeMaterialBuildState
  126387. */
  126388. export class NodeMaterialBuildStateSharedData {
  126389. /**
  126390. * Gets the list of emitted varyings
  126391. */
  126392. temps: string[];
  126393. /**
  126394. * Gets the list of emitted varyings
  126395. */
  126396. varyings: string[];
  126397. /**
  126398. * Gets the varying declaration string
  126399. */
  126400. varyingDeclaration: string;
  126401. /**
  126402. * Input blocks
  126403. */
  126404. inputBlocks: InputBlock[];
  126405. /**
  126406. * Input blocks
  126407. */
  126408. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  126409. /**
  126410. * Bindable blocks (Blocks that need to set data to the effect)
  126411. */
  126412. bindableBlocks: NodeMaterialBlock[];
  126413. /**
  126414. * List of blocks that can provide a compilation fallback
  126415. */
  126416. blocksWithFallbacks: NodeMaterialBlock[];
  126417. /**
  126418. * List of blocks that can provide a define update
  126419. */
  126420. blocksWithDefines: NodeMaterialBlock[];
  126421. /**
  126422. * List of blocks that can provide a repeatable content
  126423. */
  126424. repeatableContentBlocks: NodeMaterialBlock[];
  126425. /**
  126426. * List of blocks that can provide a dynamic list of uniforms
  126427. */
  126428. dynamicUniformBlocks: NodeMaterialBlock[];
  126429. /**
  126430. * List of blocks that can block the isReady function for the material
  126431. */
  126432. blockingBlocks: NodeMaterialBlock[];
  126433. /**
  126434. * Gets the list of animated inputs
  126435. */
  126436. animatedInputs: InputBlock[];
  126437. /**
  126438. * Build Id used to avoid multiple recompilations
  126439. */
  126440. buildId: number;
  126441. /** List of emitted variables */
  126442. variableNames: {
  126443. [key: string]: number;
  126444. };
  126445. /** List of emitted defines */
  126446. defineNames: {
  126447. [key: string]: number;
  126448. };
  126449. /** Should emit comments? */
  126450. emitComments: boolean;
  126451. /** Emit build activity */
  126452. verbose: boolean;
  126453. /** Gets or sets the hosting scene */
  126454. scene: Scene;
  126455. /**
  126456. * Gets the compilation hints emitted at compilation time
  126457. */
  126458. hints: {
  126459. needWorldViewMatrix: boolean;
  126460. needWorldViewProjectionMatrix: boolean;
  126461. needAlphaBlending: boolean;
  126462. needAlphaTesting: boolean;
  126463. };
  126464. /**
  126465. * List of compilation checks
  126466. */
  126467. checks: {
  126468. emitVertex: boolean;
  126469. emitFragment: boolean;
  126470. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  126471. };
  126472. /** Creates a new shared data */
  126473. constructor();
  126474. /**
  126475. * Emits console errors and exceptions if there is a failing check
  126476. */
  126477. emitErrors(): void;
  126478. }
  126479. }
  126480. declare module BABYLON {
  126481. /**
  126482. * Class used to store node based material build state
  126483. */
  126484. export class NodeMaterialBuildState {
  126485. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  126486. supportUniformBuffers: boolean;
  126487. /**
  126488. * Gets the list of emitted attributes
  126489. */
  126490. attributes: string[];
  126491. /**
  126492. * Gets the list of emitted uniforms
  126493. */
  126494. uniforms: string[];
  126495. /**
  126496. * Gets the list of emitted constants
  126497. */
  126498. constants: string[];
  126499. /**
  126500. * Gets the list of emitted samplers
  126501. */
  126502. samplers: string[];
  126503. /**
  126504. * Gets the list of emitted functions
  126505. */
  126506. functions: {
  126507. [key: string]: string;
  126508. };
  126509. /**
  126510. * Gets the list of emitted extensions
  126511. */
  126512. extensions: {
  126513. [key: string]: string;
  126514. };
  126515. /**
  126516. * Gets the target of the compilation state
  126517. */
  126518. target: NodeMaterialBlockTargets;
  126519. /**
  126520. * Gets the list of emitted counters
  126521. */
  126522. counters: {
  126523. [key: string]: number;
  126524. };
  126525. /**
  126526. * Shared data between multiple NodeMaterialBuildState instances
  126527. */
  126528. sharedData: NodeMaterialBuildStateSharedData;
  126529. /** @hidden */
  126530. _vertexState: NodeMaterialBuildState;
  126531. /** @hidden */
  126532. _attributeDeclaration: string;
  126533. /** @hidden */
  126534. _uniformDeclaration: string;
  126535. /** @hidden */
  126536. _constantDeclaration: string;
  126537. /** @hidden */
  126538. _samplerDeclaration: string;
  126539. /** @hidden */
  126540. _varyingTransfer: string;
  126541. private _repeatableContentAnchorIndex;
  126542. /** @hidden */
  126543. _builtCompilationString: string;
  126544. /**
  126545. * Gets the emitted compilation strings
  126546. */
  126547. compilationString: string;
  126548. /**
  126549. * Finalize the compilation strings
  126550. * @param state defines the current compilation state
  126551. */
  126552. finalize(state: NodeMaterialBuildState): void;
  126553. /** @hidden */
  126554. get _repeatableContentAnchor(): string;
  126555. /** @hidden */
  126556. _getFreeVariableName(prefix: string): string;
  126557. /** @hidden */
  126558. _getFreeDefineName(prefix: string): string;
  126559. /** @hidden */
  126560. _excludeVariableName(name: string): void;
  126561. /** @hidden */
  126562. _emit2DSampler(name: string): void;
  126563. /** @hidden */
  126564. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  126565. /** @hidden */
  126566. _emitExtension(name: string, extension: string): void;
  126567. /** @hidden */
  126568. _emitFunction(name: string, code: string, comments: string): void;
  126569. /** @hidden */
  126570. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  126571. replaceStrings?: {
  126572. search: RegExp;
  126573. replace: string;
  126574. }[];
  126575. repeatKey?: string;
  126576. }): string;
  126577. /** @hidden */
  126578. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  126579. repeatKey?: string;
  126580. removeAttributes?: boolean;
  126581. removeUniforms?: boolean;
  126582. removeVaryings?: boolean;
  126583. removeIfDef?: boolean;
  126584. replaceStrings?: {
  126585. search: RegExp;
  126586. replace: string;
  126587. }[];
  126588. }, storeKey?: string): void;
  126589. /** @hidden */
  126590. _registerTempVariable(name: string): boolean;
  126591. /** @hidden */
  126592. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  126593. /** @hidden */
  126594. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  126595. /** @hidden */
  126596. _emitFloat(value: number): string;
  126597. }
  126598. }
  126599. declare module BABYLON {
  126600. /**
  126601. * Defines a block that can be used inside a node based material
  126602. */
  126603. export class NodeMaterialBlock {
  126604. private _buildId;
  126605. private _buildTarget;
  126606. private _target;
  126607. private _isFinalMerger;
  126608. private _isInput;
  126609. protected _isUnique: boolean;
  126610. /** @hidden */
  126611. _codeVariableName: string;
  126612. /** @hidden */
  126613. _inputs: NodeMaterialConnectionPoint[];
  126614. /** @hidden */
  126615. _outputs: NodeMaterialConnectionPoint[];
  126616. /** @hidden */
  126617. _preparationId: number;
  126618. /**
  126619. * Gets or sets the name of the block
  126620. */
  126621. name: string;
  126622. /**
  126623. * Gets or sets the unique id of the node
  126624. */
  126625. uniqueId: number;
  126626. /**
  126627. * Gets or sets the comments associated with this block
  126628. */
  126629. comments: string;
  126630. /**
  126631. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  126632. */
  126633. get isUnique(): boolean;
  126634. /**
  126635. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  126636. */
  126637. get isFinalMerger(): boolean;
  126638. /**
  126639. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  126640. */
  126641. get isInput(): boolean;
  126642. /**
  126643. * Gets or sets the build Id
  126644. */
  126645. get buildId(): number;
  126646. set buildId(value: number);
  126647. /**
  126648. * Gets or sets the target of the block
  126649. */
  126650. get target(): NodeMaterialBlockTargets;
  126651. set target(value: NodeMaterialBlockTargets);
  126652. /**
  126653. * Gets the list of input points
  126654. */
  126655. get inputs(): NodeMaterialConnectionPoint[];
  126656. /** Gets the list of output points */
  126657. get outputs(): NodeMaterialConnectionPoint[];
  126658. /**
  126659. * Find an input by its name
  126660. * @param name defines the name of the input to look for
  126661. * @returns the input or null if not found
  126662. */
  126663. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126664. /**
  126665. * Find an output by its name
  126666. * @param name defines the name of the outputto look for
  126667. * @returns the output or null if not found
  126668. */
  126669. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126670. /**
  126671. * Creates a new NodeMaterialBlock
  126672. * @param name defines the block name
  126673. * @param target defines the target of that block (Vertex by default)
  126674. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  126675. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  126676. */
  126677. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  126678. /**
  126679. * Initialize the block and prepare the context for build
  126680. * @param state defines the state that will be used for the build
  126681. */
  126682. initialize(state: NodeMaterialBuildState): void;
  126683. /**
  126684. * Bind data to effect. Will only be called for blocks with isBindable === true
  126685. * @param effect defines the effect to bind data to
  126686. * @param nodeMaterial defines the hosting NodeMaterial
  126687. * @param mesh defines the mesh that will be rendered
  126688. */
  126689. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126690. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  126691. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  126692. protected _writeFloat(value: number): string;
  126693. /**
  126694. * Gets the current class name e.g. "NodeMaterialBlock"
  126695. * @returns the class name
  126696. */
  126697. getClassName(): string;
  126698. /**
  126699. * Register a new input. Must be called inside a block constructor
  126700. * @param name defines the connection point name
  126701. * @param type defines the connection point type
  126702. * @param isOptional defines a boolean indicating that this input can be omitted
  126703. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126704. * @returns the current block
  126705. */
  126706. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  126707. /**
  126708. * Register a new output. Must be called inside a block constructor
  126709. * @param name defines the connection point name
  126710. * @param type defines the connection point type
  126711. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126712. * @returns the current block
  126713. */
  126714. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  126715. /**
  126716. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  126717. * @param forOutput defines an optional connection point to check compatibility with
  126718. * @returns the first available input or null
  126719. */
  126720. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  126721. /**
  126722. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  126723. * @param forBlock defines an optional block to check compatibility with
  126724. * @returns the first available input or null
  126725. */
  126726. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  126727. /**
  126728. * Gets the sibling of the given output
  126729. * @param current defines the current output
  126730. * @returns the next output in the list or null
  126731. */
  126732. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  126733. /**
  126734. * Connect current block with another block
  126735. * @param other defines the block to connect with
  126736. * @param options define the various options to help pick the right connections
  126737. * @returns the current block
  126738. */
  126739. connectTo(other: NodeMaterialBlock, options?: {
  126740. input?: string;
  126741. output?: string;
  126742. outputSwizzle?: string;
  126743. }): this | undefined;
  126744. protected _buildBlock(state: NodeMaterialBuildState): void;
  126745. /**
  126746. * Add uniforms, samplers and uniform buffers at compilation time
  126747. * @param state defines the state to update
  126748. * @param nodeMaterial defines the node material requesting the update
  126749. * @param defines defines the material defines to update
  126750. * @param uniformBuffers defines the list of uniform buffer names
  126751. */
  126752. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  126753. /**
  126754. * Add potential fallbacks if shader compilation fails
  126755. * @param mesh defines the mesh to be rendered
  126756. * @param fallbacks defines the current prioritized list of fallbacks
  126757. */
  126758. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  126759. /**
  126760. * Initialize defines for shader compilation
  126761. * @param mesh defines the mesh to be rendered
  126762. * @param nodeMaterial defines the node material requesting the update
  126763. * @param defines defines the material defines to update
  126764. * @param useInstances specifies that instances should be used
  126765. */
  126766. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126767. /**
  126768. * Update defines for shader compilation
  126769. * @param mesh defines the mesh to be rendered
  126770. * @param nodeMaterial defines the node material requesting the update
  126771. * @param defines defines the material defines to update
  126772. * @param useInstances specifies that instances should be used
  126773. */
  126774. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126775. /**
  126776. * Lets the block try to connect some inputs automatically
  126777. * @param material defines the hosting NodeMaterial
  126778. */
  126779. autoConfigure(material: NodeMaterial): void;
  126780. /**
  126781. * Function called when a block is declared as repeatable content generator
  126782. * @param vertexShaderState defines the current compilation state for the vertex shader
  126783. * @param fragmentShaderState defines the current compilation state for the fragment shader
  126784. * @param mesh defines the mesh to be rendered
  126785. * @param defines defines the material defines to update
  126786. */
  126787. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  126788. /**
  126789. * Checks if the block is ready
  126790. * @param mesh defines the mesh to be rendered
  126791. * @param nodeMaterial defines the node material requesting the update
  126792. * @param defines defines the material defines to update
  126793. * @param useInstances specifies that instances should be used
  126794. * @returns true if the block is ready
  126795. */
  126796. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  126797. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  126798. private _processBuild;
  126799. /**
  126800. * Compile the current node and generate the shader code
  126801. * @param state defines the current compilation state (uniforms, samplers, current string)
  126802. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  126803. * @returns true if already built
  126804. */
  126805. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  126806. protected _inputRename(name: string): string;
  126807. protected _outputRename(name: string): string;
  126808. protected _dumpPropertiesCode(): string;
  126809. /** @hidden */
  126810. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  126811. /** @hidden */
  126812. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  126813. /**
  126814. * Clone the current block to a new identical block
  126815. * @param scene defines the hosting scene
  126816. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126817. * @returns a copy of the current block
  126818. */
  126819. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  126820. /**
  126821. * Serializes this block in a JSON representation
  126822. * @returns the serialized block object
  126823. */
  126824. serialize(): any;
  126825. /** @hidden */
  126826. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126827. /**
  126828. * Release resources
  126829. */
  126830. dispose(): void;
  126831. }
  126832. }
  126833. declare module BABYLON {
  126834. /**
  126835. * Enum defining the type of animations supported by InputBlock
  126836. */
  126837. export enum AnimatedInputBlockTypes {
  126838. /** No animation */
  126839. None = 0,
  126840. /** Time based animation. Will only work for floats */
  126841. Time = 1
  126842. }
  126843. }
  126844. declare module BABYLON {
  126845. /**
  126846. * Block used to expose an input value
  126847. */
  126848. export class InputBlock extends NodeMaterialBlock {
  126849. private _mode;
  126850. private _associatedVariableName;
  126851. private _storedValue;
  126852. private _valueCallback;
  126853. private _type;
  126854. private _animationType;
  126855. /** Gets or set a value used to limit the range of float values */
  126856. min: number;
  126857. /** Gets or set a value used to limit the range of float values */
  126858. max: number;
  126859. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  126860. matrixMode: number;
  126861. /** @hidden */
  126862. _systemValue: Nullable<NodeMaterialSystemValues>;
  126863. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  126864. visibleInInspector: boolean;
  126865. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  126866. isConstant: boolean;
  126867. /** Gets or sets the group to use to display this block in the Inspector */
  126868. groupInInspector: string;
  126869. /**
  126870. * Gets or sets the connection point type (default is float)
  126871. */
  126872. get type(): NodeMaterialBlockConnectionPointTypes;
  126873. /**
  126874. * Creates a new InputBlock
  126875. * @param name defines the block name
  126876. * @param target defines the target of that block (Vertex by default)
  126877. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  126878. */
  126879. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  126880. /**
  126881. * Gets the output component
  126882. */
  126883. get output(): NodeMaterialConnectionPoint;
  126884. /**
  126885. * Set the source of this connection point to a vertex attribute
  126886. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  126887. * @returns the current connection point
  126888. */
  126889. setAsAttribute(attributeName?: string): InputBlock;
  126890. /**
  126891. * Set the source of this connection point to a system value
  126892. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  126893. * @returns the current connection point
  126894. */
  126895. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  126896. /**
  126897. * Gets or sets the value of that point.
  126898. * Please note that this value will be ignored if valueCallback is defined
  126899. */
  126900. get value(): any;
  126901. set value(value: any);
  126902. /**
  126903. * Gets or sets a callback used to get the value of that point.
  126904. * Please note that setting this value will force the connection point to ignore the value property
  126905. */
  126906. get valueCallback(): () => any;
  126907. set valueCallback(value: () => any);
  126908. /**
  126909. * Gets or sets the associated variable name in the shader
  126910. */
  126911. get associatedVariableName(): string;
  126912. set associatedVariableName(value: string);
  126913. /** Gets or sets the type of animation applied to the input */
  126914. get animationType(): AnimatedInputBlockTypes;
  126915. set animationType(value: AnimatedInputBlockTypes);
  126916. /**
  126917. * Gets a boolean indicating that this connection point not defined yet
  126918. */
  126919. get isUndefined(): boolean;
  126920. /**
  126921. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  126922. * In this case the connection point name must be the name of the uniform to use.
  126923. * Can only be set on inputs
  126924. */
  126925. get isUniform(): boolean;
  126926. set isUniform(value: boolean);
  126927. /**
  126928. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  126929. * In this case the connection point name must be the name of the attribute to use
  126930. * Can only be set on inputs
  126931. */
  126932. get isAttribute(): boolean;
  126933. set isAttribute(value: boolean);
  126934. /**
  126935. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  126936. * Can only be set on exit points
  126937. */
  126938. get isVarying(): boolean;
  126939. set isVarying(value: boolean);
  126940. /**
  126941. * Gets a boolean indicating that the current connection point is a system value
  126942. */
  126943. get isSystemValue(): boolean;
  126944. /**
  126945. * Gets or sets the current well known value or null if not defined as a system value
  126946. */
  126947. get systemValue(): Nullable<NodeMaterialSystemValues>;
  126948. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  126949. /**
  126950. * Gets the current class name
  126951. * @returns the class name
  126952. */
  126953. getClassName(): string;
  126954. /**
  126955. * Animate the input if animationType !== None
  126956. * @param scene defines the rendering scene
  126957. */
  126958. animate(scene: Scene): void;
  126959. private _emitDefine;
  126960. initialize(state: NodeMaterialBuildState): void;
  126961. /**
  126962. * Set the input block to its default value (based on its type)
  126963. */
  126964. setDefaultValue(): void;
  126965. private _emitConstant;
  126966. private _emit;
  126967. /** @hidden */
  126968. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  126969. /** @hidden */
  126970. _transmit(effect: Effect, scene: Scene): void;
  126971. protected _buildBlock(state: NodeMaterialBuildState): void;
  126972. protected _dumpPropertiesCode(): string;
  126973. serialize(): any;
  126974. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126975. }
  126976. }
  126977. declare module BABYLON {
  126978. /**
  126979. * Enum used to define the compatibility state between two connection points
  126980. */
  126981. export enum NodeMaterialConnectionPointCompatibilityStates {
  126982. /** Points are compatibles */
  126983. Compatible = 0,
  126984. /** Points are incompatible because of their types */
  126985. TypeIncompatible = 1,
  126986. /** Points are incompatible because of their targets (vertex vs fragment) */
  126987. TargetIncompatible = 2
  126988. }
  126989. /**
  126990. * Defines the direction of a connection point
  126991. */
  126992. export enum NodeMaterialConnectionPointDirection {
  126993. /** Input */
  126994. Input = 0,
  126995. /** Output */
  126996. Output = 1
  126997. }
  126998. /**
  126999. * Defines a connection point for a block
  127000. */
  127001. export class NodeMaterialConnectionPoint {
  127002. /** @hidden */
  127003. _ownerBlock: NodeMaterialBlock;
  127004. /** @hidden */
  127005. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  127006. private _endpoints;
  127007. private _associatedVariableName;
  127008. private _direction;
  127009. /** @hidden */
  127010. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  127011. /** @hidden */
  127012. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  127013. private _type;
  127014. /** @hidden */
  127015. _enforceAssociatedVariableName: boolean;
  127016. /** Gets the direction of the point */
  127017. get direction(): NodeMaterialConnectionPointDirection;
  127018. /**
  127019. * Gets or sets the additional types supported by this connection point
  127020. */
  127021. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  127022. /**
  127023. * Gets or sets the additional types excluded by this connection point
  127024. */
  127025. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  127026. /**
  127027. * Observable triggered when this point is connected
  127028. */
  127029. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  127030. /**
  127031. * Gets or sets the associated variable name in the shader
  127032. */
  127033. get associatedVariableName(): string;
  127034. set associatedVariableName(value: string);
  127035. /**
  127036. * Gets or sets the connection point type (default is float)
  127037. */
  127038. get type(): NodeMaterialBlockConnectionPointTypes;
  127039. set type(value: NodeMaterialBlockConnectionPointTypes);
  127040. /**
  127041. * Gets or sets the connection point name
  127042. */
  127043. name: string;
  127044. /**
  127045. * Gets or sets a boolean indicating that this connection point can be omitted
  127046. */
  127047. isOptional: boolean;
  127048. /**
  127049. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  127050. */
  127051. define: string;
  127052. /** @hidden */
  127053. _prioritizeVertex: boolean;
  127054. private _target;
  127055. /** Gets or sets the target of that connection point */
  127056. get target(): NodeMaterialBlockTargets;
  127057. set target(value: NodeMaterialBlockTargets);
  127058. /**
  127059. * Gets a boolean indicating that the current point is connected
  127060. */
  127061. get isConnected(): boolean;
  127062. /**
  127063. * Gets a boolean indicating that the current point is connected to an input block
  127064. */
  127065. get isConnectedToInputBlock(): boolean;
  127066. /**
  127067. * Gets a the connected input block (if any)
  127068. */
  127069. get connectInputBlock(): Nullable<InputBlock>;
  127070. /** Get the other side of the connection (if any) */
  127071. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  127072. /** Get the block that owns this connection point */
  127073. get ownerBlock(): NodeMaterialBlock;
  127074. /** Get the block connected on the other side of this connection (if any) */
  127075. get sourceBlock(): Nullable<NodeMaterialBlock>;
  127076. /** Get the block connected on the endpoints of this connection (if any) */
  127077. get connectedBlocks(): Array<NodeMaterialBlock>;
  127078. /** Gets the list of connected endpoints */
  127079. get endpoints(): NodeMaterialConnectionPoint[];
  127080. /** Gets a boolean indicating if that output point is connected to at least one input */
  127081. get hasEndpoints(): boolean;
  127082. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  127083. get isConnectedInVertexShader(): boolean;
  127084. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  127085. get isConnectedInFragmentShader(): boolean;
  127086. /**
  127087. * Creates a new connection point
  127088. * @param name defines the connection point name
  127089. * @param ownerBlock defines the block hosting this connection point
  127090. * @param direction defines the direction of the connection point
  127091. */
  127092. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  127093. /**
  127094. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  127095. * @returns the class name
  127096. */
  127097. getClassName(): string;
  127098. /**
  127099. * Gets a boolean indicating if the current point can be connected to another point
  127100. * @param connectionPoint defines the other connection point
  127101. * @returns a boolean
  127102. */
  127103. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  127104. /**
  127105. * Gets a number indicating if the current point can be connected to another point
  127106. * @param connectionPoint defines the other connection point
  127107. * @returns a number defining the compatibility state
  127108. */
  127109. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  127110. /**
  127111. * Connect this point to another connection point
  127112. * @param connectionPoint defines the other connection point
  127113. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  127114. * @returns the current connection point
  127115. */
  127116. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  127117. /**
  127118. * Disconnect this point from one of his endpoint
  127119. * @param endpoint defines the other connection point
  127120. * @returns the current connection point
  127121. */
  127122. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  127123. /**
  127124. * Serializes this point in a JSON representation
  127125. * @returns the serialized point object
  127126. */
  127127. serialize(): any;
  127128. /**
  127129. * Release resources
  127130. */
  127131. dispose(): void;
  127132. }
  127133. }
  127134. declare module BABYLON {
  127135. /**
  127136. * Block used to add support for vertex skinning (bones)
  127137. */
  127138. export class BonesBlock extends NodeMaterialBlock {
  127139. /**
  127140. * Creates a new BonesBlock
  127141. * @param name defines the block name
  127142. */
  127143. constructor(name: string);
  127144. /**
  127145. * Initialize the block and prepare the context for build
  127146. * @param state defines the state that will be used for the build
  127147. */
  127148. initialize(state: NodeMaterialBuildState): void;
  127149. /**
  127150. * Gets the current class name
  127151. * @returns the class name
  127152. */
  127153. getClassName(): string;
  127154. /**
  127155. * Gets the matrix indices input component
  127156. */
  127157. get matricesIndices(): NodeMaterialConnectionPoint;
  127158. /**
  127159. * Gets the matrix weights input component
  127160. */
  127161. get matricesWeights(): NodeMaterialConnectionPoint;
  127162. /**
  127163. * Gets the extra matrix indices input component
  127164. */
  127165. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  127166. /**
  127167. * Gets the extra matrix weights input component
  127168. */
  127169. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  127170. /**
  127171. * Gets the world input component
  127172. */
  127173. get world(): NodeMaterialConnectionPoint;
  127174. /**
  127175. * Gets the output component
  127176. */
  127177. get output(): NodeMaterialConnectionPoint;
  127178. autoConfigure(material: NodeMaterial): void;
  127179. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  127180. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127181. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127182. protected _buildBlock(state: NodeMaterialBuildState): this;
  127183. }
  127184. }
  127185. declare module BABYLON {
  127186. /**
  127187. * Block used to add support for instances
  127188. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  127189. */
  127190. export class InstancesBlock extends NodeMaterialBlock {
  127191. /**
  127192. * Creates a new InstancesBlock
  127193. * @param name defines the block name
  127194. */
  127195. constructor(name: string);
  127196. /**
  127197. * Gets the current class name
  127198. * @returns the class name
  127199. */
  127200. getClassName(): string;
  127201. /**
  127202. * Gets the first world row input component
  127203. */
  127204. get world0(): NodeMaterialConnectionPoint;
  127205. /**
  127206. * Gets the second world row input component
  127207. */
  127208. get world1(): NodeMaterialConnectionPoint;
  127209. /**
  127210. * Gets the third world row input component
  127211. */
  127212. get world2(): NodeMaterialConnectionPoint;
  127213. /**
  127214. * Gets the forth world row input component
  127215. */
  127216. get world3(): NodeMaterialConnectionPoint;
  127217. /**
  127218. * Gets the world input component
  127219. */
  127220. get world(): NodeMaterialConnectionPoint;
  127221. /**
  127222. * Gets the output component
  127223. */
  127224. get output(): NodeMaterialConnectionPoint;
  127225. autoConfigure(material: NodeMaterial): void;
  127226. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  127227. protected _buildBlock(state: NodeMaterialBuildState): this;
  127228. }
  127229. }
  127230. declare module BABYLON {
  127231. /**
  127232. * Block used to add morph targets support to vertex shader
  127233. */
  127234. export class MorphTargetsBlock extends NodeMaterialBlock {
  127235. private _repeatableContentAnchor;
  127236. private _repeatebleContentGenerated;
  127237. /**
  127238. * Create a new MorphTargetsBlock
  127239. * @param name defines the block name
  127240. */
  127241. constructor(name: string);
  127242. /**
  127243. * Gets the current class name
  127244. * @returns the class name
  127245. */
  127246. getClassName(): string;
  127247. /**
  127248. * Gets the position input component
  127249. */
  127250. get position(): NodeMaterialConnectionPoint;
  127251. /**
  127252. * Gets the normal input component
  127253. */
  127254. get normal(): NodeMaterialConnectionPoint;
  127255. /**
  127256. * Gets the tangent input component
  127257. */
  127258. get tangent(): NodeMaterialConnectionPoint;
  127259. /**
  127260. * Gets the tangent input component
  127261. */
  127262. get uv(): NodeMaterialConnectionPoint;
  127263. /**
  127264. * Gets the position output component
  127265. */
  127266. get positionOutput(): NodeMaterialConnectionPoint;
  127267. /**
  127268. * Gets the normal output component
  127269. */
  127270. get normalOutput(): NodeMaterialConnectionPoint;
  127271. /**
  127272. * Gets the tangent output component
  127273. */
  127274. get tangentOutput(): NodeMaterialConnectionPoint;
  127275. /**
  127276. * Gets the tangent output component
  127277. */
  127278. get uvOutput(): NodeMaterialConnectionPoint;
  127279. initialize(state: NodeMaterialBuildState): void;
  127280. autoConfigure(material: NodeMaterial): void;
  127281. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127283. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  127284. protected _buildBlock(state: NodeMaterialBuildState): this;
  127285. }
  127286. }
  127287. declare module BABYLON {
  127288. /**
  127289. * Block used to get data information from a light
  127290. */
  127291. export class LightInformationBlock extends NodeMaterialBlock {
  127292. private _lightDataUniformName;
  127293. private _lightColorUniformName;
  127294. private _lightTypeDefineName;
  127295. /**
  127296. * Gets or sets the light associated with this block
  127297. */
  127298. light: Nullable<Light>;
  127299. /**
  127300. * Creates a new LightInformationBlock
  127301. * @param name defines the block name
  127302. */
  127303. constructor(name: string);
  127304. /**
  127305. * Gets the current class name
  127306. * @returns the class name
  127307. */
  127308. getClassName(): string;
  127309. /**
  127310. * Gets the world position input component
  127311. */
  127312. get worldPosition(): NodeMaterialConnectionPoint;
  127313. /**
  127314. * Gets the direction output component
  127315. */
  127316. get direction(): NodeMaterialConnectionPoint;
  127317. /**
  127318. * Gets the direction output component
  127319. */
  127320. get color(): NodeMaterialConnectionPoint;
  127321. /**
  127322. * Gets the direction output component
  127323. */
  127324. get intensity(): NodeMaterialConnectionPoint;
  127325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127326. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127327. protected _buildBlock(state: NodeMaterialBuildState): this;
  127328. serialize(): any;
  127329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127330. }
  127331. }
  127332. declare module BABYLON {
  127333. /**
  127334. * Block used to add image processing support to fragment shader
  127335. */
  127336. export class ImageProcessingBlock extends NodeMaterialBlock {
  127337. /**
  127338. * Create a new ImageProcessingBlock
  127339. * @param name defines the block name
  127340. */
  127341. constructor(name: string);
  127342. /**
  127343. * Gets the current class name
  127344. * @returns the class name
  127345. */
  127346. getClassName(): string;
  127347. /**
  127348. * Gets the color input component
  127349. */
  127350. get color(): NodeMaterialConnectionPoint;
  127351. /**
  127352. * Gets the output component
  127353. */
  127354. get output(): NodeMaterialConnectionPoint;
  127355. /**
  127356. * Initialize the block and prepare the context for build
  127357. * @param state defines the state that will be used for the build
  127358. */
  127359. initialize(state: NodeMaterialBuildState): void;
  127360. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  127361. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127362. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127363. protected _buildBlock(state: NodeMaterialBuildState): this;
  127364. }
  127365. }
  127366. declare module BABYLON {
  127367. /**
  127368. * Block used to pertub normals based on a normal map
  127369. */
  127370. export class PerturbNormalBlock extends NodeMaterialBlock {
  127371. private _tangentSpaceParameterName;
  127372. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  127373. invertX: boolean;
  127374. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  127375. invertY: boolean;
  127376. /**
  127377. * Create a new PerturbNormalBlock
  127378. * @param name defines the block name
  127379. */
  127380. constructor(name: string);
  127381. /**
  127382. * Gets the current class name
  127383. * @returns the class name
  127384. */
  127385. getClassName(): string;
  127386. /**
  127387. * Gets the world position input component
  127388. */
  127389. get worldPosition(): NodeMaterialConnectionPoint;
  127390. /**
  127391. * Gets the world normal input component
  127392. */
  127393. get worldNormal(): NodeMaterialConnectionPoint;
  127394. /**
  127395. * Gets the uv input component
  127396. */
  127397. get uv(): NodeMaterialConnectionPoint;
  127398. /**
  127399. * Gets the normal map color input component
  127400. */
  127401. get normalMapColor(): NodeMaterialConnectionPoint;
  127402. /**
  127403. * Gets the strength input component
  127404. */
  127405. get strength(): NodeMaterialConnectionPoint;
  127406. /**
  127407. * Gets the output component
  127408. */
  127409. get output(): NodeMaterialConnectionPoint;
  127410. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127411. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127412. autoConfigure(material: NodeMaterial): void;
  127413. protected _buildBlock(state: NodeMaterialBuildState): this;
  127414. protected _dumpPropertiesCode(): string;
  127415. serialize(): any;
  127416. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127417. }
  127418. }
  127419. declare module BABYLON {
  127420. /**
  127421. * Block used to discard a pixel if a value is smaller than a cutoff
  127422. */
  127423. export class DiscardBlock extends NodeMaterialBlock {
  127424. /**
  127425. * Create a new DiscardBlock
  127426. * @param name defines the block name
  127427. */
  127428. constructor(name: string);
  127429. /**
  127430. * Gets the current class name
  127431. * @returns the class name
  127432. */
  127433. getClassName(): string;
  127434. /**
  127435. * Gets the color input component
  127436. */
  127437. get value(): NodeMaterialConnectionPoint;
  127438. /**
  127439. * Gets the cutoff input component
  127440. */
  127441. get cutoff(): NodeMaterialConnectionPoint;
  127442. protected _buildBlock(state: NodeMaterialBuildState): this;
  127443. }
  127444. }
  127445. declare module BABYLON {
  127446. /**
  127447. * Block used to test if the fragment shader is front facing
  127448. */
  127449. export class FrontFacingBlock extends NodeMaterialBlock {
  127450. /**
  127451. * Creates a new FrontFacingBlock
  127452. * @param name defines the block name
  127453. */
  127454. constructor(name: string);
  127455. /**
  127456. * Gets the current class name
  127457. * @returns the class name
  127458. */
  127459. getClassName(): string;
  127460. /**
  127461. * Gets the output component
  127462. */
  127463. get output(): NodeMaterialConnectionPoint;
  127464. protected _buildBlock(state: NodeMaterialBuildState): this;
  127465. }
  127466. }
  127467. declare module BABYLON {
  127468. /**
  127469. * Block used to get the derivative value on x and y of a given input
  127470. */
  127471. export class DerivativeBlock extends NodeMaterialBlock {
  127472. /**
  127473. * Create a new DerivativeBlock
  127474. * @param name defines the block name
  127475. */
  127476. constructor(name: string);
  127477. /**
  127478. * Gets the current class name
  127479. * @returns the class name
  127480. */
  127481. getClassName(): string;
  127482. /**
  127483. * Gets the input component
  127484. */
  127485. get input(): NodeMaterialConnectionPoint;
  127486. /**
  127487. * Gets the derivative output on x
  127488. */
  127489. get dx(): NodeMaterialConnectionPoint;
  127490. /**
  127491. * Gets the derivative output on y
  127492. */
  127493. get dy(): NodeMaterialConnectionPoint;
  127494. protected _buildBlock(state: NodeMaterialBuildState): this;
  127495. }
  127496. }
  127497. declare module BABYLON {
  127498. /**
  127499. * Block used to add support for scene fog
  127500. */
  127501. export class FogBlock extends NodeMaterialBlock {
  127502. private _fogDistanceName;
  127503. private _fogParameters;
  127504. /**
  127505. * Create a new FogBlock
  127506. * @param name defines the block name
  127507. */
  127508. constructor(name: string);
  127509. /**
  127510. * Gets the current class name
  127511. * @returns the class name
  127512. */
  127513. getClassName(): string;
  127514. /**
  127515. * Gets the world position input component
  127516. */
  127517. get worldPosition(): NodeMaterialConnectionPoint;
  127518. /**
  127519. * Gets the view input component
  127520. */
  127521. get view(): NodeMaterialConnectionPoint;
  127522. /**
  127523. * Gets the color input component
  127524. */
  127525. get input(): NodeMaterialConnectionPoint;
  127526. /**
  127527. * Gets the fog color input component
  127528. */
  127529. get fogColor(): NodeMaterialConnectionPoint;
  127530. /**
  127531. * Gets the output component
  127532. */
  127533. get output(): NodeMaterialConnectionPoint;
  127534. autoConfigure(material: NodeMaterial): void;
  127535. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127536. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127537. protected _buildBlock(state: NodeMaterialBuildState): this;
  127538. }
  127539. }
  127540. declare module BABYLON {
  127541. /**
  127542. * Block used to add light in the fragment shader
  127543. */
  127544. export class LightBlock extends NodeMaterialBlock {
  127545. private _lightId;
  127546. /**
  127547. * Gets or sets the light associated with this block
  127548. */
  127549. light: Nullable<Light>;
  127550. /**
  127551. * Create a new LightBlock
  127552. * @param name defines the block name
  127553. */
  127554. constructor(name: string);
  127555. /**
  127556. * Gets the current class name
  127557. * @returns the class name
  127558. */
  127559. getClassName(): string;
  127560. /**
  127561. * Gets the world position input component
  127562. */
  127563. get worldPosition(): NodeMaterialConnectionPoint;
  127564. /**
  127565. * Gets the world normal input component
  127566. */
  127567. get worldNormal(): NodeMaterialConnectionPoint;
  127568. /**
  127569. * Gets the camera (or eye) position component
  127570. */
  127571. get cameraPosition(): NodeMaterialConnectionPoint;
  127572. /**
  127573. * Gets the glossiness component
  127574. */
  127575. get glossiness(): NodeMaterialConnectionPoint;
  127576. /**
  127577. * Gets the glossinness power component
  127578. */
  127579. get glossPower(): NodeMaterialConnectionPoint;
  127580. /**
  127581. * Gets the diffuse color component
  127582. */
  127583. get diffuseColor(): NodeMaterialConnectionPoint;
  127584. /**
  127585. * Gets the specular color component
  127586. */
  127587. get specularColor(): NodeMaterialConnectionPoint;
  127588. /**
  127589. * Gets the diffuse output component
  127590. */
  127591. get diffuseOutput(): NodeMaterialConnectionPoint;
  127592. /**
  127593. * Gets the specular output component
  127594. */
  127595. get specularOutput(): NodeMaterialConnectionPoint;
  127596. /**
  127597. * Gets the shadow output component
  127598. */
  127599. get shadow(): NodeMaterialConnectionPoint;
  127600. autoConfigure(material: NodeMaterial): void;
  127601. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127602. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  127603. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127604. private _injectVertexCode;
  127605. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127606. serialize(): any;
  127607. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127608. }
  127609. }
  127610. declare module BABYLON {
  127611. /**
  127612. * Block used to multiply 2 values
  127613. */
  127614. export class MultiplyBlock extends NodeMaterialBlock {
  127615. /**
  127616. * Creates a new MultiplyBlock
  127617. * @param name defines the block name
  127618. */
  127619. constructor(name: string);
  127620. /**
  127621. * Gets the current class name
  127622. * @returns the class name
  127623. */
  127624. getClassName(): string;
  127625. /**
  127626. * Gets the left operand input component
  127627. */
  127628. get left(): NodeMaterialConnectionPoint;
  127629. /**
  127630. * Gets the right operand input component
  127631. */
  127632. get right(): NodeMaterialConnectionPoint;
  127633. /**
  127634. * Gets the output component
  127635. */
  127636. get output(): NodeMaterialConnectionPoint;
  127637. protected _buildBlock(state: NodeMaterialBuildState): this;
  127638. }
  127639. }
  127640. declare module BABYLON {
  127641. /**
  127642. * Block used to add 2 vectors
  127643. */
  127644. export class AddBlock extends NodeMaterialBlock {
  127645. /**
  127646. * Creates a new AddBlock
  127647. * @param name defines the block name
  127648. */
  127649. constructor(name: string);
  127650. /**
  127651. * Gets the current class name
  127652. * @returns the class name
  127653. */
  127654. getClassName(): string;
  127655. /**
  127656. * Gets the left operand input component
  127657. */
  127658. get left(): NodeMaterialConnectionPoint;
  127659. /**
  127660. * Gets the right operand input component
  127661. */
  127662. get right(): NodeMaterialConnectionPoint;
  127663. /**
  127664. * Gets the output component
  127665. */
  127666. get output(): NodeMaterialConnectionPoint;
  127667. protected _buildBlock(state: NodeMaterialBuildState): this;
  127668. }
  127669. }
  127670. declare module BABYLON {
  127671. /**
  127672. * Block used to scale a vector by a float
  127673. */
  127674. export class ScaleBlock extends NodeMaterialBlock {
  127675. /**
  127676. * Creates a new ScaleBlock
  127677. * @param name defines the block name
  127678. */
  127679. constructor(name: string);
  127680. /**
  127681. * Gets the current class name
  127682. * @returns the class name
  127683. */
  127684. getClassName(): string;
  127685. /**
  127686. * Gets the input component
  127687. */
  127688. get input(): NodeMaterialConnectionPoint;
  127689. /**
  127690. * Gets the factor input component
  127691. */
  127692. get factor(): NodeMaterialConnectionPoint;
  127693. /**
  127694. * Gets the output component
  127695. */
  127696. get output(): NodeMaterialConnectionPoint;
  127697. protected _buildBlock(state: NodeMaterialBuildState): this;
  127698. }
  127699. }
  127700. declare module BABYLON {
  127701. /**
  127702. * Block used to clamp a float
  127703. */
  127704. export class ClampBlock extends NodeMaterialBlock {
  127705. /** Gets or sets the minimum range */
  127706. minimum: number;
  127707. /** Gets or sets the maximum range */
  127708. maximum: number;
  127709. /**
  127710. * Creates a new ClampBlock
  127711. * @param name defines the block name
  127712. */
  127713. constructor(name: string);
  127714. /**
  127715. * Gets the current class name
  127716. * @returns the class name
  127717. */
  127718. getClassName(): string;
  127719. /**
  127720. * Gets the value input component
  127721. */
  127722. get value(): NodeMaterialConnectionPoint;
  127723. /**
  127724. * Gets the output component
  127725. */
  127726. get output(): NodeMaterialConnectionPoint;
  127727. protected _buildBlock(state: NodeMaterialBuildState): this;
  127728. protected _dumpPropertiesCode(): string;
  127729. serialize(): any;
  127730. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127731. }
  127732. }
  127733. declare module BABYLON {
  127734. /**
  127735. * Block used to apply a cross product between 2 vectors
  127736. */
  127737. export class CrossBlock extends NodeMaterialBlock {
  127738. /**
  127739. * Creates a new CrossBlock
  127740. * @param name defines the block name
  127741. */
  127742. constructor(name: string);
  127743. /**
  127744. * Gets the current class name
  127745. * @returns the class name
  127746. */
  127747. getClassName(): string;
  127748. /**
  127749. * Gets the left operand input component
  127750. */
  127751. get left(): NodeMaterialConnectionPoint;
  127752. /**
  127753. * Gets the right operand input component
  127754. */
  127755. get right(): NodeMaterialConnectionPoint;
  127756. /**
  127757. * Gets the output component
  127758. */
  127759. get output(): NodeMaterialConnectionPoint;
  127760. protected _buildBlock(state: NodeMaterialBuildState): this;
  127761. }
  127762. }
  127763. declare module BABYLON {
  127764. /**
  127765. * Block used to apply a dot product between 2 vectors
  127766. */
  127767. export class DotBlock extends NodeMaterialBlock {
  127768. /**
  127769. * Creates a new DotBlock
  127770. * @param name defines the block name
  127771. */
  127772. constructor(name: string);
  127773. /**
  127774. * Gets the current class name
  127775. * @returns the class name
  127776. */
  127777. getClassName(): string;
  127778. /**
  127779. * Gets the left operand input component
  127780. */
  127781. get left(): NodeMaterialConnectionPoint;
  127782. /**
  127783. * Gets the right operand input component
  127784. */
  127785. get right(): NodeMaterialConnectionPoint;
  127786. /**
  127787. * Gets the output component
  127788. */
  127789. get output(): NodeMaterialConnectionPoint;
  127790. protected _buildBlock(state: NodeMaterialBuildState): this;
  127791. }
  127792. }
  127793. declare module BABYLON {
  127794. /**
  127795. * Block used to remap a float from a range to a new one
  127796. */
  127797. export class RemapBlock extends NodeMaterialBlock {
  127798. /**
  127799. * Gets or sets the source range
  127800. */
  127801. sourceRange: Vector2;
  127802. /**
  127803. * Gets or sets the target range
  127804. */
  127805. targetRange: Vector2;
  127806. /**
  127807. * Creates a new RemapBlock
  127808. * @param name defines the block name
  127809. */
  127810. constructor(name: string);
  127811. /**
  127812. * Gets the current class name
  127813. * @returns the class name
  127814. */
  127815. getClassName(): string;
  127816. /**
  127817. * Gets the input component
  127818. */
  127819. get input(): NodeMaterialConnectionPoint;
  127820. /**
  127821. * Gets the source min input component
  127822. */
  127823. get sourceMin(): NodeMaterialConnectionPoint;
  127824. /**
  127825. * Gets the source max input component
  127826. */
  127827. get sourceMax(): NodeMaterialConnectionPoint;
  127828. /**
  127829. * Gets the target min input component
  127830. */
  127831. get targetMin(): NodeMaterialConnectionPoint;
  127832. /**
  127833. * Gets the target max input component
  127834. */
  127835. get targetMax(): NodeMaterialConnectionPoint;
  127836. /**
  127837. * Gets the output component
  127838. */
  127839. get output(): NodeMaterialConnectionPoint;
  127840. protected _buildBlock(state: NodeMaterialBuildState): this;
  127841. protected _dumpPropertiesCode(): string;
  127842. serialize(): any;
  127843. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127844. }
  127845. }
  127846. declare module BABYLON {
  127847. /**
  127848. * Block used to normalize a vector
  127849. */
  127850. export class NormalizeBlock extends NodeMaterialBlock {
  127851. /**
  127852. * Creates a new NormalizeBlock
  127853. * @param name defines the block name
  127854. */
  127855. constructor(name: string);
  127856. /**
  127857. * Gets the current class name
  127858. * @returns the class name
  127859. */
  127860. getClassName(): string;
  127861. /**
  127862. * Gets the input component
  127863. */
  127864. get input(): NodeMaterialConnectionPoint;
  127865. /**
  127866. * Gets the output component
  127867. */
  127868. get output(): NodeMaterialConnectionPoint;
  127869. protected _buildBlock(state: NodeMaterialBuildState): this;
  127870. }
  127871. }
  127872. declare module BABYLON {
  127873. /**
  127874. * Operations supported by the Trigonometry block
  127875. */
  127876. export enum TrigonometryBlockOperations {
  127877. /** Cos */
  127878. Cos = 0,
  127879. /** Sin */
  127880. Sin = 1,
  127881. /** Abs */
  127882. Abs = 2,
  127883. /** Exp */
  127884. Exp = 3,
  127885. /** Exp2 */
  127886. Exp2 = 4,
  127887. /** Round */
  127888. Round = 5,
  127889. /** Floor */
  127890. Floor = 6,
  127891. /** Ceiling */
  127892. Ceiling = 7,
  127893. /** Square root */
  127894. Sqrt = 8,
  127895. /** Log */
  127896. Log = 9,
  127897. /** Tangent */
  127898. Tan = 10,
  127899. /** Arc tangent */
  127900. ArcTan = 11,
  127901. /** Arc cosinus */
  127902. ArcCos = 12,
  127903. /** Arc sinus */
  127904. ArcSin = 13,
  127905. /** Fraction */
  127906. Fract = 14,
  127907. /** Sign */
  127908. Sign = 15,
  127909. /** To radians (from degrees) */
  127910. Radians = 16,
  127911. /** To degrees (from radians) */
  127912. Degrees = 17
  127913. }
  127914. /**
  127915. * Block used to apply trigonometry operation to floats
  127916. */
  127917. export class TrigonometryBlock extends NodeMaterialBlock {
  127918. /**
  127919. * Gets or sets the operation applied by the block
  127920. */
  127921. operation: TrigonometryBlockOperations;
  127922. /**
  127923. * Creates a new TrigonometryBlock
  127924. * @param name defines the block name
  127925. */
  127926. constructor(name: string);
  127927. /**
  127928. * Gets the current class name
  127929. * @returns the class name
  127930. */
  127931. getClassName(): string;
  127932. /**
  127933. * Gets the input component
  127934. */
  127935. get input(): NodeMaterialConnectionPoint;
  127936. /**
  127937. * Gets the output component
  127938. */
  127939. get output(): NodeMaterialConnectionPoint;
  127940. protected _buildBlock(state: NodeMaterialBuildState): this;
  127941. serialize(): any;
  127942. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127943. protected _dumpPropertiesCode(): string;
  127944. }
  127945. }
  127946. declare module BABYLON {
  127947. /**
  127948. * Block used to create a Color3/4 out of individual inputs (one for each component)
  127949. */
  127950. export class ColorMergerBlock extends NodeMaterialBlock {
  127951. /**
  127952. * Create a new ColorMergerBlock
  127953. * @param name defines the block name
  127954. */
  127955. constructor(name: string);
  127956. /**
  127957. * Gets the current class name
  127958. * @returns the class name
  127959. */
  127960. getClassName(): string;
  127961. /**
  127962. * Gets the rgb component (input)
  127963. */
  127964. get rgbIn(): NodeMaterialConnectionPoint;
  127965. /**
  127966. * Gets the r component (input)
  127967. */
  127968. get r(): NodeMaterialConnectionPoint;
  127969. /**
  127970. * Gets the g component (input)
  127971. */
  127972. get g(): NodeMaterialConnectionPoint;
  127973. /**
  127974. * Gets the b component (input)
  127975. */
  127976. get b(): NodeMaterialConnectionPoint;
  127977. /**
  127978. * Gets the a component (input)
  127979. */
  127980. get a(): NodeMaterialConnectionPoint;
  127981. /**
  127982. * Gets the rgba component (output)
  127983. */
  127984. get rgba(): NodeMaterialConnectionPoint;
  127985. /**
  127986. * Gets the rgb component (output)
  127987. */
  127988. get rgbOut(): NodeMaterialConnectionPoint;
  127989. /**
  127990. * Gets the rgb component (output)
  127991. * @deprecated Please use rgbOut instead.
  127992. */
  127993. get rgb(): NodeMaterialConnectionPoint;
  127994. protected _buildBlock(state: NodeMaterialBuildState): this;
  127995. }
  127996. }
  127997. declare module BABYLON {
  127998. /**
  127999. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  128000. */
  128001. export class VectorMergerBlock extends NodeMaterialBlock {
  128002. /**
  128003. * Create a new VectorMergerBlock
  128004. * @param name defines the block name
  128005. */
  128006. constructor(name: string);
  128007. /**
  128008. * Gets the current class name
  128009. * @returns the class name
  128010. */
  128011. getClassName(): string;
  128012. /**
  128013. * Gets the xyz component (input)
  128014. */
  128015. get xyzIn(): NodeMaterialConnectionPoint;
  128016. /**
  128017. * Gets the xy component (input)
  128018. */
  128019. get xyIn(): NodeMaterialConnectionPoint;
  128020. /**
  128021. * Gets the x component (input)
  128022. */
  128023. get x(): NodeMaterialConnectionPoint;
  128024. /**
  128025. * Gets the y component (input)
  128026. */
  128027. get y(): NodeMaterialConnectionPoint;
  128028. /**
  128029. * Gets the z component (input)
  128030. */
  128031. get z(): NodeMaterialConnectionPoint;
  128032. /**
  128033. * Gets the w component (input)
  128034. */
  128035. get w(): NodeMaterialConnectionPoint;
  128036. /**
  128037. * Gets the xyzw component (output)
  128038. */
  128039. get xyzw(): NodeMaterialConnectionPoint;
  128040. /**
  128041. * Gets the xyz component (output)
  128042. */
  128043. get xyzOut(): NodeMaterialConnectionPoint;
  128044. /**
  128045. * Gets the xy component (output)
  128046. */
  128047. get xyOut(): NodeMaterialConnectionPoint;
  128048. /**
  128049. * Gets the xy component (output)
  128050. * @deprecated Please use xyOut instead.
  128051. */
  128052. get xy(): NodeMaterialConnectionPoint;
  128053. /**
  128054. * Gets the xyz component (output)
  128055. * @deprecated Please use xyzOut instead.
  128056. */
  128057. get xyz(): NodeMaterialConnectionPoint;
  128058. protected _buildBlock(state: NodeMaterialBuildState): this;
  128059. }
  128060. }
  128061. declare module BABYLON {
  128062. /**
  128063. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  128064. */
  128065. export class ColorSplitterBlock extends NodeMaterialBlock {
  128066. /**
  128067. * Create a new ColorSplitterBlock
  128068. * @param name defines the block name
  128069. */
  128070. constructor(name: string);
  128071. /**
  128072. * Gets the current class name
  128073. * @returns the class name
  128074. */
  128075. getClassName(): string;
  128076. /**
  128077. * Gets the rgba component (input)
  128078. */
  128079. get rgba(): NodeMaterialConnectionPoint;
  128080. /**
  128081. * Gets the rgb component (input)
  128082. */
  128083. get rgbIn(): NodeMaterialConnectionPoint;
  128084. /**
  128085. * Gets the rgb component (output)
  128086. */
  128087. get rgbOut(): NodeMaterialConnectionPoint;
  128088. /**
  128089. * Gets the r component (output)
  128090. */
  128091. get r(): NodeMaterialConnectionPoint;
  128092. /**
  128093. * Gets the g component (output)
  128094. */
  128095. get g(): NodeMaterialConnectionPoint;
  128096. /**
  128097. * Gets the b component (output)
  128098. */
  128099. get b(): NodeMaterialConnectionPoint;
  128100. /**
  128101. * Gets the a component (output)
  128102. */
  128103. get a(): NodeMaterialConnectionPoint;
  128104. protected _inputRename(name: string): string;
  128105. protected _outputRename(name: string): string;
  128106. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128107. }
  128108. }
  128109. declare module BABYLON {
  128110. /**
  128111. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  128112. */
  128113. export class VectorSplitterBlock extends NodeMaterialBlock {
  128114. /**
  128115. * Create a new VectorSplitterBlock
  128116. * @param name defines the block name
  128117. */
  128118. constructor(name: string);
  128119. /**
  128120. * Gets the current class name
  128121. * @returns the class name
  128122. */
  128123. getClassName(): string;
  128124. /**
  128125. * Gets the xyzw component (input)
  128126. */
  128127. get xyzw(): NodeMaterialConnectionPoint;
  128128. /**
  128129. * Gets the xyz component (input)
  128130. */
  128131. get xyzIn(): NodeMaterialConnectionPoint;
  128132. /**
  128133. * Gets the xy component (input)
  128134. */
  128135. get xyIn(): NodeMaterialConnectionPoint;
  128136. /**
  128137. * Gets the xyz component (output)
  128138. */
  128139. get xyzOut(): NodeMaterialConnectionPoint;
  128140. /**
  128141. * Gets the xy component (output)
  128142. */
  128143. get xyOut(): NodeMaterialConnectionPoint;
  128144. /**
  128145. * Gets the x component (output)
  128146. */
  128147. get x(): NodeMaterialConnectionPoint;
  128148. /**
  128149. * Gets the y component (output)
  128150. */
  128151. get y(): NodeMaterialConnectionPoint;
  128152. /**
  128153. * Gets the z component (output)
  128154. */
  128155. get z(): NodeMaterialConnectionPoint;
  128156. /**
  128157. * Gets the w component (output)
  128158. */
  128159. get w(): NodeMaterialConnectionPoint;
  128160. protected _inputRename(name: string): string;
  128161. protected _outputRename(name: string): string;
  128162. protected _buildBlock(state: NodeMaterialBuildState): this;
  128163. }
  128164. }
  128165. declare module BABYLON {
  128166. /**
  128167. * Block used to lerp between 2 values
  128168. */
  128169. export class LerpBlock extends NodeMaterialBlock {
  128170. /**
  128171. * Creates a new LerpBlock
  128172. * @param name defines the block name
  128173. */
  128174. constructor(name: string);
  128175. /**
  128176. * Gets the current class name
  128177. * @returns the class name
  128178. */
  128179. getClassName(): string;
  128180. /**
  128181. * Gets the left operand input component
  128182. */
  128183. get left(): NodeMaterialConnectionPoint;
  128184. /**
  128185. * Gets the right operand input component
  128186. */
  128187. get right(): NodeMaterialConnectionPoint;
  128188. /**
  128189. * Gets the gradient operand input component
  128190. */
  128191. get gradient(): NodeMaterialConnectionPoint;
  128192. /**
  128193. * Gets the output component
  128194. */
  128195. get output(): NodeMaterialConnectionPoint;
  128196. protected _buildBlock(state: NodeMaterialBuildState): this;
  128197. }
  128198. }
  128199. declare module BABYLON {
  128200. /**
  128201. * Block used to divide 2 vectors
  128202. */
  128203. export class DivideBlock extends NodeMaterialBlock {
  128204. /**
  128205. * Creates a new DivideBlock
  128206. * @param name defines the block name
  128207. */
  128208. constructor(name: string);
  128209. /**
  128210. * Gets the current class name
  128211. * @returns the class name
  128212. */
  128213. getClassName(): string;
  128214. /**
  128215. * Gets the left operand input component
  128216. */
  128217. get left(): NodeMaterialConnectionPoint;
  128218. /**
  128219. * Gets the right operand input component
  128220. */
  128221. get right(): NodeMaterialConnectionPoint;
  128222. /**
  128223. * Gets the output component
  128224. */
  128225. get output(): NodeMaterialConnectionPoint;
  128226. protected _buildBlock(state: NodeMaterialBuildState): this;
  128227. }
  128228. }
  128229. declare module BABYLON {
  128230. /**
  128231. * Block used to subtract 2 vectors
  128232. */
  128233. export class SubtractBlock extends NodeMaterialBlock {
  128234. /**
  128235. * Creates a new SubtractBlock
  128236. * @param name defines the block name
  128237. */
  128238. constructor(name: string);
  128239. /**
  128240. * Gets the current class name
  128241. * @returns the class name
  128242. */
  128243. getClassName(): string;
  128244. /**
  128245. * Gets the left operand input component
  128246. */
  128247. get left(): NodeMaterialConnectionPoint;
  128248. /**
  128249. * Gets the right operand input component
  128250. */
  128251. get right(): NodeMaterialConnectionPoint;
  128252. /**
  128253. * Gets the output component
  128254. */
  128255. get output(): NodeMaterialConnectionPoint;
  128256. protected _buildBlock(state: NodeMaterialBuildState): this;
  128257. }
  128258. }
  128259. declare module BABYLON {
  128260. /**
  128261. * Block used to step a value
  128262. */
  128263. export class StepBlock extends NodeMaterialBlock {
  128264. /**
  128265. * Creates a new StepBlock
  128266. * @param name defines the block name
  128267. */
  128268. constructor(name: string);
  128269. /**
  128270. * Gets the current class name
  128271. * @returns the class name
  128272. */
  128273. getClassName(): string;
  128274. /**
  128275. * Gets the value operand input component
  128276. */
  128277. get value(): NodeMaterialConnectionPoint;
  128278. /**
  128279. * Gets the edge operand input component
  128280. */
  128281. get edge(): NodeMaterialConnectionPoint;
  128282. /**
  128283. * Gets the output component
  128284. */
  128285. get output(): NodeMaterialConnectionPoint;
  128286. protected _buildBlock(state: NodeMaterialBuildState): this;
  128287. }
  128288. }
  128289. declare module BABYLON {
  128290. /**
  128291. * Block used to get the opposite (1 - x) of a value
  128292. */
  128293. export class OneMinusBlock extends NodeMaterialBlock {
  128294. /**
  128295. * Creates a new OneMinusBlock
  128296. * @param name defines the block name
  128297. */
  128298. constructor(name: string);
  128299. /**
  128300. * Gets the current class name
  128301. * @returns the class name
  128302. */
  128303. getClassName(): string;
  128304. /**
  128305. * Gets the input component
  128306. */
  128307. get input(): NodeMaterialConnectionPoint;
  128308. /**
  128309. * Gets the output component
  128310. */
  128311. get output(): NodeMaterialConnectionPoint;
  128312. protected _buildBlock(state: NodeMaterialBuildState): this;
  128313. }
  128314. }
  128315. declare module BABYLON {
  128316. /**
  128317. * Block used to get the view direction
  128318. */
  128319. export class ViewDirectionBlock extends NodeMaterialBlock {
  128320. /**
  128321. * Creates a new ViewDirectionBlock
  128322. * @param name defines the block name
  128323. */
  128324. constructor(name: string);
  128325. /**
  128326. * Gets the current class name
  128327. * @returns the class name
  128328. */
  128329. getClassName(): string;
  128330. /**
  128331. * Gets the world position component
  128332. */
  128333. get worldPosition(): NodeMaterialConnectionPoint;
  128334. /**
  128335. * Gets the camera position component
  128336. */
  128337. get cameraPosition(): NodeMaterialConnectionPoint;
  128338. /**
  128339. * Gets the output component
  128340. */
  128341. get output(): NodeMaterialConnectionPoint;
  128342. autoConfigure(material: NodeMaterial): void;
  128343. protected _buildBlock(state: NodeMaterialBuildState): this;
  128344. }
  128345. }
  128346. declare module BABYLON {
  128347. /**
  128348. * Block used to compute fresnel value
  128349. */
  128350. export class FresnelBlock extends NodeMaterialBlock {
  128351. /**
  128352. * Create a new FresnelBlock
  128353. * @param name defines the block name
  128354. */
  128355. constructor(name: string);
  128356. /**
  128357. * Gets the current class name
  128358. * @returns the class name
  128359. */
  128360. getClassName(): string;
  128361. /**
  128362. * Gets the world normal input component
  128363. */
  128364. get worldNormal(): NodeMaterialConnectionPoint;
  128365. /**
  128366. * Gets the view direction input component
  128367. */
  128368. get viewDirection(): NodeMaterialConnectionPoint;
  128369. /**
  128370. * Gets the bias input component
  128371. */
  128372. get bias(): NodeMaterialConnectionPoint;
  128373. /**
  128374. * Gets the camera (or eye) position component
  128375. */
  128376. get power(): NodeMaterialConnectionPoint;
  128377. /**
  128378. * Gets the fresnel output component
  128379. */
  128380. get fresnel(): NodeMaterialConnectionPoint;
  128381. autoConfigure(material: NodeMaterial): void;
  128382. protected _buildBlock(state: NodeMaterialBuildState): this;
  128383. }
  128384. }
  128385. declare module BABYLON {
  128386. /**
  128387. * Block used to get the max of 2 values
  128388. */
  128389. export class MaxBlock extends NodeMaterialBlock {
  128390. /**
  128391. * Creates a new MaxBlock
  128392. * @param name defines the block name
  128393. */
  128394. constructor(name: string);
  128395. /**
  128396. * Gets the current class name
  128397. * @returns the class name
  128398. */
  128399. getClassName(): string;
  128400. /**
  128401. * Gets the left operand input component
  128402. */
  128403. get left(): NodeMaterialConnectionPoint;
  128404. /**
  128405. * Gets the right operand input component
  128406. */
  128407. get right(): NodeMaterialConnectionPoint;
  128408. /**
  128409. * Gets the output component
  128410. */
  128411. get output(): NodeMaterialConnectionPoint;
  128412. protected _buildBlock(state: NodeMaterialBuildState): this;
  128413. }
  128414. }
  128415. declare module BABYLON {
  128416. /**
  128417. * Block used to get the min of 2 values
  128418. */
  128419. export class MinBlock extends NodeMaterialBlock {
  128420. /**
  128421. * Creates a new MinBlock
  128422. * @param name defines the block name
  128423. */
  128424. constructor(name: string);
  128425. /**
  128426. * Gets the current class name
  128427. * @returns the class name
  128428. */
  128429. getClassName(): string;
  128430. /**
  128431. * Gets the left operand input component
  128432. */
  128433. get left(): NodeMaterialConnectionPoint;
  128434. /**
  128435. * Gets the right operand input component
  128436. */
  128437. get right(): NodeMaterialConnectionPoint;
  128438. /**
  128439. * Gets the output component
  128440. */
  128441. get output(): NodeMaterialConnectionPoint;
  128442. protected _buildBlock(state: NodeMaterialBuildState): this;
  128443. }
  128444. }
  128445. declare module BABYLON {
  128446. /**
  128447. * Block used to get the distance between 2 values
  128448. */
  128449. export class DistanceBlock extends NodeMaterialBlock {
  128450. /**
  128451. * Creates a new DistanceBlock
  128452. * @param name defines the block name
  128453. */
  128454. constructor(name: string);
  128455. /**
  128456. * Gets the current class name
  128457. * @returns the class name
  128458. */
  128459. getClassName(): string;
  128460. /**
  128461. * Gets the left operand input component
  128462. */
  128463. get left(): NodeMaterialConnectionPoint;
  128464. /**
  128465. * Gets the right operand input component
  128466. */
  128467. get right(): NodeMaterialConnectionPoint;
  128468. /**
  128469. * Gets the output component
  128470. */
  128471. get output(): NodeMaterialConnectionPoint;
  128472. protected _buildBlock(state: NodeMaterialBuildState): this;
  128473. }
  128474. }
  128475. declare module BABYLON {
  128476. /**
  128477. * Block used to get the length of a vector
  128478. */
  128479. export class LengthBlock extends NodeMaterialBlock {
  128480. /**
  128481. * Creates a new LengthBlock
  128482. * @param name defines the block name
  128483. */
  128484. constructor(name: string);
  128485. /**
  128486. * Gets the current class name
  128487. * @returns the class name
  128488. */
  128489. getClassName(): string;
  128490. /**
  128491. * Gets the value input component
  128492. */
  128493. get value(): NodeMaterialConnectionPoint;
  128494. /**
  128495. * Gets the output component
  128496. */
  128497. get output(): NodeMaterialConnectionPoint;
  128498. protected _buildBlock(state: NodeMaterialBuildState): this;
  128499. }
  128500. }
  128501. declare module BABYLON {
  128502. /**
  128503. * Block used to get negative version of a value (i.e. x * -1)
  128504. */
  128505. export class NegateBlock extends NodeMaterialBlock {
  128506. /**
  128507. * Creates a new NegateBlock
  128508. * @param name defines the block name
  128509. */
  128510. constructor(name: string);
  128511. /**
  128512. * Gets the current class name
  128513. * @returns the class name
  128514. */
  128515. getClassName(): string;
  128516. /**
  128517. * Gets the value input component
  128518. */
  128519. get value(): NodeMaterialConnectionPoint;
  128520. /**
  128521. * Gets the output component
  128522. */
  128523. get output(): NodeMaterialConnectionPoint;
  128524. protected _buildBlock(state: NodeMaterialBuildState): this;
  128525. }
  128526. }
  128527. declare module BABYLON {
  128528. /**
  128529. * Block used to get the value of the first parameter raised to the power of the second
  128530. */
  128531. export class PowBlock extends NodeMaterialBlock {
  128532. /**
  128533. * Creates a new PowBlock
  128534. * @param name defines the block name
  128535. */
  128536. constructor(name: string);
  128537. /**
  128538. * Gets the current class name
  128539. * @returns the class name
  128540. */
  128541. getClassName(): string;
  128542. /**
  128543. * Gets the value operand input component
  128544. */
  128545. get value(): NodeMaterialConnectionPoint;
  128546. /**
  128547. * Gets the power operand input component
  128548. */
  128549. get power(): NodeMaterialConnectionPoint;
  128550. /**
  128551. * Gets the output component
  128552. */
  128553. get output(): NodeMaterialConnectionPoint;
  128554. protected _buildBlock(state: NodeMaterialBuildState): this;
  128555. }
  128556. }
  128557. declare module BABYLON {
  128558. /**
  128559. * Block used to get a random number
  128560. */
  128561. export class RandomNumberBlock extends NodeMaterialBlock {
  128562. /**
  128563. * Creates a new RandomNumberBlock
  128564. * @param name defines the block name
  128565. */
  128566. constructor(name: string);
  128567. /**
  128568. * Gets the current class name
  128569. * @returns the class name
  128570. */
  128571. getClassName(): string;
  128572. /**
  128573. * Gets the seed input component
  128574. */
  128575. get seed(): NodeMaterialConnectionPoint;
  128576. /**
  128577. * Gets the output component
  128578. */
  128579. get output(): NodeMaterialConnectionPoint;
  128580. protected _buildBlock(state: NodeMaterialBuildState): this;
  128581. }
  128582. }
  128583. declare module BABYLON {
  128584. /**
  128585. * Block used to compute arc tangent of 2 values
  128586. */
  128587. export class ArcTan2Block extends NodeMaterialBlock {
  128588. /**
  128589. * Creates a new ArcTan2Block
  128590. * @param name defines the block name
  128591. */
  128592. constructor(name: string);
  128593. /**
  128594. * Gets the current class name
  128595. * @returns the class name
  128596. */
  128597. getClassName(): string;
  128598. /**
  128599. * Gets the x operand input component
  128600. */
  128601. get x(): NodeMaterialConnectionPoint;
  128602. /**
  128603. * Gets the y operand input component
  128604. */
  128605. get y(): NodeMaterialConnectionPoint;
  128606. /**
  128607. * Gets the output component
  128608. */
  128609. get output(): NodeMaterialConnectionPoint;
  128610. protected _buildBlock(state: NodeMaterialBuildState): this;
  128611. }
  128612. }
  128613. declare module BABYLON {
  128614. /**
  128615. * Block used to smooth step a value
  128616. */
  128617. export class SmoothStepBlock extends NodeMaterialBlock {
  128618. /**
  128619. * Creates a new SmoothStepBlock
  128620. * @param name defines the block name
  128621. */
  128622. constructor(name: string);
  128623. /**
  128624. * Gets the current class name
  128625. * @returns the class name
  128626. */
  128627. getClassName(): string;
  128628. /**
  128629. * Gets the value operand input component
  128630. */
  128631. get value(): NodeMaterialConnectionPoint;
  128632. /**
  128633. * Gets the first edge operand input component
  128634. */
  128635. get edge0(): NodeMaterialConnectionPoint;
  128636. /**
  128637. * Gets the second edge operand input component
  128638. */
  128639. get edge1(): NodeMaterialConnectionPoint;
  128640. /**
  128641. * Gets the output component
  128642. */
  128643. get output(): NodeMaterialConnectionPoint;
  128644. protected _buildBlock(state: NodeMaterialBuildState): this;
  128645. }
  128646. }
  128647. declare module BABYLON {
  128648. /**
  128649. * Block used to get the reciprocal (1 / x) of a value
  128650. */
  128651. export class ReciprocalBlock extends NodeMaterialBlock {
  128652. /**
  128653. * Creates a new ReciprocalBlock
  128654. * @param name defines the block name
  128655. */
  128656. constructor(name: string);
  128657. /**
  128658. * Gets the current class name
  128659. * @returns the class name
  128660. */
  128661. getClassName(): string;
  128662. /**
  128663. * Gets the input component
  128664. */
  128665. get input(): NodeMaterialConnectionPoint;
  128666. /**
  128667. * Gets the output component
  128668. */
  128669. get output(): NodeMaterialConnectionPoint;
  128670. protected _buildBlock(state: NodeMaterialBuildState): this;
  128671. }
  128672. }
  128673. declare module BABYLON {
  128674. /**
  128675. * Block used to replace a color by another one
  128676. */
  128677. export class ReplaceColorBlock extends NodeMaterialBlock {
  128678. /**
  128679. * Creates a new ReplaceColorBlock
  128680. * @param name defines the block name
  128681. */
  128682. constructor(name: string);
  128683. /**
  128684. * Gets the current class name
  128685. * @returns the class name
  128686. */
  128687. getClassName(): string;
  128688. /**
  128689. * Gets the value input component
  128690. */
  128691. get value(): NodeMaterialConnectionPoint;
  128692. /**
  128693. * Gets the reference input component
  128694. */
  128695. get reference(): NodeMaterialConnectionPoint;
  128696. /**
  128697. * Gets the distance input component
  128698. */
  128699. get distance(): NodeMaterialConnectionPoint;
  128700. /**
  128701. * Gets the replacement input component
  128702. */
  128703. get replacement(): NodeMaterialConnectionPoint;
  128704. /**
  128705. * Gets the output component
  128706. */
  128707. get output(): NodeMaterialConnectionPoint;
  128708. protected _buildBlock(state: NodeMaterialBuildState): this;
  128709. }
  128710. }
  128711. declare module BABYLON {
  128712. /**
  128713. * Block used to posterize a value
  128714. * @see https://en.wikipedia.org/wiki/Posterization
  128715. */
  128716. export class PosterizeBlock extends NodeMaterialBlock {
  128717. /**
  128718. * Creates a new PosterizeBlock
  128719. * @param name defines the block name
  128720. */
  128721. constructor(name: string);
  128722. /**
  128723. * Gets the current class name
  128724. * @returns the class name
  128725. */
  128726. getClassName(): string;
  128727. /**
  128728. * Gets the value input component
  128729. */
  128730. get value(): NodeMaterialConnectionPoint;
  128731. /**
  128732. * Gets the steps input component
  128733. */
  128734. get steps(): NodeMaterialConnectionPoint;
  128735. /**
  128736. * Gets the output component
  128737. */
  128738. get output(): NodeMaterialConnectionPoint;
  128739. protected _buildBlock(state: NodeMaterialBuildState): this;
  128740. }
  128741. }
  128742. declare module BABYLON {
  128743. /**
  128744. * Operations supported by the Wave block
  128745. */
  128746. export enum WaveBlockKind {
  128747. /** SawTooth */
  128748. SawTooth = 0,
  128749. /** Square */
  128750. Square = 1,
  128751. /** Triangle */
  128752. Triangle = 2
  128753. }
  128754. /**
  128755. * Block used to apply wave operation to floats
  128756. */
  128757. export class WaveBlock extends NodeMaterialBlock {
  128758. /**
  128759. * Gets or sets the kibnd of wave to be applied by the block
  128760. */
  128761. kind: WaveBlockKind;
  128762. /**
  128763. * Creates a new WaveBlock
  128764. * @param name defines the block name
  128765. */
  128766. constructor(name: string);
  128767. /**
  128768. * Gets the current class name
  128769. * @returns the class name
  128770. */
  128771. getClassName(): string;
  128772. /**
  128773. * Gets the input component
  128774. */
  128775. get input(): NodeMaterialConnectionPoint;
  128776. /**
  128777. * Gets the output component
  128778. */
  128779. get output(): NodeMaterialConnectionPoint;
  128780. protected _buildBlock(state: NodeMaterialBuildState): this;
  128781. serialize(): any;
  128782. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128783. }
  128784. }
  128785. declare module BABYLON {
  128786. /**
  128787. * Class used to store a color step for the GradientBlock
  128788. */
  128789. export class GradientBlockColorStep {
  128790. /**
  128791. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128792. */
  128793. step: number;
  128794. /**
  128795. * Gets or sets the color associated with this step
  128796. */
  128797. color: Color3;
  128798. /**
  128799. * Creates a new GradientBlockColorStep
  128800. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  128801. * @param color defines the color associated with this step
  128802. */
  128803. constructor(
  128804. /**
  128805. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128806. */
  128807. step: number,
  128808. /**
  128809. * Gets or sets the color associated with this step
  128810. */
  128811. color: Color3);
  128812. }
  128813. /**
  128814. * Block used to return a color from a gradient based on an input value between 0 and 1
  128815. */
  128816. export class GradientBlock extends NodeMaterialBlock {
  128817. /**
  128818. * Gets or sets the list of color steps
  128819. */
  128820. colorSteps: GradientBlockColorStep[];
  128821. /**
  128822. * Creates a new GradientBlock
  128823. * @param name defines the block name
  128824. */
  128825. constructor(name: string);
  128826. /**
  128827. * Gets the current class name
  128828. * @returns the class name
  128829. */
  128830. getClassName(): string;
  128831. /**
  128832. * Gets the gradient input component
  128833. */
  128834. get gradient(): NodeMaterialConnectionPoint;
  128835. /**
  128836. * Gets the output component
  128837. */
  128838. get output(): NodeMaterialConnectionPoint;
  128839. private _writeColorConstant;
  128840. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128841. serialize(): any;
  128842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128843. protected _dumpPropertiesCode(): string;
  128844. }
  128845. }
  128846. declare module BABYLON {
  128847. /**
  128848. * Block used to normalize lerp between 2 values
  128849. */
  128850. export class NLerpBlock extends NodeMaterialBlock {
  128851. /**
  128852. * Creates a new NLerpBlock
  128853. * @param name defines the block name
  128854. */
  128855. constructor(name: string);
  128856. /**
  128857. * Gets the current class name
  128858. * @returns the class name
  128859. */
  128860. getClassName(): string;
  128861. /**
  128862. * Gets the left operand input component
  128863. */
  128864. get left(): NodeMaterialConnectionPoint;
  128865. /**
  128866. * Gets the right operand input component
  128867. */
  128868. get right(): NodeMaterialConnectionPoint;
  128869. /**
  128870. * Gets the gradient operand input component
  128871. */
  128872. get gradient(): NodeMaterialConnectionPoint;
  128873. /**
  128874. * Gets the output component
  128875. */
  128876. get output(): NodeMaterialConnectionPoint;
  128877. protected _buildBlock(state: NodeMaterialBuildState): this;
  128878. }
  128879. }
  128880. declare module BABYLON {
  128881. /**
  128882. * block used to Generate a Worley Noise 3D Noise Pattern
  128883. */
  128884. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  128885. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  128886. manhattanDistance: boolean;
  128887. /**
  128888. * Creates a new WorleyNoise3DBlock
  128889. * @param name defines the block name
  128890. */
  128891. constructor(name: string);
  128892. /**
  128893. * Gets the current class name
  128894. * @returns the class name
  128895. */
  128896. getClassName(): string;
  128897. /**
  128898. * Gets the seed input component
  128899. */
  128900. get seed(): NodeMaterialConnectionPoint;
  128901. /**
  128902. * Gets the jitter input component
  128903. */
  128904. get jitter(): NodeMaterialConnectionPoint;
  128905. /**
  128906. * Gets the output component
  128907. */
  128908. get output(): NodeMaterialConnectionPoint;
  128909. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128910. /**
  128911. * Exposes the properties to the UI?
  128912. */
  128913. protected _dumpPropertiesCode(): string;
  128914. /**
  128915. * Exposes the properties to the Seralize?
  128916. */
  128917. serialize(): any;
  128918. /**
  128919. * Exposes the properties to the deseralize?
  128920. */
  128921. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128922. }
  128923. }
  128924. declare module BABYLON {
  128925. /**
  128926. * block used to Generate a Simplex Perlin 3d Noise Pattern
  128927. */
  128928. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  128929. /**
  128930. * Creates a new SimplexPerlin3DBlock
  128931. * @param name defines the block name
  128932. */
  128933. constructor(name: string);
  128934. /**
  128935. * Gets the current class name
  128936. * @returns the class name
  128937. */
  128938. getClassName(): string;
  128939. /**
  128940. * Gets the seed operand input component
  128941. */
  128942. get seed(): NodeMaterialConnectionPoint;
  128943. /**
  128944. * Gets the output component
  128945. */
  128946. get output(): NodeMaterialConnectionPoint;
  128947. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128948. }
  128949. }
  128950. declare module BABYLON {
  128951. /**
  128952. * Block used to blend normals
  128953. */
  128954. export class NormalBlendBlock extends NodeMaterialBlock {
  128955. /**
  128956. * Creates a new NormalBlendBlock
  128957. * @param name defines the block name
  128958. */
  128959. constructor(name: string);
  128960. /**
  128961. * Gets the current class name
  128962. * @returns the class name
  128963. */
  128964. getClassName(): string;
  128965. /**
  128966. * Gets the first input component
  128967. */
  128968. get normalMap0(): NodeMaterialConnectionPoint;
  128969. /**
  128970. * Gets the second input component
  128971. */
  128972. get normalMap1(): NodeMaterialConnectionPoint;
  128973. /**
  128974. * Gets the output component
  128975. */
  128976. get output(): NodeMaterialConnectionPoint;
  128977. protected _buildBlock(state: NodeMaterialBuildState): this;
  128978. }
  128979. }
  128980. declare module BABYLON {
  128981. /**
  128982. * Block used to rotate a 2d vector by a given angle
  128983. */
  128984. export class Rotate2dBlock extends NodeMaterialBlock {
  128985. /**
  128986. * Creates a new Rotate2dBlock
  128987. * @param name defines the block name
  128988. */
  128989. constructor(name: string);
  128990. /**
  128991. * Gets the current class name
  128992. * @returns the class name
  128993. */
  128994. getClassName(): string;
  128995. /**
  128996. * Gets the input vector
  128997. */
  128998. get input(): NodeMaterialConnectionPoint;
  128999. /**
  129000. * Gets the input angle
  129001. */
  129002. get angle(): NodeMaterialConnectionPoint;
  129003. /**
  129004. * Gets the output component
  129005. */
  129006. get output(): NodeMaterialConnectionPoint;
  129007. autoConfigure(material: NodeMaterial): void;
  129008. protected _buildBlock(state: NodeMaterialBuildState): this;
  129009. }
  129010. }
  129011. declare module BABYLON {
  129012. /**
  129013. * Block used to get the reflected vector from a direction and a normal
  129014. */
  129015. export class ReflectBlock extends NodeMaterialBlock {
  129016. /**
  129017. * Creates a new ReflectBlock
  129018. * @param name defines the block name
  129019. */
  129020. constructor(name: string);
  129021. /**
  129022. * Gets the current class name
  129023. * @returns the class name
  129024. */
  129025. getClassName(): string;
  129026. /**
  129027. * Gets the incident component
  129028. */
  129029. get incident(): NodeMaterialConnectionPoint;
  129030. /**
  129031. * Gets the normal component
  129032. */
  129033. get normal(): NodeMaterialConnectionPoint;
  129034. /**
  129035. * Gets the output component
  129036. */
  129037. get output(): NodeMaterialConnectionPoint;
  129038. protected _buildBlock(state: NodeMaterialBuildState): this;
  129039. }
  129040. }
  129041. declare module BABYLON {
  129042. /**
  129043. * Block used to get the refracted vector from a direction and a normal
  129044. */
  129045. export class RefractBlock extends NodeMaterialBlock {
  129046. /**
  129047. * Creates a new RefractBlock
  129048. * @param name defines the block name
  129049. */
  129050. constructor(name: string);
  129051. /**
  129052. * Gets the current class name
  129053. * @returns the class name
  129054. */
  129055. getClassName(): string;
  129056. /**
  129057. * Gets the incident component
  129058. */
  129059. get incident(): NodeMaterialConnectionPoint;
  129060. /**
  129061. * Gets the normal component
  129062. */
  129063. get normal(): NodeMaterialConnectionPoint;
  129064. /**
  129065. * Gets the index of refraction component
  129066. */
  129067. get ior(): NodeMaterialConnectionPoint;
  129068. /**
  129069. * Gets the output component
  129070. */
  129071. get output(): NodeMaterialConnectionPoint;
  129072. protected _buildBlock(state: NodeMaterialBuildState): this;
  129073. }
  129074. }
  129075. declare module BABYLON {
  129076. /**
  129077. * Block used to desaturate a color
  129078. */
  129079. export class DesaturateBlock extends NodeMaterialBlock {
  129080. /**
  129081. * Creates a new DesaturateBlock
  129082. * @param name defines the block name
  129083. */
  129084. constructor(name: string);
  129085. /**
  129086. * Gets the current class name
  129087. * @returns the class name
  129088. */
  129089. getClassName(): string;
  129090. /**
  129091. * Gets the color operand input component
  129092. */
  129093. get color(): NodeMaterialConnectionPoint;
  129094. /**
  129095. * Gets the level operand input component
  129096. */
  129097. get level(): NodeMaterialConnectionPoint;
  129098. /**
  129099. * Gets the output component
  129100. */
  129101. get output(): NodeMaterialConnectionPoint;
  129102. protected _buildBlock(state: NodeMaterialBuildState): this;
  129103. }
  129104. }
  129105. declare module BABYLON {
  129106. /**
  129107. * Effect Render Options
  129108. */
  129109. export interface IEffectRendererOptions {
  129110. /**
  129111. * Defines the vertices positions.
  129112. */
  129113. positions?: number[];
  129114. /**
  129115. * Defines the indices.
  129116. */
  129117. indices?: number[];
  129118. }
  129119. /**
  129120. * Helper class to render one or more effects
  129121. */
  129122. export class EffectRenderer {
  129123. private engine;
  129124. private static _DefaultOptions;
  129125. private _vertexBuffers;
  129126. private _indexBuffer;
  129127. private _ringBufferIndex;
  129128. private _ringScreenBuffer;
  129129. private _fullscreenViewport;
  129130. private _getNextFrameBuffer;
  129131. /**
  129132. * Creates an effect renderer
  129133. * @param engine the engine to use for rendering
  129134. * @param options defines the options of the effect renderer
  129135. */
  129136. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  129137. /**
  129138. * Sets the current viewport in normalized coordinates 0-1
  129139. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  129140. */
  129141. setViewport(viewport?: Viewport): void;
  129142. /**
  129143. * Binds the embedded attributes buffer to the effect.
  129144. * @param effect Defines the effect to bind the attributes for
  129145. */
  129146. bindBuffers(effect: Effect): void;
  129147. /**
  129148. * Sets the current effect wrapper to use during draw.
  129149. * The effect needs to be ready before calling this api.
  129150. * This also sets the default full screen position attribute.
  129151. * @param effectWrapper Defines the effect to draw with
  129152. */
  129153. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  129154. /**
  129155. * Draws a full screen quad.
  129156. */
  129157. draw(): void;
  129158. /**
  129159. * renders one or more effects to a specified texture
  129160. * @param effectWrappers list of effects to renderer
  129161. * @param outputTexture texture to draw to, if null it will render to the screen
  129162. */
  129163. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  129164. /**
  129165. * Disposes of the effect renderer
  129166. */
  129167. dispose(): void;
  129168. }
  129169. /**
  129170. * Options to create an EffectWrapper
  129171. */
  129172. interface EffectWrapperCreationOptions {
  129173. /**
  129174. * Engine to use to create the effect
  129175. */
  129176. engine: ThinEngine;
  129177. /**
  129178. * Fragment shader for the effect
  129179. */
  129180. fragmentShader: string;
  129181. /**
  129182. * Vertex shader for the effect
  129183. */
  129184. vertexShader?: string;
  129185. /**
  129186. * Attributes to use in the shader
  129187. */
  129188. attributeNames?: Array<string>;
  129189. /**
  129190. * Uniforms to use in the shader
  129191. */
  129192. uniformNames?: Array<string>;
  129193. /**
  129194. * Texture sampler names to use in the shader
  129195. */
  129196. samplerNames?: Array<string>;
  129197. /**
  129198. * The friendly name of the effect displayed in Spector.
  129199. */
  129200. name?: string;
  129201. }
  129202. /**
  129203. * Wraps an effect to be used for rendering
  129204. */
  129205. export class EffectWrapper {
  129206. /**
  129207. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  129208. */
  129209. onApplyObservable: Observable<{}>;
  129210. /**
  129211. * The underlying effect
  129212. */
  129213. effect: Effect;
  129214. /**
  129215. * Creates an effect to be renderer
  129216. * @param creationOptions options to create the effect
  129217. */
  129218. constructor(creationOptions: EffectWrapperCreationOptions);
  129219. /**
  129220. * Disposes of the effect wrapper
  129221. */
  129222. dispose(): void;
  129223. }
  129224. }
  129225. declare module BABYLON {
  129226. /**
  129227. * Helper class to push actions to a pool of workers.
  129228. */
  129229. export class WorkerPool implements IDisposable {
  129230. private _workerInfos;
  129231. private _pendingActions;
  129232. /**
  129233. * Constructor
  129234. * @param workers Array of workers to use for actions
  129235. */
  129236. constructor(workers: Array<Worker>);
  129237. /**
  129238. * Terminates all workers and clears any pending actions.
  129239. */
  129240. dispose(): void;
  129241. /**
  129242. * Pushes an action to the worker pool. If all the workers are active, the action will be
  129243. * pended until a worker has completed its action.
  129244. * @param action The action to perform. Call onComplete when the action is complete.
  129245. */
  129246. push(action: (worker: Worker, onComplete: () => void) => void): void;
  129247. private _execute;
  129248. }
  129249. }
  129250. declare module BABYLON {
  129251. /**
  129252. * Configuration for Draco compression
  129253. */
  129254. export interface IDracoCompressionConfiguration {
  129255. /**
  129256. * Configuration for the decoder.
  129257. */
  129258. decoder: {
  129259. /**
  129260. * The url to the WebAssembly module.
  129261. */
  129262. wasmUrl?: string;
  129263. /**
  129264. * The url to the WebAssembly binary.
  129265. */
  129266. wasmBinaryUrl?: string;
  129267. /**
  129268. * The url to the fallback JavaScript module.
  129269. */
  129270. fallbackUrl?: string;
  129271. };
  129272. }
  129273. /**
  129274. * Draco compression (https://google.github.io/draco/)
  129275. *
  129276. * This class wraps the Draco module.
  129277. *
  129278. * **Encoder**
  129279. *
  129280. * The encoder is not currently implemented.
  129281. *
  129282. * **Decoder**
  129283. *
  129284. * 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.
  129285. *
  129286. * To update the configuration, use the following code:
  129287. * ```javascript
  129288. * DracoCompression.Configuration = {
  129289. * decoder: {
  129290. * wasmUrl: "<url to the WebAssembly library>",
  129291. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  129292. * fallbackUrl: "<url to the fallback JavaScript library>",
  129293. * }
  129294. * };
  129295. * ```
  129296. *
  129297. * 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.
  129298. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  129299. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  129300. *
  129301. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  129302. * ```javascript
  129303. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  129304. * ```
  129305. *
  129306. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  129307. */
  129308. export class DracoCompression implements IDisposable {
  129309. private _workerPoolPromise?;
  129310. private _decoderModulePromise?;
  129311. /**
  129312. * The configuration. Defaults to the following urls:
  129313. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  129314. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  129315. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  129316. */
  129317. static Configuration: IDracoCompressionConfiguration;
  129318. /**
  129319. * Returns true if the decoder configuration is available.
  129320. */
  129321. static get DecoderAvailable(): boolean;
  129322. /**
  129323. * Default number of workers to create when creating the draco compression object.
  129324. */
  129325. static DefaultNumWorkers: number;
  129326. private static GetDefaultNumWorkers;
  129327. private static _Default;
  129328. /**
  129329. * Default instance for the draco compression object.
  129330. */
  129331. static get Default(): DracoCompression;
  129332. /**
  129333. * Constructor
  129334. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  129335. */
  129336. constructor(numWorkers?: number);
  129337. /**
  129338. * Stop all async operations and release resources.
  129339. */
  129340. dispose(): void;
  129341. /**
  129342. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  129343. * @returns a promise that resolves when ready
  129344. */
  129345. whenReadyAsync(): Promise<void>;
  129346. /**
  129347. * Decode Draco compressed mesh data to vertex data.
  129348. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  129349. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  129350. * @returns A promise that resolves with the decoded vertex data
  129351. */
  129352. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  129353. [kind: string]: number;
  129354. }): Promise<VertexData>;
  129355. }
  129356. }
  129357. declare module BABYLON {
  129358. /**
  129359. * Class for building Constructive Solid Geometry
  129360. */
  129361. export class CSG {
  129362. private polygons;
  129363. /**
  129364. * The world matrix
  129365. */
  129366. matrix: Matrix;
  129367. /**
  129368. * Stores the position
  129369. */
  129370. position: Vector3;
  129371. /**
  129372. * Stores the rotation
  129373. */
  129374. rotation: Vector3;
  129375. /**
  129376. * Stores the rotation quaternion
  129377. */
  129378. rotationQuaternion: Nullable<Quaternion>;
  129379. /**
  129380. * Stores the scaling vector
  129381. */
  129382. scaling: Vector3;
  129383. /**
  129384. * Convert the Mesh to CSG
  129385. * @param mesh The Mesh to convert to CSG
  129386. * @returns A new CSG from the Mesh
  129387. */
  129388. static FromMesh(mesh: Mesh): CSG;
  129389. /**
  129390. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  129391. * @param polygons Polygons used to construct a CSG solid
  129392. */
  129393. private static FromPolygons;
  129394. /**
  129395. * Clones, or makes a deep copy, of the CSG
  129396. * @returns A new CSG
  129397. */
  129398. clone(): CSG;
  129399. /**
  129400. * Unions this CSG with another CSG
  129401. * @param csg The CSG to union against this CSG
  129402. * @returns The unioned CSG
  129403. */
  129404. union(csg: CSG): CSG;
  129405. /**
  129406. * Unions this CSG with another CSG in place
  129407. * @param csg The CSG to union against this CSG
  129408. */
  129409. unionInPlace(csg: CSG): void;
  129410. /**
  129411. * Subtracts this CSG with another CSG
  129412. * @param csg The CSG to subtract against this CSG
  129413. * @returns A new CSG
  129414. */
  129415. subtract(csg: CSG): CSG;
  129416. /**
  129417. * Subtracts this CSG with another CSG in place
  129418. * @param csg The CSG to subtact against this CSG
  129419. */
  129420. subtractInPlace(csg: CSG): void;
  129421. /**
  129422. * Intersect this CSG with another CSG
  129423. * @param csg The CSG to intersect against this CSG
  129424. * @returns A new CSG
  129425. */
  129426. intersect(csg: CSG): CSG;
  129427. /**
  129428. * Intersects this CSG with another CSG in place
  129429. * @param csg The CSG to intersect against this CSG
  129430. */
  129431. intersectInPlace(csg: CSG): void;
  129432. /**
  129433. * Return a new CSG solid with solid and empty space switched. This solid is
  129434. * not modified.
  129435. * @returns A new CSG solid with solid and empty space switched
  129436. */
  129437. inverse(): CSG;
  129438. /**
  129439. * Inverses the CSG in place
  129440. */
  129441. inverseInPlace(): void;
  129442. /**
  129443. * This is used to keep meshes transformations so they can be restored
  129444. * when we build back a Babylon Mesh
  129445. * NB : All CSG operations are performed in world coordinates
  129446. * @param csg The CSG to copy the transform attributes from
  129447. * @returns This CSG
  129448. */
  129449. copyTransformAttributes(csg: CSG): CSG;
  129450. /**
  129451. * Build Raw mesh from CSG
  129452. * Coordinates here are in world space
  129453. * @param name The name of the mesh geometry
  129454. * @param scene The Scene
  129455. * @param keepSubMeshes Specifies if the submeshes should be kept
  129456. * @returns A new Mesh
  129457. */
  129458. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129459. /**
  129460. * Build Mesh from CSG taking material and transforms into account
  129461. * @param name The name of the Mesh
  129462. * @param material The material of the Mesh
  129463. * @param scene The Scene
  129464. * @param keepSubMeshes Specifies if submeshes should be kept
  129465. * @returns The new Mesh
  129466. */
  129467. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129468. }
  129469. }
  129470. declare module BABYLON {
  129471. /**
  129472. * Class used to create a trail following a mesh
  129473. */
  129474. export class TrailMesh extends Mesh {
  129475. private _generator;
  129476. private _autoStart;
  129477. private _running;
  129478. private _diameter;
  129479. private _length;
  129480. private _sectionPolygonPointsCount;
  129481. private _sectionVectors;
  129482. private _sectionNormalVectors;
  129483. private _beforeRenderObserver;
  129484. /**
  129485. * @constructor
  129486. * @param name The value used by scene.getMeshByName() to do a lookup.
  129487. * @param generator The mesh to generate a trail.
  129488. * @param scene The scene to add this mesh to.
  129489. * @param diameter Diameter of trailing mesh. Default is 1.
  129490. * @param length Length of trailing mesh. Default is 60.
  129491. * @param autoStart Automatically start trailing mesh. Default true.
  129492. */
  129493. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  129494. /**
  129495. * "TrailMesh"
  129496. * @returns "TrailMesh"
  129497. */
  129498. getClassName(): string;
  129499. private _createMesh;
  129500. /**
  129501. * Start trailing mesh.
  129502. */
  129503. start(): void;
  129504. /**
  129505. * Stop trailing mesh.
  129506. */
  129507. stop(): void;
  129508. /**
  129509. * Update trailing mesh geometry.
  129510. */
  129511. update(): void;
  129512. /**
  129513. * Returns a new TrailMesh object.
  129514. * @param name is a string, the name given to the new mesh
  129515. * @param newGenerator use new generator object for cloned trail mesh
  129516. * @returns a new mesh
  129517. */
  129518. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  129519. /**
  129520. * Serializes this trail mesh
  129521. * @param serializationObject object to write serialization to
  129522. */
  129523. serialize(serializationObject: any): void;
  129524. /**
  129525. * Parses a serialized trail mesh
  129526. * @param parsedMesh the serialized mesh
  129527. * @param scene the scene to create the trail mesh in
  129528. * @returns the created trail mesh
  129529. */
  129530. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  129531. }
  129532. }
  129533. declare module BABYLON {
  129534. /**
  129535. * Class containing static functions to help procedurally build meshes
  129536. */
  129537. export class TiledBoxBuilder {
  129538. /**
  129539. * Creates a box mesh
  129540. * 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)
  129541. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129543. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129545. * @param name defines the name of the mesh
  129546. * @param options defines the options used to create the mesh
  129547. * @param scene defines the hosting scene
  129548. * @returns the box mesh
  129549. */
  129550. static CreateTiledBox(name: string, options: {
  129551. pattern?: number;
  129552. width?: number;
  129553. height?: number;
  129554. depth?: number;
  129555. tileSize?: number;
  129556. tileWidth?: number;
  129557. tileHeight?: number;
  129558. alignHorizontal?: number;
  129559. alignVertical?: number;
  129560. faceUV?: Vector4[];
  129561. faceColors?: Color4[];
  129562. sideOrientation?: number;
  129563. updatable?: boolean;
  129564. }, scene?: Nullable<Scene>): Mesh;
  129565. }
  129566. }
  129567. declare module BABYLON {
  129568. /**
  129569. * Class containing static functions to help procedurally build meshes
  129570. */
  129571. export class TorusKnotBuilder {
  129572. /**
  129573. * Creates a torus knot mesh
  129574. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  129575. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  129576. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  129577. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  129578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129581. * @param name defines the name of the mesh
  129582. * @param options defines the options used to create the mesh
  129583. * @param scene defines the hosting scene
  129584. * @returns the torus knot mesh
  129585. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  129586. */
  129587. static CreateTorusKnot(name: string, options: {
  129588. radius?: number;
  129589. tube?: number;
  129590. radialSegments?: number;
  129591. tubularSegments?: number;
  129592. p?: number;
  129593. q?: number;
  129594. updatable?: boolean;
  129595. sideOrientation?: number;
  129596. frontUVs?: Vector4;
  129597. backUVs?: Vector4;
  129598. }, scene: any): Mesh;
  129599. }
  129600. }
  129601. declare module BABYLON {
  129602. /**
  129603. * Polygon
  129604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  129605. */
  129606. export class Polygon {
  129607. /**
  129608. * Creates a rectangle
  129609. * @param xmin bottom X coord
  129610. * @param ymin bottom Y coord
  129611. * @param xmax top X coord
  129612. * @param ymax top Y coord
  129613. * @returns points that make the resulting rectation
  129614. */
  129615. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  129616. /**
  129617. * Creates a circle
  129618. * @param radius radius of circle
  129619. * @param cx scale in x
  129620. * @param cy scale in y
  129621. * @param numberOfSides number of sides that make up the circle
  129622. * @returns points that make the resulting circle
  129623. */
  129624. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  129625. /**
  129626. * Creates a polygon from input string
  129627. * @param input Input polygon data
  129628. * @returns the parsed points
  129629. */
  129630. static Parse(input: string): Vector2[];
  129631. /**
  129632. * Starts building a polygon from x and y coordinates
  129633. * @param x x coordinate
  129634. * @param y y coordinate
  129635. * @returns the started path2
  129636. */
  129637. static StartingAt(x: number, y: number): Path2;
  129638. }
  129639. /**
  129640. * Builds a polygon
  129641. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  129642. */
  129643. export class PolygonMeshBuilder {
  129644. private _points;
  129645. private _outlinepoints;
  129646. private _holes;
  129647. private _name;
  129648. private _scene;
  129649. private _epoints;
  129650. private _eholes;
  129651. private _addToepoint;
  129652. /**
  129653. * Babylon reference to the earcut plugin.
  129654. */
  129655. bjsEarcut: any;
  129656. /**
  129657. * Creates a PolygonMeshBuilder
  129658. * @param name name of the builder
  129659. * @param contours Path of the polygon
  129660. * @param scene scene to add to when creating the mesh
  129661. * @param earcutInjection can be used to inject your own earcut reference
  129662. */
  129663. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  129664. /**
  129665. * Adds a whole within the polygon
  129666. * @param hole Array of points defining the hole
  129667. * @returns this
  129668. */
  129669. addHole(hole: Vector2[]): PolygonMeshBuilder;
  129670. /**
  129671. * Creates the polygon
  129672. * @param updatable If the mesh should be updatable
  129673. * @param depth The depth of the mesh created
  129674. * @returns the created mesh
  129675. */
  129676. build(updatable?: boolean, depth?: number): Mesh;
  129677. /**
  129678. * Creates the polygon
  129679. * @param depth The depth of the mesh created
  129680. * @returns the created VertexData
  129681. */
  129682. buildVertexData(depth?: number): VertexData;
  129683. /**
  129684. * Adds a side to the polygon
  129685. * @param positions points that make the polygon
  129686. * @param normals normals of the polygon
  129687. * @param uvs uvs of the polygon
  129688. * @param indices indices of the polygon
  129689. * @param bounds bounds of the polygon
  129690. * @param points points of the polygon
  129691. * @param depth depth of the polygon
  129692. * @param flip flip of the polygon
  129693. */
  129694. private addSide;
  129695. }
  129696. }
  129697. declare module BABYLON {
  129698. /**
  129699. * Class containing static functions to help procedurally build meshes
  129700. */
  129701. export class PolygonBuilder {
  129702. /**
  129703. * Creates a polygon mesh
  129704. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  129705. * * 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
  129706. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  129709. * * Remember you can only change the shape positions, not their number when updating a polygon
  129710. * @param name defines the name of the mesh
  129711. * @param options defines the options used to create the mesh
  129712. * @param scene defines the hosting scene
  129713. * @param earcutInjection can be used to inject your own earcut reference
  129714. * @returns the polygon mesh
  129715. */
  129716. static CreatePolygon(name: string, options: {
  129717. shape: Vector3[];
  129718. holes?: Vector3[][];
  129719. depth?: number;
  129720. faceUV?: Vector4[];
  129721. faceColors?: Color4[];
  129722. updatable?: boolean;
  129723. sideOrientation?: number;
  129724. frontUVs?: Vector4;
  129725. backUVs?: Vector4;
  129726. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129727. /**
  129728. * Creates an extruded polygon mesh, with depth in the Y direction.
  129729. * * 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)
  129730. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129731. * @param name defines the name of the mesh
  129732. * @param options defines the options used to create the mesh
  129733. * @param scene defines the hosting scene
  129734. * @param earcutInjection can be used to inject your own earcut reference
  129735. * @returns the polygon mesh
  129736. */
  129737. static ExtrudePolygon(name: string, options: {
  129738. shape: Vector3[];
  129739. holes?: Vector3[][];
  129740. depth?: number;
  129741. faceUV?: Vector4[];
  129742. faceColors?: Color4[];
  129743. updatable?: boolean;
  129744. sideOrientation?: number;
  129745. frontUVs?: Vector4;
  129746. backUVs?: Vector4;
  129747. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129748. }
  129749. }
  129750. declare module BABYLON {
  129751. /**
  129752. * Class containing static functions to help procedurally build meshes
  129753. */
  129754. export class LatheBuilder {
  129755. /**
  129756. * Creates lathe mesh.
  129757. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  129758. * * 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
  129759. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  129760. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  129761. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  129762. * * 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
  129763. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  129764. * * 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
  129765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129767. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129769. * @param name defines the name of the mesh
  129770. * @param options defines the options used to create the mesh
  129771. * @param scene defines the hosting scene
  129772. * @returns the lathe mesh
  129773. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  129774. */
  129775. static CreateLathe(name: string, options: {
  129776. shape: Vector3[];
  129777. radius?: number;
  129778. tessellation?: number;
  129779. clip?: number;
  129780. arc?: number;
  129781. closed?: boolean;
  129782. updatable?: boolean;
  129783. sideOrientation?: number;
  129784. frontUVs?: Vector4;
  129785. backUVs?: Vector4;
  129786. cap?: number;
  129787. invertUV?: boolean;
  129788. }, scene?: Nullable<Scene>): Mesh;
  129789. }
  129790. }
  129791. declare module BABYLON {
  129792. /**
  129793. * Class containing static functions to help procedurally build meshes
  129794. */
  129795. export class TiledPlaneBuilder {
  129796. /**
  129797. * Creates a tiled plane mesh
  129798. * * The parameter `pattern` will, depending on value, do nothing or
  129799. * * * flip (reflect about central vertical) alternate tiles across and up
  129800. * * * flip every tile on alternate rows
  129801. * * * rotate (180 degs) alternate tiles across and up
  129802. * * * rotate every tile on alternate rows
  129803. * * * flip and rotate alternate tiles across and up
  129804. * * * flip and rotate every tile on alternate rows
  129805. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  129806. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  129807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129808. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129809. * * 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)
  129810. * * 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)
  129811. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129812. * @param name defines the name of the mesh
  129813. * @param options defines the options used to create the mesh
  129814. * @param scene defines the hosting scene
  129815. * @returns the box mesh
  129816. */
  129817. static CreateTiledPlane(name: string, options: {
  129818. pattern?: number;
  129819. tileSize?: number;
  129820. tileWidth?: number;
  129821. tileHeight?: number;
  129822. size?: number;
  129823. width?: number;
  129824. height?: number;
  129825. alignHorizontal?: number;
  129826. alignVertical?: number;
  129827. sideOrientation?: number;
  129828. frontUVs?: Vector4;
  129829. backUVs?: Vector4;
  129830. updatable?: boolean;
  129831. }, scene?: Nullable<Scene>): Mesh;
  129832. }
  129833. }
  129834. declare module BABYLON {
  129835. /**
  129836. * Class containing static functions to help procedurally build meshes
  129837. */
  129838. export class TubeBuilder {
  129839. /**
  129840. * Creates a tube mesh.
  129841. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129842. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  129843. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  129844. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  129845. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  129846. * * 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)
  129847. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  129848. * * 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
  129849. * * 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
  129850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129852. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129854. * @param name defines the name of the mesh
  129855. * @param options defines the options used to create the mesh
  129856. * @param scene defines the hosting scene
  129857. * @returns the tube mesh
  129858. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129859. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  129860. */
  129861. static CreateTube(name: string, options: {
  129862. path: Vector3[];
  129863. radius?: number;
  129864. tessellation?: number;
  129865. radiusFunction?: {
  129866. (i: number, distance: number): number;
  129867. };
  129868. cap?: number;
  129869. arc?: number;
  129870. updatable?: boolean;
  129871. sideOrientation?: number;
  129872. frontUVs?: Vector4;
  129873. backUVs?: Vector4;
  129874. instance?: Mesh;
  129875. invertUV?: boolean;
  129876. }, scene?: Nullable<Scene>): Mesh;
  129877. }
  129878. }
  129879. declare module BABYLON {
  129880. /**
  129881. * Class containing static functions to help procedurally build meshes
  129882. */
  129883. export class IcoSphereBuilder {
  129884. /**
  129885. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129886. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129887. * * 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`)
  129888. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129889. * * 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
  129890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129893. * @param name defines the name of the mesh
  129894. * @param options defines the options used to create the mesh
  129895. * @param scene defines the hosting scene
  129896. * @returns the icosahedron mesh
  129897. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129898. */
  129899. static CreateIcoSphere(name: string, options: {
  129900. radius?: number;
  129901. radiusX?: number;
  129902. radiusY?: number;
  129903. radiusZ?: number;
  129904. flat?: boolean;
  129905. subdivisions?: number;
  129906. sideOrientation?: number;
  129907. frontUVs?: Vector4;
  129908. backUVs?: Vector4;
  129909. updatable?: boolean;
  129910. }, scene?: Nullable<Scene>): Mesh;
  129911. }
  129912. }
  129913. declare module BABYLON {
  129914. /**
  129915. * Class containing static functions to help procedurally build meshes
  129916. */
  129917. export class DecalBuilder {
  129918. /**
  129919. * Creates a decal mesh.
  129920. * 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
  129921. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  129922. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  129923. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  129924. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  129925. * @param name defines the name of the mesh
  129926. * @param sourceMesh defines the mesh where the decal must be applied
  129927. * @param options defines the options used to create the mesh
  129928. * @param scene defines the hosting scene
  129929. * @returns the decal mesh
  129930. * @see https://doc.babylonjs.com/how_to/decals
  129931. */
  129932. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  129933. position?: Vector3;
  129934. normal?: Vector3;
  129935. size?: Vector3;
  129936. angle?: number;
  129937. }): Mesh;
  129938. }
  129939. }
  129940. declare module BABYLON {
  129941. /**
  129942. * Class containing static functions to help procedurally build meshes
  129943. */
  129944. export class MeshBuilder {
  129945. /**
  129946. * Creates a box mesh
  129947. * * The parameter `size` sets the size (float) of each box side (default 1)
  129948. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129949. * * 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)
  129950. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129954. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129955. * @param name defines the name of the mesh
  129956. * @param options defines the options used to create the mesh
  129957. * @param scene defines the hosting scene
  129958. * @returns the box mesh
  129959. */
  129960. static CreateBox(name: string, options: {
  129961. size?: number;
  129962. width?: number;
  129963. height?: number;
  129964. depth?: number;
  129965. faceUV?: Vector4[];
  129966. faceColors?: Color4[];
  129967. sideOrientation?: number;
  129968. frontUVs?: Vector4;
  129969. backUVs?: Vector4;
  129970. updatable?: boolean;
  129971. }, scene?: Nullable<Scene>): Mesh;
  129972. /**
  129973. * Creates a tiled box mesh
  129974. * * faceTiles sets the pattern, tile size and number of tiles for a face
  129975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129976. * @param name defines the name of the mesh
  129977. * @param options defines the options used to create the mesh
  129978. * @param scene defines the hosting scene
  129979. * @returns the tiled box mesh
  129980. */
  129981. static CreateTiledBox(name: string, options: {
  129982. pattern?: number;
  129983. size?: number;
  129984. width?: number;
  129985. height?: number;
  129986. depth: number;
  129987. tileSize?: number;
  129988. tileWidth?: number;
  129989. tileHeight?: number;
  129990. faceUV?: Vector4[];
  129991. faceColors?: Color4[];
  129992. alignHorizontal?: number;
  129993. alignVertical?: number;
  129994. sideOrientation?: number;
  129995. updatable?: boolean;
  129996. }, scene?: Nullable<Scene>): Mesh;
  129997. /**
  129998. * Creates a sphere mesh
  129999. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  130000. * * 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`)
  130001. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  130002. * * 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
  130003. * * 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)
  130004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130007. * @param name defines the name of the mesh
  130008. * @param options defines the options used to create the mesh
  130009. * @param scene defines the hosting scene
  130010. * @returns the sphere mesh
  130011. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  130012. */
  130013. static CreateSphere(name: string, options: {
  130014. segments?: number;
  130015. diameter?: number;
  130016. diameterX?: number;
  130017. diameterY?: number;
  130018. diameterZ?: number;
  130019. arc?: number;
  130020. slice?: number;
  130021. sideOrientation?: number;
  130022. frontUVs?: Vector4;
  130023. backUVs?: Vector4;
  130024. updatable?: boolean;
  130025. }, scene?: Nullable<Scene>): Mesh;
  130026. /**
  130027. * Creates a plane polygonal mesh. By default, this is a disc
  130028. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  130029. * * 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
  130030. * * 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
  130031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130034. * @param name defines the name of the mesh
  130035. * @param options defines the options used to create the mesh
  130036. * @param scene defines the hosting scene
  130037. * @returns the plane polygonal mesh
  130038. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  130039. */
  130040. static CreateDisc(name: string, options: {
  130041. radius?: number;
  130042. tessellation?: number;
  130043. arc?: number;
  130044. updatable?: boolean;
  130045. sideOrientation?: number;
  130046. frontUVs?: Vector4;
  130047. backUVs?: Vector4;
  130048. }, scene?: Nullable<Scene>): Mesh;
  130049. /**
  130050. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  130051. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  130052. * * 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`)
  130053. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  130054. * * 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
  130055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130058. * @param name defines the name of the mesh
  130059. * @param options defines the options used to create the mesh
  130060. * @param scene defines the hosting scene
  130061. * @returns the icosahedron mesh
  130062. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  130063. */
  130064. static CreateIcoSphere(name: string, options: {
  130065. radius?: number;
  130066. radiusX?: number;
  130067. radiusY?: number;
  130068. radiusZ?: number;
  130069. flat?: boolean;
  130070. subdivisions?: number;
  130071. sideOrientation?: number;
  130072. frontUVs?: Vector4;
  130073. backUVs?: Vector4;
  130074. updatable?: boolean;
  130075. }, scene?: Nullable<Scene>): Mesh;
  130076. /**
  130077. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130078. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  130079. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  130080. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  130081. * * 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
  130082. * * 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
  130083. * * 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
  130084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130086. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130087. * * 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
  130088. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  130089. * * 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
  130090. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  130091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130092. * @param name defines the name of the mesh
  130093. * @param options defines the options used to create the mesh
  130094. * @param scene defines the hosting scene
  130095. * @returns the ribbon mesh
  130096. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  130097. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130098. */
  130099. static CreateRibbon(name: string, options: {
  130100. pathArray: Vector3[][];
  130101. closeArray?: boolean;
  130102. closePath?: boolean;
  130103. offset?: number;
  130104. updatable?: boolean;
  130105. sideOrientation?: number;
  130106. frontUVs?: Vector4;
  130107. backUVs?: Vector4;
  130108. instance?: Mesh;
  130109. invertUV?: boolean;
  130110. uvs?: Vector2[];
  130111. colors?: Color4[];
  130112. }, scene?: Nullable<Scene>): Mesh;
  130113. /**
  130114. * Creates a cylinder or a cone mesh
  130115. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130116. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130117. * * 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.
  130118. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130119. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130120. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130121. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130122. * * 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).
  130123. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130124. * * 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).
  130125. * * 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
  130126. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130127. * * 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
  130128. * * 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.
  130129. * * If `enclose` is false, a ring surface is one element.
  130130. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130131. * * 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
  130132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130135. * @param name defines the name of the mesh
  130136. * @param options defines the options used to create the mesh
  130137. * @param scene defines the hosting scene
  130138. * @returns the cylinder mesh
  130139. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130140. */
  130141. static CreateCylinder(name: string, options: {
  130142. height?: number;
  130143. diameterTop?: number;
  130144. diameterBottom?: number;
  130145. diameter?: number;
  130146. tessellation?: number;
  130147. subdivisions?: number;
  130148. arc?: number;
  130149. faceColors?: Color4[];
  130150. faceUV?: Vector4[];
  130151. updatable?: boolean;
  130152. hasRings?: boolean;
  130153. enclose?: boolean;
  130154. cap?: number;
  130155. sideOrientation?: number;
  130156. frontUVs?: Vector4;
  130157. backUVs?: Vector4;
  130158. }, scene?: Nullable<Scene>): Mesh;
  130159. /**
  130160. * Creates a torus mesh
  130161. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130162. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130163. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130167. * @param name defines the name of the mesh
  130168. * @param options defines the options used to create the mesh
  130169. * @param scene defines the hosting scene
  130170. * @returns the torus mesh
  130171. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130172. */
  130173. static CreateTorus(name: string, options: {
  130174. diameter?: number;
  130175. thickness?: number;
  130176. tessellation?: number;
  130177. updatable?: boolean;
  130178. sideOrientation?: number;
  130179. frontUVs?: Vector4;
  130180. backUVs?: Vector4;
  130181. }, scene?: Nullable<Scene>): Mesh;
  130182. /**
  130183. * Creates a torus knot mesh
  130184. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  130185. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  130186. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  130187. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  130188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130191. * @param name defines the name of the mesh
  130192. * @param options defines the options used to create the mesh
  130193. * @param scene defines the hosting scene
  130194. * @returns the torus knot mesh
  130195. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  130196. */
  130197. static CreateTorusKnot(name: string, options: {
  130198. radius?: number;
  130199. tube?: number;
  130200. radialSegments?: number;
  130201. tubularSegments?: number;
  130202. p?: number;
  130203. q?: number;
  130204. updatable?: boolean;
  130205. sideOrientation?: number;
  130206. frontUVs?: Vector4;
  130207. backUVs?: Vector4;
  130208. }, scene?: Nullable<Scene>): Mesh;
  130209. /**
  130210. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  130211. * * 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
  130212. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  130213. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  130214. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  130215. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  130216. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  130217. * * 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
  130218. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  130219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  130221. * @param name defines the name of the new line system
  130222. * @param options defines the options used to create the line system
  130223. * @param scene defines the hosting scene
  130224. * @returns a new line system mesh
  130225. */
  130226. static CreateLineSystem(name: string, options: {
  130227. lines: Vector3[][];
  130228. updatable?: boolean;
  130229. instance?: Nullable<LinesMesh>;
  130230. colors?: Nullable<Color4[][]>;
  130231. useVertexAlpha?: boolean;
  130232. }, scene: Nullable<Scene>): LinesMesh;
  130233. /**
  130234. * Creates a line mesh
  130235. * 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
  130236. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130237. * * The parameter `points` is an array successive Vector3
  130238. * * 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
  130239. * * The optional parameter `colors` is an array of successive Color4, one per line point
  130240. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  130241. * * When updating an instance, remember that only point positions can change, not the number of points
  130242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  130244. * @param name defines the name of the new line system
  130245. * @param options defines the options used to create the line system
  130246. * @param scene defines the hosting scene
  130247. * @returns a new line mesh
  130248. */
  130249. static CreateLines(name: string, options: {
  130250. points: Vector3[];
  130251. updatable?: boolean;
  130252. instance?: Nullable<LinesMesh>;
  130253. colors?: Color4[];
  130254. useVertexAlpha?: boolean;
  130255. }, scene?: Nullable<Scene>): LinesMesh;
  130256. /**
  130257. * Creates a dashed line mesh
  130258. * * 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
  130259. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130260. * * The parameter `points` is an array successive Vector3
  130261. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  130262. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  130263. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  130264. * * 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
  130265. * * When updating an instance, remember that only point positions can change, not the number of points
  130266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130267. * @param name defines the name of the mesh
  130268. * @param options defines the options used to create the mesh
  130269. * @param scene defines the hosting scene
  130270. * @returns the dashed line mesh
  130271. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  130272. */
  130273. static CreateDashedLines(name: string, options: {
  130274. points: Vector3[];
  130275. dashSize?: number;
  130276. gapSize?: number;
  130277. dashNb?: number;
  130278. updatable?: boolean;
  130279. instance?: LinesMesh;
  130280. }, scene?: Nullable<Scene>): LinesMesh;
  130281. /**
  130282. * 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.
  130283. * * 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.
  130284. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130285. * * 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.
  130286. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130287. * * 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
  130288. * * 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
  130289. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130292. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130294. * @param name defines the name of the mesh
  130295. * @param options defines the options used to create the mesh
  130296. * @param scene defines the hosting scene
  130297. * @returns the extruded shape mesh
  130298. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130300. */
  130301. static ExtrudeShape(name: string, options: {
  130302. shape: Vector3[];
  130303. path: Vector3[];
  130304. scale?: number;
  130305. rotation?: number;
  130306. cap?: number;
  130307. updatable?: boolean;
  130308. sideOrientation?: number;
  130309. frontUVs?: Vector4;
  130310. backUVs?: Vector4;
  130311. instance?: Mesh;
  130312. invertUV?: boolean;
  130313. }, scene?: Nullable<Scene>): Mesh;
  130314. /**
  130315. * Creates an custom extruded shape mesh.
  130316. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130317. * * 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.
  130318. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130319. * * 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
  130320. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130321. * * 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
  130322. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130323. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130324. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130325. * * 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
  130326. * * 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
  130327. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130330. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130332. * @param name defines the name of the mesh
  130333. * @param options defines the options used to create the mesh
  130334. * @param scene defines the hosting scene
  130335. * @returns the custom extruded shape mesh
  130336. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130337. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130339. */
  130340. static ExtrudeShapeCustom(name: string, options: {
  130341. shape: Vector3[];
  130342. path: Vector3[];
  130343. scaleFunction?: any;
  130344. rotationFunction?: any;
  130345. ribbonCloseArray?: boolean;
  130346. ribbonClosePath?: boolean;
  130347. cap?: number;
  130348. updatable?: boolean;
  130349. sideOrientation?: number;
  130350. frontUVs?: Vector4;
  130351. backUVs?: Vector4;
  130352. instance?: Mesh;
  130353. invertUV?: boolean;
  130354. }, scene?: Nullable<Scene>): Mesh;
  130355. /**
  130356. * Creates lathe mesh.
  130357. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  130358. * * 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
  130359. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  130360. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  130361. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  130362. * * 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
  130363. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  130364. * * 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
  130365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130367. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130369. * @param name defines the name of the mesh
  130370. * @param options defines the options used to create the mesh
  130371. * @param scene defines the hosting scene
  130372. * @returns the lathe mesh
  130373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  130374. */
  130375. static CreateLathe(name: string, options: {
  130376. shape: Vector3[];
  130377. radius?: number;
  130378. tessellation?: number;
  130379. clip?: number;
  130380. arc?: number;
  130381. closed?: boolean;
  130382. updatable?: boolean;
  130383. sideOrientation?: number;
  130384. frontUVs?: Vector4;
  130385. backUVs?: Vector4;
  130386. cap?: number;
  130387. invertUV?: boolean;
  130388. }, scene?: Nullable<Scene>): Mesh;
  130389. /**
  130390. * Creates a tiled plane mesh
  130391. * * You can set a limited pattern arrangement with the tiles
  130392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130395. * @param name defines the name of the mesh
  130396. * @param options defines the options used to create the mesh
  130397. * @param scene defines the hosting scene
  130398. * @returns the plane mesh
  130399. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130400. */
  130401. static CreateTiledPlane(name: string, options: {
  130402. pattern?: number;
  130403. tileSize?: number;
  130404. tileWidth?: number;
  130405. tileHeight?: number;
  130406. size?: number;
  130407. width?: number;
  130408. height?: number;
  130409. alignHorizontal?: number;
  130410. alignVertical?: number;
  130411. sideOrientation?: number;
  130412. frontUVs?: Vector4;
  130413. backUVs?: Vector4;
  130414. updatable?: boolean;
  130415. }, scene?: Nullable<Scene>): Mesh;
  130416. /**
  130417. * Creates a plane mesh
  130418. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  130419. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  130420. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  130421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130424. * @param name defines the name of the mesh
  130425. * @param options defines the options used to create the mesh
  130426. * @param scene defines the hosting scene
  130427. * @returns the plane mesh
  130428. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130429. */
  130430. static CreatePlane(name: string, options: {
  130431. size?: number;
  130432. width?: number;
  130433. height?: number;
  130434. sideOrientation?: number;
  130435. frontUVs?: Vector4;
  130436. backUVs?: Vector4;
  130437. updatable?: boolean;
  130438. sourcePlane?: Plane;
  130439. }, scene?: Nullable<Scene>): Mesh;
  130440. /**
  130441. * Creates a ground mesh
  130442. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130443. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130445. * @param name defines the name of the mesh
  130446. * @param options defines the options used to create the mesh
  130447. * @param scene defines the hosting scene
  130448. * @returns the ground mesh
  130449. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130450. */
  130451. static CreateGround(name: string, options: {
  130452. width?: number;
  130453. height?: number;
  130454. subdivisions?: number;
  130455. subdivisionsX?: number;
  130456. subdivisionsY?: number;
  130457. updatable?: boolean;
  130458. }, scene?: Nullable<Scene>): Mesh;
  130459. /**
  130460. * Creates a tiled ground mesh
  130461. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130462. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130463. * * 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
  130464. * * 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
  130465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130466. * @param name defines the name of the mesh
  130467. * @param options defines the options used to create the mesh
  130468. * @param scene defines the hosting scene
  130469. * @returns the tiled ground mesh
  130470. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130471. */
  130472. static CreateTiledGround(name: string, options: {
  130473. xmin: number;
  130474. zmin: number;
  130475. xmax: number;
  130476. zmax: number;
  130477. subdivisions?: {
  130478. w: number;
  130479. h: number;
  130480. };
  130481. precision?: {
  130482. w: number;
  130483. h: number;
  130484. };
  130485. updatable?: boolean;
  130486. }, scene?: Nullable<Scene>): Mesh;
  130487. /**
  130488. * Creates a ground mesh from a height map
  130489. * * The parameter `url` sets the URL of the height map image resource.
  130490. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130491. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130492. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130493. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130494. * * 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.
  130495. * * 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).
  130496. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130498. * @param name defines the name of the mesh
  130499. * @param url defines the url to the height map
  130500. * @param options defines the options used to create the mesh
  130501. * @param scene defines the hosting scene
  130502. * @returns the ground mesh
  130503. * @see https://doc.babylonjs.com/babylon101/height_map
  130504. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130505. */
  130506. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130507. width?: number;
  130508. height?: number;
  130509. subdivisions?: number;
  130510. minHeight?: number;
  130511. maxHeight?: number;
  130512. colorFilter?: Color3;
  130513. alphaFilter?: number;
  130514. updatable?: boolean;
  130515. onReady?: (mesh: GroundMesh) => void;
  130516. }, scene?: Nullable<Scene>): GroundMesh;
  130517. /**
  130518. * Creates a polygon mesh
  130519. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  130520. * * 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
  130521. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  130522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  130524. * * Remember you can only change the shape positions, not their number when updating a polygon
  130525. * @param name defines the name of the mesh
  130526. * @param options defines the options used to create the mesh
  130527. * @param scene defines the hosting scene
  130528. * @param earcutInjection can be used to inject your own earcut reference
  130529. * @returns the polygon mesh
  130530. */
  130531. static CreatePolygon(name: string, options: {
  130532. shape: Vector3[];
  130533. holes?: Vector3[][];
  130534. depth?: number;
  130535. faceUV?: Vector4[];
  130536. faceColors?: Color4[];
  130537. updatable?: boolean;
  130538. sideOrientation?: number;
  130539. frontUVs?: Vector4;
  130540. backUVs?: Vector4;
  130541. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130542. /**
  130543. * Creates an extruded polygon mesh, with depth in the Y direction.
  130544. * * 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)
  130545. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130546. * @param name defines the name of the mesh
  130547. * @param options defines the options used to create the mesh
  130548. * @param scene defines the hosting scene
  130549. * @param earcutInjection can be used to inject your own earcut reference
  130550. * @returns the polygon mesh
  130551. */
  130552. static ExtrudePolygon(name: string, options: {
  130553. shape: Vector3[];
  130554. holes?: Vector3[][];
  130555. depth?: number;
  130556. faceUV?: Vector4[];
  130557. faceColors?: Color4[];
  130558. updatable?: boolean;
  130559. sideOrientation?: number;
  130560. frontUVs?: Vector4;
  130561. backUVs?: Vector4;
  130562. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130563. /**
  130564. * Creates a tube mesh.
  130565. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130566. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  130567. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  130568. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  130569. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  130570. * * 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)
  130571. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  130572. * * 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
  130573. * * 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
  130574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130576. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130578. * @param name defines the name of the mesh
  130579. * @param options defines the options used to create the mesh
  130580. * @param scene defines the hosting scene
  130581. * @returns the tube mesh
  130582. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130583. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  130584. */
  130585. static CreateTube(name: string, options: {
  130586. path: Vector3[];
  130587. radius?: number;
  130588. tessellation?: number;
  130589. radiusFunction?: {
  130590. (i: number, distance: number): number;
  130591. };
  130592. cap?: number;
  130593. arc?: number;
  130594. updatable?: boolean;
  130595. sideOrientation?: number;
  130596. frontUVs?: Vector4;
  130597. backUVs?: Vector4;
  130598. instance?: Mesh;
  130599. invertUV?: boolean;
  130600. }, scene?: Nullable<Scene>): Mesh;
  130601. /**
  130602. * Creates a polyhedron mesh
  130603. * * 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
  130604. * * The parameter `size` (positive float, default 1) sets the polygon size
  130605. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130606. * * 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`
  130607. * * 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
  130608. * * 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)`)
  130609. * * 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
  130610. * * 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
  130611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130614. * @param name defines the name of the mesh
  130615. * @param options defines the options used to create the mesh
  130616. * @param scene defines the hosting scene
  130617. * @returns the polyhedron mesh
  130618. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130619. */
  130620. static CreatePolyhedron(name: string, options: {
  130621. type?: number;
  130622. size?: number;
  130623. sizeX?: number;
  130624. sizeY?: number;
  130625. sizeZ?: number;
  130626. custom?: any;
  130627. faceUV?: Vector4[];
  130628. faceColors?: Color4[];
  130629. flat?: boolean;
  130630. updatable?: boolean;
  130631. sideOrientation?: number;
  130632. frontUVs?: Vector4;
  130633. backUVs?: Vector4;
  130634. }, scene?: Nullable<Scene>): Mesh;
  130635. /**
  130636. * Creates a decal mesh.
  130637. * 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
  130638. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  130639. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  130640. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  130641. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  130642. * @param name defines the name of the mesh
  130643. * @param sourceMesh defines the mesh where the decal must be applied
  130644. * @param options defines the options used to create the mesh
  130645. * @param scene defines the hosting scene
  130646. * @returns the decal mesh
  130647. * @see https://doc.babylonjs.com/how_to/decals
  130648. */
  130649. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  130650. position?: Vector3;
  130651. normal?: Vector3;
  130652. size?: Vector3;
  130653. angle?: number;
  130654. }): Mesh;
  130655. }
  130656. }
  130657. declare module BABYLON {
  130658. /**
  130659. * A simplifier interface for future simplification implementations
  130660. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130661. */
  130662. export interface ISimplifier {
  130663. /**
  130664. * Simplification of a given mesh according to the given settings.
  130665. * Since this requires computation, it is assumed that the function runs async.
  130666. * @param settings The settings of the simplification, including quality and distance
  130667. * @param successCallback A callback that will be called after the mesh was simplified.
  130668. * @param errorCallback in case of an error, this callback will be called. optional.
  130669. */
  130670. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  130671. }
  130672. /**
  130673. * Expected simplification settings.
  130674. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  130675. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130676. */
  130677. export interface ISimplificationSettings {
  130678. /**
  130679. * Gets or sets the expected quality
  130680. */
  130681. quality: number;
  130682. /**
  130683. * Gets or sets the distance when this optimized version should be used
  130684. */
  130685. distance: number;
  130686. /**
  130687. * Gets an already optimized mesh
  130688. */
  130689. optimizeMesh?: boolean;
  130690. }
  130691. /**
  130692. * Class used to specify simplification options
  130693. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130694. */
  130695. export class SimplificationSettings implements ISimplificationSettings {
  130696. /** expected quality */
  130697. quality: number;
  130698. /** distance when this optimized version should be used */
  130699. distance: number;
  130700. /** already optimized mesh */
  130701. optimizeMesh?: boolean | undefined;
  130702. /**
  130703. * Creates a SimplificationSettings
  130704. * @param quality expected quality
  130705. * @param distance distance when this optimized version should be used
  130706. * @param optimizeMesh already optimized mesh
  130707. */
  130708. constructor(
  130709. /** expected quality */
  130710. quality: number,
  130711. /** distance when this optimized version should be used */
  130712. distance: number,
  130713. /** already optimized mesh */
  130714. optimizeMesh?: boolean | undefined);
  130715. }
  130716. /**
  130717. * Interface used to define a simplification task
  130718. */
  130719. export interface ISimplificationTask {
  130720. /**
  130721. * Array of settings
  130722. */
  130723. settings: Array<ISimplificationSettings>;
  130724. /**
  130725. * Simplification type
  130726. */
  130727. simplificationType: SimplificationType;
  130728. /**
  130729. * Mesh to simplify
  130730. */
  130731. mesh: Mesh;
  130732. /**
  130733. * Callback called on success
  130734. */
  130735. successCallback?: () => void;
  130736. /**
  130737. * Defines if parallel processing can be used
  130738. */
  130739. parallelProcessing: boolean;
  130740. }
  130741. /**
  130742. * Queue used to order the simplification tasks
  130743. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130744. */
  130745. export class SimplificationQueue {
  130746. private _simplificationArray;
  130747. /**
  130748. * Gets a boolean indicating that the process is still running
  130749. */
  130750. running: boolean;
  130751. /**
  130752. * Creates a new queue
  130753. */
  130754. constructor();
  130755. /**
  130756. * Adds a new simplification task
  130757. * @param task defines a task to add
  130758. */
  130759. addTask(task: ISimplificationTask): void;
  130760. /**
  130761. * Execute next task
  130762. */
  130763. executeNext(): void;
  130764. /**
  130765. * Execute a simplification task
  130766. * @param task defines the task to run
  130767. */
  130768. runSimplification(task: ISimplificationTask): void;
  130769. private getSimplifier;
  130770. }
  130771. /**
  130772. * The implemented types of simplification
  130773. * At the moment only Quadratic Error Decimation is implemented
  130774. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130775. */
  130776. export enum SimplificationType {
  130777. /** Quadratic error decimation */
  130778. QUADRATIC = 0
  130779. }
  130780. }
  130781. declare module BABYLON {
  130782. interface Scene {
  130783. /** @hidden (Backing field) */
  130784. _simplificationQueue: SimplificationQueue;
  130785. /**
  130786. * Gets or sets the simplification queue attached to the scene
  130787. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130788. */
  130789. simplificationQueue: SimplificationQueue;
  130790. }
  130791. interface Mesh {
  130792. /**
  130793. * Simplify the mesh according to the given array of settings.
  130794. * Function will return immediately and will simplify async
  130795. * @param settings a collection of simplification settings
  130796. * @param parallelProcessing should all levels calculate parallel or one after the other
  130797. * @param simplificationType the type of simplification to run
  130798. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  130799. * @returns the current mesh
  130800. */
  130801. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  130802. }
  130803. /**
  130804. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  130805. * created in a scene
  130806. */
  130807. export class SimplicationQueueSceneComponent implements ISceneComponent {
  130808. /**
  130809. * The component name helpfull to identify the component in the list of scene components.
  130810. */
  130811. readonly name: string;
  130812. /**
  130813. * The scene the component belongs to.
  130814. */
  130815. scene: Scene;
  130816. /**
  130817. * Creates a new instance of the component for the given scene
  130818. * @param scene Defines the scene to register the component in
  130819. */
  130820. constructor(scene: Scene);
  130821. /**
  130822. * Registers the component in a given scene
  130823. */
  130824. register(): void;
  130825. /**
  130826. * Rebuilds the elements related to this component in case of
  130827. * context lost for instance.
  130828. */
  130829. rebuild(): void;
  130830. /**
  130831. * Disposes the component and the associated ressources
  130832. */
  130833. dispose(): void;
  130834. private _beforeCameraUpdate;
  130835. }
  130836. }
  130837. declare module BABYLON {
  130838. /**
  130839. * Navigation plugin interface to add navigation constrained by a navigation mesh
  130840. */
  130841. export interface INavigationEnginePlugin {
  130842. /**
  130843. * plugin name
  130844. */
  130845. name: string;
  130846. /**
  130847. * Creates a navigation mesh
  130848. * @param meshes array of all the geometry used to compute the navigatio mesh
  130849. * @param parameters bunch of parameters used to filter geometry
  130850. */
  130851. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  130852. /**
  130853. * Create a navigation mesh debug mesh
  130854. * @param scene is where the mesh will be added
  130855. * @returns debug display mesh
  130856. */
  130857. createDebugNavMesh(scene: Scene): Mesh;
  130858. /**
  130859. * Get a navigation mesh constrained position, closest to the parameter position
  130860. * @param position world position
  130861. * @returns the closest point to position constrained by the navigation mesh
  130862. */
  130863. getClosestPoint(position: Vector3): Vector3;
  130864. /**
  130865. * Get a navigation mesh constrained position, within a particular radius
  130866. * @param position world position
  130867. * @param maxRadius the maximum distance to the constrained world position
  130868. * @returns the closest point to position constrained by the navigation mesh
  130869. */
  130870. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  130871. /**
  130872. * Compute the final position from a segment made of destination-position
  130873. * @param position world position
  130874. * @param destination world position
  130875. * @returns the resulting point along the navmesh
  130876. */
  130877. moveAlong(position: Vector3, destination: Vector3): Vector3;
  130878. /**
  130879. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  130880. * @param start world position
  130881. * @param end world position
  130882. * @returns array containing world position composing the path
  130883. */
  130884. computePath(start: Vector3, end: Vector3): Vector3[];
  130885. /**
  130886. * If this plugin is supported
  130887. * @returns true if plugin is supported
  130888. */
  130889. isSupported(): boolean;
  130890. /**
  130891. * Create a new Crowd so you can add agents
  130892. * @param maxAgents the maximum agent count in the crowd
  130893. * @param maxAgentRadius the maximum radius an agent can have
  130894. * @param scene to attach the crowd to
  130895. * @returns the crowd you can add agents to
  130896. */
  130897. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  130898. /**
  130899. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130900. * The queries will try to find a solution within those bounds
  130901. * default is (1,1,1)
  130902. * @param extent x,y,z value that define the extent around the queries point of reference
  130903. */
  130904. setDefaultQueryExtent(extent: Vector3): void;
  130905. /**
  130906. * Get the Bounding box extent specified by setDefaultQueryExtent
  130907. * @returns the box extent values
  130908. */
  130909. getDefaultQueryExtent(): Vector3;
  130910. /**
  130911. * Release all resources
  130912. */
  130913. dispose(): void;
  130914. }
  130915. /**
  130916. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  130917. */
  130918. export interface ICrowd {
  130919. /**
  130920. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  130921. * You can attach anything to that node. The node position is updated in the scene update tick.
  130922. * @param pos world position that will be constrained by the navigation mesh
  130923. * @param parameters agent parameters
  130924. * @param transform hooked to the agent that will be update by the scene
  130925. * @returns agent index
  130926. */
  130927. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  130928. /**
  130929. * Returns the agent position in world space
  130930. * @param index agent index returned by addAgent
  130931. * @returns world space position
  130932. */
  130933. getAgentPosition(index: number): Vector3;
  130934. /**
  130935. * Gets the agent velocity in world space
  130936. * @param index agent index returned by addAgent
  130937. * @returns world space velocity
  130938. */
  130939. getAgentVelocity(index: number): Vector3;
  130940. /**
  130941. * remove a particular agent previously created
  130942. * @param index agent index returned by addAgent
  130943. */
  130944. removeAgent(index: number): void;
  130945. /**
  130946. * get the list of all agents attached to this crowd
  130947. * @returns list of agent indices
  130948. */
  130949. getAgents(): number[];
  130950. /**
  130951. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  130952. * @param deltaTime in seconds
  130953. */
  130954. update(deltaTime: number): void;
  130955. /**
  130956. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  130957. * @param index agent index returned by addAgent
  130958. * @param destination targeted world position
  130959. */
  130960. agentGoto(index: number, destination: Vector3): void;
  130961. /**
  130962. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130963. * The queries will try to find a solution within those bounds
  130964. * default is (1,1,1)
  130965. * @param extent x,y,z value that define the extent around the queries point of reference
  130966. */
  130967. setDefaultQueryExtent(extent: Vector3): void;
  130968. /**
  130969. * Get the Bounding box extent specified by setDefaultQueryExtent
  130970. * @returns the box extent values
  130971. */
  130972. getDefaultQueryExtent(): Vector3;
  130973. /**
  130974. * Release all resources
  130975. */
  130976. dispose(): void;
  130977. }
  130978. /**
  130979. * Configures an agent
  130980. */
  130981. export interface IAgentParameters {
  130982. /**
  130983. * Agent radius. [Limit: >= 0]
  130984. */
  130985. radius: number;
  130986. /**
  130987. * Agent height. [Limit: > 0]
  130988. */
  130989. height: number;
  130990. /**
  130991. * Maximum allowed acceleration. [Limit: >= 0]
  130992. */
  130993. maxAcceleration: number;
  130994. /**
  130995. * Maximum allowed speed. [Limit: >= 0]
  130996. */
  130997. maxSpeed: number;
  130998. /**
  130999. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  131000. */
  131001. collisionQueryRange: number;
  131002. /**
  131003. * The path visibility optimization range. [Limit: > 0]
  131004. */
  131005. pathOptimizationRange: number;
  131006. /**
  131007. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  131008. */
  131009. separationWeight: number;
  131010. }
  131011. /**
  131012. * Configures the navigation mesh creation
  131013. */
  131014. export interface INavMeshParameters {
  131015. /**
  131016. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  131017. */
  131018. cs: number;
  131019. /**
  131020. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  131021. */
  131022. ch: number;
  131023. /**
  131024. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  131025. */
  131026. walkableSlopeAngle: number;
  131027. /**
  131028. * Minimum floor to 'ceiling' height that will still allow the floor area to
  131029. * be considered walkable. [Limit: >= 3] [Units: vx]
  131030. */
  131031. walkableHeight: number;
  131032. /**
  131033. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  131034. */
  131035. walkableClimb: number;
  131036. /**
  131037. * The distance to erode/shrink the walkable area of the heightfield away from
  131038. * obstructions. [Limit: >=0] [Units: vx]
  131039. */
  131040. walkableRadius: number;
  131041. /**
  131042. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  131043. */
  131044. maxEdgeLen: number;
  131045. /**
  131046. * The maximum distance a simplfied contour's border edges should deviate
  131047. * the original raw contour. [Limit: >=0] [Units: vx]
  131048. */
  131049. maxSimplificationError: number;
  131050. /**
  131051. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  131052. */
  131053. minRegionArea: number;
  131054. /**
  131055. * Any regions with a span count smaller than this value will, if possible,
  131056. * be merged with larger regions. [Limit: >=0] [Units: vx]
  131057. */
  131058. mergeRegionArea: number;
  131059. /**
  131060. * The maximum number of vertices allowed for polygons generated during the
  131061. * contour to polygon conversion process. [Limit: >= 3]
  131062. */
  131063. maxVertsPerPoly: number;
  131064. /**
  131065. * Sets the sampling distance to use when generating the detail mesh.
  131066. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  131067. */
  131068. detailSampleDist: number;
  131069. /**
  131070. * The maximum distance the detail mesh surface should deviate from heightfield
  131071. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  131072. */
  131073. detailSampleMaxError: number;
  131074. }
  131075. }
  131076. declare module BABYLON {
  131077. /**
  131078. * RecastJS navigation plugin
  131079. */
  131080. export class RecastJSPlugin implements INavigationEnginePlugin {
  131081. /**
  131082. * Reference to the Recast library
  131083. */
  131084. bjsRECAST: any;
  131085. /**
  131086. * plugin name
  131087. */
  131088. name: string;
  131089. /**
  131090. * the first navmesh created. We might extend this to support multiple navmeshes
  131091. */
  131092. navMesh: any;
  131093. /**
  131094. * Initializes the recastJS plugin
  131095. * @param recastInjection can be used to inject your own recast reference
  131096. */
  131097. constructor(recastInjection?: any);
  131098. /**
  131099. * Creates a navigation mesh
  131100. * @param meshes array of all the geometry used to compute the navigatio mesh
  131101. * @param parameters bunch of parameters used to filter geometry
  131102. */
  131103. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  131104. /**
  131105. * Create a navigation mesh debug mesh
  131106. * @param scene is where the mesh will be added
  131107. * @returns debug display mesh
  131108. */
  131109. createDebugNavMesh(scene: Scene): Mesh;
  131110. /**
  131111. * Get a navigation mesh constrained position, closest to the parameter position
  131112. * @param position world position
  131113. * @returns the closest point to position constrained by the navigation mesh
  131114. */
  131115. getClosestPoint(position: Vector3): Vector3;
  131116. /**
  131117. * Get a navigation mesh constrained position, within a particular radius
  131118. * @param position world position
  131119. * @param maxRadius the maximum distance to the constrained world position
  131120. * @returns the closest point to position constrained by the navigation mesh
  131121. */
  131122. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  131123. /**
  131124. * Compute the final position from a segment made of destination-position
  131125. * @param position world position
  131126. * @param destination world position
  131127. * @returns the resulting point along the navmesh
  131128. */
  131129. moveAlong(position: Vector3, destination: Vector3): Vector3;
  131130. /**
  131131. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  131132. * @param start world position
  131133. * @param end world position
  131134. * @returns array containing world position composing the path
  131135. */
  131136. computePath(start: Vector3, end: Vector3): Vector3[];
  131137. /**
  131138. * Create a new Crowd so you can add agents
  131139. * @param maxAgents the maximum agent count in the crowd
  131140. * @param maxAgentRadius the maximum radius an agent can have
  131141. * @param scene to attach the crowd to
  131142. * @returns the crowd you can add agents to
  131143. */
  131144. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  131145. /**
  131146. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  131147. * The queries will try to find a solution within those bounds
  131148. * default is (1,1,1)
  131149. * @param extent x,y,z value that define the extent around the queries point of reference
  131150. */
  131151. setDefaultQueryExtent(extent: Vector3): void;
  131152. /**
  131153. * Get the Bounding box extent specified by setDefaultQueryExtent
  131154. * @returns the box extent values
  131155. */
  131156. getDefaultQueryExtent(): Vector3;
  131157. /**
  131158. * Disposes
  131159. */
  131160. dispose(): void;
  131161. /**
  131162. * If this plugin is supported
  131163. * @returns true if plugin is supported
  131164. */
  131165. isSupported(): boolean;
  131166. }
  131167. /**
  131168. * Recast detour crowd implementation
  131169. */
  131170. export class RecastJSCrowd implements ICrowd {
  131171. /**
  131172. * Recast/detour plugin
  131173. */
  131174. bjsRECASTPlugin: RecastJSPlugin;
  131175. /**
  131176. * Link to the detour crowd
  131177. */
  131178. recastCrowd: any;
  131179. /**
  131180. * One transform per agent
  131181. */
  131182. transforms: TransformNode[];
  131183. /**
  131184. * All agents created
  131185. */
  131186. agents: number[];
  131187. /**
  131188. * Link to the scene is kept to unregister the crowd from the scene
  131189. */
  131190. private _scene;
  131191. /**
  131192. * Observer for crowd updates
  131193. */
  131194. private _onBeforeAnimationsObserver;
  131195. /**
  131196. * Constructor
  131197. * @param plugin recastJS plugin
  131198. * @param maxAgents the maximum agent count in the crowd
  131199. * @param maxAgentRadius the maximum radius an agent can have
  131200. * @param scene to attach the crowd to
  131201. * @returns the crowd you can add agents to
  131202. */
  131203. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  131204. /**
  131205. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  131206. * You can attach anything to that node. The node position is updated in the scene update tick.
  131207. * @param pos world position that will be constrained by the navigation mesh
  131208. * @param parameters agent parameters
  131209. * @param transform hooked to the agent that will be update by the scene
  131210. * @returns agent index
  131211. */
  131212. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  131213. /**
  131214. * Returns the agent position in world space
  131215. * @param index agent index returned by addAgent
  131216. * @returns world space position
  131217. */
  131218. getAgentPosition(index: number): Vector3;
  131219. /**
  131220. * Returns the agent velocity in world space
  131221. * @param index agent index returned by addAgent
  131222. * @returns world space velocity
  131223. */
  131224. getAgentVelocity(index: number): Vector3;
  131225. /**
  131226. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  131227. * @param index agent index returned by addAgent
  131228. * @param destination targeted world position
  131229. */
  131230. agentGoto(index: number, destination: Vector3): void;
  131231. /**
  131232. * remove a particular agent previously created
  131233. * @param index agent index returned by addAgent
  131234. */
  131235. removeAgent(index: number): void;
  131236. /**
  131237. * get the list of all agents attached to this crowd
  131238. * @returns list of agent indices
  131239. */
  131240. getAgents(): number[];
  131241. /**
  131242. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  131243. * @param deltaTime in seconds
  131244. */
  131245. update(deltaTime: number): void;
  131246. /**
  131247. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  131248. * The queries will try to find a solution within those bounds
  131249. * default is (1,1,1)
  131250. * @param extent x,y,z value that define the extent around the queries point of reference
  131251. */
  131252. setDefaultQueryExtent(extent: Vector3): void;
  131253. /**
  131254. * Get the Bounding box extent specified by setDefaultQueryExtent
  131255. * @returns the box extent values
  131256. */
  131257. getDefaultQueryExtent(): Vector3;
  131258. /**
  131259. * Release all resources
  131260. */
  131261. dispose(): void;
  131262. }
  131263. }
  131264. declare module BABYLON {
  131265. /**
  131266. * Class used to enable access to IndexedDB
  131267. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  131268. */
  131269. export class Database implements IOfflineProvider {
  131270. private _callbackManifestChecked;
  131271. private _currentSceneUrl;
  131272. private _db;
  131273. private _enableSceneOffline;
  131274. private _enableTexturesOffline;
  131275. private _manifestVersionFound;
  131276. private _mustUpdateRessources;
  131277. private _hasReachedQuota;
  131278. private _isSupported;
  131279. private _idbFactory;
  131280. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  131281. private static IsUASupportingBlobStorage;
  131282. /**
  131283. * Gets a boolean indicating if Database storate is enabled (off by default)
  131284. */
  131285. static IDBStorageEnabled: boolean;
  131286. /**
  131287. * Gets a boolean indicating if scene must be saved in the database
  131288. */
  131289. get enableSceneOffline(): boolean;
  131290. /**
  131291. * Gets a boolean indicating if textures must be saved in the database
  131292. */
  131293. get enableTexturesOffline(): boolean;
  131294. /**
  131295. * Creates a new Database
  131296. * @param urlToScene defines the url to load the scene
  131297. * @param callbackManifestChecked defines the callback to use when manifest is checked
  131298. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  131299. */
  131300. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  131301. private static _ParseURL;
  131302. private static _ReturnFullUrlLocation;
  131303. private _checkManifestFile;
  131304. /**
  131305. * Open the database and make it available
  131306. * @param successCallback defines the callback to call on success
  131307. * @param errorCallback defines the callback to call on error
  131308. */
  131309. open(successCallback: () => void, errorCallback: () => void): void;
  131310. /**
  131311. * Loads an image from the database
  131312. * @param url defines the url to load from
  131313. * @param image defines the target DOM image
  131314. */
  131315. loadImage(url: string, image: HTMLImageElement): void;
  131316. private _loadImageFromDBAsync;
  131317. private _saveImageIntoDBAsync;
  131318. private _checkVersionFromDB;
  131319. private _loadVersionFromDBAsync;
  131320. private _saveVersionIntoDBAsync;
  131321. /**
  131322. * Loads a file from database
  131323. * @param url defines the URL to load from
  131324. * @param sceneLoaded defines a callback to call on success
  131325. * @param progressCallBack defines a callback to call when progress changed
  131326. * @param errorCallback defines a callback to call on error
  131327. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  131328. */
  131329. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  131330. private _loadFileAsync;
  131331. private _saveFileAsync;
  131332. /**
  131333. * Validates if xhr data is correct
  131334. * @param xhr defines the request to validate
  131335. * @param dataType defines the expected data type
  131336. * @returns true if data is correct
  131337. */
  131338. private static _ValidateXHRData;
  131339. }
  131340. }
  131341. declare module BABYLON {
  131342. /** @hidden */
  131343. export var gpuUpdateParticlesPixelShader: {
  131344. name: string;
  131345. shader: string;
  131346. };
  131347. }
  131348. declare module BABYLON {
  131349. /** @hidden */
  131350. export var gpuUpdateParticlesVertexShader: {
  131351. name: string;
  131352. shader: string;
  131353. };
  131354. }
  131355. declare module BABYLON {
  131356. /** @hidden */
  131357. export var clipPlaneFragmentDeclaration2: {
  131358. name: string;
  131359. shader: string;
  131360. };
  131361. }
  131362. declare module BABYLON {
  131363. /** @hidden */
  131364. export var gpuRenderParticlesPixelShader: {
  131365. name: string;
  131366. shader: string;
  131367. };
  131368. }
  131369. declare module BABYLON {
  131370. /** @hidden */
  131371. export var clipPlaneVertexDeclaration2: {
  131372. name: string;
  131373. shader: string;
  131374. };
  131375. }
  131376. declare module BABYLON {
  131377. /** @hidden */
  131378. export var gpuRenderParticlesVertexShader: {
  131379. name: string;
  131380. shader: string;
  131381. };
  131382. }
  131383. declare module BABYLON {
  131384. /**
  131385. * This represents a GPU particle system in Babylon
  131386. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  131387. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  131388. */
  131389. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  131390. /**
  131391. * The layer mask we are rendering the particles through.
  131392. */
  131393. layerMask: number;
  131394. private _capacity;
  131395. private _activeCount;
  131396. private _currentActiveCount;
  131397. private _accumulatedCount;
  131398. private _renderEffect;
  131399. private _updateEffect;
  131400. private _buffer0;
  131401. private _buffer1;
  131402. private _spriteBuffer;
  131403. private _updateVAO;
  131404. private _renderVAO;
  131405. private _targetIndex;
  131406. private _sourceBuffer;
  131407. private _targetBuffer;
  131408. private _engine;
  131409. private _currentRenderId;
  131410. private _started;
  131411. private _stopped;
  131412. private _timeDelta;
  131413. private _randomTexture;
  131414. private _randomTexture2;
  131415. private _attributesStrideSize;
  131416. private _updateEffectOptions;
  131417. private _randomTextureSize;
  131418. private _actualFrame;
  131419. private readonly _rawTextureWidth;
  131420. /**
  131421. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  131422. */
  131423. static get IsSupported(): boolean;
  131424. /**
  131425. * An event triggered when the system is disposed.
  131426. */
  131427. onDisposeObservable: Observable<GPUParticleSystem>;
  131428. /**
  131429. * Gets the maximum number of particles active at the same time.
  131430. * @returns The max number of active particles.
  131431. */
  131432. getCapacity(): number;
  131433. /**
  131434. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  131435. * to override the particles.
  131436. */
  131437. forceDepthWrite: boolean;
  131438. /**
  131439. * Gets or set the number of active particles
  131440. */
  131441. get activeParticleCount(): number;
  131442. set activeParticleCount(value: number);
  131443. private _preWarmDone;
  131444. /**
  131445. * Is this system ready to be used/rendered
  131446. * @return true if the system is ready
  131447. */
  131448. isReady(): boolean;
  131449. /**
  131450. * Gets if the system has been started. (Note: this will still be true after stop is called)
  131451. * @returns True if it has been started, otherwise false.
  131452. */
  131453. isStarted(): boolean;
  131454. /**
  131455. * Starts the particle system and begins to emit
  131456. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  131457. */
  131458. start(delay?: number): void;
  131459. /**
  131460. * Stops the particle system.
  131461. */
  131462. stop(): void;
  131463. /**
  131464. * Remove all active particles
  131465. */
  131466. reset(): void;
  131467. /**
  131468. * Returns the string "GPUParticleSystem"
  131469. * @returns a string containing the class name
  131470. */
  131471. getClassName(): string;
  131472. private _colorGradientsTexture;
  131473. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  131474. /**
  131475. * Adds a new color gradient
  131476. * @param gradient defines the gradient to use (between 0 and 1)
  131477. * @param color1 defines the color to affect to the specified gradient
  131478. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  131479. * @returns the current particle system
  131480. */
  131481. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  131482. /**
  131483. * Remove a specific color gradient
  131484. * @param gradient defines the gradient to remove
  131485. * @returns the current particle system
  131486. */
  131487. removeColorGradient(gradient: number): GPUParticleSystem;
  131488. private _angularSpeedGradientsTexture;
  131489. private _sizeGradientsTexture;
  131490. private _velocityGradientsTexture;
  131491. private _limitVelocityGradientsTexture;
  131492. private _dragGradientsTexture;
  131493. private _addFactorGradient;
  131494. /**
  131495. * Adds a new size gradient
  131496. * @param gradient defines the gradient to use (between 0 and 1)
  131497. * @param factor defines the size factor to affect to the specified gradient
  131498. * @returns the current particle system
  131499. */
  131500. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  131501. /**
  131502. * Remove a specific size gradient
  131503. * @param gradient defines the gradient to remove
  131504. * @returns the current particle system
  131505. */
  131506. removeSizeGradient(gradient: number): GPUParticleSystem;
  131507. /**
  131508. * Adds a new angular speed gradient
  131509. * @param gradient defines the gradient to use (between 0 and 1)
  131510. * @param factor defines the angular speed to affect to the specified gradient
  131511. * @returns the current particle system
  131512. */
  131513. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  131514. /**
  131515. * Remove a specific angular speed gradient
  131516. * @param gradient defines the gradient to remove
  131517. * @returns the current particle system
  131518. */
  131519. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  131520. /**
  131521. * Adds a new velocity gradient
  131522. * @param gradient defines the gradient to use (between 0 and 1)
  131523. * @param factor defines the velocity to affect to the specified gradient
  131524. * @returns the current particle system
  131525. */
  131526. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131527. /**
  131528. * Remove a specific velocity gradient
  131529. * @param gradient defines the gradient to remove
  131530. * @returns the current particle system
  131531. */
  131532. removeVelocityGradient(gradient: number): GPUParticleSystem;
  131533. /**
  131534. * Adds a new limit velocity gradient
  131535. * @param gradient defines the gradient to use (between 0 and 1)
  131536. * @param factor defines the limit velocity value to affect to the specified gradient
  131537. * @returns the current particle system
  131538. */
  131539. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131540. /**
  131541. * Remove a specific limit velocity gradient
  131542. * @param gradient defines the gradient to remove
  131543. * @returns the current particle system
  131544. */
  131545. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  131546. /**
  131547. * Adds a new drag gradient
  131548. * @param gradient defines the gradient to use (between 0 and 1)
  131549. * @param factor defines the drag value to affect to the specified gradient
  131550. * @returns the current particle system
  131551. */
  131552. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  131553. /**
  131554. * Remove a specific drag gradient
  131555. * @param gradient defines the gradient to remove
  131556. * @returns the current particle system
  131557. */
  131558. removeDragGradient(gradient: number): GPUParticleSystem;
  131559. /**
  131560. * Not supported by GPUParticleSystem
  131561. * @param gradient defines the gradient to use (between 0 and 1)
  131562. * @param factor defines the emit rate value to affect to the specified gradient
  131563. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131564. * @returns the current particle system
  131565. */
  131566. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131567. /**
  131568. * Not supported by GPUParticleSystem
  131569. * @param gradient defines the gradient to remove
  131570. * @returns the current particle system
  131571. */
  131572. removeEmitRateGradient(gradient: number): IParticleSystem;
  131573. /**
  131574. * Not supported by GPUParticleSystem
  131575. * @param gradient defines the gradient to use (between 0 and 1)
  131576. * @param factor defines the start size value to affect to the specified gradient
  131577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131578. * @returns the current particle system
  131579. */
  131580. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131581. /**
  131582. * Not supported by GPUParticleSystem
  131583. * @param gradient defines the gradient to remove
  131584. * @returns the current particle system
  131585. */
  131586. removeStartSizeGradient(gradient: number): IParticleSystem;
  131587. /**
  131588. * Not supported by GPUParticleSystem
  131589. * @param gradient defines the gradient to use (between 0 and 1)
  131590. * @param min defines the color remap minimal range
  131591. * @param max defines the color remap maximal range
  131592. * @returns the current particle system
  131593. */
  131594. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131595. /**
  131596. * Not supported by GPUParticleSystem
  131597. * @param gradient defines the gradient to remove
  131598. * @returns the current particle system
  131599. */
  131600. removeColorRemapGradient(): IParticleSystem;
  131601. /**
  131602. * Not supported by GPUParticleSystem
  131603. * @param gradient defines the gradient to use (between 0 and 1)
  131604. * @param min defines the alpha remap minimal range
  131605. * @param max defines the alpha remap maximal range
  131606. * @returns the current particle system
  131607. */
  131608. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131609. /**
  131610. * Not supported by GPUParticleSystem
  131611. * @param gradient defines the gradient to remove
  131612. * @returns the current particle system
  131613. */
  131614. removeAlphaRemapGradient(): IParticleSystem;
  131615. /**
  131616. * Not supported by GPUParticleSystem
  131617. * @param gradient defines the gradient to use (between 0 and 1)
  131618. * @param color defines the color to affect to the specified gradient
  131619. * @returns the current particle system
  131620. */
  131621. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  131622. /**
  131623. * Not supported by GPUParticleSystem
  131624. * @param gradient defines the gradient to remove
  131625. * @returns the current particle system
  131626. */
  131627. removeRampGradient(): IParticleSystem;
  131628. /**
  131629. * Not supported by GPUParticleSystem
  131630. * @returns the list of ramp gradients
  131631. */
  131632. getRampGradients(): Nullable<Array<Color3Gradient>>;
  131633. /**
  131634. * Not supported by GPUParticleSystem
  131635. * Gets or sets a boolean indicating that ramp gradients must be used
  131636. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  131637. */
  131638. get useRampGradients(): boolean;
  131639. set useRampGradients(value: boolean);
  131640. /**
  131641. * Not supported by GPUParticleSystem
  131642. * @param gradient defines the gradient to use (between 0 and 1)
  131643. * @param factor defines the life time factor to affect to the specified gradient
  131644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131645. * @returns the current particle system
  131646. */
  131647. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131648. /**
  131649. * Not supported by GPUParticleSystem
  131650. * @param gradient defines the gradient to remove
  131651. * @returns the current particle system
  131652. */
  131653. removeLifeTimeGradient(gradient: number): IParticleSystem;
  131654. /**
  131655. * Instantiates a GPU particle system.
  131656. * 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.
  131657. * @param name The name of the particle system
  131658. * @param options The options used to create the system
  131659. * @param scene The scene the particle system belongs to
  131660. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  131661. */
  131662. constructor(name: string, options: Partial<{
  131663. capacity: number;
  131664. randomTextureSize: number;
  131665. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  131666. protected _reset(): void;
  131667. private _createUpdateVAO;
  131668. private _createRenderVAO;
  131669. private _initialize;
  131670. /** @hidden */
  131671. _recreateUpdateEffect(): void;
  131672. /** @hidden */
  131673. _recreateRenderEffect(): void;
  131674. /**
  131675. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  131676. * @param preWarm defines if we are in the pre-warmimg phase
  131677. */
  131678. animate(preWarm?: boolean): void;
  131679. private _createFactorGradientTexture;
  131680. private _createSizeGradientTexture;
  131681. private _createAngularSpeedGradientTexture;
  131682. private _createVelocityGradientTexture;
  131683. private _createLimitVelocityGradientTexture;
  131684. private _createDragGradientTexture;
  131685. private _createColorGradientTexture;
  131686. /**
  131687. * Renders the particle system in its current state
  131688. * @param preWarm defines if the system should only update the particles but not render them
  131689. * @returns the current number of particles
  131690. */
  131691. render(preWarm?: boolean): number;
  131692. /**
  131693. * Rebuilds the particle system
  131694. */
  131695. rebuild(): void;
  131696. private _releaseBuffers;
  131697. private _releaseVAOs;
  131698. /**
  131699. * Disposes the particle system and free the associated resources
  131700. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  131701. */
  131702. dispose(disposeTexture?: boolean): void;
  131703. /**
  131704. * Clones the particle system.
  131705. * @param name The name of the cloned object
  131706. * @param newEmitter The new emitter to use
  131707. * @returns the cloned particle system
  131708. */
  131709. clone(name: string, newEmitter: any): GPUParticleSystem;
  131710. /**
  131711. * Serializes the particle system to a JSON object.
  131712. * @returns the JSON object
  131713. */
  131714. serialize(): any;
  131715. /**
  131716. * Parses a JSON object to create a GPU particle system.
  131717. * @param parsedParticleSystem The JSON object to parse
  131718. * @param scene The scene to create the particle system in
  131719. * @param rootUrl The root url to use to load external dependencies like texture
  131720. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  131721. * @returns the parsed GPU particle system
  131722. */
  131723. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  131724. }
  131725. }
  131726. declare module BABYLON {
  131727. /**
  131728. * Represents a set of particle systems working together to create a specific effect
  131729. */
  131730. export class ParticleSystemSet implements IDisposable {
  131731. /**
  131732. * Gets or sets base Assets URL
  131733. */
  131734. static BaseAssetsUrl: string;
  131735. private _emitterCreationOptions;
  131736. private _emitterNode;
  131737. /**
  131738. * Gets the particle system list
  131739. */
  131740. systems: IParticleSystem[];
  131741. /**
  131742. * Gets the emitter node used with this set
  131743. */
  131744. get emitterNode(): Nullable<TransformNode>;
  131745. /**
  131746. * Creates a new emitter mesh as a sphere
  131747. * @param options defines the options used to create the sphere
  131748. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  131749. * @param scene defines the hosting scene
  131750. */
  131751. setEmitterAsSphere(options: {
  131752. diameter: number;
  131753. segments: number;
  131754. color: Color3;
  131755. }, renderingGroupId: number, scene: Scene): void;
  131756. /**
  131757. * Starts all particle systems of the set
  131758. * @param emitter defines an optional mesh to use as emitter for the particle systems
  131759. */
  131760. start(emitter?: AbstractMesh): void;
  131761. /**
  131762. * Release all associated resources
  131763. */
  131764. dispose(): void;
  131765. /**
  131766. * Serialize the set into a JSON compatible object
  131767. * @returns a JSON compatible representation of the set
  131768. */
  131769. serialize(): any;
  131770. /**
  131771. * Parse a new ParticleSystemSet from a serialized source
  131772. * @param data defines a JSON compatible representation of the set
  131773. * @param scene defines the hosting scene
  131774. * @param gpu defines if we want GPU particles or CPU particles
  131775. * @returns a new ParticleSystemSet
  131776. */
  131777. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  131778. }
  131779. }
  131780. declare module BABYLON {
  131781. /**
  131782. * This class is made for on one-liner static method to help creating particle system set.
  131783. */
  131784. export class ParticleHelper {
  131785. /**
  131786. * Gets or sets base Assets URL
  131787. */
  131788. static BaseAssetsUrl: string;
  131789. /**
  131790. * Create a default particle system that you can tweak
  131791. * @param emitter defines the emitter to use
  131792. * @param capacity defines the system capacity (default is 500 particles)
  131793. * @param scene defines the hosting scene
  131794. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  131795. * @returns the new Particle system
  131796. */
  131797. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  131798. /**
  131799. * This is the main static method (one-liner) of this helper to create different particle systems
  131800. * @param type This string represents the type to the particle system to create
  131801. * @param scene The scene where the particle system should live
  131802. * @param gpu If the system will use gpu
  131803. * @returns the ParticleSystemSet created
  131804. */
  131805. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  131806. /**
  131807. * Static function used to export a particle system to a ParticleSystemSet variable.
  131808. * Please note that the emitter shape is not exported
  131809. * @param systems defines the particle systems to export
  131810. * @returns the created particle system set
  131811. */
  131812. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  131813. }
  131814. }
  131815. declare module BABYLON {
  131816. interface Engine {
  131817. /**
  131818. * Create an effect to use with particle systems.
  131819. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  131820. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  131821. * @param uniformsNames defines a list of attribute names
  131822. * @param samplers defines an array of string used to represent textures
  131823. * @param defines defines the string containing the defines to use to compile the shaders
  131824. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  131825. * @param onCompiled defines a function to call when the effect creation is successful
  131826. * @param onError defines a function to call when the effect creation has failed
  131827. * @returns the new Effect
  131828. */
  131829. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  131830. }
  131831. interface Mesh {
  131832. /**
  131833. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  131834. * @returns an array of IParticleSystem
  131835. */
  131836. getEmittedParticleSystems(): IParticleSystem[];
  131837. /**
  131838. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  131839. * @returns an array of IParticleSystem
  131840. */
  131841. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  131842. }
  131843. /**
  131844. * @hidden
  131845. */
  131846. export var _IDoNeedToBeInTheBuild: number;
  131847. }
  131848. declare module BABYLON {
  131849. /** Defines the 4 color options */
  131850. export enum PointColor {
  131851. /** color value */
  131852. Color = 2,
  131853. /** uv value */
  131854. UV = 1,
  131855. /** random value */
  131856. Random = 0,
  131857. /** stated value */
  131858. Stated = 3
  131859. }
  131860. /**
  131861. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  131862. * 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.
  131863. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  131864. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  131865. *
  131866. * Full documentation here : TO BE ENTERED
  131867. */
  131868. export class PointsCloudSystem implements IDisposable {
  131869. /**
  131870. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  131871. * Example : var p = SPS.particles[i];
  131872. */
  131873. particles: CloudPoint[];
  131874. /**
  131875. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  131876. */
  131877. nbParticles: number;
  131878. /**
  131879. * This a counter for your own usage. It's not set by any SPS functions.
  131880. */
  131881. counter: number;
  131882. /**
  131883. * The PCS name. This name is also given to the underlying mesh.
  131884. */
  131885. name: string;
  131886. /**
  131887. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  131888. */
  131889. mesh: Mesh;
  131890. /**
  131891. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  131892. * Please read :
  131893. */
  131894. vars: any;
  131895. /**
  131896. * @hidden
  131897. */
  131898. _size: number;
  131899. private _scene;
  131900. private _promises;
  131901. private _positions;
  131902. private _indices;
  131903. private _normals;
  131904. private _colors;
  131905. private _uvs;
  131906. private _indices32;
  131907. private _positions32;
  131908. private _colors32;
  131909. private _uvs32;
  131910. private _updatable;
  131911. private _isVisibilityBoxLocked;
  131912. private _alwaysVisible;
  131913. private _groups;
  131914. private _groupCounter;
  131915. private _computeParticleColor;
  131916. private _computeParticleTexture;
  131917. private _computeParticleRotation;
  131918. private _computeBoundingBox;
  131919. private _isReady;
  131920. /**
  131921. * Creates a PCS (Points Cloud System) object
  131922. * @param name (String) is the PCS name, this will be the underlying mesh name
  131923. * @param pointSize (number) is the size for each point
  131924. * @param scene (Scene) is the scene in which the PCS is added
  131925. * @param options defines the options of the PCS e.g.
  131926. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  131927. */
  131928. constructor(name: string, pointSize: number, scene: Scene, options?: {
  131929. updatable?: boolean;
  131930. });
  131931. /**
  131932. * Builds the PCS underlying mesh. Returns a standard Mesh.
  131933. * If no points were added to the PCS, the returned mesh is just a single point.
  131934. * @returns a promise for the created mesh
  131935. */
  131936. buildMeshAsync(): Promise<Mesh>;
  131937. /**
  131938. * @hidden
  131939. */
  131940. private _buildMesh;
  131941. private _addParticle;
  131942. private _randomUnitVector;
  131943. private _getColorIndicesForCoord;
  131944. private _setPointsColorOrUV;
  131945. private _colorFromTexture;
  131946. private _calculateDensity;
  131947. /**
  131948. * Adds points to the PCS in random positions within a unit sphere
  131949. * @param nb (positive integer) the number of particles to be created from this model
  131950. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  131951. * @returns the number of groups in the system
  131952. */
  131953. addPoints(nb: number, pointFunction?: any): number;
  131954. /**
  131955. * Adds points to the PCS from the surface of the model shape
  131956. * @param mesh is any Mesh object that will be used as a surface model for the points
  131957. * @param nb (positive integer) the number of particles to be created from this model
  131958. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131959. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131960. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131961. * @returns the number of groups in the system
  131962. */
  131963. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131964. /**
  131965. * Adds points to the PCS inside the model shape
  131966. * @param mesh is any Mesh object that will be used as a surface model for the points
  131967. * @param nb (positive integer) the number of particles to be created from this model
  131968. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131969. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131970. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131971. * @returns the number of groups in the system
  131972. */
  131973. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131974. /**
  131975. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  131976. * This method calls `updateParticle()` for each particle of the SPS.
  131977. * For an animated SPS, it is usually called within the render loop.
  131978. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  131979. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  131980. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  131981. * @returns the PCS.
  131982. */
  131983. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  131984. /**
  131985. * Disposes the PCS.
  131986. */
  131987. dispose(): void;
  131988. /**
  131989. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  131990. * doc :
  131991. * @returns the PCS.
  131992. */
  131993. refreshVisibleSize(): PointsCloudSystem;
  131994. /**
  131995. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  131996. * @param size the size (float) of the visibility box
  131997. * note : this doesn't lock the PCS mesh bounding box.
  131998. * doc :
  131999. */
  132000. setVisibilityBox(size: number): void;
  132001. /**
  132002. * Gets whether the PCS is always visible or not
  132003. * doc :
  132004. */
  132005. get isAlwaysVisible(): boolean;
  132006. /**
  132007. * Sets the PCS as always visible or not
  132008. * doc :
  132009. */
  132010. set isAlwaysVisible(val: boolean);
  132011. /**
  132012. * Tells to `setParticles()` to compute the particle rotations or not
  132013. * Default value : false. The PCS is faster when it's set to false
  132014. * Note : particle rotations are only applied to parent particles
  132015. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  132016. */
  132017. set computeParticleRotation(val: boolean);
  132018. /**
  132019. * Tells to `setParticles()` to compute the particle colors or not.
  132020. * Default value : true. The PCS is faster when it's set to false.
  132021. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  132022. */
  132023. set computeParticleColor(val: boolean);
  132024. set computeParticleTexture(val: boolean);
  132025. /**
  132026. * Gets if `setParticles()` computes the particle colors or not.
  132027. * Default value : false. The PCS is faster when it's set to false.
  132028. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  132029. */
  132030. get computeParticleColor(): boolean;
  132031. /**
  132032. * Gets if `setParticles()` computes the particle textures or not.
  132033. * Default value : false. The PCS is faster when it's set to false.
  132034. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  132035. */
  132036. get computeParticleTexture(): boolean;
  132037. /**
  132038. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  132039. */
  132040. set computeBoundingBox(val: boolean);
  132041. /**
  132042. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  132043. */
  132044. get computeBoundingBox(): boolean;
  132045. /**
  132046. * This function does nothing. It may be overwritten to set all the particle first values.
  132047. * The PCS doesn't call this function, you may have to call it by your own.
  132048. * doc :
  132049. */
  132050. initParticles(): void;
  132051. /**
  132052. * This function does nothing. It may be overwritten to recycle a particle
  132053. * The PCS doesn't call this function, you can to call it
  132054. * doc :
  132055. * @param particle The particle to recycle
  132056. * @returns the recycled particle
  132057. */
  132058. recycleParticle(particle: CloudPoint): CloudPoint;
  132059. /**
  132060. * Updates a particle : this function should be overwritten by the user.
  132061. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  132062. * doc :
  132063. * @example : just set a particle position or velocity and recycle conditions
  132064. * @param particle The particle to update
  132065. * @returns the updated particle
  132066. */
  132067. updateParticle(particle: CloudPoint): CloudPoint;
  132068. /**
  132069. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  132070. * This does nothing and may be overwritten by the user.
  132071. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  132072. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  132073. * @param update the boolean update value actually passed to setParticles()
  132074. */
  132075. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  132076. /**
  132077. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  132078. * This will be passed three parameters.
  132079. * This does nothing and may be overwritten by the user.
  132080. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  132081. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  132082. * @param update the boolean update value actually passed to setParticles()
  132083. */
  132084. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  132085. }
  132086. }
  132087. declare module BABYLON {
  132088. /**
  132089. * Represents one particle of a points cloud system.
  132090. */
  132091. export class CloudPoint {
  132092. /**
  132093. * particle global index
  132094. */
  132095. idx: number;
  132096. /**
  132097. * The color of the particle
  132098. */
  132099. color: Nullable<Color4>;
  132100. /**
  132101. * The world space position of the particle.
  132102. */
  132103. position: Vector3;
  132104. /**
  132105. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  132106. */
  132107. rotation: Vector3;
  132108. /**
  132109. * The world space rotation quaternion of the particle.
  132110. */
  132111. rotationQuaternion: Nullable<Quaternion>;
  132112. /**
  132113. * The uv of the particle.
  132114. */
  132115. uv: Nullable<Vector2>;
  132116. /**
  132117. * The current speed of the particle.
  132118. */
  132119. velocity: Vector3;
  132120. /**
  132121. * The pivot point in the particle local space.
  132122. */
  132123. pivot: Vector3;
  132124. /**
  132125. * Must the particle be translated from its pivot point in its local space ?
  132126. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  132127. * Default : false
  132128. */
  132129. translateFromPivot: boolean;
  132130. /**
  132131. * Index of this particle in the global "positions" array (Internal use)
  132132. * @hidden
  132133. */
  132134. _pos: number;
  132135. /**
  132136. * @hidden Index of this particle in the global "indices" array (Internal use)
  132137. */
  132138. _ind: number;
  132139. /**
  132140. * Group this particle belongs to
  132141. */
  132142. _group: PointsGroup;
  132143. /**
  132144. * Group id of this particle
  132145. */
  132146. groupId: number;
  132147. /**
  132148. * Index of the particle in its group id (Internal use)
  132149. */
  132150. idxInGroup: number;
  132151. /**
  132152. * @hidden Particle BoundingInfo object (Internal use)
  132153. */
  132154. _boundingInfo: BoundingInfo;
  132155. /**
  132156. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  132157. */
  132158. _pcs: PointsCloudSystem;
  132159. /**
  132160. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  132161. */
  132162. _stillInvisible: boolean;
  132163. /**
  132164. * @hidden Last computed particle rotation matrix
  132165. */
  132166. _rotationMatrix: number[];
  132167. /**
  132168. * Parent particle Id, if any.
  132169. * Default null.
  132170. */
  132171. parentId: Nullable<number>;
  132172. /**
  132173. * @hidden Internal global position in the PCS.
  132174. */
  132175. _globalPosition: Vector3;
  132176. /**
  132177. * Creates a Point Cloud object.
  132178. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  132179. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  132180. * @param group (PointsGroup) is the group the particle belongs to
  132181. * @param groupId (integer) is the group identifier in the PCS.
  132182. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  132183. * @param pcs defines the PCS it is associated to
  132184. */
  132185. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  132186. /**
  132187. * get point size
  132188. */
  132189. get size(): Vector3;
  132190. /**
  132191. * Set point size
  132192. */
  132193. set size(scale: Vector3);
  132194. /**
  132195. * Legacy support, changed quaternion to rotationQuaternion
  132196. */
  132197. get quaternion(): Nullable<Quaternion>;
  132198. /**
  132199. * Legacy support, changed quaternion to rotationQuaternion
  132200. */
  132201. set quaternion(q: Nullable<Quaternion>);
  132202. /**
  132203. * Returns a boolean. True if the particle intersects a mesh, else false
  132204. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  132205. * @param target is the object (point or mesh) what the intersection is computed against
  132206. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  132207. * @returns true if it intersects
  132208. */
  132209. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  132210. /**
  132211. * get the rotation matrix of the particle
  132212. * @hidden
  132213. */
  132214. getRotationMatrix(m: Matrix): void;
  132215. }
  132216. /**
  132217. * Represents a group of points in a points cloud system
  132218. * * PCS internal tool, don't use it manually.
  132219. */
  132220. export class PointsGroup {
  132221. /**
  132222. * The group id
  132223. * @hidden
  132224. */
  132225. groupID: number;
  132226. /**
  132227. * image data for group (internal use)
  132228. * @hidden
  132229. */
  132230. _groupImageData: Nullable<ArrayBufferView>;
  132231. /**
  132232. * Image Width (internal use)
  132233. * @hidden
  132234. */
  132235. _groupImgWidth: number;
  132236. /**
  132237. * Image Height (internal use)
  132238. * @hidden
  132239. */
  132240. _groupImgHeight: number;
  132241. /**
  132242. * Custom position function (internal use)
  132243. * @hidden
  132244. */
  132245. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  132246. /**
  132247. * density per facet for surface points
  132248. * @hidden
  132249. */
  132250. _groupDensity: number[];
  132251. /**
  132252. * Only when points are colored by texture carries pointer to texture list array
  132253. * @hidden
  132254. */
  132255. _textureNb: number;
  132256. /**
  132257. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  132258. * PCS internal tool, don't use it manually.
  132259. * @hidden
  132260. */
  132261. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  132262. }
  132263. }
  132264. declare module BABYLON {
  132265. interface Scene {
  132266. /** @hidden (Backing field) */
  132267. _physicsEngine: Nullable<IPhysicsEngine>;
  132268. /** @hidden */
  132269. _physicsTimeAccumulator: number;
  132270. /**
  132271. * Gets the current physics engine
  132272. * @returns a IPhysicsEngine or null if none attached
  132273. */
  132274. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  132275. /**
  132276. * Enables physics to the current scene
  132277. * @param gravity defines the scene's gravity for the physics engine
  132278. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  132279. * @return a boolean indicating if the physics engine was initialized
  132280. */
  132281. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  132282. /**
  132283. * Disables and disposes the physics engine associated with the scene
  132284. */
  132285. disablePhysicsEngine(): void;
  132286. /**
  132287. * Gets a boolean indicating if there is an active physics engine
  132288. * @returns a boolean indicating if there is an active physics engine
  132289. */
  132290. isPhysicsEnabled(): boolean;
  132291. /**
  132292. * Deletes a physics compound impostor
  132293. * @param compound defines the compound to delete
  132294. */
  132295. deleteCompoundImpostor(compound: any): void;
  132296. /**
  132297. * An event triggered when physic simulation is about to be run
  132298. */
  132299. onBeforePhysicsObservable: Observable<Scene>;
  132300. /**
  132301. * An event triggered when physic simulation has been done
  132302. */
  132303. onAfterPhysicsObservable: Observable<Scene>;
  132304. }
  132305. interface AbstractMesh {
  132306. /** @hidden */
  132307. _physicsImpostor: Nullable<PhysicsImpostor>;
  132308. /**
  132309. * Gets or sets impostor used for physic simulation
  132310. * @see http://doc.babylonjs.com/features/physics_engine
  132311. */
  132312. physicsImpostor: Nullable<PhysicsImpostor>;
  132313. /**
  132314. * Gets the current physics impostor
  132315. * @see http://doc.babylonjs.com/features/physics_engine
  132316. * @returns a physics impostor or null
  132317. */
  132318. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  132319. /** Apply a physic impulse to the mesh
  132320. * @param force defines the force to apply
  132321. * @param contactPoint defines where to apply the force
  132322. * @returns the current mesh
  132323. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  132324. */
  132325. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  132326. /**
  132327. * Creates a physic joint between two meshes
  132328. * @param otherMesh defines the other mesh to use
  132329. * @param pivot1 defines the pivot to use on this mesh
  132330. * @param pivot2 defines the pivot to use on the other mesh
  132331. * @param options defines additional options (can be plugin dependent)
  132332. * @returns the current mesh
  132333. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  132334. */
  132335. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  132336. /** @hidden */
  132337. _disposePhysicsObserver: Nullable<Observer<Node>>;
  132338. }
  132339. /**
  132340. * Defines the physics engine scene component responsible to manage a physics engine
  132341. */
  132342. export class PhysicsEngineSceneComponent implements ISceneComponent {
  132343. /**
  132344. * The component name helpful to identify the component in the list of scene components.
  132345. */
  132346. readonly name: string;
  132347. /**
  132348. * The scene the component belongs to.
  132349. */
  132350. scene: Scene;
  132351. /**
  132352. * Creates a new instance of the component for the given scene
  132353. * @param scene Defines the scene to register the component in
  132354. */
  132355. constructor(scene: Scene);
  132356. /**
  132357. * Registers the component in a given scene
  132358. */
  132359. register(): void;
  132360. /**
  132361. * Rebuilds the elements related to this component in case of
  132362. * context lost for instance.
  132363. */
  132364. rebuild(): void;
  132365. /**
  132366. * Disposes the component and the associated ressources
  132367. */
  132368. dispose(): void;
  132369. }
  132370. }
  132371. declare module BABYLON {
  132372. /**
  132373. * A helper for physics simulations
  132374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132375. */
  132376. export class PhysicsHelper {
  132377. private _scene;
  132378. private _physicsEngine;
  132379. /**
  132380. * Initializes the Physics helper
  132381. * @param scene Babylon.js scene
  132382. */
  132383. constructor(scene: Scene);
  132384. /**
  132385. * Applies a radial explosion impulse
  132386. * @param origin the origin of the explosion
  132387. * @param radiusOrEventOptions the radius or the options of radial explosion
  132388. * @param strength the explosion strength
  132389. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132390. * @returns A physics radial explosion event, or null
  132391. */
  132392. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132393. /**
  132394. * Applies a radial explosion force
  132395. * @param origin the origin of the explosion
  132396. * @param radiusOrEventOptions the radius or the options of radial explosion
  132397. * @param strength the explosion strength
  132398. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132399. * @returns A physics radial explosion event, or null
  132400. */
  132401. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132402. /**
  132403. * Creates a gravitational field
  132404. * @param origin the origin of the explosion
  132405. * @param radiusOrEventOptions the radius or the options of radial explosion
  132406. * @param strength the explosion strength
  132407. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132408. * @returns A physics gravitational field event, or null
  132409. */
  132410. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  132411. /**
  132412. * Creates a physics updraft event
  132413. * @param origin the origin of the updraft
  132414. * @param radiusOrEventOptions the radius or the options of the updraft
  132415. * @param strength the strength of the updraft
  132416. * @param height the height of the updraft
  132417. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  132418. * @returns A physics updraft event, or null
  132419. */
  132420. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  132421. /**
  132422. * Creates a physics vortex event
  132423. * @param origin the of the vortex
  132424. * @param radiusOrEventOptions the radius or the options of the vortex
  132425. * @param strength the strength of the vortex
  132426. * @param height the height of the vortex
  132427. * @returns a Physics vortex event, or null
  132428. * A physics vortex event or null
  132429. */
  132430. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  132431. }
  132432. /**
  132433. * Represents a physics radial explosion event
  132434. */
  132435. class PhysicsRadialExplosionEvent {
  132436. private _scene;
  132437. private _options;
  132438. private _sphere;
  132439. private _dataFetched;
  132440. /**
  132441. * Initializes a radial explosioin event
  132442. * @param _scene BabylonJS scene
  132443. * @param _options The options for the vortex event
  132444. */
  132445. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  132446. /**
  132447. * Returns the data related to the radial explosion event (sphere).
  132448. * @returns The radial explosion event data
  132449. */
  132450. getData(): PhysicsRadialExplosionEventData;
  132451. /**
  132452. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  132453. * @param impostor A physics imposter
  132454. * @param origin the origin of the explosion
  132455. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  132456. */
  132457. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  132458. /**
  132459. * Triggers affecterd impostors callbacks
  132460. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  132461. */
  132462. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  132463. /**
  132464. * Disposes the sphere.
  132465. * @param force Specifies if the sphere should be disposed by force
  132466. */
  132467. dispose(force?: boolean): void;
  132468. /*** Helpers ***/
  132469. private _prepareSphere;
  132470. private _intersectsWithSphere;
  132471. }
  132472. /**
  132473. * Represents a gravitational field event
  132474. */
  132475. class PhysicsGravitationalFieldEvent {
  132476. private _physicsHelper;
  132477. private _scene;
  132478. private _origin;
  132479. private _options;
  132480. private _tickCallback;
  132481. private _sphere;
  132482. private _dataFetched;
  132483. /**
  132484. * Initializes the physics gravitational field event
  132485. * @param _physicsHelper A physics helper
  132486. * @param _scene BabylonJS scene
  132487. * @param _origin The origin position of the gravitational field event
  132488. * @param _options The options for the vortex event
  132489. */
  132490. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  132491. /**
  132492. * Returns the data related to the gravitational field event (sphere).
  132493. * @returns A gravitational field event
  132494. */
  132495. getData(): PhysicsGravitationalFieldEventData;
  132496. /**
  132497. * Enables the gravitational field.
  132498. */
  132499. enable(): void;
  132500. /**
  132501. * Disables the gravitational field.
  132502. */
  132503. disable(): void;
  132504. /**
  132505. * Disposes the sphere.
  132506. * @param force The force to dispose from the gravitational field event
  132507. */
  132508. dispose(force?: boolean): void;
  132509. private _tick;
  132510. }
  132511. /**
  132512. * Represents a physics updraft event
  132513. */
  132514. class PhysicsUpdraftEvent {
  132515. private _scene;
  132516. private _origin;
  132517. private _options;
  132518. private _physicsEngine;
  132519. private _originTop;
  132520. private _originDirection;
  132521. private _tickCallback;
  132522. private _cylinder;
  132523. private _cylinderPosition;
  132524. private _dataFetched;
  132525. /**
  132526. * Initializes the physics updraft event
  132527. * @param _scene BabylonJS scene
  132528. * @param _origin The origin position of the updraft
  132529. * @param _options The options for the updraft event
  132530. */
  132531. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  132532. /**
  132533. * Returns the data related to the updraft event (cylinder).
  132534. * @returns A physics updraft event
  132535. */
  132536. getData(): PhysicsUpdraftEventData;
  132537. /**
  132538. * Enables the updraft.
  132539. */
  132540. enable(): void;
  132541. /**
  132542. * Disables the updraft.
  132543. */
  132544. disable(): void;
  132545. /**
  132546. * Disposes the cylinder.
  132547. * @param force Specifies if the updraft should be disposed by force
  132548. */
  132549. dispose(force?: boolean): void;
  132550. private getImpostorHitData;
  132551. private _tick;
  132552. /*** Helpers ***/
  132553. private _prepareCylinder;
  132554. private _intersectsWithCylinder;
  132555. }
  132556. /**
  132557. * Represents a physics vortex event
  132558. */
  132559. class PhysicsVortexEvent {
  132560. private _scene;
  132561. private _origin;
  132562. private _options;
  132563. private _physicsEngine;
  132564. private _originTop;
  132565. private _tickCallback;
  132566. private _cylinder;
  132567. private _cylinderPosition;
  132568. private _dataFetched;
  132569. /**
  132570. * Initializes the physics vortex event
  132571. * @param _scene The BabylonJS scene
  132572. * @param _origin The origin position of the vortex
  132573. * @param _options The options for the vortex event
  132574. */
  132575. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  132576. /**
  132577. * Returns the data related to the vortex event (cylinder).
  132578. * @returns The physics vortex event data
  132579. */
  132580. getData(): PhysicsVortexEventData;
  132581. /**
  132582. * Enables the vortex.
  132583. */
  132584. enable(): void;
  132585. /**
  132586. * Disables the cortex.
  132587. */
  132588. disable(): void;
  132589. /**
  132590. * Disposes the sphere.
  132591. * @param force
  132592. */
  132593. dispose(force?: boolean): void;
  132594. private getImpostorHitData;
  132595. private _tick;
  132596. /*** Helpers ***/
  132597. private _prepareCylinder;
  132598. private _intersectsWithCylinder;
  132599. }
  132600. /**
  132601. * Options fot the radial explosion event
  132602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132603. */
  132604. export class PhysicsRadialExplosionEventOptions {
  132605. /**
  132606. * The radius of the sphere for the radial explosion.
  132607. */
  132608. radius: number;
  132609. /**
  132610. * The strenth of the explosion.
  132611. */
  132612. strength: number;
  132613. /**
  132614. * The strenght of the force in correspondence to the distance of the affected object
  132615. */
  132616. falloff: PhysicsRadialImpulseFalloff;
  132617. /**
  132618. * Sphere options for the radial explosion.
  132619. */
  132620. sphere: {
  132621. segments: number;
  132622. diameter: number;
  132623. };
  132624. /**
  132625. * Sphere options for the radial explosion.
  132626. */
  132627. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  132628. }
  132629. /**
  132630. * Options fot the updraft event
  132631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132632. */
  132633. export class PhysicsUpdraftEventOptions {
  132634. /**
  132635. * The radius of the cylinder for the vortex
  132636. */
  132637. radius: number;
  132638. /**
  132639. * The strenth of the updraft.
  132640. */
  132641. strength: number;
  132642. /**
  132643. * The height of the cylinder for the updraft.
  132644. */
  132645. height: number;
  132646. /**
  132647. * The mode for the the updraft.
  132648. */
  132649. updraftMode: PhysicsUpdraftMode;
  132650. }
  132651. /**
  132652. * Options fot the vortex event
  132653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132654. */
  132655. export class PhysicsVortexEventOptions {
  132656. /**
  132657. * The radius of the cylinder for the vortex
  132658. */
  132659. radius: number;
  132660. /**
  132661. * The strenth of the vortex.
  132662. */
  132663. strength: number;
  132664. /**
  132665. * The height of the cylinder for the vortex.
  132666. */
  132667. height: number;
  132668. /**
  132669. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  132670. */
  132671. centripetalForceThreshold: number;
  132672. /**
  132673. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  132674. */
  132675. centripetalForceMultiplier: number;
  132676. /**
  132677. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  132678. */
  132679. centrifugalForceMultiplier: number;
  132680. /**
  132681. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  132682. */
  132683. updraftForceMultiplier: number;
  132684. }
  132685. /**
  132686. * The strenght of the force in correspondence to the distance of the affected object
  132687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132688. */
  132689. export enum PhysicsRadialImpulseFalloff {
  132690. /** Defines that impulse is constant in strength across it's whole radius */
  132691. Constant = 0,
  132692. /** Defines that impulse gets weaker if it's further from the origin */
  132693. Linear = 1
  132694. }
  132695. /**
  132696. * The strength of the force in correspondence to the distance of the affected object
  132697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132698. */
  132699. export enum PhysicsUpdraftMode {
  132700. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  132701. Center = 0,
  132702. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  132703. Perpendicular = 1
  132704. }
  132705. /**
  132706. * Interface for a physics hit data
  132707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132708. */
  132709. export interface PhysicsHitData {
  132710. /**
  132711. * The force applied at the contact point
  132712. */
  132713. force: Vector3;
  132714. /**
  132715. * The contact point
  132716. */
  132717. contactPoint: Vector3;
  132718. /**
  132719. * The distance from the origin to the contact point
  132720. */
  132721. distanceFromOrigin: number;
  132722. }
  132723. /**
  132724. * Interface for radial explosion event data
  132725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132726. */
  132727. export interface PhysicsRadialExplosionEventData {
  132728. /**
  132729. * A sphere used for the radial explosion event
  132730. */
  132731. sphere: Mesh;
  132732. }
  132733. /**
  132734. * Interface for gravitational field event data
  132735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132736. */
  132737. export interface PhysicsGravitationalFieldEventData {
  132738. /**
  132739. * A sphere mesh used for the gravitational field event
  132740. */
  132741. sphere: Mesh;
  132742. }
  132743. /**
  132744. * Interface for updraft event data
  132745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132746. */
  132747. export interface PhysicsUpdraftEventData {
  132748. /**
  132749. * A cylinder used for the updraft event
  132750. */
  132751. cylinder: Mesh;
  132752. }
  132753. /**
  132754. * Interface for vortex event data
  132755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132756. */
  132757. export interface PhysicsVortexEventData {
  132758. /**
  132759. * A cylinder used for the vortex event
  132760. */
  132761. cylinder: Mesh;
  132762. }
  132763. /**
  132764. * Interface for an affected physics impostor
  132765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132766. */
  132767. export interface PhysicsAffectedImpostorWithData {
  132768. /**
  132769. * The impostor affected by the effect
  132770. */
  132771. impostor: PhysicsImpostor;
  132772. /**
  132773. * The data about the hit/horce from the explosion
  132774. */
  132775. hitData: PhysicsHitData;
  132776. }
  132777. }
  132778. declare module BABYLON {
  132779. /** @hidden */
  132780. export var blackAndWhitePixelShader: {
  132781. name: string;
  132782. shader: string;
  132783. };
  132784. }
  132785. declare module BABYLON {
  132786. /**
  132787. * Post process used to render in black and white
  132788. */
  132789. export class BlackAndWhitePostProcess extends PostProcess {
  132790. /**
  132791. * Linear about to convert he result to black and white (default: 1)
  132792. */
  132793. degree: number;
  132794. /**
  132795. * Creates a black and white post process
  132796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  132797. * @param name The name of the effect.
  132798. * @param options The required width/height ratio to downsize to before computing the render pass.
  132799. * @param camera The camera to apply the render pass to.
  132800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132801. * @param engine The engine which the post process will be applied. (default: current engine)
  132802. * @param reusable If the post process can be reused on the same frame. (default: false)
  132803. */
  132804. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132805. }
  132806. }
  132807. declare module BABYLON {
  132808. /**
  132809. * This represents a set of one or more post processes in Babylon.
  132810. * A post process can be used to apply a shader to a texture after it is rendered.
  132811. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  132812. */
  132813. export class PostProcessRenderEffect {
  132814. private _postProcesses;
  132815. private _getPostProcesses;
  132816. private _singleInstance;
  132817. private _cameras;
  132818. private _indicesForCamera;
  132819. /**
  132820. * Name of the effect
  132821. * @hidden
  132822. */
  132823. _name: string;
  132824. /**
  132825. * Instantiates a post process render effect.
  132826. * A post process can be used to apply a shader to a texture after it is rendered.
  132827. * @param engine The engine the effect is tied to
  132828. * @param name The name of the effect
  132829. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  132830. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  132831. */
  132832. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  132833. /**
  132834. * Checks if all the post processes in the effect are supported.
  132835. */
  132836. get isSupported(): boolean;
  132837. /**
  132838. * Updates the current state of the effect
  132839. * @hidden
  132840. */
  132841. _update(): void;
  132842. /**
  132843. * Attaches the effect on cameras
  132844. * @param cameras The camera to attach to.
  132845. * @hidden
  132846. */
  132847. _attachCameras(cameras: Camera): void;
  132848. /**
  132849. * Attaches the effect on cameras
  132850. * @param cameras The camera to attach to.
  132851. * @hidden
  132852. */
  132853. _attachCameras(cameras: Camera[]): void;
  132854. /**
  132855. * Detaches the effect on cameras
  132856. * @param cameras The camera to detatch from.
  132857. * @hidden
  132858. */
  132859. _detachCameras(cameras: Camera): void;
  132860. /**
  132861. * Detatches the effect on cameras
  132862. * @param cameras The camera to detatch from.
  132863. * @hidden
  132864. */
  132865. _detachCameras(cameras: Camera[]): void;
  132866. /**
  132867. * Enables the effect on given cameras
  132868. * @param cameras The camera to enable.
  132869. * @hidden
  132870. */
  132871. _enable(cameras: Camera): void;
  132872. /**
  132873. * Enables the effect on given cameras
  132874. * @param cameras The camera to enable.
  132875. * @hidden
  132876. */
  132877. _enable(cameras: Nullable<Camera[]>): void;
  132878. /**
  132879. * Disables the effect on the given cameras
  132880. * @param cameras The camera to disable.
  132881. * @hidden
  132882. */
  132883. _disable(cameras: Camera): void;
  132884. /**
  132885. * Disables the effect on the given cameras
  132886. * @param cameras The camera to disable.
  132887. * @hidden
  132888. */
  132889. _disable(cameras: Nullable<Camera[]>): void;
  132890. /**
  132891. * Gets a list of the post processes contained in the effect.
  132892. * @param camera The camera to get the post processes on.
  132893. * @returns The list of the post processes in the effect.
  132894. */
  132895. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  132896. }
  132897. }
  132898. declare module BABYLON {
  132899. /** @hidden */
  132900. export var extractHighlightsPixelShader: {
  132901. name: string;
  132902. shader: string;
  132903. };
  132904. }
  132905. declare module BABYLON {
  132906. /**
  132907. * 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.
  132908. */
  132909. export class ExtractHighlightsPostProcess extends PostProcess {
  132910. /**
  132911. * The luminance threshold, pixels below this value will be set to black.
  132912. */
  132913. threshold: number;
  132914. /** @hidden */
  132915. _exposure: number;
  132916. /**
  132917. * Post process which has the input texture to be used when performing highlight extraction
  132918. * @hidden
  132919. */
  132920. _inputPostProcess: Nullable<PostProcess>;
  132921. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132922. }
  132923. }
  132924. declare module BABYLON {
  132925. /** @hidden */
  132926. export var bloomMergePixelShader: {
  132927. name: string;
  132928. shader: string;
  132929. };
  132930. }
  132931. declare module BABYLON {
  132932. /**
  132933. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  132934. */
  132935. export class BloomMergePostProcess extends PostProcess {
  132936. /** Weight of the bloom to be added to the original input. */
  132937. weight: number;
  132938. /**
  132939. * Creates a new instance of @see BloomMergePostProcess
  132940. * @param name The name of the effect.
  132941. * @param originalFromInput Post process which's input will be used for the merge.
  132942. * @param blurred Blurred highlights post process which's output will be used.
  132943. * @param weight Weight of the bloom to be added to the original input.
  132944. * @param options The required width/height ratio to downsize to before computing the render pass.
  132945. * @param camera The camera to apply the render pass to.
  132946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132947. * @param engine The engine which the post process will be applied. (default: current engine)
  132948. * @param reusable If the post process can be reused on the same frame. (default: false)
  132949. * @param textureType Type of textures used when performing the post process. (default: 0)
  132950. * @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)
  132951. */
  132952. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  132953. /** Weight of the bloom to be added to the original input. */
  132954. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132955. }
  132956. }
  132957. declare module BABYLON {
  132958. /**
  132959. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  132960. */
  132961. export class BloomEffect extends PostProcessRenderEffect {
  132962. private bloomScale;
  132963. /**
  132964. * @hidden Internal
  132965. */
  132966. _effects: Array<PostProcess>;
  132967. /**
  132968. * @hidden Internal
  132969. */
  132970. _downscale: ExtractHighlightsPostProcess;
  132971. private _blurX;
  132972. private _blurY;
  132973. private _merge;
  132974. /**
  132975. * The luminance threshold to find bright areas of the image to bloom.
  132976. */
  132977. get threshold(): number;
  132978. set threshold(value: number);
  132979. /**
  132980. * The strength of the bloom.
  132981. */
  132982. get weight(): number;
  132983. set weight(value: number);
  132984. /**
  132985. * Specifies the size of the bloom blur kernel, relative to the final output size
  132986. */
  132987. get kernel(): number;
  132988. set kernel(value: number);
  132989. /**
  132990. * Creates a new instance of @see BloomEffect
  132991. * @param scene The scene the effect belongs to.
  132992. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  132993. * @param bloomKernel The size of the kernel to be used when applying the blur.
  132994. * @param bloomWeight The the strength of bloom.
  132995. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  132996. * @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)
  132997. */
  132998. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  132999. /**
  133000. * Disposes each of the internal effects for a given camera.
  133001. * @param camera The camera to dispose the effect on.
  133002. */
  133003. disposeEffects(camera: Camera): void;
  133004. /**
  133005. * @hidden Internal
  133006. */
  133007. _updateEffects(): void;
  133008. /**
  133009. * Internal
  133010. * @returns if all the contained post processes are ready.
  133011. * @hidden
  133012. */
  133013. _isReady(): boolean;
  133014. }
  133015. }
  133016. declare module BABYLON {
  133017. /** @hidden */
  133018. export var chromaticAberrationPixelShader: {
  133019. name: string;
  133020. shader: string;
  133021. };
  133022. }
  133023. declare module BABYLON {
  133024. /**
  133025. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  133026. */
  133027. export class ChromaticAberrationPostProcess extends PostProcess {
  133028. /**
  133029. * The amount of seperation of rgb channels (default: 30)
  133030. */
  133031. aberrationAmount: number;
  133032. /**
  133033. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  133034. */
  133035. radialIntensity: number;
  133036. /**
  133037. * 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))
  133038. */
  133039. direction: Vector2;
  133040. /**
  133041. * 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))
  133042. */
  133043. centerPosition: Vector2;
  133044. /**
  133045. * Creates a new instance ChromaticAberrationPostProcess
  133046. * @param name The name of the effect.
  133047. * @param screenWidth The width of the screen to apply the effect on.
  133048. * @param screenHeight The height of the screen to apply the effect on.
  133049. * @param options The required width/height ratio to downsize to before computing the render pass.
  133050. * @param camera The camera to apply the render pass to.
  133051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133052. * @param engine The engine which the post process will be applied. (default: current engine)
  133053. * @param reusable If the post process can be reused on the same frame. (default: false)
  133054. * @param textureType Type of textures used when performing the post process. (default: 0)
  133055. * @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)
  133056. */
  133057. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133058. }
  133059. }
  133060. declare module BABYLON {
  133061. /** @hidden */
  133062. export var circleOfConfusionPixelShader: {
  133063. name: string;
  133064. shader: string;
  133065. };
  133066. }
  133067. declare module BABYLON {
  133068. /**
  133069. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  133070. */
  133071. export class CircleOfConfusionPostProcess extends PostProcess {
  133072. /**
  133073. * 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.
  133074. */
  133075. lensSize: number;
  133076. /**
  133077. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  133078. */
  133079. fStop: number;
  133080. /**
  133081. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  133082. */
  133083. focusDistance: number;
  133084. /**
  133085. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  133086. */
  133087. focalLength: number;
  133088. private _depthTexture;
  133089. /**
  133090. * Creates a new instance CircleOfConfusionPostProcess
  133091. * @param name The name of the effect.
  133092. * @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.
  133093. * @param options The required width/height ratio to downsize to before computing the render pass.
  133094. * @param camera The camera to apply the render pass to.
  133095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133096. * @param engine The engine which the post process will be applied. (default: current engine)
  133097. * @param reusable If the post process can be reused on the same frame. (default: false)
  133098. * @param textureType Type of textures used when performing the post process. (default: 0)
  133099. * @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)
  133100. */
  133101. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133102. /**
  133103. * 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.
  133104. */
  133105. set depthTexture(value: RenderTargetTexture);
  133106. }
  133107. }
  133108. declare module BABYLON {
  133109. /** @hidden */
  133110. export var colorCorrectionPixelShader: {
  133111. name: string;
  133112. shader: string;
  133113. };
  133114. }
  133115. declare module BABYLON {
  133116. /**
  133117. *
  133118. * This post-process allows the modification of rendered colors by using
  133119. * a 'look-up table' (LUT). This effect is also called Color Grading.
  133120. *
  133121. * The object needs to be provided an url to a texture containing the color
  133122. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  133123. * Use an image editing software to tweak the LUT to match your needs.
  133124. *
  133125. * For an example of a color LUT, see here:
  133126. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  133127. * For explanations on color grading, see here:
  133128. * @see http://udn.epicgames.com/Three/ColorGrading.html
  133129. *
  133130. */
  133131. export class ColorCorrectionPostProcess extends PostProcess {
  133132. private _colorTableTexture;
  133133. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133134. }
  133135. }
  133136. declare module BABYLON {
  133137. /** @hidden */
  133138. export var convolutionPixelShader: {
  133139. name: string;
  133140. shader: string;
  133141. };
  133142. }
  133143. declare module BABYLON {
  133144. /**
  133145. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  133146. * input texture to perform effects such as edge detection or sharpening
  133147. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  133148. */
  133149. export class ConvolutionPostProcess extends PostProcess {
  133150. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  133151. kernel: number[];
  133152. /**
  133153. * Creates a new instance ConvolutionPostProcess
  133154. * @param name The name of the effect.
  133155. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  133156. * @param options The required width/height ratio to downsize to before computing the render pass.
  133157. * @param camera The camera to apply the render pass to.
  133158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133159. * @param engine The engine which the post process will be applied. (default: current engine)
  133160. * @param reusable If the post process can be reused on the same frame. (default: false)
  133161. * @param textureType Type of textures used when performing the post process. (default: 0)
  133162. */
  133163. constructor(name: string,
  133164. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  133165. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133166. /**
  133167. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133168. */
  133169. static EdgeDetect0Kernel: number[];
  133170. /**
  133171. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133172. */
  133173. static EdgeDetect1Kernel: number[];
  133174. /**
  133175. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133176. */
  133177. static EdgeDetect2Kernel: number[];
  133178. /**
  133179. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133180. */
  133181. static SharpenKernel: number[];
  133182. /**
  133183. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133184. */
  133185. static EmbossKernel: number[];
  133186. /**
  133187. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133188. */
  133189. static GaussianKernel: number[];
  133190. }
  133191. }
  133192. declare module BABYLON {
  133193. /**
  133194. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  133195. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  133196. * based on samples that have a large difference in distance than the center pixel.
  133197. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  133198. */
  133199. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  133200. direction: Vector2;
  133201. /**
  133202. * Creates a new instance CircleOfConfusionPostProcess
  133203. * @param name The name of the effect.
  133204. * @param scene The scene the effect belongs to.
  133205. * @param direction The direction the blur should be applied.
  133206. * @param kernel The size of the kernel used to blur.
  133207. * @param options The required width/height ratio to downsize to before computing the render pass.
  133208. * @param camera The camera to apply the render pass to.
  133209. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  133210. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  133211. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133212. * @param engine The engine which the post process will be applied. (default: current engine)
  133213. * @param reusable If the post process can be reused on the same frame. (default: false)
  133214. * @param textureType Type of textures used when performing the post process. (default: 0)
  133215. * @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)
  133216. */
  133217. 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);
  133218. }
  133219. }
  133220. declare module BABYLON {
  133221. /** @hidden */
  133222. export var depthOfFieldMergePixelShader: {
  133223. name: string;
  133224. shader: string;
  133225. };
  133226. }
  133227. declare module BABYLON {
  133228. /**
  133229. * Options to be set when merging outputs from the default pipeline.
  133230. */
  133231. export class DepthOfFieldMergePostProcessOptions {
  133232. /**
  133233. * The original image to merge on top of
  133234. */
  133235. originalFromInput: PostProcess;
  133236. /**
  133237. * Parameters to perform the merge of the depth of field effect
  133238. */
  133239. depthOfField?: {
  133240. circleOfConfusion: PostProcess;
  133241. blurSteps: Array<PostProcess>;
  133242. };
  133243. /**
  133244. * Parameters to perform the merge of bloom effect
  133245. */
  133246. bloom?: {
  133247. blurred: PostProcess;
  133248. weight: number;
  133249. };
  133250. }
  133251. /**
  133252. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  133253. */
  133254. export class DepthOfFieldMergePostProcess extends PostProcess {
  133255. private blurSteps;
  133256. /**
  133257. * Creates a new instance of DepthOfFieldMergePostProcess
  133258. * @param name The name of the effect.
  133259. * @param originalFromInput Post process which's input will be used for the merge.
  133260. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  133261. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  133262. * @param options The required width/height ratio to downsize to before computing the render pass.
  133263. * @param camera The camera to apply the render pass to.
  133264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133265. * @param engine The engine which the post process will be applied. (default: current engine)
  133266. * @param reusable If the post process can be reused on the same frame. (default: false)
  133267. * @param textureType Type of textures used when performing the post process. (default: 0)
  133268. * @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)
  133269. */
  133270. 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);
  133271. /**
  133272. * Updates the effect with the current post process compile time values and recompiles the shader.
  133273. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  133274. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  133275. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  133276. * @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
  133277. * @param onCompiled Called when the shader has been compiled.
  133278. * @param onError Called if there is an error when compiling a shader.
  133279. */
  133280. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  133281. }
  133282. }
  133283. declare module BABYLON {
  133284. /**
  133285. * Specifies the level of max blur that should be applied when using the depth of field effect
  133286. */
  133287. export enum DepthOfFieldEffectBlurLevel {
  133288. /**
  133289. * Subtle blur
  133290. */
  133291. Low = 0,
  133292. /**
  133293. * Medium blur
  133294. */
  133295. Medium = 1,
  133296. /**
  133297. * Large blur
  133298. */
  133299. High = 2
  133300. }
  133301. /**
  133302. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  133303. */
  133304. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  133305. private _circleOfConfusion;
  133306. /**
  133307. * @hidden Internal, blurs from high to low
  133308. */
  133309. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  133310. private _depthOfFieldBlurY;
  133311. private _dofMerge;
  133312. /**
  133313. * @hidden Internal post processes in depth of field effect
  133314. */
  133315. _effects: Array<PostProcess>;
  133316. /**
  133317. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  133318. */
  133319. set focalLength(value: number);
  133320. get focalLength(): number;
  133321. /**
  133322. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  133323. */
  133324. set fStop(value: number);
  133325. get fStop(): number;
  133326. /**
  133327. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  133328. */
  133329. set focusDistance(value: number);
  133330. get focusDistance(): number;
  133331. /**
  133332. * 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.
  133333. */
  133334. set lensSize(value: number);
  133335. get lensSize(): number;
  133336. /**
  133337. * Creates a new instance DepthOfFieldEffect
  133338. * @param scene The scene the effect belongs to.
  133339. * @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.
  133340. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  133341. * @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)
  133342. */
  133343. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  133344. /**
  133345. * Get the current class name of the current effet
  133346. * @returns "DepthOfFieldEffect"
  133347. */
  133348. getClassName(): string;
  133349. /**
  133350. * 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.
  133351. */
  133352. set depthTexture(value: RenderTargetTexture);
  133353. /**
  133354. * Disposes each of the internal effects for a given camera.
  133355. * @param camera The camera to dispose the effect on.
  133356. */
  133357. disposeEffects(camera: Camera): void;
  133358. /**
  133359. * @hidden Internal
  133360. */
  133361. _updateEffects(): void;
  133362. /**
  133363. * Internal
  133364. * @returns if all the contained post processes are ready.
  133365. * @hidden
  133366. */
  133367. _isReady(): boolean;
  133368. }
  133369. }
  133370. declare module BABYLON {
  133371. /** @hidden */
  133372. export var displayPassPixelShader: {
  133373. name: string;
  133374. shader: string;
  133375. };
  133376. }
  133377. declare module BABYLON {
  133378. /**
  133379. * DisplayPassPostProcess which produces an output the same as it's input
  133380. */
  133381. export class DisplayPassPostProcess extends PostProcess {
  133382. /**
  133383. * Creates the DisplayPassPostProcess
  133384. * @param name The name of the effect.
  133385. * @param options The required width/height ratio to downsize to before computing the render pass.
  133386. * @param camera The camera to apply the render pass to.
  133387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133388. * @param engine The engine which the post process will be applied. (default: current engine)
  133389. * @param reusable If the post process can be reused on the same frame. (default: false)
  133390. */
  133391. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133392. }
  133393. }
  133394. declare module BABYLON {
  133395. /** @hidden */
  133396. export var filterPixelShader: {
  133397. name: string;
  133398. shader: string;
  133399. };
  133400. }
  133401. declare module BABYLON {
  133402. /**
  133403. * Applies a kernel filter to the image
  133404. */
  133405. export class FilterPostProcess extends PostProcess {
  133406. /** The matrix to be applied to the image */
  133407. kernelMatrix: Matrix;
  133408. /**
  133409. *
  133410. * @param name The name of the effect.
  133411. * @param kernelMatrix The matrix to be applied to the image
  133412. * @param options The required width/height ratio to downsize to before computing the render pass.
  133413. * @param camera The camera to apply the render pass to.
  133414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133415. * @param engine The engine which the post process will be applied. (default: current engine)
  133416. * @param reusable If the post process can be reused on the same frame. (default: false)
  133417. */
  133418. constructor(name: string,
  133419. /** The matrix to be applied to the image */
  133420. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133421. }
  133422. }
  133423. declare module BABYLON {
  133424. /** @hidden */
  133425. export var fxaaPixelShader: {
  133426. name: string;
  133427. shader: string;
  133428. };
  133429. }
  133430. declare module BABYLON {
  133431. /** @hidden */
  133432. export var fxaaVertexShader: {
  133433. name: string;
  133434. shader: string;
  133435. };
  133436. }
  133437. declare module BABYLON {
  133438. /**
  133439. * Fxaa post process
  133440. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  133441. */
  133442. export class FxaaPostProcess extends PostProcess {
  133443. /** @hidden */
  133444. texelWidth: number;
  133445. /** @hidden */
  133446. texelHeight: number;
  133447. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133448. private _getDefines;
  133449. }
  133450. }
  133451. declare module BABYLON {
  133452. /** @hidden */
  133453. export var grainPixelShader: {
  133454. name: string;
  133455. shader: string;
  133456. };
  133457. }
  133458. declare module BABYLON {
  133459. /**
  133460. * The GrainPostProcess adds noise to the image at mid luminance levels
  133461. */
  133462. export class GrainPostProcess extends PostProcess {
  133463. /**
  133464. * The intensity of the grain added (default: 30)
  133465. */
  133466. intensity: number;
  133467. /**
  133468. * If the grain should be randomized on every frame
  133469. */
  133470. animated: boolean;
  133471. /**
  133472. * Creates a new instance of @see GrainPostProcess
  133473. * @param name The name of the effect.
  133474. * @param options The required width/height ratio to downsize to before computing the render pass.
  133475. * @param camera The camera to apply the render pass to.
  133476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133477. * @param engine The engine which the post process will be applied. (default: current engine)
  133478. * @param reusable If the post process can be reused on the same frame. (default: false)
  133479. * @param textureType Type of textures used when performing the post process. (default: 0)
  133480. * @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)
  133481. */
  133482. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133483. }
  133484. }
  133485. declare module BABYLON {
  133486. /** @hidden */
  133487. export var highlightsPixelShader: {
  133488. name: string;
  133489. shader: string;
  133490. };
  133491. }
  133492. declare module BABYLON {
  133493. /**
  133494. * Extracts highlights from the image
  133495. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133496. */
  133497. export class HighlightsPostProcess extends PostProcess {
  133498. /**
  133499. * Extracts highlights from the image
  133500. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133501. * @param name The name of the effect.
  133502. * @param options The required width/height ratio to downsize to before computing the render pass.
  133503. * @param camera The camera to apply the render pass to.
  133504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133505. * @param engine The engine which the post process will be applied. (default: current engine)
  133506. * @param reusable If the post process can be reused on the same frame. (default: false)
  133507. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  133508. */
  133509. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133510. }
  133511. }
  133512. declare module BABYLON {
  133513. /** @hidden */
  133514. export var mrtFragmentDeclaration: {
  133515. name: string;
  133516. shader: string;
  133517. };
  133518. }
  133519. declare module BABYLON {
  133520. /** @hidden */
  133521. export var geometryPixelShader: {
  133522. name: string;
  133523. shader: string;
  133524. };
  133525. }
  133526. declare module BABYLON {
  133527. /** @hidden */
  133528. export var geometryVertexShader: {
  133529. name: string;
  133530. shader: string;
  133531. };
  133532. }
  133533. declare module BABYLON {
  133534. /** @hidden */
  133535. interface ISavedTransformationMatrix {
  133536. world: Matrix;
  133537. viewProjection: Matrix;
  133538. }
  133539. /**
  133540. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  133541. */
  133542. export class GeometryBufferRenderer {
  133543. /**
  133544. * Constant used to retrieve the position texture index in the G-Buffer textures array
  133545. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  133546. */
  133547. static readonly POSITION_TEXTURE_TYPE: number;
  133548. /**
  133549. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  133550. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  133551. */
  133552. static readonly VELOCITY_TEXTURE_TYPE: number;
  133553. /**
  133554. * Dictionary used to store the previous transformation matrices of each rendered mesh
  133555. * in order to compute objects velocities when enableVelocity is set to "true"
  133556. * @hidden
  133557. */
  133558. _previousTransformationMatrices: {
  133559. [index: number]: ISavedTransformationMatrix;
  133560. };
  133561. /**
  133562. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  133563. * in order to compute objects velocities when enableVelocity is set to "true"
  133564. * @hidden
  133565. */
  133566. _previousBonesTransformationMatrices: {
  133567. [index: number]: Float32Array;
  133568. };
  133569. /**
  133570. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  133571. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  133572. */
  133573. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  133574. private _scene;
  133575. private _multiRenderTarget;
  133576. private _ratio;
  133577. private _enablePosition;
  133578. private _enableVelocity;
  133579. private _positionIndex;
  133580. private _velocityIndex;
  133581. protected _effect: Effect;
  133582. protected _cachedDefines: string;
  133583. /**
  133584. * Set the render list (meshes to be rendered) used in the G buffer.
  133585. */
  133586. set renderList(meshes: Mesh[]);
  133587. /**
  133588. * Gets wether or not G buffer are supported by the running hardware.
  133589. * This requires draw buffer supports
  133590. */
  133591. get isSupported(): boolean;
  133592. /**
  133593. * Returns the index of the given texture type in the G-Buffer textures array
  133594. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  133595. * @returns the index of the given texture type in the G-Buffer textures array
  133596. */
  133597. getTextureIndex(textureType: number): number;
  133598. /**
  133599. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  133600. */
  133601. get enablePosition(): boolean;
  133602. /**
  133603. * Sets whether or not objects positions are enabled for the G buffer.
  133604. */
  133605. set enablePosition(enable: boolean);
  133606. /**
  133607. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  133608. */
  133609. get enableVelocity(): boolean;
  133610. /**
  133611. * Sets wether or not objects velocities are enabled for the G buffer.
  133612. */
  133613. set enableVelocity(enable: boolean);
  133614. /**
  133615. * Gets the scene associated with the buffer.
  133616. */
  133617. get scene(): Scene;
  133618. /**
  133619. * Gets the ratio used by the buffer during its creation.
  133620. * How big is the buffer related to the main canvas.
  133621. */
  133622. get ratio(): number;
  133623. /** @hidden */
  133624. static _SceneComponentInitialization: (scene: Scene) => void;
  133625. /**
  133626. * Creates a new G Buffer for the scene
  133627. * @param scene The scene the buffer belongs to
  133628. * @param ratio How big is the buffer related to the main canvas.
  133629. */
  133630. constructor(scene: Scene, ratio?: number);
  133631. /**
  133632. * Checks wether everything is ready to render a submesh to the G buffer.
  133633. * @param subMesh the submesh to check readiness for
  133634. * @param useInstances is the mesh drawn using instance or not
  133635. * @returns true if ready otherwise false
  133636. */
  133637. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133638. /**
  133639. * Gets the current underlying G Buffer.
  133640. * @returns the buffer
  133641. */
  133642. getGBuffer(): MultiRenderTarget;
  133643. /**
  133644. * Gets the number of samples used to render the buffer (anti aliasing).
  133645. */
  133646. get samples(): number;
  133647. /**
  133648. * Sets the number of samples used to render the buffer (anti aliasing).
  133649. */
  133650. set samples(value: number);
  133651. /**
  133652. * Disposes the renderer and frees up associated resources.
  133653. */
  133654. dispose(): void;
  133655. protected _createRenderTargets(): void;
  133656. private _copyBonesTransformationMatrices;
  133657. }
  133658. }
  133659. declare module BABYLON {
  133660. interface Scene {
  133661. /** @hidden (Backing field) */
  133662. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133663. /**
  133664. * Gets or Sets the current geometry buffer associated to the scene.
  133665. */
  133666. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133667. /**
  133668. * Enables a GeometryBufferRender and associates it with the scene
  133669. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  133670. * @returns the GeometryBufferRenderer
  133671. */
  133672. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  133673. /**
  133674. * Disables the GeometryBufferRender associated with the scene
  133675. */
  133676. disableGeometryBufferRenderer(): void;
  133677. }
  133678. /**
  133679. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  133680. * in several rendering techniques.
  133681. */
  133682. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  133683. /**
  133684. * The component name helpful to identify the component in the list of scene components.
  133685. */
  133686. readonly name: string;
  133687. /**
  133688. * The scene the component belongs to.
  133689. */
  133690. scene: Scene;
  133691. /**
  133692. * Creates a new instance of the component for the given scene
  133693. * @param scene Defines the scene to register the component in
  133694. */
  133695. constructor(scene: Scene);
  133696. /**
  133697. * Registers the component in a given scene
  133698. */
  133699. register(): void;
  133700. /**
  133701. * Rebuilds the elements related to this component in case of
  133702. * context lost for instance.
  133703. */
  133704. rebuild(): void;
  133705. /**
  133706. * Disposes the component and the associated ressources
  133707. */
  133708. dispose(): void;
  133709. private _gatherRenderTargets;
  133710. }
  133711. }
  133712. declare module BABYLON {
  133713. /** @hidden */
  133714. export var motionBlurPixelShader: {
  133715. name: string;
  133716. shader: string;
  133717. };
  133718. }
  133719. declare module BABYLON {
  133720. /**
  133721. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  133722. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  133723. * As an example, all you have to do is to create the post-process:
  133724. * var mb = new BABYLON.MotionBlurPostProcess(
  133725. * 'mb', // The name of the effect.
  133726. * scene, // The scene containing the objects to blur according to their velocity.
  133727. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  133728. * camera // The camera to apply the render pass to.
  133729. * );
  133730. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  133731. */
  133732. export class MotionBlurPostProcess extends PostProcess {
  133733. /**
  133734. * Defines how much the image is blurred by the movement. Default value is equal to 1
  133735. */
  133736. motionStrength: number;
  133737. /**
  133738. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  133739. */
  133740. get motionBlurSamples(): number;
  133741. /**
  133742. * Sets the number of iterations to be used for motion blur quality
  133743. */
  133744. set motionBlurSamples(samples: number);
  133745. private _motionBlurSamples;
  133746. private _geometryBufferRenderer;
  133747. /**
  133748. * Creates a new instance MotionBlurPostProcess
  133749. * @param name The name of the effect.
  133750. * @param scene The scene containing the objects to blur according to their velocity.
  133751. * @param options The required width/height ratio to downsize to before computing the render pass.
  133752. * @param camera The camera to apply the render pass to.
  133753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133754. * @param engine The engine which the post process will be applied. (default: current engine)
  133755. * @param reusable If the post process can be reused on the same frame. (default: false)
  133756. * @param textureType Type of textures used when performing the post process. (default: 0)
  133757. * @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)
  133758. */
  133759. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133760. /**
  133761. * Excludes the given skinned mesh from computing bones velocities.
  133762. * 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.
  133763. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  133764. */
  133765. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133766. /**
  133767. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  133768. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  133769. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  133770. */
  133771. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133772. /**
  133773. * Disposes the post process.
  133774. * @param camera The camera to dispose the post process on.
  133775. */
  133776. dispose(camera?: Camera): void;
  133777. }
  133778. }
  133779. declare module BABYLON {
  133780. /** @hidden */
  133781. export var refractionPixelShader: {
  133782. name: string;
  133783. shader: string;
  133784. };
  133785. }
  133786. declare module BABYLON {
  133787. /**
  133788. * Post process which applies a refractin texture
  133789. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133790. */
  133791. export class RefractionPostProcess extends PostProcess {
  133792. /** the base color of the refraction (used to taint the rendering) */
  133793. color: Color3;
  133794. /** simulated refraction depth */
  133795. depth: number;
  133796. /** the coefficient of the base color (0 to remove base color tainting) */
  133797. colorLevel: number;
  133798. private _refTexture;
  133799. private _ownRefractionTexture;
  133800. /**
  133801. * Gets or sets the refraction texture
  133802. * Please note that you are responsible for disposing the texture if you set it manually
  133803. */
  133804. get refractionTexture(): Texture;
  133805. set refractionTexture(value: Texture);
  133806. /**
  133807. * Initializes the RefractionPostProcess
  133808. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133809. * @param name The name of the effect.
  133810. * @param refractionTextureUrl Url of the refraction texture to use
  133811. * @param color the base color of the refraction (used to taint the rendering)
  133812. * @param depth simulated refraction depth
  133813. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  133814. * @param camera The camera to apply the render pass to.
  133815. * @param options The required width/height ratio to downsize to before computing the render pass.
  133816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133817. * @param engine The engine which the post process will be applied. (default: current engine)
  133818. * @param reusable If the post process can be reused on the same frame. (default: false)
  133819. */
  133820. constructor(name: string, refractionTextureUrl: string,
  133821. /** the base color of the refraction (used to taint the rendering) */
  133822. color: Color3,
  133823. /** simulated refraction depth */
  133824. depth: number,
  133825. /** the coefficient of the base color (0 to remove base color tainting) */
  133826. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133827. /**
  133828. * Disposes of the post process
  133829. * @param camera Camera to dispose post process on
  133830. */
  133831. dispose(camera: Camera): void;
  133832. }
  133833. }
  133834. declare module BABYLON {
  133835. /** @hidden */
  133836. export var sharpenPixelShader: {
  133837. name: string;
  133838. shader: string;
  133839. };
  133840. }
  133841. declare module BABYLON {
  133842. /**
  133843. * The SharpenPostProcess applies a sharpen kernel to every pixel
  133844. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  133845. */
  133846. export class SharpenPostProcess extends PostProcess {
  133847. /**
  133848. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  133849. */
  133850. colorAmount: number;
  133851. /**
  133852. * How much sharpness should be applied (default: 0.3)
  133853. */
  133854. edgeAmount: number;
  133855. /**
  133856. * Creates a new instance ConvolutionPostProcess
  133857. * @param name The name of the effect.
  133858. * @param options The required width/height ratio to downsize to before computing the render pass.
  133859. * @param camera The camera to apply the render pass to.
  133860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133861. * @param engine The engine which the post process will be applied. (default: current engine)
  133862. * @param reusable If the post process can be reused on the same frame. (default: false)
  133863. * @param textureType Type of textures used when performing the post process. (default: 0)
  133864. * @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)
  133865. */
  133866. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133867. }
  133868. }
  133869. declare module BABYLON {
  133870. /**
  133871. * PostProcessRenderPipeline
  133872. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133873. */
  133874. export class PostProcessRenderPipeline {
  133875. private engine;
  133876. private _renderEffects;
  133877. private _renderEffectsForIsolatedPass;
  133878. /**
  133879. * List of inspectable custom properties (used by the Inspector)
  133880. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  133881. */
  133882. inspectableCustomProperties: IInspectable[];
  133883. /**
  133884. * @hidden
  133885. */
  133886. protected _cameras: Camera[];
  133887. /** @hidden */
  133888. _name: string;
  133889. /**
  133890. * Gets pipeline name
  133891. */
  133892. get name(): string;
  133893. /** Gets the list of attached cameras */
  133894. get cameras(): Camera[];
  133895. /**
  133896. * Initializes a PostProcessRenderPipeline
  133897. * @param engine engine to add the pipeline to
  133898. * @param name name of the pipeline
  133899. */
  133900. constructor(engine: Engine, name: string);
  133901. /**
  133902. * Gets the class name
  133903. * @returns "PostProcessRenderPipeline"
  133904. */
  133905. getClassName(): string;
  133906. /**
  133907. * If all the render effects in the pipeline are supported
  133908. */
  133909. get isSupported(): boolean;
  133910. /**
  133911. * Adds an effect to the pipeline
  133912. * @param renderEffect the effect to add
  133913. */
  133914. addEffect(renderEffect: PostProcessRenderEffect): void;
  133915. /** @hidden */
  133916. _rebuild(): void;
  133917. /** @hidden */
  133918. _enableEffect(renderEffectName: string, cameras: Camera): void;
  133919. /** @hidden */
  133920. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  133921. /** @hidden */
  133922. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133923. /** @hidden */
  133924. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133925. /** @hidden */
  133926. _attachCameras(cameras: Camera, unique: boolean): void;
  133927. /** @hidden */
  133928. _attachCameras(cameras: Camera[], unique: boolean): void;
  133929. /** @hidden */
  133930. _detachCameras(cameras: Camera): void;
  133931. /** @hidden */
  133932. _detachCameras(cameras: Nullable<Camera[]>): void;
  133933. /** @hidden */
  133934. _update(): void;
  133935. /** @hidden */
  133936. _reset(): void;
  133937. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  133938. /**
  133939. * Disposes of the pipeline
  133940. */
  133941. dispose(): void;
  133942. }
  133943. }
  133944. declare module BABYLON {
  133945. /**
  133946. * PostProcessRenderPipelineManager class
  133947. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133948. */
  133949. export class PostProcessRenderPipelineManager {
  133950. private _renderPipelines;
  133951. /**
  133952. * Initializes a PostProcessRenderPipelineManager
  133953. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133954. */
  133955. constructor();
  133956. /**
  133957. * Gets the list of supported render pipelines
  133958. */
  133959. get supportedPipelines(): PostProcessRenderPipeline[];
  133960. /**
  133961. * Adds a pipeline to the manager
  133962. * @param renderPipeline The pipeline to add
  133963. */
  133964. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  133965. /**
  133966. * Attaches a camera to the pipeline
  133967. * @param renderPipelineName The name of the pipeline to attach to
  133968. * @param cameras the camera to attach
  133969. * @param unique if the camera can be attached multiple times to the pipeline
  133970. */
  133971. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  133972. /**
  133973. * Detaches a camera from the pipeline
  133974. * @param renderPipelineName The name of the pipeline to detach from
  133975. * @param cameras the camera to detach
  133976. */
  133977. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  133978. /**
  133979. * Enables an effect by name on a pipeline
  133980. * @param renderPipelineName the name of the pipeline to enable the effect in
  133981. * @param renderEffectName the name of the effect to enable
  133982. * @param cameras the cameras that the effect should be enabled on
  133983. */
  133984. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133985. /**
  133986. * Disables an effect by name on a pipeline
  133987. * @param renderPipelineName the name of the pipeline to disable the effect in
  133988. * @param renderEffectName the name of the effect to disable
  133989. * @param cameras the cameras that the effect should be disabled on
  133990. */
  133991. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133992. /**
  133993. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  133994. */
  133995. update(): void;
  133996. /** @hidden */
  133997. _rebuild(): void;
  133998. /**
  133999. * Disposes of the manager and pipelines
  134000. */
  134001. dispose(): void;
  134002. }
  134003. }
  134004. declare module BABYLON {
  134005. interface Scene {
  134006. /** @hidden (Backing field) */
  134007. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  134008. /**
  134009. * Gets the postprocess render pipeline manager
  134010. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  134011. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  134012. */
  134013. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  134014. }
  134015. /**
  134016. * Defines the Render Pipeline scene component responsible to rendering pipelines
  134017. */
  134018. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  134019. /**
  134020. * The component name helpfull to identify the component in the list of scene components.
  134021. */
  134022. readonly name: string;
  134023. /**
  134024. * The scene the component belongs to.
  134025. */
  134026. scene: Scene;
  134027. /**
  134028. * Creates a new instance of the component for the given scene
  134029. * @param scene Defines the scene to register the component in
  134030. */
  134031. constructor(scene: Scene);
  134032. /**
  134033. * Registers the component in a given scene
  134034. */
  134035. register(): void;
  134036. /**
  134037. * Rebuilds the elements related to this component in case of
  134038. * context lost for instance.
  134039. */
  134040. rebuild(): void;
  134041. /**
  134042. * Disposes the component and the associated ressources
  134043. */
  134044. dispose(): void;
  134045. private _gatherRenderTargets;
  134046. }
  134047. }
  134048. declare module BABYLON {
  134049. /**
  134050. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  134051. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  134052. */
  134053. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  134054. private _scene;
  134055. private _camerasToBeAttached;
  134056. /**
  134057. * ID of the sharpen post process,
  134058. */
  134059. private readonly SharpenPostProcessId;
  134060. /**
  134061. * @ignore
  134062. * ID of the image processing post process;
  134063. */
  134064. readonly ImageProcessingPostProcessId: string;
  134065. /**
  134066. * @ignore
  134067. * ID of the Fast Approximate Anti-Aliasing post process;
  134068. */
  134069. readonly FxaaPostProcessId: string;
  134070. /**
  134071. * ID of the chromatic aberration post process,
  134072. */
  134073. private readonly ChromaticAberrationPostProcessId;
  134074. /**
  134075. * ID of the grain post process
  134076. */
  134077. private readonly GrainPostProcessId;
  134078. /**
  134079. * Sharpen post process which will apply a sharpen convolution to enhance edges
  134080. */
  134081. sharpen: SharpenPostProcess;
  134082. private _sharpenEffect;
  134083. private bloom;
  134084. /**
  134085. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  134086. */
  134087. depthOfField: DepthOfFieldEffect;
  134088. /**
  134089. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  134090. */
  134091. fxaa: FxaaPostProcess;
  134092. /**
  134093. * Image post processing pass used to perform operations such as tone mapping or color grading.
  134094. */
  134095. imageProcessing: ImageProcessingPostProcess;
  134096. /**
  134097. * Chromatic aberration post process which will shift rgb colors in the image
  134098. */
  134099. chromaticAberration: ChromaticAberrationPostProcess;
  134100. private _chromaticAberrationEffect;
  134101. /**
  134102. * Grain post process which add noise to the image
  134103. */
  134104. grain: GrainPostProcess;
  134105. private _grainEffect;
  134106. /**
  134107. * Glow post process which adds a glow to emissive areas of the image
  134108. */
  134109. private _glowLayer;
  134110. /**
  134111. * Animations which can be used to tweak settings over a period of time
  134112. */
  134113. animations: Animation[];
  134114. private _imageProcessingConfigurationObserver;
  134115. private _sharpenEnabled;
  134116. private _bloomEnabled;
  134117. private _depthOfFieldEnabled;
  134118. private _depthOfFieldBlurLevel;
  134119. private _fxaaEnabled;
  134120. private _imageProcessingEnabled;
  134121. private _defaultPipelineTextureType;
  134122. private _bloomScale;
  134123. private _chromaticAberrationEnabled;
  134124. private _grainEnabled;
  134125. private _buildAllowed;
  134126. /**
  134127. * Gets active scene
  134128. */
  134129. get scene(): Scene;
  134130. /**
  134131. * Enable or disable the sharpen process from the pipeline
  134132. */
  134133. set sharpenEnabled(enabled: boolean);
  134134. get sharpenEnabled(): boolean;
  134135. private _resizeObserver;
  134136. private _hardwareScaleLevel;
  134137. private _bloomKernel;
  134138. /**
  134139. * Specifies the size of the bloom blur kernel, relative to the final output size
  134140. */
  134141. get bloomKernel(): number;
  134142. set bloomKernel(value: number);
  134143. /**
  134144. * Specifies the weight of the bloom in the final rendering
  134145. */
  134146. private _bloomWeight;
  134147. /**
  134148. * Specifies the luma threshold for the area that will be blurred by the bloom
  134149. */
  134150. private _bloomThreshold;
  134151. private _hdr;
  134152. /**
  134153. * The strength of the bloom.
  134154. */
  134155. set bloomWeight(value: number);
  134156. get bloomWeight(): number;
  134157. /**
  134158. * The strength of the bloom.
  134159. */
  134160. set bloomThreshold(value: number);
  134161. get bloomThreshold(): number;
  134162. /**
  134163. * The scale of the bloom, lower value will provide better performance.
  134164. */
  134165. set bloomScale(value: number);
  134166. get bloomScale(): number;
  134167. /**
  134168. * Enable or disable the bloom from the pipeline
  134169. */
  134170. set bloomEnabled(enabled: boolean);
  134171. get bloomEnabled(): boolean;
  134172. private _rebuildBloom;
  134173. /**
  134174. * If the depth of field is enabled.
  134175. */
  134176. get depthOfFieldEnabled(): boolean;
  134177. set depthOfFieldEnabled(enabled: boolean);
  134178. /**
  134179. * Blur level of the depth of field effect. (Higher blur will effect performance)
  134180. */
  134181. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  134182. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  134183. /**
  134184. * If the anti aliasing is enabled.
  134185. */
  134186. set fxaaEnabled(enabled: boolean);
  134187. get fxaaEnabled(): boolean;
  134188. private _samples;
  134189. /**
  134190. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  134191. */
  134192. set samples(sampleCount: number);
  134193. get samples(): number;
  134194. /**
  134195. * If image processing is enabled.
  134196. */
  134197. set imageProcessingEnabled(enabled: boolean);
  134198. get imageProcessingEnabled(): boolean;
  134199. /**
  134200. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  134201. */
  134202. set glowLayerEnabled(enabled: boolean);
  134203. get glowLayerEnabled(): boolean;
  134204. /**
  134205. * Gets the glow layer (or null if not defined)
  134206. */
  134207. get glowLayer(): Nullable<GlowLayer>;
  134208. /**
  134209. * Enable or disable the chromaticAberration process from the pipeline
  134210. */
  134211. set chromaticAberrationEnabled(enabled: boolean);
  134212. get chromaticAberrationEnabled(): boolean;
  134213. /**
  134214. * Enable or disable the grain process from the pipeline
  134215. */
  134216. set grainEnabled(enabled: boolean);
  134217. get grainEnabled(): boolean;
  134218. /**
  134219. * @constructor
  134220. * @param name - The rendering pipeline name (default: "")
  134221. * @param hdr - If high dynamic range textures should be used (default: true)
  134222. * @param scene - The scene linked to this pipeline (default: the last created scene)
  134223. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  134224. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  134225. */
  134226. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  134227. /**
  134228. * Get the class name
  134229. * @returns "DefaultRenderingPipeline"
  134230. */
  134231. getClassName(): string;
  134232. /**
  134233. * Force the compilation of the entire pipeline.
  134234. */
  134235. prepare(): void;
  134236. private _hasCleared;
  134237. private _prevPostProcess;
  134238. private _prevPrevPostProcess;
  134239. private _setAutoClearAndTextureSharing;
  134240. private _depthOfFieldSceneObserver;
  134241. private _buildPipeline;
  134242. private _disposePostProcesses;
  134243. /**
  134244. * Adds a camera to the pipeline
  134245. * @param camera the camera to be added
  134246. */
  134247. addCamera(camera: Camera): void;
  134248. /**
  134249. * Removes a camera from the pipeline
  134250. * @param camera the camera to remove
  134251. */
  134252. removeCamera(camera: Camera): void;
  134253. /**
  134254. * Dispose of the pipeline and stop all post processes
  134255. */
  134256. dispose(): void;
  134257. /**
  134258. * Serialize the rendering pipeline (Used when exporting)
  134259. * @returns the serialized object
  134260. */
  134261. serialize(): any;
  134262. /**
  134263. * Parse the serialized pipeline
  134264. * @param source Source pipeline.
  134265. * @param scene The scene to load the pipeline to.
  134266. * @param rootUrl The URL of the serialized pipeline.
  134267. * @returns An instantiated pipeline from the serialized object.
  134268. */
  134269. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  134270. }
  134271. }
  134272. declare module BABYLON {
  134273. /** @hidden */
  134274. export var lensHighlightsPixelShader: {
  134275. name: string;
  134276. shader: string;
  134277. };
  134278. }
  134279. declare module BABYLON {
  134280. /** @hidden */
  134281. export var depthOfFieldPixelShader: {
  134282. name: string;
  134283. shader: string;
  134284. };
  134285. }
  134286. declare module BABYLON {
  134287. /**
  134288. * BABYLON.JS Chromatic Aberration GLSL Shader
  134289. * Author: Olivier Guyot
  134290. * Separates very slightly R, G and B colors on the edges of the screen
  134291. * Inspired by Francois Tarlier & Martins Upitis
  134292. */
  134293. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  134294. /**
  134295. * @ignore
  134296. * The chromatic aberration PostProcess id in the pipeline
  134297. */
  134298. LensChromaticAberrationEffect: string;
  134299. /**
  134300. * @ignore
  134301. * The highlights enhancing PostProcess id in the pipeline
  134302. */
  134303. HighlightsEnhancingEffect: string;
  134304. /**
  134305. * @ignore
  134306. * The depth-of-field PostProcess id in the pipeline
  134307. */
  134308. LensDepthOfFieldEffect: string;
  134309. private _scene;
  134310. private _depthTexture;
  134311. private _grainTexture;
  134312. private _chromaticAberrationPostProcess;
  134313. private _highlightsPostProcess;
  134314. private _depthOfFieldPostProcess;
  134315. private _edgeBlur;
  134316. private _grainAmount;
  134317. private _chromaticAberration;
  134318. private _distortion;
  134319. private _highlightsGain;
  134320. private _highlightsThreshold;
  134321. private _dofDistance;
  134322. private _dofAperture;
  134323. private _dofDarken;
  134324. private _dofPentagon;
  134325. private _blurNoise;
  134326. /**
  134327. * @constructor
  134328. *
  134329. * Effect parameters are as follow:
  134330. * {
  134331. * chromatic_aberration: number; // from 0 to x (1 for realism)
  134332. * edge_blur: number; // from 0 to x (1 for realism)
  134333. * distortion: number; // from 0 to x (1 for realism)
  134334. * grain_amount: number; // from 0 to 1
  134335. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  134336. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  134337. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  134338. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  134339. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  134340. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  134341. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  134342. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  134343. * }
  134344. * Note: if an effect parameter is unset, effect is disabled
  134345. *
  134346. * @param name The rendering pipeline name
  134347. * @param parameters - An object containing all parameters (see above)
  134348. * @param scene The scene linked to this pipeline
  134349. * @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)
  134350. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134351. */
  134352. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  134353. /**
  134354. * Get the class name
  134355. * @returns "LensRenderingPipeline"
  134356. */
  134357. getClassName(): string;
  134358. /**
  134359. * Gets associated scene
  134360. */
  134361. get scene(): Scene;
  134362. /**
  134363. * Gets or sets the edge blur
  134364. */
  134365. get edgeBlur(): number;
  134366. set edgeBlur(value: number);
  134367. /**
  134368. * Gets or sets the grain amount
  134369. */
  134370. get grainAmount(): number;
  134371. set grainAmount(value: number);
  134372. /**
  134373. * Gets or sets the chromatic aberration amount
  134374. */
  134375. get chromaticAberration(): number;
  134376. set chromaticAberration(value: number);
  134377. /**
  134378. * Gets or sets the depth of field aperture
  134379. */
  134380. get dofAperture(): number;
  134381. set dofAperture(value: number);
  134382. /**
  134383. * Gets or sets the edge distortion
  134384. */
  134385. get edgeDistortion(): number;
  134386. set edgeDistortion(value: number);
  134387. /**
  134388. * Gets or sets the depth of field distortion
  134389. */
  134390. get dofDistortion(): number;
  134391. set dofDistortion(value: number);
  134392. /**
  134393. * Gets or sets the darken out of focus amount
  134394. */
  134395. get darkenOutOfFocus(): number;
  134396. set darkenOutOfFocus(value: number);
  134397. /**
  134398. * Gets or sets a boolean indicating if blur noise is enabled
  134399. */
  134400. get blurNoise(): boolean;
  134401. set blurNoise(value: boolean);
  134402. /**
  134403. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  134404. */
  134405. get pentagonBokeh(): boolean;
  134406. set pentagonBokeh(value: boolean);
  134407. /**
  134408. * Gets or sets the highlight grain amount
  134409. */
  134410. get highlightsGain(): number;
  134411. set highlightsGain(value: number);
  134412. /**
  134413. * Gets or sets the highlight threshold
  134414. */
  134415. get highlightsThreshold(): number;
  134416. set highlightsThreshold(value: number);
  134417. /**
  134418. * Sets the amount of blur at the edges
  134419. * @param amount blur amount
  134420. */
  134421. setEdgeBlur(amount: number): void;
  134422. /**
  134423. * Sets edge blur to 0
  134424. */
  134425. disableEdgeBlur(): void;
  134426. /**
  134427. * Sets the amout of grain
  134428. * @param amount Amount of grain
  134429. */
  134430. setGrainAmount(amount: number): void;
  134431. /**
  134432. * Set grain amount to 0
  134433. */
  134434. disableGrain(): void;
  134435. /**
  134436. * Sets the chromatic aberration amount
  134437. * @param amount amount of chromatic aberration
  134438. */
  134439. setChromaticAberration(amount: number): void;
  134440. /**
  134441. * Sets chromatic aberration amount to 0
  134442. */
  134443. disableChromaticAberration(): void;
  134444. /**
  134445. * Sets the EdgeDistortion amount
  134446. * @param amount amount of EdgeDistortion
  134447. */
  134448. setEdgeDistortion(amount: number): void;
  134449. /**
  134450. * Sets edge distortion to 0
  134451. */
  134452. disableEdgeDistortion(): void;
  134453. /**
  134454. * Sets the FocusDistance amount
  134455. * @param amount amount of FocusDistance
  134456. */
  134457. setFocusDistance(amount: number): void;
  134458. /**
  134459. * Disables depth of field
  134460. */
  134461. disableDepthOfField(): void;
  134462. /**
  134463. * Sets the Aperture amount
  134464. * @param amount amount of Aperture
  134465. */
  134466. setAperture(amount: number): void;
  134467. /**
  134468. * Sets the DarkenOutOfFocus amount
  134469. * @param amount amount of DarkenOutOfFocus
  134470. */
  134471. setDarkenOutOfFocus(amount: number): void;
  134472. private _pentagonBokehIsEnabled;
  134473. /**
  134474. * Creates a pentagon bokeh effect
  134475. */
  134476. enablePentagonBokeh(): void;
  134477. /**
  134478. * Disables the pentagon bokeh effect
  134479. */
  134480. disablePentagonBokeh(): void;
  134481. /**
  134482. * Enables noise blur
  134483. */
  134484. enableNoiseBlur(): void;
  134485. /**
  134486. * Disables noise blur
  134487. */
  134488. disableNoiseBlur(): void;
  134489. /**
  134490. * Sets the HighlightsGain amount
  134491. * @param amount amount of HighlightsGain
  134492. */
  134493. setHighlightsGain(amount: number): void;
  134494. /**
  134495. * Sets the HighlightsThreshold amount
  134496. * @param amount amount of HighlightsThreshold
  134497. */
  134498. setHighlightsThreshold(amount: number): void;
  134499. /**
  134500. * Disables highlights
  134501. */
  134502. disableHighlights(): void;
  134503. /**
  134504. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  134505. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  134506. */
  134507. dispose(disableDepthRender?: boolean): void;
  134508. private _createChromaticAberrationPostProcess;
  134509. private _createHighlightsPostProcess;
  134510. private _createDepthOfFieldPostProcess;
  134511. private _createGrainTexture;
  134512. }
  134513. }
  134514. declare module BABYLON {
  134515. /** @hidden */
  134516. export var ssao2PixelShader: {
  134517. name: string;
  134518. shader: string;
  134519. };
  134520. }
  134521. declare module BABYLON {
  134522. /** @hidden */
  134523. export var ssaoCombinePixelShader: {
  134524. name: string;
  134525. shader: string;
  134526. };
  134527. }
  134528. declare module BABYLON {
  134529. /**
  134530. * Render pipeline to produce ssao effect
  134531. */
  134532. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  134533. /**
  134534. * @ignore
  134535. * The PassPostProcess id in the pipeline that contains the original scene color
  134536. */
  134537. SSAOOriginalSceneColorEffect: string;
  134538. /**
  134539. * @ignore
  134540. * The SSAO PostProcess id in the pipeline
  134541. */
  134542. SSAORenderEffect: string;
  134543. /**
  134544. * @ignore
  134545. * The horizontal blur PostProcess id in the pipeline
  134546. */
  134547. SSAOBlurHRenderEffect: string;
  134548. /**
  134549. * @ignore
  134550. * The vertical blur PostProcess id in the pipeline
  134551. */
  134552. SSAOBlurVRenderEffect: string;
  134553. /**
  134554. * @ignore
  134555. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134556. */
  134557. SSAOCombineRenderEffect: string;
  134558. /**
  134559. * The output strength of the SSAO post-process. Default value is 1.0.
  134560. */
  134561. totalStrength: number;
  134562. /**
  134563. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  134564. */
  134565. maxZ: number;
  134566. /**
  134567. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  134568. */
  134569. minZAspect: number;
  134570. private _samples;
  134571. /**
  134572. * Number of samples used for the SSAO calculations. Default value is 8
  134573. */
  134574. set samples(n: number);
  134575. get samples(): number;
  134576. private _textureSamples;
  134577. /**
  134578. * Number of samples to use for antialiasing
  134579. */
  134580. set textureSamples(n: number);
  134581. get textureSamples(): number;
  134582. /**
  134583. * Ratio object used for SSAO ratio and blur ratio
  134584. */
  134585. private _ratio;
  134586. /**
  134587. * Dynamically generated sphere sampler.
  134588. */
  134589. private _sampleSphere;
  134590. /**
  134591. * Blur filter offsets
  134592. */
  134593. private _samplerOffsets;
  134594. private _expensiveBlur;
  134595. /**
  134596. * If bilateral blur should be used
  134597. */
  134598. set expensiveBlur(b: boolean);
  134599. get expensiveBlur(): boolean;
  134600. /**
  134601. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  134602. */
  134603. radius: number;
  134604. /**
  134605. * The base color of the SSAO post-process
  134606. * The final result is "base + ssao" between [0, 1]
  134607. */
  134608. base: number;
  134609. /**
  134610. * Support test.
  134611. */
  134612. static get IsSupported(): boolean;
  134613. private _scene;
  134614. private _depthTexture;
  134615. private _normalTexture;
  134616. private _randomTexture;
  134617. private _originalColorPostProcess;
  134618. private _ssaoPostProcess;
  134619. private _blurHPostProcess;
  134620. private _blurVPostProcess;
  134621. private _ssaoCombinePostProcess;
  134622. /**
  134623. * Gets active scene
  134624. */
  134625. get scene(): Scene;
  134626. /**
  134627. * @constructor
  134628. * @param name The rendering pipeline name
  134629. * @param scene The scene linked to this pipeline
  134630. * @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 }
  134631. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134632. */
  134633. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134634. /**
  134635. * Get the class name
  134636. * @returns "SSAO2RenderingPipeline"
  134637. */
  134638. getClassName(): string;
  134639. /**
  134640. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134641. */
  134642. dispose(disableGeometryBufferRenderer?: boolean): void;
  134643. private _createBlurPostProcess;
  134644. /** @hidden */
  134645. _rebuild(): void;
  134646. private _bits;
  134647. private _radicalInverse_VdC;
  134648. private _hammersley;
  134649. private _hemisphereSample_uniform;
  134650. private _generateHemisphere;
  134651. private _createSSAOPostProcess;
  134652. private _createSSAOCombinePostProcess;
  134653. private _createRandomTexture;
  134654. /**
  134655. * Serialize the rendering pipeline (Used when exporting)
  134656. * @returns the serialized object
  134657. */
  134658. serialize(): any;
  134659. /**
  134660. * Parse the serialized pipeline
  134661. * @param source Source pipeline.
  134662. * @param scene The scene to load the pipeline to.
  134663. * @param rootUrl The URL of the serialized pipeline.
  134664. * @returns An instantiated pipeline from the serialized object.
  134665. */
  134666. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  134667. }
  134668. }
  134669. declare module BABYLON {
  134670. /** @hidden */
  134671. export var ssaoPixelShader: {
  134672. name: string;
  134673. shader: string;
  134674. };
  134675. }
  134676. declare module BABYLON {
  134677. /**
  134678. * Render pipeline to produce ssao effect
  134679. */
  134680. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  134681. /**
  134682. * @ignore
  134683. * The PassPostProcess id in the pipeline that contains the original scene color
  134684. */
  134685. SSAOOriginalSceneColorEffect: string;
  134686. /**
  134687. * @ignore
  134688. * The SSAO PostProcess id in the pipeline
  134689. */
  134690. SSAORenderEffect: string;
  134691. /**
  134692. * @ignore
  134693. * The horizontal blur PostProcess id in the pipeline
  134694. */
  134695. SSAOBlurHRenderEffect: string;
  134696. /**
  134697. * @ignore
  134698. * The vertical blur PostProcess id in the pipeline
  134699. */
  134700. SSAOBlurVRenderEffect: string;
  134701. /**
  134702. * @ignore
  134703. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134704. */
  134705. SSAOCombineRenderEffect: string;
  134706. /**
  134707. * The output strength of the SSAO post-process. Default value is 1.0.
  134708. */
  134709. totalStrength: number;
  134710. /**
  134711. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  134712. */
  134713. radius: number;
  134714. /**
  134715. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  134716. * Must not be equal to fallOff and superior to fallOff.
  134717. * Default value is 0.0075
  134718. */
  134719. area: number;
  134720. /**
  134721. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  134722. * Must not be equal to area and inferior to area.
  134723. * Default value is 0.000001
  134724. */
  134725. fallOff: number;
  134726. /**
  134727. * The base color of the SSAO post-process
  134728. * The final result is "base + ssao" between [0, 1]
  134729. */
  134730. base: number;
  134731. private _scene;
  134732. private _depthTexture;
  134733. private _randomTexture;
  134734. private _originalColorPostProcess;
  134735. private _ssaoPostProcess;
  134736. private _blurHPostProcess;
  134737. private _blurVPostProcess;
  134738. private _ssaoCombinePostProcess;
  134739. private _firstUpdate;
  134740. /**
  134741. * Gets active scene
  134742. */
  134743. get scene(): Scene;
  134744. /**
  134745. * @constructor
  134746. * @param name - The rendering pipeline name
  134747. * @param scene - The scene linked to this pipeline
  134748. * @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 }
  134749. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  134750. */
  134751. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134752. /**
  134753. * Get the class name
  134754. * @returns "SSAORenderingPipeline"
  134755. */
  134756. getClassName(): string;
  134757. /**
  134758. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134759. */
  134760. dispose(disableDepthRender?: boolean): void;
  134761. private _createBlurPostProcess;
  134762. /** @hidden */
  134763. _rebuild(): void;
  134764. private _createSSAOPostProcess;
  134765. private _createSSAOCombinePostProcess;
  134766. private _createRandomTexture;
  134767. }
  134768. }
  134769. declare module BABYLON {
  134770. /** @hidden */
  134771. export var standardPixelShader: {
  134772. name: string;
  134773. shader: string;
  134774. };
  134775. }
  134776. declare module BABYLON {
  134777. /**
  134778. * Standard rendering pipeline
  134779. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  134780. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  134781. */
  134782. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  134783. /**
  134784. * Public members
  134785. */
  134786. /**
  134787. * Post-process which contains the original scene color before the pipeline applies all the effects
  134788. */
  134789. originalPostProcess: Nullable<PostProcess>;
  134790. /**
  134791. * Post-process used to down scale an image x4
  134792. */
  134793. downSampleX4PostProcess: Nullable<PostProcess>;
  134794. /**
  134795. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  134796. */
  134797. brightPassPostProcess: Nullable<PostProcess>;
  134798. /**
  134799. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  134800. */
  134801. blurHPostProcesses: PostProcess[];
  134802. /**
  134803. * Post-process array storing all the vertical blur post-processes used by the pipeline
  134804. */
  134805. blurVPostProcesses: PostProcess[];
  134806. /**
  134807. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  134808. */
  134809. textureAdderPostProcess: Nullable<PostProcess>;
  134810. /**
  134811. * Post-process used to create volumetric lighting effect
  134812. */
  134813. volumetricLightPostProcess: Nullable<PostProcess>;
  134814. /**
  134815. * Post-process used to smooth the previous volumetric light post-process on the X axis
  134816. */
  134817. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  134818. /**
  134819. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  134820. */
  134821. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  134822. /**
  134823. * Post-process used to merge the volumetric light effect and the real scene color
  134824. */
  134825. volumetricLightMergePostProces: Nullable<PostProcess>;
  134826. /**
  134827. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  134828. */
  134829. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  134830. /**
  134831. * Base post-process used to calculate the average luminance of the final image for HDR
  134832. */
  134833. luminancePostProcess: Nullable<PostProcess>;
  134834. /**
  134835. * Post-processes used to create down sample post-processes in order to get
  134836. * the average luminance of the final image for HDR
  134837. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  134838. */
  134839. luminanceDownSamplePostProcesses: PostProcess[];
  134840. /**
  134841. * Post-process used to create a HDR effect (light adaptation)
  134842. */
  134843. hdrPostProcess: Nullable<PostProcess>;
  134844. /**
  134845. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  134846. */
  134847. textureAdderFinalPostProcess: Nullable<PostProcess>;
  134848. /**
  134849. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  134850. */
  134851. lensFlareFinalPostProcess: Nullable<PostProcess>;
  134852. /**
  134853. * Post-process used to merge the final HDR post-process and the real scene color
  134854. */
  134855. hdrFinalPostProcess: Nullable<PostProcess>;
  134856. /**
  134857. * Post-process used to create a lens flare effect
  134858. */
  134859. lensFlarePostProcess: Nullable<PostProcess>;
  134860. /**
  134861. * Post-process that merges the result of the lens flare post-process and the real scene color
  134862. */
  134863. lensFlareComposePostProcess: Nullable<PostProcess>;
  134864. /**
  134865. * Post-process used to create a motion blur effect
  134866. */
  134867. motionBlurPostProcess: Nullable<PostProcess>;
  134868. /**
  134869. * Post-process used to create a depth of field effect
  134870. */
  134871. depthOfFieldPostProcess: Nullable<PostProcess>;
  134872. /**
  134873. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  134874. */
  134875. fxaaPostProcess: Nullable<FxaaPostProcess>;
  134876. /**
  134877. * Represents the brightness threshold in order to configure the illuminated surfaces
  134878. */
  134879. brightThreshold: number;
  134880. /**
  134881. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  134882. */
  134883. blurWidth: number;
  134884. /**
  134885. * Sets if the blur for highlighted surfaces must be only horizontal
  134886. */
  134887. horizontalBlur: boolean;
  134888. /**
  134889. * Gets the overall exposure used by the pipeline
  134890. */
  134891. get exposure(): number;
  134892. /**
  134893. * Sets the overall exposure used by the pipeline
  134894. */
  134895. set exposure(value: number);
  134896. /**
  134897. * Texture used typically to simulate "dirty" on camera lens
  134898. */
  134899. lensTexture: Nullable<Texture>;
  134900. /**
  134901. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  134902. */
  134903. volumetricLightCoefficient: number;
  134904. /**
  134905. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  134906. */
  134907. volumetricLightPower: number;
  134908. /**
  134909. * Used the set the blur intensity to smooth the volumetric lights
  134910. */
  134911. volumetricLightBlurScale: number;
  134912. /**
  134913. * Light (spot or directional) used to generate the volumetric lights rays
  134914. * The source light must have a shadow generate so the pipeline can get its
  134915. * depth map
  134916. */
  134917. sourceLight: Nullable<SpotLight | DirectionalLight>;
  134918. /**
  134919. * For eye adaptation, represents the minimum luminance the eye can see
  134920. */
  134921. hdrMinimumLuminance: number;
  134922. /**
  134923. * For eye adaptation, represents the decrease luminance speed
  134924. */
  134925. hdrDecreaseRate: number;
  134926. /**
  134927. * For eye adaptation, represents the increase luminance speed
  134928. */
  134929. hdrIncreaseRate: number;
  134930. /**
  134931. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134932. */
  134933. get hdrAutoExposure(): boolean;
  134934. /**
  134935. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134936. */
  134937. set hdrAutoExposure(value: boolean);
  134938. /**
  134939. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  134940. */
  134941. lensColorTexture: Nullable<Texture>;
  134942. /**
  134943. * The overall strengh for the lens flare effect
  134944. */
  134945. lensFlareStrength: number;
  134946. /**
  134947. * Dispersion coefficient for lens flare ghosts
  134948. */
  134949. lensFlareGhostDispersal: number;
  134950. /**
  134951. * Main lens flare halo width
  134952. */
  134953. lensFlareHaloWidth: number;
  134954. /**
  134955. * Based on the lens distortion effect, defines how much the lens flare result
  134956. * is distorted
  134957. */
  134958. lensFlareDistortionStrength: number;
  134959. /**
  134960. * Configures the blur intensity used for for lens flare (halo)
  134961. */
  134962. lensFlareBlurWidth: number;
  134963. /**
  134964. * Lens star texture must be used to simulate rays on the flares and is available
  134965. * in the documentation
  134966. */
  134967. lensStarTexture: Nullable<Texture>;
  134968. /**
  134969. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  134970. * flare effect by taking account of the dirt texture
  134971. */
  134972. lensFlareDirtTexture: Nullable<Texture>;
  134973. /**
  134974. * Represents the focal length for the depth of field effect
  134975. */
  134976. depthOfFieldDistance: number;
  134977. /**
  134978. * Represents the blur intensity for the blurred part of the depth of field effect
  134979. */
  134980. depthOfFieldBlurWidth: number;
  134981. /**
  134982. * Gets how much the image is blurred by the movement while using the motion blur post-process
  134983. */
  134984. get motionStrength(): number;
  134985. /**
  134986. * Sets how much the image is blurred by the movement while using the motion blur post-process
  134987. */
  134988. set motionStrength(strength: number);
  134989. /**
  134990. * Gets wether or not the motion blur post-process is object based or screen based.
  134991. */
  134992. get objectBasedMotionBlur(): boolean;
  134993. /**
  134994. * Sets wether or not the motion blur post-process should be object based or screen based
  134995. */
  134996. set objectBasedMotionBlur(value: boolean);
  134997. /**
  134998. * List of animations for the pipeline (IAnimatable implementation)
  134999. */
  135000. animations: Animation[];
  135001. /**
  135002. * Private members
  135003. */
  135004. private _scene;
  135005. private _currentDepthOfFieldSource;
  135006. private _basePostProcess;
  135007. private _fixedExposure;
  135008. private _currentExposure;
  135009. private _hdrAutoExposure;
  135010. private _hdrCurrentLuminance;
  135011. private _motionStrength;
  135012. private _isObjectBasedMotionBlur;
  135013. private _floatTextureType;
  135014. private _camerasToBeAttached;
  135015. private _ratio;
  135016. private _bloomEnabled;
  135017. private _depthOfFieldEnabled;
  135018. private _vlsEnabled;
  135019. private _lensFlareEnabled;
  135020. private _hdrEnabled;
  135021. private _motionBlurEnabled;
  135022. private _fxaaEnabled;
  135023. private _motionBlurSamples;
  135024. private _volumetricLightStepsCount;
  135025. private _samples;
  135026. /**
  135027. * @ignore
  135028. * Specifies if the bloom pipeline is enabled
  135029. */
  135030. get BloomEnabled(): boolean;
  135031. set BloomEnabled(enabled: boolean);
  135032. /**
  135033. * @ignore
  135034. * Specifies if the depth of field pipeline is enabed
  135035. */
  135036. get DepthOfFieldEnabled(): boolean;
  135037. set DepthOfFieldEnabled(enabled: boolean);
  135038. /**
  135039. * @ignore
  135040. * Specifies if the lens flare pipeline is enabed
  135041. */
  135042. get LensFlareEnabled(): boolean;
  135043. set LensFlareEnabled(enabled: boolean);
  135044. /**
  135045. * @ignore
  135046. * Specifies if the HDR pipeline is enabled
  135047. */
  135048. get HDREnabled(): boolean;
  135049. set HDREnabled(enabled: boolean);
  135050. /**
  135051. * @ignore
  135052. * Specifies if the volumetric lights scattering effect is enabled
  135053. */
  135054. get VLSEnabled(): boolean;
  135055. set VLSEnabled(enabled: boolean);
  135056. /**
  135057. * @ignore
  135058. * Specifies if the motion blur effect is enabled
  135059. */
  135060. get MotionBlurEnabled(): boolean;
  135061. set MotionBlurEnabled(enabled: boolean);
  135062. /**
  135063. * Specifies if anti-aliasing is enabled
  135064. */
  135065. get fxaaEnabled(): boolean;
  135066. set fxaaEnabled(enabled: boolean);
  135067. /**
  135068. * Specifies the number of steps used to calculate the volumetric lights
  135069. * Typically in interval [50, 200]
  135070. */
  135071. get volumetricLightStepsCount(): number;
  135072. set volumetricLightStepsCount(count: number);
  135073. /**
  135074. * Specifies the number of samples used for the motion blur effect
  135075. * Typically in interval [16, 64]
  135076. */
  135077. get motionBlurSamples(): number;
  135078. set motionBlurSamples(samples: number);
  135079. /**
  135080. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  135081. */
  135082. get samples(): number;
  135083. set samples(sampleCount: number);
  135084. /**
  135085. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  135086. * @constructor
  135087. * @param name The rendering pipeline name
  135088. * @param scene The scene linked to this pipeline
  135089. * @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)
  135090. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  135091. * @param cameras The array of cameras that the rendering pipeline will be attached to
  135092. */
  135093. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  135094. private _buildPipeline;
  135095. private _createDownSampleX4PostProcess;
  135096. private _createBrightPassPostProcess;
  135097. private _createBlurPostProcesses;
  135098. private _createTextureAdderPostProcess;
  135099. private _createVolumetricLightPostProcess;
  135100. private _createLuminancePostProcesses;
  135101. private _createHdrPostProcess;
  135102. private _createLensFlarePostProcess;
  135103. private _createDepthOfFieldPostProcess;
  135104. private _createMotionBlurPostProcess;
  135105. private _getDepthTexture;
  135106. private _disposePostProcesses;
  135107. /**
  135108. * Dispose of the pipeline and stop all post processes
  135109. */
  135110. dispose(): void;
  135111. /**
  135112. * Serialize the rendering pipeline (Used when exporting)
  135113. * @returns the serialized object
  135114. */
  135115. serialize(): any;
  135116. /**
  135117. * Parse the serialized pipeline
  135118. * @param source Source pipeline.
  135119. * @param scene The scene to load the pipeline to.
  135120. * @param rootUrl The URL of the serialized pipeline.
  135121. * @returns An instantiated pipeline from the serialized object.
  135122. */
  135123. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  135124. /**
  135125. * Luminance steps
  135126. */
  135127. static LuminanceSteps: number;
  135128. }
  135129. }
  135130. declare module BABYLON {
  135131. /** @hidden */
  135132. export var tonemapPixelShader: {
  135133. name: string;
  135134. shader: string;
  135135. };
  135136. }
  135137. declare module BABYLON {
  135138. /** Defines operator used for tonemapping */
  135139. export enum TonemappingOperator {
  135140. /** Hable */
  135141. Hable = 0,
  135142. /** Reinhard */
  135143. Reinhard = 1,
  135144. /** HejiDawson */
  135145. HejiDawson = 2,
  135146. /** Photographic */
  135147. Photographic = 3
  135148. }
  135149. /**
  135150. * Defines a post process to apply tone mapping
  135151. */
  135152. export class TonemapPostProcess extends PostProcess {
  135153. private _operator;
  135154. /** Defines the required exposure adjustement */
  135155. exposureAdjustment: number;
  135156. /**
  135157. * Creates a new TonemapPostProcess
  135158. * @param name defines the name of the postprocess
  135159. * @param _operator defines the operator to use
  135160. * @param exposureAdjustment defines the required exposure adjustement
  135161. * @param camera defines the camera to use (can be null)
  135162. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  135163. * @param engine defines the hosting engine (can be ignore if camera is set)
  135164. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  135165. */
  135166. constructor(name: string, _operator: TonemappingOperator,
  135167. /** Defines the required exposure adjustement */
  135168. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  135169. }
  135170. }
  135171. declare module BABYLON {
  135172. /** @hidden */
  135173. export var depthVertexShader: {
  135174. name: string;
  135175. shader: string;
  135176. };
  135177. }
  135178. declare module BABYLON {
  135179. /** @hidden */
  135180. export var volumetricLightScatteringPixelShader: {
  135181. name: string;
  135182. shader: string;
  135183. };
  135184. }
  135185. declare module BABYLON {
  135186. /** @hidden */
  135187. export var volumetricLightScatteringPassVertexShader: {
  135188. name: string;
  135189. shader: string;
  135190. };
  135191. }
  135192. declare module BABYLON {
  135193. /** @hidden */
  135194. export var volumetricLightScatteringPassPixelShader: {
  135195. name: string;
  135196. shader: string;
  135197. };
  135198. }
  135199. declare module BABYLON {
  135200. /**
  135201. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  135202. */
  135203. export class VolumetricLightScatteringPostProcess extends PostProcess {
  135204. private _volumetricLightScatteringPass;
  135205. private _volumetricLightScatteringRTT;
  135206. private _viewPort;
  135207. private _screenCoordinates;
  135208. private _cachedDefines;
  135209. /**
  135210. * If not undefined, the mesh position is computed from the attached node position
  135211. */
  135212. attachedNode: {
  135213. position: Vector3;
  135214. };
  135215. /**
  135216. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  135217. */
  135218. customMeshPosition: Vector3;
  135219. /**
  135220. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  135221. */
  135222. useCustomMeshPosition: boolean;
  135223. /**
  135224. * If the post-process should inverse the light scattering direction
  135225. */
  135226. invert: boolean;
  135227. /**
  135228. * The internal mesh used by the post-process
  135229. */
  135230. mesh: Mesh;
  135231. /**
  135232. * @hidden
  135233. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  135234. */
  135235. get useDiffuseColor(): boolean;
  135236. set useDiffuseColor(useDiffuseColor: boolean);
  135237. /**
  135238. * Array containing the excluded meshes not rendered in the internal pass
  135239. */
  135240. excludedMeshes: AbstractMesh[];
  135241. /**
  135242. * Controls the overall intensity of the post-process
  135243. */
  135244. exposure: number;
  135245. /**
  135246. * Dissipates each sample's contribution in range [0, 1]
  135247. */
  135248. decay: number;
  135249. /**
  135250. * Controls the overall intensity of each sample
  135251. */
  135252. weight: number;
  135253. /**
  135254. * Controls the density of each sample
  135255. */
  135256. density: number;
  135257. /**
  135258. * @constructor
  135259. * @param name The post-process name
  135260. * @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)
  135261. * @param camera The camera that the post-process will be attached to
  135262. * @param mesh The mesh used to create the light scattering
  135263. * @param samples The post-process quality, default 100
  135264. * @param samplingModeThe post-process filtering mode
  135265. * @param engine The babylon engine
  135266. * @param reusable If the post-process is reusable
  135267. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  135268. */
  135269. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  135270. /**
  135271. * Returns the string "VolumetricLightScatteringPostProcess"
  135272. * @returns "VolumetricLightScatteringPostProcess"
  135273. */
  135274. getClassName(): string;
  135275. private _isReady;
  135276. /**
  135277. * Sets the new light position for light scattering effect
  135278. * @param position The new custom light position
  135279. */
  135280. setCustomMeshPosition(position: Vector3): void;
  135281. /**
  135282. * Returns the light position for light scattering effect
  135283. * @return Vector3 The custom light position
  135284. */
  135285. getCustomMeshPosition(): Vector3;
  135286. /**
  135287. * Disposes the internal assets and detaches the post-process from the camera
  135288. */
  135289. dispose(camera: Camera): void;
  135290. /**
  135291. * Returns the render target texture used by the post-process
  135292. * @return the render target texture used by the post-process
  135293. */
  135294. getPass(): RenderTargetTexture;
  135295. private _meshExcluded;
  135296. private _createPass;
  135297. private _updateMeshScreenCoordinates;
  135298. /**
  135299. * Creates a default mesh for the Volumeric Light Scattering post-process
  135300. * @param name The mesh name
  135301. * @param scene The scene where to create the mesh
  135302. * @return the default mesh
  135303. */
  135304. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  135305. }
  135306. }
  135307. declare module BABYLON {
  135308. interface Scene {
  135309. /** @hidden (Backing field) */
  135310. _boundingBoxRenderer: BoundingBoxRenderer;
  135311. /** @hidden (Backing field) */
  135312. _forceShowBoundingBoxes: boolean;
  135313. /**
  135314. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  135315. */
  135316. forceShowBoundingBoxes: boolean;
  135317. /**
  135318. * Gets the bounding box renderer associated with the scene
  135319. * @returns a BoundingBoxRenderer
  135320. */
  135321. getBoundingBoxRenderer(): BoundingBoxRenderer;
  135322. }
  135323. interface AbstractMesh {
  135324. /** @hidden (Backing field) */
  135325. _showBoundingBox: boolean;
  135326. /**
  135327. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  135328. */
  135329. showBoundingBox: boolean;
  135330. }
  135331. /**
  135332. * Component responsible of rendering the bounding box of the meshes in a scene.
  135333. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  135334. */
  135335. export class BoundingBoxRenderer implements ISceneComponent {
  135336. /**
  135337. * The component name helpfull to identify the component in the list of scene components.
  135338. */
  135339. readonly name: string;
  135340. /**
  135341. * The scene the component belongs to.
  135342. */
  135343. scene: Scene;
  135344. /**
  135345. * Color of the bounding box lines placed in front of an object
  135346. */
  135347. frontColor: Color3;
  135348. /**
  135349. * Color of the bounding box lines placed behind an object
  135350. */
  135351. backColor: Color3;
  135352. /**
  135353. * Defines if the renderer should show the back lines or not
  135354. */
  135355. showBackLines: boolean;
  135356. /**
  135357. * @hidden
  135358. */
  135359. renderList: SmartArray<BoundingBox>;
  135360. private _colorShader;
  135361. private _vertexBuffers;
  135362. private _indexBuffer;
  135363. private _fillIndexBuffer;
  135364. private _fillIndexData;
  135365. /**
  135366. * Instantiates a new bounding box renderer in a scene.
  135367. * @param scene the scene the renderer renders in
  135368. */
  135369. constructor(scene: Scene);
  135370. /**
  135371. * Registers the component in a given scene
  135372. */
  135373. register(): void;
  135374. private _evaluateSubMesh;
  135375. private _activeMesh;
  135376. private _prepareRessources;
  135377. private _createIndexBuffer;
  135378. /**
  135379. * Rebuilds the elements related to this component in case of
  135380. * context lost for instance.
  135381. */
  135382. rebuild(): void;
  135383. /**
  135384. * @hidden
  135385. */
  135386. reset(): void;
  135387. /**
  135388. * Render the bounding boxes of a specific rendering group
  135389. * @param renderingGroupId defines the rendering group to render
  135390. */
  135391. render(renderingGroupId: number): void;
  135392. /**
  135393. * In case of occlusion queries, we can render the occlusion bounding box through this method
  135394. * @param mesh Define the mesh to render the occlusion bounding box for
  135395. */
  135396. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  135397. /**
  135398. * Dispose and release the resources attached to this renderer.
  135399. */
  135400. dispose(): void;
  135401. }
  135402. }
  135403. declare module BABYLON {
  135404. /** @hidden */
  135405. export var depthPixelShader: {
  135406. name: string;
  135407. shader: string;
  135408. };
  135409. }
  135410. declare module BABYLON {
  135411. /**
  135412. * This represents a depth renderer in Babylon.
  135413. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135414. */
  135415. export class DepthRenderer {
  135416. private _scene;
  135417. private _depthMap;
  135418. private _effect;
  135419. private readonly _storeNonLinearDepth;
  135420. private readonly _clearColor;
  135421. /** Get if the depth renderer is using packed depth or not */
  135422. readonly isPacked: boolean;
  135423. private _cachedDefines;
  135424. private _camera;
  135425. /**
  135426. * Specifiess that the depth renderer will only be used within
  135427. * the camera it is created for.
  135428. * This can help forcing its rendering during the camera processing.
  135429. */
  135430. useOnlyInActiveCamera: boolean;
  135431. /** @hidden */
  135432. static _SceneComponentInitialization: (scene: Scene) => void;
  135433. /**
  135434. * Instantiates a depth renderer
  135435. * @param scene The scene the renderer belongs to
  135436. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135437. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135438. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135439. */
  135440. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135441. /**
  135442. * Creates the depth rendering effect and checks if the effect is ready.
  135443. * @param subMesh The submesh to be used to render the depth map of
  135444. * @param useInstances If multiple world instances should be used
  135445. * @returns if the depth renderer is ready to render the depth map
  135446. */
  135447. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135448. /**
  135449. * Gets the texture which the depth map will be written to.
  135450. * @returns The depth map texture
  135451. */
  135452. getDepthMap(): RenderTargetTexture;
  135453. /**
  135454. * Disposes of the depth renderer.
  135455. */
  135456. dispose(): void;
  135457. }
  135458. }
  135459. declare module BABYLON {
  135460. interface Scene {
  135461. /** @hidden (Backing field) */
  135462. _depthRenderer: {
  135463. [id: string]: DepthRenderer;
  135464. };
  135465. /**
  135466. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  135467. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  135468. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135469. * @returns the created depth renderer
  135470. */
  135471. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  135472. /**
  135473. * Disables a depth renderer for a given camera
  135474. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  135475. */
  135476. disableDepthRenderer(camera?: Nullable<Camera>): void;
  135477. }
  135478. /**
  135479. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  135480. * in several rendering techniques.
  135481. */
  135482. export class DepthRendererSceneComponent implements ISceneComponent {
  135483. /**
  135484. * The component name helpfull to identify the component in the list of scene components.
  135485. */
  135486. readonly name: string;
  135487. /**
  135488. * The scene the component belongs to.
  135489. */
  135490. scene: Scene;
  135491. /**
  135492. * Creates a new instance of the component for the given scene
  135493. * @param scene Defines the scene to register the component in
  135494. */
  135495. constructor(scene: Scene);
  135496. /**
  135497. * Registers the component in a given scene
  135498. */
  135499. register(): void;
  135500. /**
  135501. * Rebuilds the elements related to this component in case of
  135502. * context lost for instance.
  135503. */
  135504. rebuild(): void;
  135505. /**
  135506. * Disposes the component and the associated ressources
  135507. */
  135508. dispose(): void;
  135509. private _gatherRenderTargets;
  135510. private _gatherActiveCameraRenderTargets;
  135511. }
  135512. }
  135513. declare module BABYLON {
  135514. /** @hidden */
  135515. export var outlinePixelShader: {
  135516. name: string;
  135517. shader: string;
  135518. };
  135519. }
  135520. declare module BABYLON {
  135521. /** @hidden */
  135522. export var outlineVertexShader: {
  135523. name: string;
  135524. shader: string;
  135525. };
  135526. }
  135527. declare module BABYLON {
  135528. interface Scene {
  135529. /** @hidden */
  135530. _outlineRenderer: OutlineRenderer;
  135531. /**
  135532. * Gets the outline renderer associated with the scene
  135533. * @returns a OutlineRenderer
  135534. */
  135535. getOutlineRenderer(): OutlineRenderer;
  135536. }
  135537. interface AbstractMesh {
  135538. /** @hidden (Backing field) */
  135539. _renderOutline: boolean;
  135540. /**
  135541. * Gets or sets a boolean indicating if the outline must be rendered as well
  135542. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  135543. */
  135544. renderOutline: boolean;
  135545. /** @hidden (Backing field) */
  135546. _renderOverlay: boolean;
  135547. /**
  135548. * Gets or sets a boolean indicating if the overlay must be rendered as well
  135549. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  135550. */
  135551. renderOverlay: boolean;
  135552. }
  135553. /**
  135554. * This class is responsible to draw bothe outline/overlay of meshes.
  135555. * It should not be used directly but through the available method on mesh.
  135556. */
  135557. export class OutlineRenderer implements ISceneComponent {
  135558. /**
  135559. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  135560. */
  135561. private static _StencilReference;
  135562. /**
  135563. * The name of the component. Each component must have a unique name.
  135564. */
  135565. name: string;
  135566. /**
  135567. * The scene the component belongs to.
  135568. */
  135569. scene: Scene;
  135570. /**
  135571. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  135572. */
  135573. zOffset: number;
  135574. private _engine;
  135575. private _effect;
  135576. private _cachedDefines;
  135577. private _savedDepthWrite;
  135578. /**
  135579. * Instantiates a new outline renderer. (There could be only one per scene).
  135580. * @param scene Defines the scene it belongs to
  135581. */
  135582. constructor(scene: Scene);
  135583. /**
  135584. * Register the component to one instance of a scene.
  135585. */
  135586. register(): void;
  135587. /**
  135588. * Rebuilds the elements related to this component in case of
  135589. * context lost for instance.
  135590. */
  135591. rebuild(): void;
  135592. /**
  135593. * Disposes the component and the associated ressources.
  135594. */
  135595. dispose(): void;
  135596. /**
  135597. * Renders the outline in the canvas.
  135598. * @param subMesh Defines the sumesh to render
  135599. * @param batch Defines the batch of meshes in case of instances
  135600. * @param useOverlay Defines if the rendering is for the overlay or the outline
  135601. */
  135602. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  135603. /**
  135604. * Returns whether or not the outline renderer is ready for a given submesh.
  135605. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  135606. * @param subMesh Defines the submesh to check readyness for
  135607. * @param useInstances Defines wheter wee are trying to render instances or not
  135608. * @returns true if ready otherwise false
  135609. */
  135610. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135611. private _beforeRenderingMesh;
  135612. private _afterRenderingMesh;
  135613. }
  135614. }
  135615. declare module BABYLON {
  135616. /**
  135617. * Defines the basic options interface of a Sprite Frame Source Size.
  135618. */
  135619. export interface ISpriteJSONSpriteSourceSize {
  135620. /**
  135621. * number of the original width of the Frame
  135622. */
  135623. w: number;
  135624. /**
  135625. * number of the original height of the Frame
  135626. */
  135627. h: number;
  135628. }
  135629. /**
  135630. * Defines the basic options interface of a Sprite Frame Data.
  135631. */
  135632. export interface ISpriteJSONSpriteFrameData {
  135633. /**
  135634. * number of the x offset of the Frame
  135635. */
  135636. x: number;
  135637. /**
  135638. * number of the y offset of the Frame
  135639. */
  135640. y: number;
  135641. /**
  135642. * number of the width of the Frame
  135643. */
  135644. w: number;
  135645. /**
  135646. * number of the height of the Frame
  135647. */
  135648. h: number;
  135649. }
  135650. /**
  135651. * Defines the basic options interface of a JSON Sprite.
  135652. */
  135653. export interface ISpriteJSONSprite {
  135654. /**
  135655. * string name of the Frame
  135656. */
  135657. filename: string;
  135658. /**
  135659. * ISpriteJSONSpriteFrame basic object of the frame data
  135660. */
  135661. frame: ISpriteJSONSpriteFrameData;
  135662. /**
  135663. * boolean to flag is the frame was rotated.
  135664. */
  135665. rotated: boolean;
  135666. /**
  135667. * boolean to flag is the frame was trimmed.
  135668. */
  135669. trimmed: boolean;
  135670. /**
  135671. * ISpriteJSONSpriteFrame basic object of the source data
  135672. */
  135673. spriteSourceSize: ISpriteJSONSpriteFrameData;
  135674. /**
  135675. * ISpriteJSONSpriteFrame basic object of the source data
  135676. */
  135677. sourceSize: ISpriteJSONSpriteSourceSize;
  135678. }
  135679. /**
  135680. * Defines the basic options interface of a JSON atlas.
  135681. */
  135682. export interface ISpriteJSONAtlas {
  135683. /**
  135684. * Array of objects that contain the frame data.
  135685. */
  135686. frames: Array<ISpriteJSONSprite>;
  135687. /**
  135688. * object basic object containing the sprite meta data.
  135689. */
  135690. meta?: object;
  135691. }
  135692. }
  135693. declare module BABYLON {
  135694. /** @hidden */
  135695. export var spriteMapPixelShader: {
  135696. name: string;
  135697. shader: string;
  135698. };
  135699. }
  135700. declare module BABYLON {
  135701. /** @hidden */
  135702. export var spriteMapVertexShader: {
  135703. name: string;
  135704. shader: string;
  135705. };
  135706. }
  135707. declare module BABYLON {
  135708. /**
  135709. * Defines the basic options interface of a SpriteMap
  135710. */
  135711. export interface ISpriteMapOptions {
  135712. /**
  135713. * Vector2 of the number of cells in the grid.
  135714. */
  135715. stageSize?: Vector2;
  135716. /**
  135717. * Vector2 of the size of the output plane in World Units.
  135718. */
  135719. outputSize?: Vector2;
  135720. /**
  135721. * Vector3 of the position of the output plane in World Units.
  135722. */
  135723. outputPosition?: Vector3;
  135724. /**
  135725. * Vector3 of the rotation of the output plane.
  135726. */
  135727. outputRotation?: Vector3;
  135728. /**
  135729. * number of layers that the system will reserve in resources.
  135730. */
  135731. layerCount?: number;
  135732. /**
  135733. * number of max animation frames a single cell will reserve in resources.
  135734. */
  135735. maxAnimationFrames?: number;
  135736. /**
  135737. * number cell index of the base tile when the system compiles.
  135738. */
  135739. baseTile?: number;
  135740. /**
  135741. * boolean flip the sprite after its been repositioned by the framing data.
  135742. */
  135743. flipU?: boolean;
  135744. /**
  135745. * Vector3 scalar of the global RGB values of the SpriteMap.
  135746. */
  135747. colorMultiply?: Vector3;
  135748. }
  135749. /**
  135750. * Defines the IDisposable interface in order to be cleanable from resources.
  135751. */
  135752. export interface ISpriteMap extends IDisposable {
  135753. /**
  135754. * String name of the SpriteMap.
  135755. */
  135756. name: string;
  135757. /**
  135758. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  135759. */
  135760. atlasJSON: ISpriteJSONAtlas;
  135761. /**
  135762. * Texture of the SpriteMap.
  135763. */
  135764. spriteSheet: Texture;
  135765. /**
  135766. * The parameters to initialize the SpriteMap with.
  135767. */
  135768. options: ISpriteMapOptions;
  135769. }
  135770. /**
  135771. * Class used to manage a grid restricted sprite deployment on an Output plane.
  135772. */
  135773. export class SpriteMap implements ISpriteMap {
  135774. /** The Name of the spriteMap */
  135775. name: string;
  135776. /** The JSON file with the frame and meta data */
  135777. atlasJSON: ISpriteJSONAtlas;
  135778. /** The systems Sprite Sheet Texture */
  135779. spriteSheet: Texture;
  135780. /** Arguments passed with the Constructor */
  135781. options: ISpriteMapOptions;
  135782. /** Public Sprite Storage array, parsed from atlasJSON */
  135783. sprites: Array<ISpriteJSONSprite>;
  135784. /** Returns the Number of Sprites in the System */
  135785. get spriteCount(): number;
  135786. /** Returns the Position of Output Plane*/
  135787. get position(): Vector3;
  135788. /** Returns the Position of Output Plane*/
  135789. set position(v: Vector3);
  135790. /** Returns the Rotation of Output Plane*/
  135791. get rotation(): Vector3;
  135792. /** Returns the Rotation of Output Plane*/
  135793. set rotation(v: Vector3);
  135794. /** Sets the AnimationMap*/
  135795. get animationMap(): RawTexture;
  135796. /** Sets the AnimationMap*/
  135797. set animationMap(v: RawTexture);
  135798. /** Scene that the SpriteMap was created in */
  135799. private _scene;
  135800. /** Texture Buffer of Float32 that holds tile frame data*/
  135801. private _frameMap;
  135802. /** Texture Buffers of Float32 that holds tileMap data*/
  135803. private _tileMaps;
  135804. /** Texture Buffer of Float32 that holds Animation Data*/
  135805. private _animationMap;
  135806. /** Custom ShaderMaterial Central to the System*/
  135807. private _material;
  135808. /** Custom ShaderMaterial Central to the System*/
  135809. private _output;
  135810. /** Systems Time Ticker*/
  135811. private _time;
  135812. /**
  135813. * Creates a new SpriteMap
  135814. * @param name defines the SpriteMaps Name
  135815. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  135816. * @param spriteSheet is the Texture that the Sprites are on.
  135817. * @param options a basic deployment configuration
  135818. * @param scene The Scene that the map is deployed on
  135819. */
  135820. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  135821. /**
  135822. * Returns tileID location
  135823. * @returns Vector2 the cell position ID
  135824. */
  135825. getTileID(): Vector2;
  135826. /**
  135827. * Gets the UV location of the mouse over the SpriteMap.
  135828. * @returns Vector2 the UV position of the mouse interaction
  135829. */
  135830. getMousePosition(): Vector2;
  135831. /**
  135832. * Creates the "frame" texture Buffer
  135833. * -------------------------------------
  135834. * Structure of frames
  135835. * "filename": "Falling-Water-2.png",
  135836. * "frame": {"x":69,"y":103,"w":24,"h":32},
  135837. * "rotated": true,
  135838. * "trimmed": true,
  135839. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  135840. * "sourceSize": {"w":32,"h":32}
  135841. * @returns RawTexture of the frameMap
  135842. */
  135843. private _createFrameBuffer;
  135844. /**
  135845. * Creates the tileMap texture Buffer
  135846. * @param buffer normally and array of numbers, or a false to generate from scratch
  135847. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  135848. * @returns RawTexture of the tileMap
  135849. */
  135850. private _createTileBuffer;
  135851. /**
  135852. * Modifies the data of the tileMaps
  135853. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  135854. * @param pos is the iVector2 Coordinates of the Tile
  135855. * @param tile The SpriteIndex of the new Tile
  135856. */
  135857. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  135858. /**
  135859. * Creates the animationMap texture Buffer
  135860. * @param buffer normally and array of numbers, or a false to generate from scratch
  135861. * @returns RawTexture of the animationMap
  135862. */
  135863. private _createTileAnimationBuffer;
  135864. /**
  135865. * Modifies the data of the animationMap
  135866. * @param cellID is the Index of the Sprite
  135867. * @param _frame is the target Animation frame
  135868. * @param toCell is the Target Index of the next frame of the animation
  135869. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  135870. * @param speed is a global scalar of the time variable on the map.
  135871. */
  135872. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  135873. /**
  135874. * Exports the .tilemaps file
  135875. */
  135876. saveTileMaps(): void;
  135877. /**
  135878. * Imports the .tilemaps file
  135879. * @param url of the .tilemaps file
  135880. */
  135881. loadTileMaps(url: string): void;
  135882. /**
  135883. * Release associated resources
  135884. */
  135885. dispose(): void;
  135886. }
  135887. }
  135888. declare module BABYLON {
  135889. /**
  135890. * Class used to manage multiple sprites of different sizes on the same spritesheet
  135891. * @see http://doc.babylonjs.com/babylon101/sprites
  135892. */
  135893. export class SpritePackedManager extends SpriteManager {
  135894. /** defines the packed manager's name */
  135895. name: string;
  135896. /**
  135897. * Creates a new sprite manager from a packed sprite sheet
  135898. * @param name defines the manager's name
  135899. * @param imgUrl defines the sprite sheet url
  135900. * @param capacity defines the maximum allowed number of sprites
  135901. * @param scene defines the hosting scene
  135902. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  135903. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  135904. * @param samplingMode defines the smapling mode to use with spritesheet
  135905. * @param fromPacked set to true; do not alter
  135906. */
  135907. constructor(
  135908. /** defines the packed manager's name */
  135909. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  135910. }
  135911. }
  135912. declare module BABYLON {
  135913. /**
  135914. * Defines the list of states available for a task inside a AssetsManager
  135915. */
  135916. export enum AssetTaskState {
  135917. /**
  135918. * Initialization
  135919. */
  135920. INIT = 0,
  135921. /**
  135922. * Running
  135923. */
  135924. RUNNING = 1,
  135925. /**
  135926. * Done
  135927. */
  135928. DONE = 2,
  135929. /**
  135930. * Error
  135931. */
  135932. ERROR = 3
  135933. }
  135934. /**
  135935. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  135936. */
  135937. export abstract class AbstractAssetTask {
  135938. /**
  135939. * Task name
  135940. */ name: string;
  135941. /**
  135942. * Callback called when the task is successful
  135943. */
  135944. onSuccess: (task: any) => void;
  135945. /**
  135946. * Callback called when the task is not successful
  135947. */
  135948. onError: (task: any, message?: string, exception?: any) => void;
  135949. /**
  135950. * Creates a new AssetsManager
  135951. * @param name defines the name of the task
  135952. */
  135953. constructor(
  135954. /**
  135955. * Task name
  135956. */ name: string);
  135957. private _isCompleted;
  135958. private _taskState;
  135959. private _errorObject;
  135960. /**
  135961. * Get if the task is completed
  135962. */
  135963. get isCompleted(): boolean;
  135964. /**
  135965. * Gets the current state of the task
  135966. */
  135967. get taskState(): AssetTaskState;
  135968. /**
  135969. * Gets the current error object (if task is in error)
  135970. */
  135971. get errorObject(): {
  135972. message?: string;
  135973. exception?: any;
  135974. };
  135975. /**
  135976. * Internal only
  135977. * @hidden
  135978. */
  135979. _setErrorObject(message?: string, exception?: any): void;
  135980. /**
  135981. * Execute the current task
  135982. * @param scene defines the scene where you want your assets to be loaded
  135983. * @param onSuccess is a callback called when the task is successfully executed
  135984. * @param onError is a callback called if an error occurs
  135985. */
  135986. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135987. /**
  135988. * Execute the current task
  135989. * @param scene defines the scene where you want your assets to be loaded
  135990. * @param onSuccess is a callback called when the task is successfully executed
  135991. * @param onError is a callback called if an error occurs
  135992. */
  135993. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135994. /**
  135995. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  135996. * This can be used with failed tasks that have the reason for failure fixed.
  135997. */
  135998. reset(): void;
  135999. private onErrorCallback;
  136000. private onDoneCallback;
  136001. }
  136002. /**
  136003. * Define the interface used by progress events raised during assets loading
  136004. */
  136005. export interface IAssetsProgressEvent {
  136006. /**
  136007. * Defines the number of remaining tasks to process
  136008. */
  136009. remainingCount: number;
  136010. /**
  136011. * Defines the total number of tasks
  136012. */
  136013. totalCount: number;
  136014. /**
  136015. * Defines the task that was just processed
  136016. */
  136017. task: AbstractAssetTask;
  136018. }
  136019. /**
  136020. * Class used to share progress information about assets loading
  136021. */
  136022. export class AssetsProgressEvent implements IAssetsProgressEvent {
  136023. /**
  136024. * Defines the number of remaining tasks to process
  136025. */
  136026. remainingCount: number;
  136027. /**
  136028. * Defines the total number of tasks
  136029. */
  136030. totalCount: number;
  136031. /**
  136032. * Defines the task that was just processed
  136033. */
  136034. task: AbstractAssetTask;
  136035. /**
  136036. * Creates a AssetsProgressEvent
  136037. * @param remainingCount defines the number of remaining tasks to process
  136038. * @param totalCount defines the total number of tasks
  136039. * @param task defines the task that was just processed
  136040. */
  136041. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  136042. }
  136043. /**
  136044. * Define a task used by AssetsManager to load meshes
  136045. */
  136046. export class MeshAssetTask extends AbstractAssetTask {
  136047. /**
  136048. * Defines the name of the task
  136049. */
  136050. name: string;
  136051. /**
  136052. * Defines the list of mesh's names you want to load
  136053. */
  136054. meshesNames: any;
  136055. /**
  136056. * Defines the root url to use as a base to load your meshes and associated resources
  136057. */
  136058. rootUrl: string;
  136059. /**
  136060. * Defines the filename of the scene to load from
  136061. */
  136062. sceneFilename: string;
  136063. /**
  136064. * Gets the list of loaded meshes
  136065. */
  136066. loadedMeshes: Array<AbstractMesh>;
  136067. /**
  136068. * Gets the list of loaded particle systems
  136069. */
  136070. loadedParticleSystems: Array<IParticleSystem>;
  136071. /**
  136072. * Gets the list of loaded skeletons
  136073. */
  136074. loadedSkeletons: Array<Skeleton>;
  136075. /**
  136076. * Gets the list of loaded animation groups
  136077. */
  136078. loadedAnimationGroups: Array<AnimationGroup>;
  136079. /**
  136080. * Callback called when the task is successful
  136081. */
  136082. onSuccess: (task: MeshAssetTask) => void;
  136083. /**
  136084. * Callback called when the task is successful
  136085. */
  136086. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  136087. /**
  136088. * Creates a new MeshAssetTask
  136089. * @param name defines the name of the task
  136090. * @param meshesNames defines the list of mesh's names you want to load
  136091. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  136092. * @param sceneFilename defines the filename of the scene to load from
  136093. */
  136094. constructor(
  136095. /**
  136096. * Defines the name of the task
  136097. */
  136098. name: string,
  136099. /**
  136100. * Defines the list of mesh's names you want to load
  136101. */
  136102. meshesNames: any,
  136103. /**
  136104. * Defines the root url to use as a base to load your meshes and associated resources
  136105. */
  136106. rootUrl: string,
  136107. /**
  136108. * Defines the filename of the scene to load from
  136109. */
  136110. sceneFilename: string);
  136111. /**
  136112. * Execute the current task
  136113. * @param scene defines the scene where you want your assets to be loaded
  136114. * @param onSuccess is a callback called when the task is successfully executed
  136115. * @param onError is a callback called if an error occurs
  136116. */
  136117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136118. }
  136119. /**
  136120. * Define a task used by AssetsManager to load text content
  136121. */
  136122. export class TextFileAssetTask extends AbstractAssetTask {
  136123. /**
  136124. * Defines the name of the task
  136125. */
  136126. name: string;
  136127. /**
  136128. * Defines the location of the file to load
  136129. */
  136130. url: string;
  136131. /**
  136132. * Gets the loaded text string
  136133. */
  136134. text: string;
  136135. /**
  136136. * Callback called when the task is successful
  136137. */
  136138. onSuccess: (task: TextFileAssetTask) => void;
  136139. /**
  136140. * Callback called when the task is successful
  136141. */
  136142. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  136143. /**
  136144. * Creates a new TextFileAssetTask object
  136145. * @param name defines the name of the task
  136146. * @param url defines the location of the file to load
  136147. */
  136148. constructor(
  136149. /**
  136150. * Defines the name of the task
  136151. */
  136152. name: string,
  136153. /**
  136154. * Defines the location of the file to load
  136155. */
  136156. url: string);
  136157. /**
  136158. * Execute the current task
  136159. * @param scene defines the scene where you want your assets to be loaded
  136160. * @param onSuccess is a callback called when the task is successfully executed
  136161. * @param onError is a callback called if an error occurs
  136162. */
  136163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136164. }
  136165. /**
  136166. * Define a task used by AssetsManager to load binary data
  136167. */
  136168. export class BinaryFileAssetTask extends AbstractAssetTask {
  136169. /**
  136170. * Defines the name of the task
  136171. */
  136172. name: string;
  136173. /**
  136174. * Defines the location of the file to load
  136175. */
  136176. url: string;
  136177. /**
  136178. * Gets the lodaded data (as an array buffer)
  136179. */
  136180. data: ArrayBuffer;
  136181. /**
  136182. * Callback called when the task is successful
  136183. */
  136184. onSuccess: (task: BinaryFileAssetTask) => void;
  136185. /**
  136186. * Callback called when the task is successful
  136187. */
  136188. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  136189. /**
  136190. * Creates a new BinaryFileAssetTask object
  136191. * @param name defines the name of the new task
  136192. * @param url defines the location of the file to load
  136193. */
  136194. constructor(
  136195. /**
  136196. * Defines the name of the task
  136197. */
  136198. name: string,
  136199. /**
  136200. * Defines the location of the file to load
  136201. */
  136202. url: string);
  136203. /**
  136204. * Execute the current task
  136205. * @param scene defines the scene where you want your assets to be loaded
  136206. * @param onSuccess is a callback called when the task is successfully executed
  136207. * @param onError is a callback called if an error occurs
  136208. */
  136209. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136210. }
  136211. /**
  136212. * Define a task used by AssetsManager to load images
  136213. */
  136214. export class ImageAssetTask extends AbstractAssetTask {
  136215. /**
  136216. * Defines the name of the task
  136217. */
  136218. name: string;
  136219. /**
  136220. * Defines the location of the image to load
  136221. */
  136222. url: string;
  136223. /**
  136224. * Gets the loaded images
  136225. */
  136226. image: HTMLImageElement;
  136227. /**
  136228. * Callback called when the task is successful
  136229. */
  136230. onSuccess: (task: ImageAssetTask) => void;
  136231. /**
  136232. * Callback called when the task is successful
  136233. */
  136234. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  136235. /**
  136236. * Creates a new ImageAssetTask
  136237. * @param name defines the name of the task
  136238. * @param url defines the location of the image to load
  136239. */
  136240. constructor(
  136241. /**
  136242. * Defines the name of the task
  136243. */
  136244. name: string,
  136245. /**
  136246. * Defines the location of the image to load
  136247. */
  136248. url: string);
  136249. /**
  136250. * Execute the current task
  136251. * @param scene defines the scene where you want your assets to be loaded
  136252. * @param onSuccess is a callback called when the task is successfully executed
  136253. * @param onError is a callback called if an error occurs
  136254. */
  136255. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136256. }
  136257. /**
  136258. * Defines the interface used by texture loading tasks
  136259. */
  136260. export interface ITextureAssetTask<TEX extends BaseTexture> {
  136261. /**
  136262. * Gets the loaded texture
  136263. */
  136264. texture: TEX;
  136265. }
  136266. /**
  136267. * Define a task used by AssetsManager to load 2D textures
  136268. */
  136269. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  136270. /**
  136271. * Defines the name of the task
  136272. */
  136273. name: string;
  136274. /**
  136275. * Defines the location of the file to load
  136276. */
  136277. url: string;
  136278. /**
  136279. * Defines if mipmap should not be generated (default is false)
  136280. */
  136281. noMipmap?: boolean | undefined;
  136282. /**
  136283. * Defines if texture must be inverted on Y axis (default is false)
  136284. */
  136285. invertY?: boolean | undefined;
  136286. /**
  136287. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136288. */
  136289. samplingMode: number;
  136290. /**
  136291. * Gets the loaded texture
  136292. */
  136293. texture: Texture;
  136294. /**
  136295. * Callback called when the task is successful
  136296. */
  136297. onSuccess: (task: TextureAssetTask) => void;
  136298. /**
  136299. * Callback called when the task is successful
  136300. */
  136301. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  136302. /**
  136303. * Creates a new TextureAssetTask object
  136304. * @param name defines the name of the task
  136305. * @param url defines the location of the file to load
  136306. * @param noMipmap defines if mipmap should not be generated (default is false)
  136307. * @param invertY defines if texture must be inverted on Y axis (default is false)
  136308. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136309. */
  136310. constructor(
  136311. /**
  136312. * Defines the name of the task
  136313. */
  136314. name: string,
  136315. /**
  136316. * Defines the location of the file to load
  136317. */
  136318. url: string,
  136319. /**
  136320. * Defines if mipmap should not be generated (default is false)
  136321. */
  136322. noMipmap?: boolean | undefined,
  136323. /**
  136324. * Defines if texture must be inverted on Y axis (default is false)
  136325. */
  136326. invertY?: boolean | undefined,
  136327. /**
  136328. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136329. */
  136330. samplingMode?: number);
  136331. /**
  136332. * Execute the current task
  136333. * @param scene defines the scene where you want your assets to be loaded
  136334. * @param onSuccess is a callback called when the task is successfully executed
  136335. * @param onError is a callback called if an error occurs
  136336. */
  136337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136338. }
  136339. /**
  136340. * Define a task used by AssetsManager to load cube textures
  136341. */
  136342. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  136343. /**
  136344. * Defines the name of the task
  136345. */
  136346. name: string;
  136347. /**
  136348. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136349. */
  136350. url: string;
  136351. /**
  136352. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136353. */
  136354. extensions?: string[] | undefined;
  136355. /**
  136356. * Defines if mipmaps should not be generated (default is false)
  136357. */
  136358. noMipmap?: boolean | undefined;
  136359. /**
  136360. * Defines the explicit list of files (undefined by default)
  136361. */
  136362. files?: string[] | undefined;
  136363. /**
  136364. * Gets the loaded texture
  136365. */
  136366. texture: CubeTexture;
  136367. /**
  136368. * Callback called when the task is successful
  136369. */
  136370. onSuccess: (task: CubeTextureAssetTask) => void;
  136371. /**
  136372. * Callback called when the task is successful
  136373. */
  136374. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  136375. /**
  136376. * Creates a new CubeTextureAssetTask
  136377. * @param name defines the name of the task
  136378. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136379. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136380. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136381. * @param files defines the explicit list of files (undefined by default)
  136382. */
  136383. constructor(
  136384. /**
  136385. * Defines the name of the task
  136386. */
  136387. name: string,
  136388. /**
  136389. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136390. */
  136391. url: string,
  136392. /**
  136393. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136394. */
  136395. extensions?: string[] | undefined,
  136396. /**
  136397. * Defines if mipmaps should not be generated (default is false)
  136398. */
  136399. noMipmap?: boolean | undefined,
  136400. /**
  136401. * Defines the explicit list of files (undefined by default)
  136402. */
  136403. files?: string[] | undefined);
  136404. /**
  136405. * Execute the current task
  136406. * @param scene defines the scene where you want your assets to be loaded
  136407. * @param onSuccess is a callback called when the task is successfully executed
  136408. * @param onError is a callback called if an error occurs
  136409. */
  136410. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136411. }
  136412. /**
  136413. * Define a task used by AssetsManager to load HDR cube textures
  136414. */
  136415. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  136416. /**
  136417. * Defines the name of the task
  136418. */
  136419. name: string;
  136420. /**
  136421. * Defines the location of the file to load
  136422. */
  136423. url: string;
  136424. /**
  136425. * Defines the desired size (the more it increases the longer the generation will be)
  136426. */
  136427. size: number;
  136428. /**
  136429. * Defines if mipmaps should not be generated (default is false)
  136430. */
  136431. noMipmap: boolean;
  136432. /**
  136433. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136434. */
  136435. generateHarmonics: boolean;
  136436. /**
  136437. * 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)
  136438. */
  136439. gammaSpace: boolean;
  136440. /**
  136441. * Internal Use Only
  136442. */
  136443. reserved: boolean;
  136444. /**
  136445. * Gets the loaded texture
  136446. */
  136447. texture: HDRCubeTexture;
  136448. /**
  136449. * Callback called when the task is successful
  136450. */
  136451. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  136452. /**
  136453. * Callback called when the task is successful
  136454. */
  136455. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  136456. /**
  136457. * Creates a new HDRCubeTextureAssetTask object
  136458. * @param name defines the name of the task
  136459. * @param url defines the location of the file to load
  136460. * @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.
  136461. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136462. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136463. * @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)
  136464. * @param reserved Internal use only
  136465. */
  136466. constructor(
  136467. /**
  136468. * Defines the name of the task
  136469. */
  136470. name: string,
  136471. /**
  136472. * Defines the location of the file to load
  136473. */
  136474. url: string,
  136475. /**
  136476. * Defines the desired size (the more it increases the longer the generation will be)
  136477. */
  136478. size: number,
  136479. /**
  136480. * Defines if mipmaps should not be generated (default is false)
  136481. */
  136482. noMipmap?: boolean,
  136483. /**
  136484. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136485. */
  136486. generateHarmonics?: boolean,
  136487. /**
  136488. * 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)
  136489. */
  136490. gammaSpace?: boolean,
  136491. /**
  136492. * Internal Use Only
  136493. */
  136494. reserved?: boolean);
  136495. /**
  136496. * Execute the current task
  136497. * @param scene defines the scene where you want your assets to be loaded
  136498. * @param onSuccess is a callback called when the task is successfully executed
  136499. * @param onError is a callback called if an error occurs
  136500. */
  136501. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136502. }
  136503. /**
  136504. * Define a task used by AssetsManager to load Equirectangular cube textures
  136505. */
  136506. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  136507. /**
  136508. * Defines the name of the task
  136509. */
  136510. name: string;
  136511. /**
  136512. * Defines the location of the file to load
  136513. */
  136514. url: string;
  136515. /**
  136516. * Defines the desired size (the more it increases the longer the generation will be)
  136517. */
  136518. size: number;
  136519. /**
  136520. * Defines if mipmaps should not be generated (default is false)
  136521. */
  136522. noMipmap: boolean;
  136523. /**
  136524. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136525. * but the standard material would require them in Gamma space) (default is true)
  136526. */
  136527. gammaSpace: boolean;
  136528. /**
  136529. * Gets the loaded texture
  136530. */
  136531. texture: EquiRectangularCubeTexture;
  136532. /**
  136533. * Callback called when the task is successful
  136534. */
  136535. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  136536. /**
  136537. * Callback called when the task is successful
  136538. */
  136539. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  136540. /**
  136541. * Creates a new EquiRectangularCubeTextureAssetTask object
  136542. * @param name defines the name of the task
  136543. * @param url defines the location of the file to load
  136544. * @param size defines the desired size (the more it increases the longer the generation will be)
  136545. * If the size is omitted this implies you are using a preprocessed cubemap.
  136546. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136547. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  136548. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  136549. * (default is true)
  136550. */
  136551. constructor(
  136552. /**
  136553. * Defines the name of the task
  136554. */
  136555. name: string,
  136556. /**
  136557. * Defines the location of the file to load
  136558. */
  136559. url: string,
  136560. /**
  136561. * Defines the desired size (the more it increases the longer the generation will be)
  136562. */
  136563. size: number,
  136564. /**
  136565. * Defines if mipmaps should not be generated (default is false)
  136566. */
  136567. noMipmap?: boolean,
  136568. /**
  136569. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136570. * but the standard material would require them in Gamma space) (default is true)
  136571. */
  136572. gammaSpace?: boolean);
  136573. /**
  136574. * Execute the current task
  136575. * @param scene defines the scene where you want your assets to be loaded
  136576. * @param onSuccess is a callback called when the task is successfully executed
  136577. * @param onError is a callback called if an error occurs
  136578. */
  136579. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136580. }
  136581. /**
  136582. * This class can be used to easily import assets into a scene
  136583. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  136584. */
  136585. export class AssetsManager {
  136586. private _scene;
  136587. private _isLoading;
  136588. protected _tasks: AbstractAssetTask[];
  136589. protected _waitingTasksCount: number;
  136590. protected _totalTasksCount: number;
  136591. /**
  136592. * Callback called when all tasks are processed
  136593. */
  136594. onFinish: (tasks: AbstractAssetTask[]) => void;
  136595. /**
  136596. * Callback called when a task is successful
  136597. */
  136598. onTaskSuccess: (task: AbstractAssetTask) => void;
  136599. /**
  136600. * Callback called when a task had an error
  136601. */
  136602. onTaskError: (task: AbstractAssetTask) => void;
  136603. /**
  136604. * Callback called when a task is done (whatever the result is)
  136605. */
  136606. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  136607. /**
  136608. * Observable called when all tasks are processed
  136609. */
  136610. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  136611. /**
  136612. * Observable called when a task had an error
  136613. */
  136614. onTaskErrorObservable: Observable<AbstractAssetTask>;
  136615. /**
  136616. * Observable called when all tasks were executed
  136617. */
  136618. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  136619. /**
  136620. * Observable called when a task is done (whatever the result is)
  136621. */
  136622. onProgressObservable: Observable<IAssetsProgressEvent>;
  136623. /**
  136624. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  136625. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  136626. */
  136627. useDefaultLoadingScreen: boolean;
  136628. /**
  136629. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  136630. * when all assets have been downloaded.
  136631. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  136632. */
  136633. autoHideLoadingUI: boolean;
  136634. /**
  136635. * Creates a new AssetsManager
  136636. * @param scene defines the scene to work on
  136637. */
  136638. constructor(scene: Scene);
  136639. /**
  136640. * Add a MeshAssetTask to the list of active tasks
  136641. * @param taskName defines the name of the new task
  136642. * @param meshesNames defines the name of meshes to load
  136643. * @param rootUrl defines the root url to use to locate files
  136644. * @param sceneFilename defines the filename of the scene file
  136645. * @returns a new MeshAssetTask object
  136646. */
  136647. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  136648. /**
  136649. * Add a TextFileAssetTask to the list of active tasks
  136650. * @param taskName defines the name of the new task
  136651. * @param url defines the url of the file to load
  136652. * @returns a new TextFileAssetTask object
  136653. */
  136654. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  136655. /**
  136656. * Add a BinaryFileAssetTask to the list of active tasks
  136657. * @param taskName defines the name of the new task
  136658. * @param url defines the url of the file to load
  136659. * @returns a new BinaryFileAssetTask object
  136660. */
  136661. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  136662. /**
  136663. * Add a ImageAssetTask to the list of active tasks
  136664. * @param taskName defines the name of the new task
  136665. * @param url defines the url of the file to load
  136666. * @returns a new ImageAssetTask object
  136667. */
  136668. addImageTask(taskName: string, url: string): ImageAssetTask;
  136669. /**
  136670. * Add a TextureAssetTask to the list of active tasks
  136671. * @param taskName defines the name of the new task
  136672. * @param url defines the url of the file to load
  136673. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136674. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  136675. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  136676. * @returns a new TextureAssetTask object
  136677. */
  136678. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  136679. /**
  136680. * Add a CubeTextureAssetTask to the list of active tasks
  136681. * @param taskName defines the name of the new task
  136682. * @param url defines the url of the file to load
  136683. * @param extensions defines the extension to use to load the cube map (can be null)
  136684. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136685. * @param files defines the list of files to load (can be null)
  136686. * @returns a new CubeTextureAssetTask object
  136687. */
  136688. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  136689. /**
  136690. *
  136691. * Add a HDRCubeTextureAssetTask to the list of active tasks
  136692. * @param taskName defines the name of the new task
  136693. * @param url defines the url of the file to load
  136694. * @param size defines the size you want for the cubemap (can be null)
  136695. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136696. * @param generateHarmonics defines if you want to automatically generate (true by default)
  136697. * @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)
  136698. * @param reserved Internal use only
  136699. * @returns a new HDRCubeTextureAssetTask object
  136700. */
  136701. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  136702. /**
  136703. *
  136704. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  136705. * @param taskName defines the name of the new task
  136706. * @param url defines the url of the file to load
  136707. * @param size defines the size you want for the cubemap (can be null)
  136708. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136709. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  136710. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  136711. * @returns a new EquiRectangularCubeTextureAssetTask object
  136712. */
  136713. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  136714. /**
  136715. * Remove a task from the assets manager.
  136716. * @param task the task to remove
  136717. */
  136718. removeTask(task: AbstractAssetTask): void;
  136719. private _decreaseWaitingTasksCount;
  136720. private _runTask;
  136721. /**
  136722. * Reset the AssetsManager and remove all tasks
  136723. * @return the current instance of the AssetsManager
  136724. */
  136725. reset(): AssetsManager;
  136726. /**
  136727. * Start the loading process
  136728. * @return the current instance of the AssetsManager
  136729. */
  136730. load(): AssetsManager;
  136731. /**
  136732. * Start the loading process as an async operation
  136733. * @return a promise returning the list of failed tasks
  136734. */
  136735. loadAsync(): Promise<void>;
  136736. }
  136737. }
  136738. declare module BABYLON {
  136739. /**
  136740. * Wrapper class for promise with external resolve and reject.
  136741. */
  136742. export class Deferred<T> {
  136743. /**
  136744. * The promise associated with this deferred object.
  136745. */
  136746. readonly promise: Promise<T>;
  136747. private _resolve;
  136748. private _reject;
  136749. /**
  136750. * The resolve method of the promise associated with this deferred object.
  136751. */
  136752. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  136753. /**
  136754. * The reject method of the promise associated with this deferred object.
  136755. */
  136756. get reject(): (reason?: any) => void;
  136757. /**
  136758. * Constructor for this deferred object.
  136759. */
  136760. constructor();
  136761. }
  136762. }
  136763. declare module BABYLON {
  136764. /**
  136765. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  136766. */
  136767. export class MeshExploder {
  136768. private _centerMesh;
  136769. private _meshes;
  136770. private _meshesOrigins;
  136771. private _toCenterVectors;
  136772. private _scaledDirection;
  136773. private _newPosition;
  136774. private _centerPosition;
  136775. /**
  136776. * Explodes meshes from a center mesh.
  136777. * @param meshes The meshes to explode.
  136778. * @param centerMesh The mesh to be center of explosion.
  136779. */
  136780. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  136781. private _setCenterMesh;
  136782. /**
  136783. * Get class name
  136784. * @returns "MeshExploder"
  136785. */
  136786. getClassName(): string;
  136787. /**
  136788. * "Exploded meshes"
  136789. * @returns Array of meshes with the centerMesh at index 0.
  136790. */
  136791. getMeshes(): Array<Mesh>;
  136792. /**
  136793. * Explodes meshes giving a specific direction
  136794. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  136795. */
  136796. explode(direction?: number): void;
  136797. }
  136798. }
  136799. declare module BABYLON {
  136800. /**
  136801. * Class used to help managing file picking and drag'n'drop
  136802. */
  136803. export class FilesInput {
  136804. /**
  136805. * List of files ready to be loaded
  136806. */
  136807. static get FilesToLoad(): {
  136808. [key: string]: File;
  136809. };
  136810. /**
  136811. * Callback called when a file is processed
  136812. */
  136813. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  136814. private _engine;
  136815. private _currentScene;
  136816. private _sceneLoadedCallback;
  136817. private _progressCallback;
  136818. private _additionalRenderLoopLogicCallback;
  136819. private _textureLoadingCallback;
  136820. private _startingProcessingFilesCallback;
  136821. private _onReloadCallback;
  136822. private _errorCallback;
  136823. private _elementToMonitor;
  136824. private _sceneFileToLoad;
  136825. private _filesToLoad;
  136826. /**
  136827. * Creates a new FilesInput
  136828. * @param engine defines the rendering engine
  136829. * @param scene defines the hosting scene
  136830. * @param sceneLoadedCallback callback called when scene is loaded
  136831. * @param progressCallback callback called to track progress
  136832. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  136833. * @param textureLoadingCallback callback called when a texture is loading
  136834. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  136835. * @param onReloadCallback callback called when a reload is requested
  136836. * @param errorCallback callback call if an error occurs
  136837. */
  136838. 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);
  136839. private _dragEnterHandler;
  136840. private _dragOverHandler;
  136841. private _dropHandler;
  136842. /**
  136843. * Calls this function to listen to drag'n'drop events on a specific DOM element
  136844. * @param elementToMonitor defines the DOM element to track
  136845. */
  136846. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  136847. /**
  136848. * Release all associated resources
  136849. */
  136850. dispose(): void;
  136851. private renderFunction;
  136852. private drag;
  136853. private drop;
  136854. private _traverseFolder;
  136855. private _processFiles;
  136856. /**
  136857. * Load files from a drop event
  136858. * @param event defines the drop event to use as source
  136859. */
  136860. loadFiles(event: any): void;
  136861. private _processReload;
  136862. /**
  136863. * Reload the current scene from the loaded files
  136864. */
  136865. reload(): void;
  136866. }
  136867. }
  136868. declare module BABYLON {
  136869. /**
  136870. * Defines the root class used to create scene optimization to use with SceneOptimizer
  136871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136872. */
  136873. export class SceneOptimization {
  136874. /**
  136875. * Defines the priority of this optimization (0 by default which means first in the list)
  136876. */
  136877. priority: number;
  136878. /**
  136879. * Gets a string describing the action executed by the current optimization
  136880. * @returns description string
  136881. */
  136882. getDescription(): string;
  136883. /**
  136884. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136885. * @param scene defines the current scene where to apply this optimization
  136886. * @param optimizer defines the current optimizer
  136887. * @returns true if everything that can be done was applied
  136888. */
  136889. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136890. /**
  136891. * Creates the SceneOptimization object
  136892. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136893. * @param desc defines the description associated with the optimization
  136894. */
  136895. constructor(
  136896. /**
  136897. * Defines the priority of this optimization (0 by default which means first in the list)
  136898. */
  136899. priority?: number);
  136900. }
  136901. /**
  136902. * Defines an optimization used to reduce the size of render target textures
  136903. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136904. */
  136905. export class TextureOptimization extends SceneOptimization {
  136906. /**
  136907. * Defines the priority of this optimization (0 by default which means first in the list)
  136908. */
  136909. priority: number;
  136910. /**
  136911. * 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
  136912. */
  136913. maximumSize: number;
  136914. /**
  136915. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136916. */
  136917. step: number;
  136918. /**
  136919. * Gets a string describing the action executed by the current optimization
  136920. * @returns description string
  136921. */
  136922. getDescription(): string;
  136923. /**
  136924. * Creates the TextureOptimization object
  136925. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136926. * @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
  136927. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136928. */
  136929. constructor(
  136930. /**
  136931. * Defines the priority of this optimization (0 by default which means first in the list)
  136932. */
  136933. priority?: number,
  136934. /**
  136935. * 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
  136936. */
  136937. maximumSize?: number,
  136938. /**
  136939. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136940. */
  136941. step?: number);
  136942. /**
  136943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136944. * @param scene defines the current scene where to apply this optimization
  136945. * @param optimizer defines the current optimizer
  136946. * @returns true if everything that can be done was applied
  136947. */
  136948. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136949. }
  136950. /**
  136951. * Defines an optimization used to increase or decrease the rendering resolution
  136952. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136953. */
  136954. export class HardwareScalingOptimization extends SceneOptimization {
  136955. /**
  136956. * Defines the priority of this optimization (0 by default which means first in the list)
  136957. */
  136958. priority: number;
  136959. /**
  136960. * Defines the maximum scale to use (2 by default)
  136961. */
  136962. maximumScale: number;
  136963. /**
  136964. * Defines the step to use between two passes (0.5 by default)
  136965. */
  136966. step: number;
  136967. private _currentScale;
  136968. private _directionOffset;
  136969. /**
  136970. * Gets a string describing the action executed by the current optimization
  136971. * @return description string
  136972. */
  136973. getDescription(): string;
  136974. /**
  136975. * Creates the HardwareScalingOptimization object
  136976. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136977. * @param maximumScale defines the maximum scale to use (2 by default)
  136978. * @param step defines the step to use between two passes (0.5 by default)
  136979. */
  136980. constructor(
  136981. /**
  136982. * Defines the priority of this optimization (0 by default which means first in the list)
  136983. */
  136984. priority?: number,
  136985. /**
  136986. * Defines the maximum scale to use (2 by default)
  136987. */
  136988. maximumScale?: number,
  136989. /**
  136990. * Defines the step to use between two passes (0.5 by default)
  136991. */
  136992. step?: number);
  136993. /**
  136994. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136995. * @param scene defines the current scene where to apply this optimization
  136996. * @param optimizer defines the current optimizer
  136997. * @returns true if everything that can be done was applied
  136998. */
  136999. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137000. }
  137001. /**
  137002. * Defines an optimization used to remove shadows
  137003. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137004. */
  137005. export class ShadowsOptimization extends SceneOptimization {
  137006. /**
  137007. * Gets a string describing the action executed by the current optimization
  137008. * @return description string
  137009. */
  137010. getDescription(): string;
  137011. /**
  137012. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137013. * @param scene defines the current scene where to apply this optimization
  137014. * @param optimizer defines the current optimizer
  137015. * @returns true if everything that can be done was applied
  137016. */
  137017. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137018. }
  137019. /**
  137020. * Defines an optimization used to turn post-processes off
  137021. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137022. */
  137023. export class PostProcessesOptimization extends SceneOptimization {
  137024. /**
  137025. * Gets a string describing the action executed by the current optimization
  137026. * @return description string
  137027. */
  137028. getDescription(): string;
  137029. /**
  137030. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137031. * @param scene defines the current scene where to apply this optimization
  137032. * @param optimizer defines the current optimizer
  137033. * @returns true if everything that can be done was applied
  137034. */
  137035. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137036. }
  137037. /**
  137038. * Defines an optimization used to turn lens flares off
  137039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137040. */
  137041. export class LensFlaresOptimization extends SceneOptimization {
  137042. /**
  137043. * Gets a string describing the action executed by the current optimization
  137044. * @return description string
  137045. */
  137046. getDescription(): string;
  137047. /**
  137048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137049. * @param scene defines the current scene where to apply this optimization
  137050. * @param optimizer defines the current optimizer
  137051. * @returns true if everything that can be done was applied
  137052. */
  137053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137054. }
  137055. /**
  137056. * Defines an optimization based on user defined callback.
  137057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137058. */
  137059. export class CustomOptimization extends SceneOptimization {
  137060. /**
  137061. * Callback called to apply the custom optimization.
  137062. */
  137063. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  137064. /**
  137065. * Callback called to get custom description
  137066. */
  137067. onGetDescription: () => string;
  137068. /**
  137069. * Gets a string describing the action executed by the current optimization
  137070. * @returns description string
  137071. */
  137072. getDescription(): string;
  137073. /**
  137074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137075. * @param scene defines the current scene where to apply this optimization
  137076. * @param optimizer defines the current optimizer
  137077. * @returns true if everything that can be done was applied
  137078. */
  137079. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137080. }
  137081. /**
  137082. * Defines an optimization used to turn particles off
  137083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137084. */
  137085. export class ParticlesOptimization extends SceneOptimization {
  137086. /**
  137087. * Gets a string describing the action executed by the current optimization
  137088. * @return description string
  137089. */
  137090. getDescription(): string;
  137091. /**
  137092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137093. * @param scene defines the current scene where to apply this optimization
  137094. * @param optimizer defines the current optimizer
  137095. * @returns true if everything that can be done was applied
  137096. */
  137097. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137098. }
  137099. /**
  137100. * Defines an optimization used to turn render targets off
  137101. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137102. */
  137103. export class RenderTargetsOptimization extends SceneOptimization {
  137104. /**
  137105. * Gets a string describing the action executed by the current optimization
  137106. * @return description string
  137107. */
  137108. getDescription(): string;
  137109. /**
  137110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137111. * @param scene defines the current scene where to apply this optimization
  137112. * @param optimizer defines the current optimizer
  137113. * @returns true if everything that can be done was applied
  137114. */
  137115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137116. }
  137117. /**
  137118. * Defines an optimization used to merge meshes with compatible materials
  137119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137120. */
  137121. export class MergeMeshesOptimization extends SceneOptimization {
  137122. private static _UpdateSelectionTree;
  137123. /**
  137124. * Gets or sets a boolean which defines if optimization octree has to be updated
  137125. */
  137126. static get UpdateSelectionTree(): boolean;
  137127. /**
  137128. * Gets or sets a boolean which defines if optimization octree has to be updated
  137129. */
  137130. static set UpdateSelectionTree(value: boolean);
  137131. /**
  137132. * Gets a string describing the action executed by the current optimization
  137133. * @return description string
  137134. */
  137135. getDescription(): string;
  137136. private _canBeMerged;
  137137. /**
  137138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137139. * @param scene defines the current scene where to apply this optimization
  137140. * @param optimizer defines the current optimizer
  137141. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  137142. * @returns true if everything that can be done was applied
  137143. */
  137144. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  137145. }
  137146. /**
  137147. * Defines a list of options used by SceneOptimizer
  137148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137149. */
  137150. export class SceneOptimizerOptions {
  137151. /**
  137152. * Defines the target frame rate to reach (60 by default)
  137153. */
  137154. targetFrameRate: number;
  137155. /**
  137156. * Defines the interval between two checkes (2000ms by default)
  137157. */
  137158. trackerDuration: number;
  137159. /**
  137160. * Gets the list of optimizations to apply
  137161. */
  137162. optimizations: SceneOptimization[];
  137163. /**
  137164. * Creates a new list of options used by SceneOptimizer
  137165. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  137166. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  137167. */
  137168. constructor(
  137169. /**
  137170. * Defines the target frame rate to reach (60 by default)
  137171. */
  137172. targetFrameRate?: number,
  137173. /**
  137174. * Defines the interval between two checkes (2000ms by default)
  137175. */
  137176. trackerDuration?: number);
  137177. /**
  137178. * Add a new optimization
  137179. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  137180. * @returns the current SceneOptimizerOptions
  137181. */
  137182. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  137183. /**
  137184. * Add a new custom optimization
  137185. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  137186. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  137187. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  137188. * @returns the current SceneOptimizerOptions
  137189. */
  137190. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  137191. /**
  137192. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  137193. * @param targetFrameRate defines the target frame rate (60 by default)
  137194. * @returns a SceneOptimizerOptions object
  137195. */
  137196. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137197. /**
  137198. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  137199. * @param targetFrameRate defines the target frame rate (60 by default)
  137200. * @returns a SceneOptimizerOptions object
  137201. */
  137202. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137203. /**
  137204. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  137205. * @param targetFrameRate defines the target frame rate (60 by default)
  137206. * @returns a SceneOptimizerOptions object
  137207. */
  137208. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137209. }
  137210. /**
  137211. * Class used to run optimizations in order to reach a target frame rate
  137212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137213. */
  137214. export class SceneOptimizer implements IDisposable {
  137215. private _isRunning;
  137216. private _options;
  137217. private _scene;
  137218. private _currentPriorityLevel;
  137219. private _targetFrameRate;
  137220. private _trackerDuration;
  137221. private _currentFrameRate;
  137222. private _sceneDisposeObserver;
  137223. private _improvementMode;
  137224. /**
  137225. * Defines an observable called when the optimizer reaches the target frame rate
  137226. */
  137227. onSuccessObservable: Observable<SceneOptimizer>;
  137228. /**
  137229. * Defines an observable called when the optimizer enables an optimization
  137230. */
  137231. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  137232. /**
  137233. * Defines an observable called when the optimizer is not able to reach the target frame rate
  137234. */
  137235. onFailureObservable: Observable<SceneOptimizer>;
  137236. /**
  137237. * Gets a boolean indicating if the optimizer is in improvement mode
  137238. */
  137239. get isInImprovementMode(): boolean;
  137240. /**
  137241. * Gets the current priority level (0 at start)
  137242. */
  137243. get currentPriorityLevel(): number;
  137244. /**
  137245. * Gets the current frame rate checked by the SceneOptimizer
  137246. */
  137247. get currentFrameRate(): number;
  137248. /**
  137249. * Gets or sets the current target frame rate (60 by default)
  137250. */
  137251. get targetFrameRate(): number;
  137252. /**
  137253. * Gets or sets the current target frame rate (60 by default)
  137254. */
  137255. set targetFrameRate(value: number);
  137256. /**
  137257. * Gets or sets the current interval between two checks (every 2000ms by default)
  137258. */
  137259. get trackerDuration(): number;
  137260. /**
  137261. * Gets or sets the current interval between two checks (every 2000ms by default)
  137262. */
  137263. set trackerDuration(value: number);
  137264. /**
  137265. * Gets the list of active optimizations
  137266. */
  137267. get optimizations(): SceneOptimization[];
  137268. /**
  137269. * Creates a new SceneOptimizer
  137270. * @param scene defines the scene to work on
  137271. * @param options defines the options to use with the SceneOptimizer
  137272. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  137273. * @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)
  137274. */
  137275. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  137276. /**
  137277. * Stops the current optimizer
  137278. */
  137279. stop(): void;
  137280. /**
  137281. * Reset the optimizer to initial step (current priority level = 0)
  137282. */
  137283. reset(): void;
  137284. /**
  137285. * Start the optimizer. By default it will try to reach a specific framerate
  137286. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  137287. */
  137288. start(): void;
  137289. private _checkCurrentState;
  137290. /**
  137291. * Release all resources
  137292. */
  137293. dispose(): void;
  137294. /**
  137295. * Helper function to create a SceneOptimizer with one single line of code
  137296. * @param scene defines the scene to work on
  137297. * @param options defines the options to use with the SceneOptimizer
  137298. * @param onSuccess defines a callback to call on success
  137299. * @param onFailure defines a callback to call on failure
  137300. * @returns the new SceneOptimizer object
  137301. */
  137302. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  137303. }
  137304. }
  137305. declare module BABYLON {
  137306. /**
  137307. * Class used to serialize a scene into a string
  137308. */
  137309. export class SceneSerializer {
  137310. /**
  137311. * Clear cache used by a previous serialization
  137312. */
  137313. static ClearCache(): void;
  137314. /**
  137315. * Serialize a scene into a JSON compatible object
  137316. * @param scene defines the scene to serialize
  137317. * @returns a JSON compatible object
  137318. */
  137319. static Serialize(scene: Scene): any;
  137320. /**
  137321. * Serialize a mesh into a JSON compatible object
  137322. * @param toSerialize defines the mesh to serialize
  137323. * @param withParents defines if parents must be serialized as well
  137324. * @param withChildren defines if children must be serialized as well
  137325. * @returns a JSON compatible object
  137326. */
  137327. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  137328. }
  137329. }
  137330. declare module BABYLON {
  137331. /**
  137332. * Class used to host texture specific utilities
  137333. */
  137334. export class TextureTools {
  137335. /**
  137336. * Uses the GPU to create a copy texture rescaled at a given size
  137337. * @param texture Texture to copy from
  137338. * @param width defines the desired width
  137339. * @param height defines the desired height
  137340. * @param useBilinearMode defines if bilinear mode has to be used
  137341. * @return the generated texture
  137342. */
  137343. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  137344. }
  137345. }
  137346. declare module BABYLON {
  137347. /**
  137348. * This represents the different options available for the video capture.
  137349. */
  137350. export interface VideoRecorderOptions {
  137351. /** Defines the mime type of the video. */
  137352. mimeType: string;
  137353. /** Defines the FPS the video should be recorded at. */
  137354. fps: number;
  137355. /** Defines the chunk size for the recording data. */
  137356. recordChunckSize: number;
  137357. /** The audio tracks to attach to the recording. */
  137358. audioTracks?: MediaStreamTrack[];
  137359. }
  137360. /**
  137361. * This can help with recording videos from BabylonJS.
  137362. * This is based on the available WebRTC functionalities of the browser.
  137363. *
  137364. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  137365. */
  137366. export class VideoRecorder {
  137367. private static readonly _defaultOptions;
  137368. /**
  137369. * Returns whether or not the VideoRecorder is available in your browser.
  137370. * @param engine Defines the Babylon Engine.
  137371. * @returns true if supported otherwise false.
  137372. */
  137373. static IsSupported(engine: Engine): boolean;
  137374. private readonly _options;
  137375. private _canvas;
  137376. private _mediaRecorder;
  137377. private _recordedChunks;
  137378. private _fileName;
  137379. private _resolve;
  137380. private _reject;
  137381. /**
  137382. * True when a recording is already in progress.
  137383. */
  137384. get isRecording(): boolean;
  137385. /**
  137386. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  137387. * @param engine Defines the BabylonJS Engine you wish to record.
  137388. * @param options Defines options that can be used to customize the capture.
  137389. */
  137390. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  137391. /**
  137392. * Stops the current recording before the default capture timeout passed in the startRecording function.
  137393. */
  137394. stopRecording(): void;
  137395. /**
  137396. * Starts recording the canvas for a max duration specified in parameters.
  137397. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  137398. * If null no automatic download will start and you can rely on the promise to get the data back.
  137399. * @param maxDuration Defines the maximum recording time in seconds.
  137400. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  137401. * @return A promise callback at the end of the recording with the video data in Blob.
  137402. */
  137403. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  137404. /**
  137405. * Releases internal resources used during the recording.
  137406. */
  137407. dispose(): void;
  137408. private _handleDataAvailable;
  137409. private _handleError;
  137410. private _handleStop;
  137411. }
  137412. }
  137413. declare module BABYLON {
  137414. /**
  137415. * Class containing a set of static utilities functions for screenshots
  137416. */
  137417. export class ScreenshotTools {
  137418. /**
  137419. * Captures a screenshot of the current rendering
  137420. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137421. * @param engine defines the rendering engine
  137422. * @param camera defines the source camera
  137423. * @param size This parameter can be set to a single number or to an object with the
  137424. * following (optional) properties: precision, width, height. If a single number is passed,
  137425. * it will be used for both width and height. If an object is passed, the screenshot size
  137426. * will be derived from the parameters. The precision property is a multiplier allowing
  137427. * rendering at a higher or lower resolution
  137428. * @param successCallback defines the callback receives a single parameter which contains the
  137429. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137430. * src parameter of an <img> to display it
  137431. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137432. * Check your browser for supported MIME types
  137433. */
  137434. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  137435. /**
  137436. * Captures a screenshot of the current rendering
  137437. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137438. * @param engine defines the rendering engine
  137439. * @param camera defines the source camera
  137440. * @param size This parameter can be set to a single number or to an object with the
  137441. * following (optional) properties: precision, width, height. If a single number is passed,
  137442. * it will be used for both width and height. If an object is passed, the screenshot size
  137443. * will be derived from the parameters. The precision property is a multiplier allowing
  137444. * rendering at a higher or lower resolution
  137445. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137446. * Check your browser for supported MIME types
  137447. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137448. * to the src parameter of an <img> to display it
  137449. */
  137450. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  137451. /**
  137452. * Generates an image screenshot from the specified camera.
  137453. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137454. * @param engine The engine to use for rendering
  137455. * @param camera The camera to use for rendering
  137456. * @param size This parameter can be set to a single number or to an object with the
  137457. * following (optional) properties: precision, width, height. If a single number is passed,
  137458. * it will be used for both width and height. If an object is passed, the screenshot size
  137459. * will be derived from the parameters. The precision property is a multiplier allowing
  137460. * rendering at a higher or lower resolution
  137461. * @param successCallback The callback receives a single parameter which contains the
  137462. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137463. * src parameter of an <img> to display it
  137464. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137465. * Check your browser for supported MIME types
  137466. * @param samples Texture samples (default: 1)
  137467. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137468. * @param fileName A name for for the downloaded file.
  137469. */
  137470. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  137471. /**
  137472. * Generates an image screenshot from the specified camera.
  137473. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137474. * @param engine The engine to use for rendering
  137475. * @param camera The camera to use for rendering
  137476. * @param size This parameter can be set to a single number or to an object with the
  137477. * following (optional) properties: precision, width, height. If a single number is passed,
  137478. * it will be used for both width and height. If an object is passed, the screenshot size
  137479. * will be derived from the parameters. The precision property is a multiplier allowing
  137480. * rendering at a higher or lower resolution
  137481. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137482. * Check your browser for supported MIME types
  137483. * @param samples Texture samples (default: 1)
  137484. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137485. * @param fileName A name for for the downloaded file.
  137486. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137487. * to the src parameter of an <img> to display it
  137488. */
  137489. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  137490. /**
  137491. * Gets height and width for screenshot size
  137492. * @private
  137493. */
  137494. private static _getScreenshotSize;
  137495. }
  137496. }
  137497. declare module BABYLON {
  137498. /**
  137499. * Interface for a data buffer
  137500. */
  137501. export interface IDataBuffer {
  137502. /**
  137503. * Reads bytes from the data buffer.
  137504. * @param byteOffset The byte offset to read
  137505. * @param byteLength The byte length to read
  137506. * @returns A promise that resolves when the bytes are read
  137507. */
  137508. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  137509. /**
  137510. * The byte length of the buffer.
  137511. */
  137512. readonly byteLength: number;
  137513. }
  137514. /**
  137515. * Utility class for reading from a data buffer
  137516. */
  137517. export class DataReader {
  137518. /**
  137519. * The data buffer associated with this data reader.
  137520. */
  137521. readonly buffer: IDataBuffer;
  137522. /**
  137523. * The current byte offset from the beginning of the data buffer.
  137524. */
  137525. byteOffset: number;
  137526. private _dataView;
  137527. private _dataByteOffset;
  137528. /**
  137529. * Constructor
  137530. * @param buffer The buffer to read
  137531. */
  137532. constructor(buffer: IDataBuffer);
  137533. /**
  137534. * Loads the given byte length.
  137535. * @param byteLength The byte length to load
  137536. * @returns A promise that resolves when the load is complete
  137537. */
  137538. loadAsync(byteLength: number): Promise<void>;
  137539. /**
  137540. * Read a unsigned 32-bit integer from the currently loaded data range.
  137541. * @returns The 32-bit integer read
  137542. */
  137543. readUint32(): number;
  137544. /**
  137545. * Read a byte array from the currently loaded data range.
  137546. * @param byteLength The byte length to read
  137547. * @returns The byte array read
  137548. */
  137549. readUint8Array(byteLength: number): Uint8Array;
  137550. /**
  137551. * Read a string from the currently loaded data range.
  137552. * @param byteLength The byte length to read
  137553. * @returns The string read
  137554. */
  137555. readString(byteLength: number): string;
  137556. /**
  137557. * Skips the given byte length the currently loaded data range.
  137558. * @param byteLength The byte length to skip
  137559. */
  137560. skipBytes(byteLength: number): void;
  137561. }
  137562. }
  137563. declare module BABYLON {
  137564. /**
  137565. * A cursor which tracks a point on a path
  137566. */
  137567. export class PathCursor {
  137568. private path;
  137569. /**
  137570. * Stores path cursor callbacks for when an onchange event is triggered
  137571. */
  137572. private _onchange;
  137573. /**
  137574. * The value of the path cursor
  137575. */
  137576. value: number;
  137577. /**
  137578. * The animation array of the path cursor
  137579. */
  137580. animations: Animation[];
  137581. /**
  137582. * Initializes the path cursor
  137583. * @param path The path to track
  137584. */
  137585. constructor(path: Path2);
  137586. /**
  137587. * Gets the cursor point on the path
  137588. * @returns A point on the path cursor at the cursor location
  137589. */
  137590. getPoint(): Vector3;
  137591. /**
  137592. * Moves the cursor ahead by the step amount
  137593. * @param step The amount to move the cursor forward
  137594. * @returns This path cursor
  137595. */
  137596. moveAhead(step?: number): PathCursor;
  137597. /**
  137598. * Moves the cursor behind by the step amount
  137599. * @param step The amount to move the cursor back
  137600. * @returns This path cursor
  137601. */
  137602. moveBack(step?: number): PathCursor;
  137603. /**
  137604. * Moves the cursor by the step amount
  137605. * If the step amount is greater than one, an exception is thrown
  137606. * @param step The amount to move the cursor
  137607. * @returns This path cursor
  137608. */
  137609. move(step: number): PathCursor;
  137610. /**
  137611. * Ensures that the value is limited between zero and one
  137612. * @returns This path cursor
  137613. */
  137614. private ensureLimits;
  137615. /**
  137616. * Runs onchange callbacks on change (used by the animation engine)
  137617. * @returns This path cursor
  137618. */
  137619. private raiseOnChange;
  137620. /**
  137621. * Executes a function on change
  137622. * @param f A path cursor onchange callback
  137623. * @returns This path cursor
  137624. */
  137625. onchange(f: (cursor: PathCursor) => void): PathCursor;
  137626. }
  137627. }
  137628. declare module BABYLON {
  137629. /** @hidden */
  137630. export var blurPixelShader: {
  137631. name: string;
  137632. shader: string;
  137633. };
  137634. }
  137635. declare module BABYLON {
  137636. /** @hidden */
  137637. export var pointCloudVertexDeclaration: {
  137638. name: string;
  137639. shader: string;
  137640. };
  137641. }
  137642. // Mixins
  137643. interface Window {
  137644. mozIndexedDB: IDBFactory;
  137645. webkitIndexedDB: IDBFactory;
  137646. msIndexedDB: IDBFactory;
  137647. webkitURL: typeof URL;
  137648. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  137649. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  137650. WebGLRenderingContext: WebGLRenderingContext;
  137651. MSGesture: MSGesture;
  137652. CANNON: any;
  137653. AudioContext: AudioContext;
  137654. webkitAudioContext: AudioContext;
  137655. PointerEvent: any;
  137656. Math: Math;
  137657. Uint8Array: Uint8ArrayConstructor;
  137658. Float32Array: Float32ArrayConstructor;
  137659. mozURL: typeof URL;
  137660. msURL: typeof URL;
  137661. VRFrameData: any; // WebVR, from specs 1.1
  137662. DracoDecoderModule: any;
  137663. setImmediate(handler: (...args: any[]) => void): number;
  137664. }
  137665. interface HTMLCanvasElement {
  137666. requestPointerLock(): void;
  137667. msRequestPointerLock?(): void;
  137668. mozRequestPointerLock?(): void;
  137669. webkitRequestPointerLock?(): void;
  137670. /** Track wether a record is in progress */
  137671. isRecording: boolean;
  137672. /** Capture Stream method defined by some browsers */
  137673. captureStream(fps?: number): MediaStream;
  137674. }
  137675. interface CanvasRenderingContext2D {
  137676. msImageSmoothingEnabled: boolean;
  137677. }
  137678. interface MouseEvent {
  137679. mozMovementX: number;
  137680. mozMovementY: number;
  137681. webkitMovementX: number;
  137682. webkitMovementY: number;
  137683. msMovementX: number;
  137684. msMovementY: number;
  137685. }
  137686. interface Navigator {
  137687. mozGetVRDevices: (any: any) => any;
  137688. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137689. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137690. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137691. webkitGetGamepads(): Gamepad[];
  137692. msGetGamepads(): Gamepad[];
  137693. webkitGamepads(): Gamepad[];
  137694. }
  137695. interface HTMLVideoElement {
  137696. mozSrcObject: any;
  137697. }
  137698. interface Math {
  137699. fround(x: number): number;
  137700. imul(a: number, b: number): number;
  137701. }
  137702. interface WebGLRenderingContext {
  137703. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  137704. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  137705. vertexAttribDivisor(index: number, divisor: number): void;
  137706. createVertexArray(): any;
  137707. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  137708. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  137709. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  137710. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  137711. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  137712. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  137713. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  137714. // Queries
  137715. createQuery(): WebGLQuery;
  137716. deleteQuery(query: WebGLQuery): void;
  137717. beginQuery(target: number, query: WebGLQuery): void;
  137718. endQuery(target: number): void;
  137719. getQueryParameter(query: WebGLQuery, pname: number): any;
  137720. getQuery(target: number, pname: number): any;
  137721. MAX_SAMPLES: number;
  137722. RGBA8: number;
  137723. READ_FRAMEBUFFER: number;
  137724. DRAW_FRAMEBUFFER: number;
  137725. UNIFORM_BUFFER: number;
  137726. HALF_FLOAT_OES: number;
  137727. RGBA16F: number;
  137728. RGBA32F: number;
  137729. R32F: number;
  137730. RG32F: number;
  137731. RGB32F: number;
  137732. R16F: number;
  137733. RG16F: number;
  137734. RGB16F: number;
  137735. RED: number;
  137736. RG: number;
  137737. R8: number;
  137738. RG8: number;
  137739. UNSIGNED_INT_24_8: number;
  137740. DEPTH24_STENCIL8: number;
  137741. MIN: number;
  137742. MAX: number;
  137743. /* Multiple Render Targets */
  137744. drawBuffers(buffers: number[]): void;
  137745. readBuffer(src: number): void;
  137746. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  137747. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  137748. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  137749. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  137750. // Occlusion Query
  137751. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  137752. ANY_SAMPLES_PASSED: number;
  137753. QUERY_RESULT_AVAILABLE: number;
  137754. QUERY_RESULT: number;
  137755. }
  137756. interface WebGLProgram {
  137757. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  137758. }
  137759. interface EXT_disjoint_timer_query {
  137760. QUERY_COUNTER_BITS_EXT: number;
  137761. TIME_ELAPSED_EXT: number;
  137762. TIMESTAMP_EXT: number;
  137763. GPU_DISJOINT_EXT: number;
  137764. QUERY_RESULT_EXT: number;
  137765. QUERY_RESULT_AVAILABLE_EXT: number;
  137766. queryCounterEXT(query: WebGLQuery, target: number): void;
  137767. createQueryEXT(): WebGLQuery;
  137768. beginQueryEXT(target: number, query: WebGLQuery): void;
  137769. endQueryEXT(target: number): void;
  137770. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  137771. deleteQueryEXT(query: WebGLQuery): void;
  137772. }
  137773. interface WebGLUniformLocation {
  137774. _currentState: any;
  137775. }
  137776. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  137777. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  137778. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  137779. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137780. interface WebGLRenderingContext {
  137781. readonly RASTERIZER_DISCARD: number;
  137782. readonly DEPTH_COMPONENT24: number;
  137783. readonly TEXTURE_3D: number;
  137784. readonly TEXTURE_2D_ARRAY: number;
  137785. readonly TEXTURE_COMPARE_FUNC: number;
  137786. readonly TEXTURE_COMPARE_MODE: number;
  137787. readonly COMPARE_REF_TO_TEXTURE: number;
  137788. readonly TEXTURE_WRAP_R: number;
  137789. readonly HALF_FLOAT: number;
  137790. readonly RGB8: number;
  137791. readonly RED_INTEGER: number;
  137792. readonly RG_INTEGER: number;
  137793. readonly RGB_INTEGER: number;
  137794. readonly RGBA_INTEGER: number;
  137795. readonly R8_SNORM: number;
  137796. readonly RG8_SNORM: number;
  137797. readonly RGB8_SNORM: number;
  137798. readonly RGBA8_SNORM: number;
  137799. readonly R8I: number;
  137800. readonly RG8I: number;
  137801. readonly RGB8I: number;
  137802. readonly RGBA8I: number;
  137803. readonly R8UI: number;
  137804. readonly RG8UI: number;
  137805. readonly RGB8UI: number;
  137806. readonly RGBA8UI: number;
  137807. readonly R16I: number;
  137808. readonly RG16I: number;
  137809. readonly RGB16I: number;
  137810. readonly RGBA16I: number;
  137811. readonly R16UI: number;
  137812. readonly RG16UI: number;
  137813. readonly RGB16UI: number;
  137814. readonly RGBA16UI: number;
  137815. readonly R32I: number;
  137816. readonly RG32I: number;
  137817. readonly RGB32I: number;
  137818. readonly RGBA32I: number;
  137819. readonly R32UI: number;
  137820. readonly RG32UI: number;
  137821. readonly RGB32UI: number;
  137822. readonly RGBA32UI: number;
  137823. readonly RGB10_A2UI: number;
  137824. readonly R11F_G11F_B10F: number;
  137825. readonly RGB9_E5: number;
  137826. readonly RGB10_A2: number;
  137827. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  137828. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  137829. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  137830. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  137831. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  137832. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  137833. 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;
  137834. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  137835. readonly TRANSFORM_FEEDBACK: number;
  137836. readonly INTERLEAVED_ATTRIBS: number;
  137837. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  137838. createTransformFeedback(): WebGLTransformFeedback;
  137839. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  137840. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  137841. beginTransformFeedback(primitiveMode: number): void;
  137842. endTransformFeedback(): void;
  137843. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  137844. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137845. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137846. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137847. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  137848. }
  137849. interface ImageBitmap {
  137850. readonly width: number;
  137851. readonly height: number;
  137852. close(): void;
  137853. }
  137854. interface WebGLQuery extends WebGLObject {
  137855. }
  137856. declare var WebGLQuery: {
  137857. prototype: WebGLQuery;
  137858. new(): WebGLQuery;
  137859. };
  137860. interface WebGLSampler extends WebGLObject {
  137861. }
  137862. declare var WebGLSampler: {
  137863. prototype: WebGLSampler;
  137864. new(): WebGLSampler;
  137865. };
  137866. interface WebGLSync extends WebGLObject {
  137867. }
  137868. declare var WebGLSync: {
  137869. prototype: WebGLSync;
  137870. new(): WebGLSync;
  137871. };
  137872. interface WebGLTransformFeedback extends WebGLObject {
  137873. }
  137874. declare var WebGLTransformFeedback: {
  137875. prototype: WebGLTransformFeedback;
  137876. new(): WebGLTransformFeedback;
  137877. };
  137878. interface WebGLVertexArrayObject extends WebGLObject {
  137879. }
  137880. declare var WebGLVertexArrayObject: {
  137881. prototype: WebGLVertexArrayObject;
  137882. new(): WebGLVertexArrayObject;
  137883. };
  137884. // Type definitions for WebVR API
  137885. // Project: https://w3c.github.io/webvr/
  137886. // Definitions by: six a <https://github.com/lostfictions>
  137887. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137888. interface VRDisplay extends EventTarget {
  137889. /**
  137890. * Dictionary of capabilities describing the VRDisplay.
  137891. */
  137892. readonly capabilities: VRDisplayCapabilities;
  137893. /**
  137894. * z-depth defining the far plane of the eye view frustum
  137895. * enables mapping of values in the render target depth
  137896. * attachment to scene coordinates. Initially set to 10000.0.
  137897. */
  137898. depthFar: number;
  137899. /**
  137900. * z-depth defining the near plane of the eye view frustum
  137901. * enables mapping of values in the render target depth
  137902. * attachment to scene coordinates. Initially set to 0.01.
  137903. */
  137904. depthNear: number;
  137905. /**
  137906. * An identifier for this distinct VRDisplay. Used as an
  137907. * association point in the Gamepad API.
  137908. */
  137909. readonly displayId: number;
  137910. /**
  137911. * A display name, a user-readable name identifying it.
  137912. */
  137913. readonly displayName: string;
  137914. readonly isConnected: boolean;
  137915. readonly isPresenting: boolean;
  137916. /**
  137917. * If this VRDisplay supports room-scale experiences, the optional
  137918. * stage attribute contains details on the room-scale parameters.
  137919. */
  137920. readonly stageParameters: VRStageParameters | null;
  137921. /**
  137922. * Passing the value returned by `requestAnimationFrame` to
  137923. * `cancelAnimationFrame` will unregister the callback.
  137924. * @param handle Define the hanle of the request to cancel
  137925. */
  137926. cancelAnimationFrame(handle: number): void;
  137927. /**
  137928. * Stops presenting to the VRDisplay.
  137929. * @returns a promise to know when it stopped
  137930. */
  137931. exitPresent(): Promise<void>;
  137932. /**
  137933. * Return the current VREyeParameters for the given eye.
  137934. * @param whichEye Define the eye we want the parameter for
  137935. * @returns the eye parameters
  137936. */
  137937. getEyeParameters(whichEye: string): VREyeParameters;
  137938. /**
  137939. * Populates the passed VRFrameData with the information required to render
  137940. * the current frame.
  137941. * @param frameData Define the data structure to populate
  137942. * @returns true if ok otherwise false
  137943. */
  137944. getFrameData(frameData: VRFrameData): boolean;
  137945. /**
  137946. * Get the layers currently being presented.
  137947. * @returns the list of VR layers
  137948. */
  137949. getLayers(): VRLayer[];
  137950. /**
  137951. * Return a VRPose containing the future predicted pose of the VRDisplay
  137952. * when the current frame will be presented. The value returned will not
  137953. * change until JavaScript has returned control to the browser.
  137954. *
  137955. * The VRPose will contain the position, orientation, velocity,
  137956. * and acceleration of each of these properties.
  137957. * @returns the pose object
  137958. */
  137959. getPose(): VRPose;
  137960. /**
  137961. * Return the current instantaneous pose of the VRDisplay, with no
  137962. * prediction applied.
  137963. * @returns the current instantaneous pose
  137964. */
  137965. getImmediatePose(): VRPose;
  137966. /**
  137967. * The callback passed to `requestAnimationFrame` will be called
  137968. * any time a new frame should be rendered. When the VRDisplay is
  137969. * presenting the callback will be called at the native refresh
  137970. * rate of the HMD. When not presenting this function acts
  137971. * identically to how window.requestAnimationFrame acts. Content should
  137972. * make no assumptions of frame rate or vsync behavior as the HMD runs
  137973. * asynchronously from other displays and at differing refresh rates.
  137974. * @param callback Define the eaction to run next frame
  137975. * @returns the request handle it
  137976. */
  137977. requestAnimationFrame(callback: FrameRequestCallback): number;
  137978. /**
  137979. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  137980. * Repeat calls while already presenting will update the VRLayers being displayed.
  137981. * @param layers Define the list of layer to present
  137982. * @returns a promise to know when the request has been fulfilled
  137983. */
  137984. requestPresent(layers: VRLayer[]): Promise<void>;
  137985. /**
  137986. * Reset the pose for this display, treating its current position and
  137987. * orientation as the "origin/zero" values. VRPose.position,
  137988. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  137989. * updated when calling resetPose(). This should be called in only
  137990. * sitting-space experiences.
  137991. */
  137992. resetPose(): void;
  137993. /**
  137994. * The VRLayer provided to the VRDisplay will be captured and presented
  137995. * in the HMD. Calling this function has the same effect on the source
  137996. * canvas as any other operation that uses its source image, and canvases
  137997. * created without preserveDrawingBuffer set to true will be cleared.
  137998. * @param pose Define the pose to submit
  137999. */
  138000. submitFrame(pose?: VRPose): void;
  138001. }
  138002. declare var VRDisplay: {
  138003. prototype: VRDisplay;
  138004. new(): VRDisplay;
  138005. };
  138006. interface VRLayer {
  138007. leftBounds?: number[] | Float32Array | null;
  138008. rightBounds?: number[] | Float32Array | null;
  138009. source?: HTMLCanvasElement | null;
  138010. }
  138011. interface VRDisplayCapabilities {
  138012. readonly canPresent: boolean;
  138013. readonly hasExternalDisplay: boolean;
  138014. readonly hasOrientation: boolean;
  138015. readonly hasPosition: boolean;
  138016. readonly maxLayers: number;
  138017. }
  138018. interface VREyeParameters {
  138019. /** @deprecated */
  138020. readonly fieldOfView: VRFieldOfView;
  138021. readonly offset: Float32Array;
  138022. readonly renderHeight: number;
  138023. readonly renderWidth: number;
  138024. }
  138025. interface VRFieldOfView {
  138026. readonly downDegrees: number;
  138027. readonly leftDegrees: number;
  138028. readonly rightDegrees: number;
  138029. readonly upDegrees: number;
  138030. }
  138031. interface VRFrameData {
  138032. readonly leftProjectionMatrix: Float32Array;
  138033. readonly leftViewMatrix: Float32Array;
  138034. readonly pose: VRPose;
  138035. readonly rightProjectionMatrix: Float32Array;
  138036. readonly rightViewMatrix: Float32Array;
  138037. readonly timestamp: number;
  138038. }
  138039. interface VRPose {
  138040. readonly angularAcceleration: Float32Array | null;
  138041. readonly angularVelocity: Float32Array | null;
  138042. readonly linearAcceleration: Float32Array | null;
  138043. readonly linearVelocity: Float32Array | null;
  138044. readonly orientation: Float32Array | null;
  138045. readonly position: Float32Array | null;
  138046. readonly timestamp: number;
  138047. }
  138048. interface VRStageParameters {
  138049. sittingToStandingTransform?: Float32Array;
  138050. sizeX?: number;
  138051. sizeY?: number;
  138052. }
  138053. interface Navigator {
  138054. getVRDisplays(): Promise<VRDisplay[]>;
  138055. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  138056. }
  138057. interface Window {
  138058. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  138059. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  138060. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  138061. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  138062. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  138063. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  138064. }
  138065. interface Gamepad {
  138066. readonly displayId: number;
  138067. }
  138068. type XRSessionMode =
  138069. | "inline"
  138070. | "immersive-vr"
  138071. | "immersive-ar";
  138072. type XRReferenceSpaceType =
  138073. | "viewer"
  138074. | "local"
  138075. | "local-floor"
  138076. | "bounded-floor"
  138077. | "unbounded";
  138078. type XREnvironmentBlendMode =
  138079. | "opaque"
  138080. | "additive"
  138081. | "alpha-blend";
  138082. type XRVisibilityState =
  138083. | "visible"
  138084. | "visible-blurred"
  138085. | "hidden";
  138086. type XRHandedness =
  138087. | "none"
  138088. | "left"
  138089. | "right";
  138090. type XRTargetRayMode =
  138091. | "gaze"
  138092. | "tracked-pointer"
  138093. | "screen";
  138094. type XREye =
  138095. | "none"
  138096. | "left"
  138097. | "right";
  138098. interface XRSpace extends EventTarget {
  138099. }
  138100. interface XRRenderState {
  138101. depthNear?: number;
  138102. depthFar?: number;
  138103. inlineVerticalFieldOfView?: number;
  138104. baseLayer?: XRWebGLLayer;
  138105. }
  138106. interface XRInputSource {
  138107. handedness: XRHandedness;
  138108. targetRayMode: XRTargetRayMode;
  138109. targetRaySpace: XRSpace;
  138110. gripSpace: XRSpace | undefined;
  138111. gamepad: Gamepad | undefined;
  138112. profiles: Array<string>;
  138113. }
  138114. interface XRSession extends XRAnchorCreator {
  138115. addEventListener: Function;
  138116. removeEventListener: Function;
  138117. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  138118. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  138119. requestAnimationFrame: Function;
  138120. end(): Promise<void>;
  138121. renderState: XRRenderState;
  138122. inputSources: Array<XRInputSource>;
  138123. // AR hit test
  138124. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  138125. updateWorldTrackingState(options: {
  138126. planeDetectionState?: { enabled: boolean; }
  138127. }): void;
  138128. }
  138129. interface XRReferenceSpace extends XRSpace {
  138130. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  138131. onreset: any;
  138132. }
  138133. type XRPlaneSet = Set<XRPlane>;
  138134. type XRAnchorSet = Set<XRAnchor>;
  138135. interface XRFrame {
  138136. session: XRSession;
  138137. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  138138. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  138139. // Anchors
  138140. trackedAnchors?: XRAnchorSet;
  138141. // Planes
  138142. worldInformation: {
  138143. detectedPlanes?: XRPlaneSet;
  138144. };
  138145. }
  138146. interface XRViewerPose extends XRPose {
  138147. views: Array<XRView>;
  138148. }
  138149. interface XRPose {
  138150. transform: XRRigidTransform;
  138151. emulatedPosition: boolean;
  138152. }
  138153. interface XRWebGLLayerOptions {
  138154. antialias?: boolean;
  138155. depth?: boolean;
  138156. stencil?: boolean;
  138157. alpha?: boolean;
  138158. multiview?: boolean;
  138159. framebufferScaleFactor?: number;
  138160. }
  138161. declare var XRWebGLLayer: {
  138162. prototype: XRWebGLLayer;
  138163. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  138164. };
  138165. interface XRWebGLLayer {
  138166. framebuffer: WebGLFramebuffer;
  138167. framebufferWidth: number;
  138168. framebufferHeight: number;
  138169. getViewport: Function;
  138170. }
  138171. declare class XRRigidTransform {
  138172. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  138173. position: DOMPointReadOnly;
  138174. orientation: DOMPointReadOnly;
  138175. matrix: Float32Array;
  138176. inverse: XRRigidTransform;
  138177. }
  138178. interface XRView {
  138179. eye: XREye;
  138180. projectionMatrix: Float32Array;
  138181. transform: XRRigidTransform;
  138182. }
  138183. interface XRInputSourceChangeEvent {
  138184. session: XRSession;
  138185. removed: Array<XRInputSource>;
  138186. added: Array<XRInputSource>;
  138187. }
  138188. interface XRInputSourceEvent extends Event {
  138189. readonly frame: XRFrame;
  138190. readonly inputSource: XRInputSource;
  138191. }
  138192. // Experimental(er) features
  138193. declare class XRRay {
  138194. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  138195. origin: DOMPointReadOnly;
  138196. direction: DOMPointReadOnly;
  138197. matrix: Float32Array;
  138198. }
  138199. interface XRHitResult {
  138200. hitMatrix: Float32Array;
  138201. }
  138202. interface XRAnchor {
  138203. // remove?
  138204. id?: string;
  138205. anchorSpace: XRSpace;
  138206. lastChangedTime: number;
  138207. detach(): void;
  138208. }
  138209. interface XRPlane extends XRAnchorCreator {
  138210. orientation: "Horizontal" | "Vertical";
  138211. planeSpace: XRSpace;
  138212. polygon: Array<DOMPointReadOnly>;
  138213. lastChangedTime: number;
  138214. }
  138215. interface XRAnchorCreator {
  138216. // AR Anchors
  138217. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  138218. }